Geant4 VMC
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
source
global
src
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
31
TG4StringVector
TG4G3ControlVector::fgControlNameVector
;
32
33
//_____________________________________________________________________________
34
TG4G3ControlVector::TG4G3ControlVector
() :
fControlVector
()
35
{
37
38
// initialize fControlVector
39
for
(G4int i = 0; i <=
kNoG3Controls
; i++)
40
fControlVector
.push_back(
kUnsetControlValue
);
41
42
// fill name vector
43
if
(
fgControlNameVector
.size() == 0)
FillControlNameVector
();
44
}
45
46
//_____________________________________________________________________________
47
TG4G3ControlVector::TG4G3ControlVector
(
const
TG4G3ControlVector
& right)
48
:
fControlVector
(right.
fControlVector
.size())
49
{
51
52
// copy stuff
53
*
this
= right;
54
}
55
56
//_____________________________________________________________________________
57
TG4G3ControlVector::~TG4G3ControlVector
()
58
{
60
}
61
62
//
63
// operators
64
//
65
66
//_____________________________________________________________________________
67
TG4G3ControlVector
&
TG4G3ControlVector::operator=
(
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
//_____________________________________________________________________________
83
TG4G3ControlValue
TG4G3ControlVector::operator[]
(G4int index)
const
84
{
86
87
if
(index <=
kNoG3Controls
)
88
return
fControlVector
[index];
89
else
{
90
TG4Globals::Exception
(
91
"TG4G3ControlVector"
,
"operator[]"
,
"Index out of the vector scope"
);
92
return
kUnsetControlValue
;
93
}
94
}
95
96
//
97
// private methods
98
//
99
100
//_____________________________________________________________________________
101
void
TG4G3ControlVector::FillControlNameVector
()
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
//_____________________________________________________________________________
129
TG4G3Control
TG4G3ControlVector::GetControl
(
const
G4String& controlName)
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
//_____________________________________________________________________________
170
const
G4String&
TG4G3ControlVector::GetControlName
(
TG4G3Control
control)
171
{
173
174
// fill name vector
175
if
(
fgControlNameVector
.size() == 0)
176
TG4G3ControlVector::FillControlNameVector
();
177
178
return
fgControlNameVector
[control];
179
}
180
181
//_____________________________________________________________________________
182
TG4G3ControlValue
TG4G3ControlVector::GetControlValue
(
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
//_____________________________________________________________________________
215
TG4G3ControlValue
TG4G3ControlVector::GetControlValue
(
216
G4double value,
TG4G3Control
control)
217
{
219
220
return
TG4G3ControlVector::GetControlValue
((G4int)value, control);
221
}
222
223
//_____________________________________________________________________________
224
G4bool
TG4G3ControlVector::SetControl
(
225
TG4G3Control
control,
TG4G3ControlValue
controlValue,
TG4G3CutVector
& cuts)
226
{
230
231
if
(control ==
kDRAY
) {
232
if
(controlValue ==
kActivate
&&
GetControlValue
(
kG3LOSS
) ==
kActivate2
) {
233
TG4Globals::Warning
(
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
) {
242
SetControl
(
kDRAY
,
kInActivate
, cuts);
243
cuts.
SetDeltaRaysOn
(
false
);
244
}
245
246
fControlVector
[control] = controlValue;
247
return
true
;
248
}
249
250
//_____________________________________________________________________________
251
void
TG4G3ControlVector::SetG3Defaults
()
252
{
254
255
for
(G4int i = 0; i <=
kNoG3Controls
; i++)
256
fControlVector
[i] =
TG4G3Defaults::Instance
()->ControlValue(i);
257
}
258
259
//_____________________________________________________________________________
260
G4bool
TG4G3ControlVector::Update
(
const
TG4G3ControlVector
& vector)
261
{
266
267
G4bool result =
false
;
268
269
if
(
fControlVector
[
kDRAY
] !=
kUnsetControlValue
) {
270
fControlVector
[
kDRAY
] =
kUnsetControlValue
;
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
];
278
TG4G3ControlValue
current =
fControlVector
[
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
//_____________________________________________________________________________
297
G4String
TG4G3ControlVector::Format
()
const
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
//_____________________________________________________________________________
318
void
TG4G3ControlVector::Print
()
const
319
{
321
322
G4cout <<
Format
();
323
}
324
325
//_____________________________________________________________________________
326
TG4G3ControlValue
TG4G3ControlVector::GetControlValue
(
G4VProcess
* process)
const
327
{
330
331
TG4G3Control
control =
TG4ProcessMap::Instance
()->
GetControl
(process);
332
333
return
fControlVector
[control];
334
}
335
336
//_____________________________________________________________________________
337
TG4G3ControlValue
TG4G3ControlVector::GetControlValue
(
338
TG4G3Control
control)
const
339
{
342
343
return
fControlVector
[control];
344
}
345
346
//_____________________________________________________________________________
347
G4bool
TG4G3ControlVector::IsControl
()
const
348
{
350
351
for
(G4int i = 0; i <
kNoG3Controls
; i++)
352
if
(
fControlVector
[i] !=
kUnsetControlValue
)
return
true
;
353
354
return
false
;
355
}
TG4G3ControlVector.h
Definition of the TG4G3ControlVector class.
TG4G3CutVector.h
Definition of the TG4G3CutVector class.
TG4G3Defaults.h
Definition of the TG4G3Defaults class.
TG4Globals.h
Definition of the TG4Globals class and basic container types.
TG4ProcessMap.h
Definition of the TG4ProcessMap class.
G4VProcess
TG4G3ControlVector::operator=
TG4G3ControlVector & operator=(const TG4G3ControlVector &right)
Definition
TG4G3ControlVector.cxx:67
TG4G3ControlVector::GetControlName
static const G4String & GetControlName(TG4G3Control control)
Definition
TG4G3ControlVector.cxx:170
TG4G3ControlVector::SetG3Defaults
void SetG3Defaults()
Definition
TG4G3ControlVector.cxx:251
TG4G3ControlVector::operator[]
TG4G3ControlValue operator[](G4int index) const
Definition
TG4G3ControlVector.cxx:83
TG4G3ControlVector::~TG4G3ControlVector
~TG4G3ControlVector()
Definition
TG4G3ControlVector.cxx:57
TG4G3ControlVector::GetControl
static TG4G3Control GetControl(const G4String &controlName)
Definition
TG4G3ControlVector.cxx:129
TG4G3ControlVector::Update
G4bool Update(const TG4G3ControlVector &vector)
Definition
TG4G3ControlVector.cxx:260
TG4G3ControlVector::Print
void Print() const
Definition
TG4G3ControlVector.cxx:318
TG4G3ControlVector::TG4G3ControlVector
TG4G3ControlVector()
Definition
TG4G3ControlVector.cxx:34
TG4G3ControlVector::fControlVector
TG4ControlValueVector fControlVector
vector of control process values
Definition
TG4G3ControlVector.h:83
TG4G3ControlVector::SetControl
G4bool SetControl(TG4G3Control control, TG4G3ControlValue controlValue, TG4G3CutVector &cuts)
Definition
TG4G3ControlVector.cxx:224
TG4G3ControlVector::Format
G4String Format() const
Definition
TG4G3ControlVector.cxx:297
TG4G3ControlVector::IsControl
G4bool IsControl() const
Definition
TG4G3ControlVector.cxx:347
TG4G3ControlVector::fgControlNameVector
static TG4StringVector fgControlNameVector
vector of control parameters names
Definition
TG4G3ControlVector.h:77
TG4G3ControlVector::FillControlNameVector
static void FillControlNameVector()
Definition
TG4G3ControlVector.cxx:101
TG4G3ControlVector::GetControlValue
static TG4G3ControlValue GetControlValue(G4int value, TG4G3Control control)
Definition
TG4G3ControlVector.cxx:182
TG4G3CutVector
Vector of kinetic energy cut values with convenient set/get methods.
Definition
TG4G3CutVector.h:32
TG4G3CutVector::SetDeltaRaysOn
void SetDeltaRaysOn(G4bool value)
Definition
TG4G3CutVector.h:122
TG4G3Defaults::Instance
static TG4G3Defaults * Instance()
Definition
TG4G3Defaults.h:66
TG4Globals::Warning
static void Warning(const TString &className, const TString &methodName, const TString &text)
Definition
TG4Globals.cxx:48
TG4Globals::Exception
static void Exception(const TString &className, const TString &methodName, const TString &text)
Definition
TG4Globals.cxx:33
TG4ProcessMap::GetControl
TG4G3Control GetControl(const G4VProcess *process) const
Definition
TG4ProcessMap.cxx:137
TG4ProcessMap::Instance
static TG4ProcessMap * Instance()
Definition
TG4ProcessMap.h:72
TG4StringVector
std::vector< G4String > TG4StringVector
Definition
TG4Globals.h:49
TG4G3ControlValue
TG4G3ControlValue
Enumeration for G3 processes control values.
Definition
TG4G3Control.h:176
TG4G3Control
TG4G3Control
Enumeration for G3 types of physics processes controls.
Definition
TG4G3Control.h:29
kInActivate
@ kInActivate
process is not activated
Definition
TG4G3Control.h:181
kActivate
@ kActivate
process is activated WITH generation of secondaries
Definition
TG4G3Control.h:184
kUnsetControlValue
@ kUnsetControlValue
value not set
Definition
TG4G3Control.h:178
kActivate2
@ kActivate2
process is activated WITHOUT generation of secondaries
Definition
TG4G3Control.h:187
kDCAY
@ kDCAY
Definition
TG4G3Control.h:109
kPAIR
@ kPAIR
Definition
TG4G3Control.h:37
kPFIS
@ kPFIS
Definition
TG4G3Control.h:61
kNoG3Controls
@ kNoG3Controls
No process control.
Definition
TG4G3Control.h:157
kHADR
@ kHADR
Definition
TG4G3Control.h:94
kANNI
@ kANNI
Definition
TG4G3Control.h:78
kRAYL
@ kRAYL
Definition
TG4G3Control.h:139
kDRAY
@ kDRAY
Definition
TG4G3Control.h:71
kG3LOSS
@ kG3LOSS
Definition
TG4G3Control.h:118
kCOMP
@ kCOMP
Definition
TG4G3Control.h:46
kBREM
@ kBREM
Definition
TG4G3Control.h:87
kMUNU
@ kMUNU
Definition
TG4G3Control.h:102
kLABS
@ kLABS
Definition
TG4G3Control.h:147
kSYNC
@ kSYNC
Definition
TG4G3Control.h:154
kCKOV
@ kCKOV
Definition
TG4G3Control.h:132
kMULS
@ kMULS
Definition
TG4G3Control.h:125
kPHOT
@ kPHOT
Definition
TG4G3Control.h:54
Generated on
for Geant4 VMC by
1.17.0