Geant4 VMC Version 6.7
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
TG4G3ControlVector.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2014 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 "TG4G3ControlVector.h"
16#include "TG4G3CutVector.h"
17#include "TG4G3Defaults.h"
18#include "TG4Globals.h"
19#include "TG4ProcessMap.h"
20
21#include <G4VProcess.hh>
22
23#if __GNUC__ >= 3
24#include <sstream>
25#else
26#include <strstream>
27#endif
28
29#include <math.h>
30
32
33//_____________________________________________________________________________
35{
37
38 // initialize fControlVector
39 for (G4int i = 0; i <= kNoG3Controls; i++)
41
42 // fill name vector
44}
45
46//_____________________________________________________________________________
48 : fControlVector(right.fControlVector.size())
49{
51
52 // copy stuff
53 *this = right;
54}
55
56//_____________________________________________________________________________
61
62//
63// operators
64//
65
66//_____________________________________________________________________________
68 const TG4G3ControlVector& right)
69{
71
72 // check assignement to self
73 if (this == &right) return *this;
74
75 // initialize fControlVector
76 for (G4int i = 0; i <= kNoG3Controls; i++)
77 fControlVector[i] = right.fControlVector[i];
78
79 return *this;
80}
81
82//_____________________________________________________________________________
84{
86
87 if (index <= kNoG3Controls)
88 return fControlVector[index];
89 else {
91 "TG4G3ControlVector", "operator[]", "Index out of the vector scope");
92 return kUnsetControlValue;
93 }
94}
95
96//
97// private methods
98//
99
100//_____________________________________________________________________________
102{
104
105 fgControlNameVector.push_back("PAIR");
106 fgControlNameVector.push_back("COMP");
107 fgControlNameVector.push_back("PHOT");
108 fgControlNameVector.push_back("PFIS");
109 fgControlNameVector.push_back("DRAY");
110 fgControlNameVector.push_back("ANNI");
111 fgControlNameVector.push_back("BREM");
112 fgControlNameVector.push_back("HADR");
113 fgControlNameVector.push_back("MUNU");
114 fgControlNameVector.push_back("DCAY");
115 fgControlNameVector.push_back("LOSS");
116 fgControlNameVector.push_back("MULS");
117 fgControlNameVector.push_back("CKOV");
118 fgControlNameVector.push_back("RAYL");
119 fgControlNameVector.push_back("LABS");
120 fgControlNameVector.push_back("SYNC");
121 fgControlNameVector.push_back("NONE");
122}
123
124//
125// public methods
126//
127
128//_____________________________________________________________________________
130{
132
133 if (controlName == fgControlNameVector[kPAIR])
134 return kPAIR;
135 else if (controlName == fgControlNameVector[kCOMP])
136 return kCOMP;
137 else if (controlName == fgControlNameVector[kPHOT])
138 return kPHOT;
139 else if (controlName == fgControlNameVector[kPFIS])
140 return kPFIS;
141 else if (controlName == fgControlNameVector[kDRAY])
142 return kDRAY;
143 else if (controlName == fgControlNameVector[kANNI])
144 return kANNI;
145 else if (controlName == fgControlNameVector[kBREM])
146 return kBREM;
147 else if (controlName == fgControlNameVector[kHADR])
148 return kHADR;
149 else if (controlName == fgControlNameVector[kMUNU])
150 return kMUNU;
151 else if (controlName == fgControlNameVector[kDCAY])
152 return kDCAY;
153 else if (controlName == fgControlNameVector[kG3LOSS])
154 return kG3LOSS;
155 else if (controlName == fgControlNameVector[kMULS])
156 return kMULS;
157 else if (controlName == fgControlNameVector[kCKOV])
158 return kCKOV;
159 else if (controlName == fgControlNameVector[kRAYL])
160 return kRAYL;
161 else if (controlName == fgControlNameVector[kLABS])
162 return kLABS;
163 else if (controlName == fgControlNameVector[kSYNC])
164 return kSYNC;
165 else
166 return kNoG3Controls;
167}
168
169//_____________________________________________________________________________
171{
173
174 // fill name vector
175 if (fgControlNameVector.size() == 0)
177
178 return fgControlNameVector[control];
179}
180
181//_____________________________________________________________________________
183 G4int value, TG4G3Control control)
184{
187
188 switch (value) {
189 case kInActivate:
190 return kInActivate;
191 ;
192 ;
193 case kActivate:
194 return kActivate;
195 ;
196 ;
197 case kActivate2:
198 return kActivate2;
199 ;
200 ;
201 case 3:
202 case 4:
203 case 5:
204 if (control == kG3LOSS)
205 return kActivate;
206 else
207 return kUnsetControlValue;
208 ;
209 ;
210 }
211 return kUnsetControlValue;
212}
213
214//_____________________________________________________________________________
216 G4double value, TG4G3Control control)
217{
219
220 return TG4G3ControlVector::GetControlValue((G4int)value, control);
221}
222
223//_____________________________________________________________________________
225 TG4G3Control control, TG4G3ControlValue controlValue, TG4G3CutVector& cuts)
226{
230
231 if (control == kDRAY) {
232 if (controlValue == kActivate && GetControlValue(kG3LOSS) == kActivate2) {
234 "TG4Limits", "SetG3Control", "Cannot set DRAY=1 when LOSS=2.");
235 return false;
236 }
237 else
238 cuts.SetDeltaRaysOn(true);
239 }
240
241 if (control == kG3LOSS && controlValue == kActivate2) {
243 cuts.SetDeltaRaysOn(false);
244 }
245
246 fControlVector[control] = controlValue;
247 return true;
248}
249
250//_____________________________________________________________________________
252{
254
255 for (G4int i = 0; i <= kNoG3Controls; i++)
256 fControlVector[i] = TG4G3Defaults::Instance()->ControlValue(i);
257}
258
259//_____________________________________________________________________________
261{
266
267 G4bool result = false;
268
271 result = true;
272 }
273
274 // if both kG3LOSS values will have the same effect
275 // unset this control
276
277 TG4G3ControlValue passed = vector[kG3LOSS];
279
280 if (passed == kActivate2) passed = kActivate;
281 if (current == kActivate2) current = kActivate;
282 // there is no need to distinguish
283 // kActivate, kActivate2 after Init phase
284
285 if (current == passed) current = kUnsetControlValue;
286 // if both kG3LOSS values will have the same effect
287 // unset this control
288
289 if (current != fControlVector[kG3LOSS]) {
290 fControlVector[kG3LOSS] = current;
291 result = true;
292 }
293 return result;
294}
295
296//_____________________________________________________________________________
298{
300
301#if __GNUC__ >= 3
302 std::ostringstream tmpStream;
303#else
304 std::strstream tmpStream;
305#endif
306
307 tmpStream << " G3 control vector:" << G4endl;
308 for (G4int i = 0; i < kNoG3Controls; i++)
309 // if (i != kDRAY) {
310 tmpStream << " " << fgControlNameVector[i]
311 << " control value: " << fControlVector[i] << G4endl;
312 //}
313
314 return tmpStream.str();
315}
316
317//_____________________________________________________________________________
319{
321
322 G4cout << Format();
323}
324
325//_____________________________________________________________________________
327{
330
331 TG4G3Control control = TG4ProcessMap::Instance()->GetControl(process);
332
333 return fControlVector[control];
334}
335
336//_____________________________________________________________________________
338 TG4G3Control control) const
339{
342
343 return fControlVector[control];
344}
345
346//_____________________________________________________________________________
348{
350
351 for (G4int i = 0; i < kNoG3Controls; i++)
352 if (fControlVector[i] != kUnsetControlValue) return true;
353
354 return false;
355}
Definition of the TG4G3ControlVector class.
Definition of the TG4G3CutVector class.
Definition of the TG4G3Defaults class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4ProcessMap class.
TG4G3ControlVector & operator=(const TG4G3ControlVector &right)
static const G4String & GetControlName(TG4G3Control control)
TG4G3ControlValue operator[](G4int index) const
static TG4G3Control GetControl(const G4String &controlName)
G4bool Update(const TG4G3ControlVector &vector)
TG4ControlValueVector fControlVector
vector of control process values
G4bool SetControl(TG4G3Control control, TG4G3ControlValue controlValue, TG4G3CutVector &cuts)
static TG4StringVector fgControlNameVector
vector of control parameters names
static void FillControlNameVector()
static TG4G3ControlValue GetControlValue(G4int value, TG4G3Control control)
Vector of kinetic energy cut values with convenient set/get methods.
void SetDeltaRaysOn(G4bool value)
static TG4G3Defaults * Instance()
static void Warning(const TString &className, const TString &methodName, const TString &text)
static void Exception(const TString &className, const TString &methodName, const TString &text)
TG4G3Control GetControl(const G4VProcess *process) const
static TG4ProcessMap * Instance()
std::vector< G4String > TG4StringVector
Definition TG4Globals.h:49
TG4G3ControlValue
Enumeration for G3 processes control values.
TG4G3Control
Enumeration for G3 types of physics processes controls.
@ kInActivate
process is not activated
@ kActivate
process is activated WITH generation of secondaries
@ kUnsetControlValue
value not set
@ kActivate2
process is activated WITHOUT generation of secondaries
@ kDCAY
@ kPAIR
@ kPFIS
@ kNoG3Controls
No process control.
@ kHADR
@ kANNI
@ kRAYL
@ kDRAY
@ kG3LOSS
@ kCOMP
@ kBREM
@ kMUNU
@ kLABS
@ kSYNC
@ kCKOV
@ kMULS
@ kPHOT