4 // Author: I. Hrivnacova
6 // Class TG4ProcessMCMap
7 // ---------------------
8 // See the class description in the header file.
10 #include "TG4ProcessMCMap.h"
11 #include "TG4G3PhysicsManager.h"
12 #include "TG4Globals.h"
14 #include <G4VProcess.hh>
15 #include "g4std/iomanip"
18 TG4ProcessMCMap* TG4ProcessMCMap::fgInstance = 0;
20 //_____________________________________________________________________________
21 TG4ProcessMCMap::TG4ProcessMCMap() {
24 TG4Globals::Exception(
25 "TG4ProcessMCMap: attempt to create two instances of singleton.");
31 //_____________________________________________________________________________
32 TG4ProcessMCMap::TG4ProcessMCMap(const TG4ProcessMCMap& right) {
34 TG4Globals::Exception(
35 "Attempt to copy TG4ProcessMCMap singleton.");
38 //_____________________________________________________________________________
39 TG4ProcessMCMap::~TG4ProcessMCMap() {
45 //_____________________________________________________________________________
46 TG4ProcessMCMap& TG4ProcessMCMap::operator=(const TG4ProcessMCMap& right)
48 // check assignement to self
49 if (this == &right) return *this;
51 TG4Globals::Exception(
52 "Attempt to assign TG4ProcessMCMap singleton.");
59 //_____________________________________________________________________________
60 G4bool TG4ProcessMCMap::IsDefined(const G4String& processName)
62 // Returns true if the first is already in the map.
65 if (fMap.find(processName) == fMap.end())
73 //_____________________________________________________________________________
74 G4bool TG4ProcessMCMap::Add(G4VProcess* process, AliMCProcess mcProcess)
76 // Adds the pair to the map.
79 if (!process) return false;
81 return Add(process->GetProcessName(), mcProcess);
84 //_____________________________________________________________________________
85 G4bool TG4ProcessMCMap::Add(G4String processName, AliMCProcess mcProcess)
87 // Adds the pair to the map.
90 if (!IsDefined(processName)) {
92 // only in case it is not yet here
93 fMap[processName] = mcProcess;
99 //_____________________________________________________________________________
100 void TG4ProcessMCMap::PrintAll() const
106 G4cout << "Dump of TG4ProcessMCMap - " << fMap.size() << " entries:" << G4endl;
108 for (MapConstIterator i=fMap.begin(); i != fMap.end(); i++) {
109 G4String processName = (*i).first;
110 AliMCProcess mcProcess = (*i).second;
111 G4cout << "Map element " << G4std::setw(3) << counter++ << " "
112 << processName << " "
113 << AliMCProcessName[mcProcess]
119 //_____________________________________________________________________________
120 void TG4ProcessMCMap::Clear()
128 //_____________________________________________________________________________
129 AliMCProcess TG4ProcessMCMap::GetMCProcess(const G4VProcess* process)
131 // Returns AliMCProcess code for the process with a given name.
134 if (!process) return kPNoProcess;
136 return GetMCProcess(process->GetProcessName());
139 //_____________________________________________________________________________
140 AliMCProcess TG4ProcessMCMap::GetMCProcess(const G4String& processName)
142 // Returns AliMCProcess code for the process with a given name.
145 MapIterator i = fMap.find(processName);
152 //_____________________________________________________________________________
153 G4String TG4ProcessMCMap::GetMCProcessName(const G4VProcess* process)
155 // Returns AliMCProcess code for the process with a given name.
158 if (!process) return AliMCProcessName[kPNoProcess];
160 return GetMCProcessName(process->GetProcessName());
163 //_____________________________________________________________________________
164 G4String TG4ProcessMCMap::GetMCProcessName(const G4String& processName)
166 // Returns AliMCProcess code for the process with a given name.
169 return AliMCProcessName[GetMCProcess(processName)];