Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4ProcessMap.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2022 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
14
15#include "TG4ProcessMap.h"
16#include "TG4G3PhysicsManager.h"
17#include "TG4Globals.h"
18
19#include <G4VProcess.hh>
20
21#include <iomanip>
22
24
25//_____________________________________________________________________________
27{
29
30 if (fgInstance) {
31 TG4Globals::Exception("TG4ProcessMap", "TG4ProcessMap",
32 "Cannot create two instances of singleton.");
33 }
34
35 fgInstance = this;
36}
37
38//_____________________________________________________________________________
45
46//
47// private methods
48//
49
50//_____________________________________________________________________________
51G4bool TG4ProcessMap::IsDefined(G4int subType)
52{
54
55 if (fMap.find(subType) == fMap.end())
56 return false;
57 else
58 return true;
59}
60
61//
62// public methods
63//
64
65//_____________________________________________________________________________
67 G4int subType, TMCProcess mcProcess, TG4G3Control g3Control)
68{
70
71 if (!IsDefined(subType)) {
72 // insert into map
73 // only in case it is not yet here
74 fMap[subType] = std::pair(mcProcess, g3Control);
75 return true;
76 }
77 return false;
78}
79
80//_____________________________________________________________________________
82{
84
85 if (fMap.empty()) return;
86
87 G4cout << "Dump of TG4ProcessMap - " << fMap.size()
88 << " entries:" << G4endl;
89 G4int counter = 0;
90 for (auto [subType, codes] : fMap) {
91 // TO DO: get process sub-type name
92 G4cout << "Map element " << std::setw(3) << counter++ << " "
93 << subType << " " << TMCProcessName[codes.first] << " "
94 << TG4G3ControlVector::GetControlName(codes.second) << G4endl;
95 }
96}
97
98//_____________________________________________________________________________
100{
102
103 fMap.clear();
104}
105
106//_____________________________________________________________________________
107std::pair<TMCProcess, TG4G3Control>
109{
112
113 if (!process) return { kPNoProcess, kNoG3Controls };
114
115 auto i = fMap.find(process->GetProcessSubType());
116 if (i == fMap.end()) {
117 G4String text = "Unknown process code for ";
118 text += process->GetProcessName();
119 TG4Globals::Warning("TG4ProcessMap", "GetCodes", text);
120 return { kPNoProcess, kNoG3Controls };
121 }
122 else {
123 return (*i).second;
124 }
125}
126
127
128//_____________________________________________________________________________
129TMCProcess TG4ProcessMap::GetMCProcess(const G4VProcess* process) const
130{
132
133 return GetCodes(process).first;
134}
135
136//_____________________________________________________________________________
138{
140
141 return GetCodes(process).second;
142}
143
144//_____________________________________________________________________________
145G4String TG4ProcessMap::GetMCProcessName(const G4VProcess* process) const
146{
148
149 if (!process) return TMCProcessName[kPNoProcess];
150
151 return TMCProcessName[GetMCProcess(process)];
152}
153
154//_____________________________________________________________________________
155G4String TG4ProcessMap::GetControlName(const G4VProcess* process) const
156{
158
160
162}
163
Definition of the TG4G3PhysicsManager class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4ProcessMap class.
static const G4String & GetControlName(TG4G3Control control)
static void Warning(const TString &className, const TString &methodName, const TString &text)
static void Exception(const TString &className, const TString &methodName, const TString &text)
Maps G4 process sub types to TMCProcess and TG4G3Control codes.
TG4G3Control GetControl(const G4VProcess *process) const
void PrintAll() const
std::pair< TMCProcess, TG4G3Control > GetCodes(const G4VProcess *process) const
std::map< G4int, std::pair< TMCProcess, TG4G3Control > > fMap
map container
TMCProcess GetMCProcess(const G4VProcess *process) const
G4String GetMCProcessName(const G4VProcess *process) const
G4bool Add(G4int subType, TMCProcess mcProcess, TG4G3Control g3Control)
G4String GetControlName(const G4VProcess *process) const
G4bool IsDefined(G4int subType)
static TG4ProcessMap * fgInstance
this instance
TG4G3Control
Enumeration for G3 types of physics processes controls.
@ kNoG3Controls
No process control.