]>
Commit | Line | Data |
---|---|---|
2817d3e2 | 1 | // $Id$ |
2 | // Category: global | |
3 | // | |
e5967ab3 | 4 | // Author: I. Hrivnacova |
5 | // | |
6 | // Class TG4Limits | |
7 | // --------------- | |
2817d3e2 | 8 | // See the class description in the header file. |
9 | ||
10 | #include "TG4Limits.h" | |
2817d3e2 | 11 | |
015b87e4 | 12 | #include <globals.hh> |
13 | ||
7915f36b | 14 | const G4double TG4Limits::fgkDefaultMaxStep = DBL_MAX; |
e5967ab3 | 15 | G4int TG4Limits::fgCounter = 0; |
16 | ||
17 | //_____________________________________________________________________________ | |
18 | TG4Limits::TG4Limits(const TG4G3CutVector& cuts, | |
19 | const TG4G3ControlVector& controls) | |
20 | : G4UserLimits(), | |
21 | // default values of G4UserLimits data members are set: | |
22 | // fMaxStep (DBL_MAX), fMaxTrack(DBL_MAX),fMaxTime(DBL_MAX), | |
23 | // fMinEkine(0.), fMinRange(0.) | |
24 | fName(""), | |
25 | fCutVector(cuts), | |
26 | fControlVector(), | |
27 | fIsCut(false), | |
28 | fIsControl(false) | |
29 | { | |
30 | // | |
31 | Initialize(cuts, controls); | |
32 | } | |
33 | ||
34 | //_____________________________________________________________________________ | |
35 | TG4Limits::TG4Limits(const G4String& name, | |
36 | const TG4G3CutVector& cuts, | |
37 | const TG4G3ControlVector& controls) | |
38 | : G4UserLimits(), | |
39 | // default values of G4UserLimits data members are set: | |
40 | // fMaxStep (DBL_MAX), fMaxTrack(DBL_MAX),fMaxTime(DBL_MAX), | |
41 | // fMinEkine(0.), fMinRange(0.) | |
42 | fName(name), | |
43 | fCutVector(cuts), | |
44 | fControlVector(), | |
45 | fIsCut(false), | |
46 | fIsControl(false) | |
47 | { | |
48 | // | |
49 | Initialize(cuts, controls); | |
50 | } | |
015b87e4 | 51 | |
72095f7c | 52 | //_____________________________________________________________________________ |
2817d3e2 | 53 | TG4Limits::TG4Limits() |
54 | : G4UserLimits(), | |
55 | // default values of G4UserLimits data members are set: | |
56 | // fMaxStep (DBL_MAX), fMaxTrack(DBL_MAX),fMaxTime(DBL_MAX), | |
57 | // fMinEkine(0.), fMinRange(0.) | |
e5967ab3 | 58 | fName(""), |
2817d3e2 | 59 | fIsCut(false), |
6eb43d7c | 60 | fIsControl(false) |
2817d3e2 | 61 | { |
62 | // | |
015b87e4 | 63 | fMaxStep = fgkDefaultMaxStep; |
e5967ab3 | 64 | |
65 | ++fgCounter; | |
2817d3e2 | 66 | } |
67 | ||
72095f7c | 68 | //_____________________________________________________________________________ |
2817d3e2 | 69 | TG4Limits::TG4Limits(const TG4Limits& right) |
70 | : G4UserLimits(right) | |
71 | { | |
72 | // | |
58c0119e | 73 | // copy stuff |
74 | *this = right; | |
e5967ab3 | 75 | |
76 | ++fgCounter; | |
2817d3e2 | 77 | } |
78 | ||
72095f7c | 79 | //_____________________________________________________________________________ |
2817d3e2 | 80 | TG4Limits::~TG4Limits() { |
81 | // | |
2817d3e2 | 82 | } |
83 | ||
84 | // operators | |
85 | ||
72095f7c | 86 | //_____________________________________________________________________________ |
2817d3e2 | 87 | TG4Limits& TG4Limits::operator=(const TG4Limits& right) |
88 | { | |
89 | // check assignement to self | |
90 | if (this == &right) return *this; | |
91 | ||
92 | // base class assignement | |
93 | G4UserLimits::operator=(right); | |
94 | ||
e5967ab3 | 95 | fName = right.fName; |
96 | fIsCut = right.fIsCut; | |
97 | fIsControl = right.fIsControl; | |
98 | fCutVector = right.fCutVector; | |
99 | fControlVector = right.fControlVector; | |
2817d3e2 | 100 | |
101 | return *this; | |
102 | } | |
103 | ||
104 | // private methods | |
105 | ||
e5967ab3 | 106 | //_____________________________________________________________________________ |
107 | void TG4Limits::Initialize(const TG4G3CutVector& cuts, | |
108 | const TG4G3ControlVector& controls) | |
109 | { | |
110 | // Initialization. | |
111 | // --- | |
112 | ||
113 | fMaxStep = fgkDefaultMaxStep; | |
114 | fMaxTime = cuts[kTOFMAX]; | |
115 | ||
116 | fControlVector.Update(controls); | |
117 | // only controls different from passed controls (default) are set | |
118 | ||
119 | fIsCut = fCutVector.IsCut(); | |
120 | fIsControl = fControlVector.IsControl(); | |
121 | ||
122 | ++fgCounter; | |
123 | } | |
124 | ||
125 | ||
126 | // public methods | |
127 | ||
72095f7c | 128 | //_____________________________________________________________________________ |
2817d3e2 | 129 | G4double TG4Limits::GetUserMinEkine(const G4Track& track) |
130 | { | |
e5967ab3 | 131 | // Returns the kinetic energy cut parameter. |
132 | // !! The cuts values defined if fCutVector are applied | |
133 | // only via TG4SpecialCuts process. | |
2817d3e2 | 134 | // --- |
135 | ||
e5967ab3 | 136 | return fMinEkine; |
2817d3e2 | 137 | } |
138 | ||
72095f7c | 139 | //_____________________________________________________________________________ |
6eb43d7c | 140 | void TG4Limits::SetG3Cut(TG4G3Cut cut, G4double cutValue) |
2817d3e2 | 141 | { |
142 | // Sets the cut value for the specified cut. | |
143 | // --- | |
144 | ||
e5967ab3 | 145 | fCutVector.SetCut(cut, cutValue); |
2817d3e2 | 146 | fIsCut = true; |
e5967ab3 | 147 | |
148 | if (cut == kTOFMAX) fMaxTime = cutValue; | |
2817d3e2 | 149 | } |
150 | ||
72095f7c | 151 | //_____________________________________________________________________________ |
e5967ab3 | 152 | void TG4Limits::SetG3Control(TG4G3Control control, |
153 | TG4G3ControlValue controlValue) | |
2817d3e2 | 154 | { |
e5967ab3 | 155 | // Sets the process control value for the specified control. |
2817d3e2 | 156 | // --- |
157 | ||
e5967ab3 | 158 | G4bool result |
159 | = fControlVector.SetControl(control, controlValue, fCutVector); | |
160 | ||
161 | if (result) fIsControl = true; | |
162 | ||
2817d3e2 | 163 | } |
164 | ||
72095f7c | 165 | //_____________________________________________________________________________ |
2817d3e2 | 166 | void TG4Limits::SetG3DefaultCuts() |
167 | { | |
168 | // Sets the G3 default cut values for all cuts. | |
169 | // --- | |
170 | ||
e5967ab3 | 171 | fCutVector.SetG3Defaults(); |
2817d3e2 | 172 | fIsCut = true; |
173 | } | |
174 | ||
e5967ab3 | 175 | //_____________________________________________________________________________ |
176 | G4bool TG4Limits::Update(const TG4G3ControlVector& controls) | |
177 | { | |
178 | // Updates controls in a special way. | |
179 | // Returns true if some control in fControlVector is after update | |
180 | // still set. | |
181 | // --- | |
182 | ||
183 | //G4bool result = fCutVector.Update(cutVector); | |
184 | //if (result) fIsCut = true; | |
185 | ||
186 | fControlVector.Update(controls); | |
187 | fIsControl = fControlVector.IsControl(); | |
188 | ||
189 | return fIsControl; | |
190 | } | |
191 | ||
72095f7c | 192 | //_____________________________________________________________________________ |
6eb43d7c | 193 | void TG4Limits::SetG3DefaultControls() |
2817d3e2 | 194 | { |
195 | // Sets the G3 default process control values for all flags. | |
196 | // --- | |
197 | ||
e5967ab3 | 198 | fControlVector.SetG3Defaults(); |
6eb43d7c | 199 | fIsControl = true; |
2817d3e2 | 200 | } |
201 | ||
e5967ab3 | 202 | //_____________________________________________________________________________ |
203 | void TG4Limits::Print() const | |
204 | { | |
205 | // Prints limits. | |
206 | // --- | |
207 | ||
208 | G4cout << "\"" << fName << "\" limits:"<< G4endl; | |
209 | G4cout << " Max step length (mm): " << fMaxStep/mm << G4endl; | |
210 | G4cout << " Max track length (mm): " << fMaxTrack/mm << G4endl; | |
211 | G4cout << " Max time (s) " << fMaxTime/s << G4endl; | |
212 | G4cout << " Min kin. energy (MeV) " << fMinEkine/MeV << G4endl; | |
213 | G4cout << " Min range (mm): " << fMinRange/mm << G4endl; | |
214 | ||
215 | if (!fIsCut) G4cout << " No special cuts. "<< G4endl; | |
216 | if (!fIsControl) G4cout << " No special controls. "<< G4endl; | |
217 | ||
218 | if (fIsCut) fCutVector.Print(); | |
219 | if (fIsControl) fControlVector.Print(); | |
220 | } | |
221 | ||
72095f7c | 222 | //_____________________________________________________________________________ |
2817d3e2 | 223 | G4double TG4Limits::GetMinEkineForGamma(const G4Track& track) const |
224 | { | |
225 | // Returns the cut value for gamma. | |
226 | // --- | |
227 | ||
228 | if (fIsCut) | |
e5967ab3 | 229 | return fCutVector.GetMinEkineForGamma(track); |
2817d3e2 | 230 | else |
231 | return fMinEkine; | |
232 | } | |
233 | ||
72095f7c | 234 | //_____________________________________________________________________________ |
2817d3e2 | 235 | G4double TG4Limits::GetMinEkineForElectron(const G4Track& track) const |
236 | { | |
237 | // Returns the cut value for e-. | |
238 | // --- | |
239 | ||
240 | if (fIsCut) | |
e5967ab3 | 241 | return fCutVector.GetMinEkineForElectron(track); |
242 | else | |
243 | return fMinEkine; | |
244 | } | |
245 | ||
246 | //_____________________________________________________________________________ | |
247 | G4double TG4Limits::GetMinEkineForEplus(const G4Track& track) const | |
248 | { | |
249 | // Returns the cut value for e-. | |
250 | // --- | |
251 | ||
252 | if (fIsCut) | |
253 | return fCutVector.GetMinEkineForEplus(track); | |
2817d3e2 | 254 | else |
255 | return fMinEkine; | |
256 | } | |
257 | ||
72095f7c | 258 | //_____________________________________________________________________________ |
e5967ab3 | 259 | G4double TG4Limits::GetMinEkineForChargedHadron(const G4Track& track) const |
2817d3e2 | 260 | { |
261 | // Returns the cut value for charged hadron. | |
262 | // --- | |
263 | ||
264 | if (fIsCut) | |
e5967ab3 | 265 | return fCutVector.GetMinEkineForChargedHadron(track); |
2817d3e2 | 266 | else |
267 | return fMinEkine; | |
268 | } | |
269 | ||
72095f7c | 270 | //_____________________________________________________________________________ |
2817d3e2 | 271 | G4double TG4Limits::GetMinEkineForNeutralHadron(const G4Track& track) const |
272 | { | |
273 | // Returns the cut value for neutral hadron. | |
274 | // --- | |
275 | ||
276 | if (fIsCut) | |
e5967ab3 | 277 | return fCutVector.GetMinEkineForNeutralHadron(track); |
2817d3e2 | 278 | else |
279 | return fMinEkine; | |
280 | } | |
281 | ||
72095f7c | 282 | //_____________________________________________________________________________ |
2817d3e2 | 283 | G4double TG4Limits::GetMinEkineForMuon(const G4Track& track) const |
284 | { | |
285 | // Returns the cut value for neutral muon. | |
286 | // --- | |
287 | ||
288 | if (fIsCut) | |
e5967ab3 | 289 | return fCutVector.GetMinEkineForMuon(track); |
2817d3e2 | 290 | else |
291 | return fMinEkine; | |
292 | } | |
293 | ||
72095f7c | 294 | //_____________________________________________________________________________ |
2817d3e2 | 295 | G4double TG4Limits::GetMinEkineForOther(const G4Track& track) const |
296 | { | |
297 | // Returns 0. | |
298 | // --- | |
299 | ||
e5967ab3 | 300 | if (fIsCut) |
301 | return fCutVector.GetMinEkineForOther(track); | |
302 | else | |
303 | return fMinEkine; | |
2817d3e2 | 304 | } |
305 | ||
72095f7c | 306 | //_____________________________________________________________________________ |
e5967ab3 | 307 | TG4G3ControlValue TG4Limits::GetControl(G4VProcess* process) const |
2817d3e2 | 308 | { |
309 | // Returns the flag value for the particle associated with | |
310 | // the specified process. | |
311 | // --- | |
312 | ||
6eb43d7c | 313 | if (fIsControl) |
e5967ab3 | 314 | return fControlVector.GetControlValue(process); |
2817d3e2 | 315 | else |
316 | return kUnset; | |
317 | } |