4 // Author: I. Hrivnacova
6 // Class TG4G3ControlVector
7 // ------------------------
8 // See the class description in the header file.
10 #include "TG4G3ControlVector.h"
11 #include "TG4G3CutVector.h"
12 #include "TG4ProcessControlMap.h"
13 #include "TG4G3Defaults.h"
14 #include "TG4Globals.h"
16 #include <G4VProcess.hh>
20 TG4StringVector TG4G3ControlVector::fgControlNameVector;
22 //_____________________________________________________________________________
23 TG4G3ControlVector::TG4G3ControlVector()
25 // initialize fControlVector
26 for (G4int i=0; i<=kNoG3Controls; i++) fControlVector.push_back(kUnset);
29 if (fgControlNameVector.size() == 0) FillControlNameVector();
32 //_____________________________________________________________________________
33 TG4G3ControlVector::TG4G3ControlVector(const TG4G3ControlVector& right)
34 : fControlVector(right.fControlVector.size())
40 //_____________________________________________________________________________
41 TG4G3ControlVector::~TG4G3ControlVector() {
47 //_____________________________________________________________________________
48 TG4G3ControlVector& TG4G3ControlVector::operator=(
49 const TG4G3ControlVector& right)
51 // check assignement to self
52 if (this == &right) return *this;
54 // initialize fControlVector
55 for (G4int i=0; i<=kNoG3Controls; i++)
56 fControlVector[i] = right.fControlVector[i];
61 //_____________________________________________________________________________
62 TG4G3ControlValue TG4G3ControlVector::operator[](G4int index) const
65 if (index <= kNoG3Controls)
66 return fControlVector[index];
68 TG4Globals::Exception(
69 "TG4G3ControlVector::operator[]: index out of the vector scope");
76 //_____________________________________________________________________________
77 void TG4G3ControlVector::FillControlNameVector()
79 // Defines fControlNameVector.
82 fgControlNameVector.push_back("PAIR");
83 fgControlNameVector.push_back("COMP");
84 fgControlNameVector.push_back("PHOT");
85 fgControlNameVector.push_back("PFIS");
86 fgControlNameVector.push_back("DRAY");
87 fgControlNameVector.push_back("ANNI");
88 fgControlNameVector.push_back("BREM");
89 fgControlNameVector.push_back("HADR");
90 fgControlNameVector.push_back("MUNU");
91 fgControlNameVector.push_back("DCAY");
92 fgControlNameVector.push_back("LOSS");
93 fgControlNameVector.push_back("MULS");
94 fgControlNameVector.push_back("CKOV");
95 fgControlNameVector.push_back("RAYL");
96 fgControlNameVector.push_back("LABS");
97 fgControlNameVector.push_back("SYNC");
98 fgControlNameVector.push_back("NONE");
103 //_____________________________________________________________________________
104 TG4G3Control TG4G3ControlVector::GetControl(const G4String& controlName)
106 // Retrieves corresponding TG4G3Control constant from the controlName.
109 if (controlName == fgControlNameVector[kPAIR]) return kPAIR;
110 else if (controlName == fgControlNameVector[kCOMP]) return kCOMP;
111 else if (controlName == fgControlNameVector[kPHOT]) return kPHOT;
112 else if (controlName == fgControlNameVector[kPFIS]) return kPFIS;
113 else if (controlName == fgControlNameVector[kDRAY]) return kDRAY;
114 else if (controlName == fgControlNameVector[kANNI]) return kANNI;
115 else if (controlName == fgControlNameVector[kBREM]) return kBREM;
116 else if (controlName == fgControlNameVector[kHADR]) return kHADR;
117 else if (controlName == fgControlNameVector[kMUNU]) return kMUNU;
118 else if (controlName == fgControlNameVector[kDCAY]) return kDCAY;
119 else if (controlName == fgControlNameVector[kLOSS]) return kLOSS;
120 else if (controlName == fgControlNameVector[kMULS]) return kMULS;
121 else return kNoG3Controls;
124 //_____________________________________________________________________________
125 const G4String& TG4G3ControlVector::GetControlName(TG4G3Control control)
127 // Returns name of a specified cut.
131 if (fgControlNameVector.size() == 0)
132 TG4G3ControlVector::FillControlNameVector();
134 return fgControlNameVector[control];
137 //_____________________________________________________________________________
138 TG4G3ControlValue TG4G3ControlVector::GetControlValue(G4int value,
139 TG4G3Control control)
141 // Conversion G4int -> G3ControlValue,
142 // special treatment for LOSS values 3,4,5.
155 case 3: case 4: case 5:
156 if (control == kLOSS)
165 //_____________________________________________________________________________
166 TG4G3ControlValue TG4G3ControlVector::GetControlValue(G4double value,
167 TG4G3Control control)
169 // Conversion G4double -> G3ControlValue
172 return TG4G3ControlVector::GetControlValue((G4int)value, control);
176 //_____________________________________________________________________________
177 G4bool TG4G3ControlVector::SetControl(TG4G3Control control,
178 TG4G3ControlValue controlValue,
179 TG4G3CutVector& cuts)
181 // Sets the controlValue for the specified process control.
182 // Modifies cuts if necessary.
183 // Returns true if the control value was set.
186 if (control == kDRAY)
187 if (controlValue == kActivate &&
188 GetControlValue(kLOSS) == kActivate2) {
190 "TG4Limits::SetG3Control: Cannot set DRAY=1 when LOSS=2.");
194 cuts.SetDeltaRaysOn(true);
196 if (control == kLOSS && controlValue == kActivate2) {
197 SetControl(kDRAY, kInActivate, cuts);
198 cuts.SetDeltaRaysOn(false);
201 fControlVector[control] = controlValue;
205 //_____________________________________________________________________________
206 void TG4G3ControlVector::SetG3Defaults()
208 // Sets G3 default values for all controls.
211 for (G4int i=0; i<=kNoG3Controls; i++)
212 fControlVector[i] = TG4G3Defaults::Instance()->ControlValue(i);
215 //_____________________________________________________________________________
216 G4bool TG4G3ControlVector::Update(const TG4G3ControlVector& vector)
218 // Unset value of DRAY (this information was passed to cut vector.)
219 // Resets value of LOSS (the special controls process operates only with
220 // activate/inactivate options.)
221 // Returns true if some value was modified.
224 G4bool result = false;
226 if (fControlVector[kDRAY] != kUnset ) {
227 fControlVector[kDRAY] = kUnset;
231 // if both kLOSS values will have the same effect
232 // unset this control
234 TG4G3ControlValue passed = vector[kLOSS];
235 TG4G3ControlValue current = fControlVector[kLOSS];
237 if (passed == kActivate2) passed = kActivate;
238 if (current == kActivate2) current = kActivate;
239 // there is no need to distinguish
240 // kActivate, kActivate2 after Init phase
242 if (current == passed) current = kUnset;
243 // if both kLOSS values will have the same effect
244 // unset this control
246 if (current != fControlVector[kLOSS]) {
247 fControlVector[kLOSS] = current;
253 //_____________________________________________________________________________
254 void TG4G3ControlVector::Print() const
256 // Prints the controls.
259 G4cout << " G3 control vector:" << G4endl;
260 for (G4int i=0; i<kNoG3Controls; i++)
262 G4cout << " " << fgControlNameVector[i]
263 << " control value: " << fControlVector[i] << G4endl;
267 //_____________________________________________________________________________
269 TG4G3ControlVector::GetControlValue(G4VProcess* process) const
271 // Returns the control value for the particle associated with
272 // the specified process.
276 = TG4ProcessControlMap::Instance()->GetControl(process);
278 return fControlVector[control];
281 //_____________________________________________________________________________
283 TG4G3ControlVector::GetControlValue(TG4G3Control control) const
285 // Returns the control value for the particle associated with
286 // the specified process.
289 return fControlVector[control];
292 //_____________________________________________________________________________
293 G4bool TG4G3ControlVector::IsControl() const
295 // Returns true if any of controls is set.
298 for (G4int i=0; i<kNoG3Controls; i++)
299 if (fControlVector[i] != kUnset) return true;