]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4ProcessMCMap.cxx
New Clusterization by IHEP (yuri)
[u/mrichter/AliRoot.git] / TGeant4 / TG4ProcessMCMap.cxx
CommitLineData
27703356 1// $Id$
2// Category: physics
3//
4// Author: I. Hrivnacova
5//
6// Class TG4ProcessMCMap
7// ---------------------
8// See the class description in the header file.
9
10#include "TG4ProcessMCMap.h"
11#include "TG4G3PhysicsManager.h"
12#include "TG4Globals.h"
13
14#include <G4VProcess.hh>
15#include "g4std/iomanip"
16#include "globals.hh"
17
18TG4ProcessMCMap* TG4ProcessMCMap::fgInstance = 0;
19
20//_____________________________________________________________________________
21TG4ProcessMCMap::TG4ProcessMCMap() {
22//
23 if (fgInstance) {
24 TG4Globals::Exception(
25 "TG4ProcessMCMap: attempt to create two instances of singleton.");
26 }
27
28 fgInstance = this;
29}
30
31//_____________________________________________________________________________
32TG4ProcessMCMap::TG4ProcessMCMap(const TG4ProcessMCMap& right) {
33//
34 TG4Globals::Exception(
35 "Attempt to copy TG4ProcessMCMap singleton.");
36}
37
38//_____________________________________________________________________________
39TG4ProcessMCMap::~TG4ProcessMCMap() {
40//
41}
42
43// operators
44
45//_____________________________________________________________________________
46TG4ProcessMCMap& TG4ProcessMCMap::operator=(const TG4ProcessMCMap& right)
47{
48 // check assignement to self
49 if (this == &right) return *this;
50
51 TG4Globals::Exception(
52 "Attempt to assign TG4ProcessMCMap singleton.");
53
54 return *this;
55}
56
57// private methods
58
59//_____________________________________________________________________________
60G4bool TG4ProcessMCMap::IsDefined(const G4String& processName)
61{
62// Returns true if the first is already in the map.
63// ---
64
65 if (fMap.find(processName) == fMap.end())
66 return false;
67 else
68 return true;
69}
70
71// public methods
72
73//_____________________________________________________________________________
74G4bool TG4ProcessMCMap::Add(G4VProcess* process, AliMCProcess mcProcess)
75{
76// Adds the pair to the map.
77// ---
78
79 if (!process) return false;
80
81 return Add(process->GetProcessName(), mcProcess);
82}
83
84//_____________________________________________________________________________
85G4bool TG4ProcessMCMap::Add(G4String processName, AliMCProcess mcProcess)
86{
87// Adds the pair to the map.
88// ---
89
90 if (!IsDefined(processName)) {
91 // insert into map
92 // only in case it is not yet here
93 fMap[processName] = mcProcess;
94 return true;
95 }
96 return false;
97}
98
99//_____________________________________________________________________________
100void TG4ProcessMCMap::PrintAll() const
101{
102// Dumps all map.
103// ---
104
105 if (fMap.size()) {
106 G4cout << "Dump of TG4ProcessMCMap - " << fMap.size() << " entries:" << G4endl;
107 G4int counter = 0;
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]
114 << G4endl;
115 }
116 }
117}
118
119//_____________________________________________________________________________
120void TG4ProcessMCMap::Clear()
121{
122// Clears the map.
123// ---
124
125 fMap.clear();
126}
127
128//_____________________________________________________________________________
129AliMCProcess TG4ProcessMCMap::GetMCProcess(const G4VProcess* process)
130{
131// Returns AliMCProcess code for the process with a given name.
132// ---
133
134 if (!process) return kPNoProcess;
135
136 return GetMCProcess(process->GetProcessName());
137}
138
139//_____________________________________________________________________________
140AliMCProcess TG4ProcessMCMap::GetMCProcess(const G4String& processName)
141{
142// Returns AliMCProcess code for the process with a given name.
143// ---
144
145 MapIterator i = fMap.find(processName);
146 if (i == fMap.end())
147 return kPNoProcess;
148 else
149 return (*i).second;
150}
151
152//_____________________________________________________________________________
153G4String TG4ProcessMCMap::GetMCProcessName(const G4VProcess* process)
154{
155// Returns AliMCProcess code for the process with a given name.
156// ---
157
158 if (!process) return AliMCProcessName[kPNoProcess];
159
160 return GetMCProcessName(process->GetProcessName());
161}
162
163//_____________________________________________________________________________
164G4String TG4ProcessMCMap::GetMCProcessName(const G4String& processName)
165{
166// Returns AliMCProcess code for the process with a given name.
167// ---
168
169 return AliMCProcessName[GetMCProcess(processName)];
170}
171