Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4G3CutVector.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2018 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 "TG4G3CutVector.h"
16#include "TG4G3Defaults.h"
17#include "TG4Globals.h"
18
19#include "CLHEP/Units/PhysicalConstants.h"
20
21#include <G4EmProcessSubType.hh>
22#include <G4ParticleDefinition.hh>
23#include <G4SystemOfUnits.hh>
24#include <G4Track.hh>
25#include <G4VProcess.hh>
26
27#if __GNUC__ >= 3
28#include <sstream>
29#else
30#include <strstream>
31#endif
32
33const G4double TG4G3CutVector::fgkDCUTEOff = 10. * TeV;
34const G4double TG4G3CutVector::fgkDCUTMOff = 10. * TeV;
35const G4double TG4G3CutVector::fgkTolerance = 1. * keV;
36// for cut in time this value represents 1e-03s
38
39//
40// static methods
41//
42
43//_____________________________________________________________________________
44TG4G3Cut TG4G3CutVector::GetCut(const G4String& cutName)
45{
47
48 if (cutName == fgCutNameVector[kCUTGAM])
49 return kCUTGAM;
50 else if (cutName == fgCutNameVector[kCUTELE])
51 return kCUTELE;
52 else if (cutName == fgCutNameVector[kCUTNEU])
53 return kCUTNEU;
54 else if (cutName == fgCutNameVector[kCUTHAD])
55 return kCUTHAD;
56 else if (cutName == fgCutNameVector[kCUTMUO])
57 return kCUTMUO;
58 else if (cutName == fgCutNameVector[kBCUTE])
59 return kBCUTE;
60 else if (cutName == fgCutNameVector[kBCUTM])
61 return kBCUTM;
62 else if (cutName == fgCutNameVector[kDCUTE])
63 return kDCUTE;
64 else if (cutName == fgCutNameVector[kDCUTM])
65 return kDCUTM;
66 else if (cutName == fgCutNameVector[kPPCUTM])
67 return kPPCUTM;
68 else if (cutName == fgCutNameVector[kTOFMAX])
69 return kTOFMAX;
70 else
71 return kNoG3Cuts;
72}
73
74//_____________________________________________________________________________
75G4bool TG4G3CutVector::CheckCutValue(TG4G3Cut cut, G4double value)
76{
80
81 // G4cout << "TG4G3CutVector::CheckCutValue: "
82 // << value / MeV << " MeV "
83 // << 2.*CLHEP::electron_mass_c2 / MeV << " MeV" << G4endl;
84
85 if (cut == kPPCUTM &&
86 value < (2. * CLHEP::electron_mass_c2 - TG4G3CutVector::Tolerance())) {
87 // TString message = "PPCUTM cut value ";
88 // message += value;
89 // message += " MeV is lower than 2*e_mass.";
90 // TG4Globals::Warning(
91 // "TG4G3CutVector", "CheckCutValue",
92 // message + TG4Globals::Endl() +
93 // TString("The cut will be ignored."));
94 // The cut value is often set to 1 MeV, which makes no difference
95 // in Geant4, but in Geant3 it overrides the default, 10 MeV
96 return false;
97 }
98
99 return true;
100}
101
102//_____________________________________________________________________________
104{
106
107 // fill name vector
109
110 return fgCutNameVector[cut];
111}
112
113//
114// ctors, dtors
115//
116
117//_____________________________________________________________________________
119{
121
122 // fill name vector
123 if (fgCutNameVector.size() == 0) FillCutNameVector();
124
125 // initialize fCutVector
126 for (G4int i = 0; i < kTOFMAX; i++) {
127 fCutVector.push_back(0.);
128 }
129 fCutVector.push_back(DBL_MAX);
130}
131
132//_____________________________________________________________________________
134 : fCutVector(right.fCutVector.size()), fDeltaRaysOn(right.fDeltaRaysOn)
135{
137
138 // copy stuff
139 *this = right;
140}
141
142//_____________________________________________________________________________
147
148//
149// operators
150//
151
152//_____________________________________________________________________________
154{
156
157 // check assignement to self
158 if (this == &right) return *this;
159
160 // copy fCutVector
161 for (G4int i = 0; i < kNoG3Cuts; i++) {
162 fCutVector[i] = right.fCutVector[i];
163 }
164
166 fIsCut = right.fIsCut;
167
168 // copy flag arrays
169 for (G4int i = 0; i <= kDM; ++i) {
170 fIsBDCut[i] = right.fIsBDCut[i];
171 fApplyBDCut[i] = right.fApplyBDCut[i];
172 }
173;
174
175 return *this;
176}
177
178//_____________________________________________________________________________
179G4double TG4G3CutVector::operator[](G4int index) const
180{
182
183 if (index < kNoG3Cuts)
184 return fCutVector[index];
185 else {
187 "TG4G3CutVector", "operator[]", "Index out of the vector scope");
188 return 0.;
189 }
190}
191
192//
193// private methods
194//
195
196//_____________________________________________________________________________
198{
200
201 fgCutNameVector.push_back("CUTGAM");
202 fgCutNameVector.push_back("CUTELE");
203 fgCutNameVector.push_back("CUTNEU");
204 fgCutNameVector.push_back("CUTHAD");
205 fgCutNameVector.push_back("CUTMUO");
206 fgCutNameVector.push_back("BCUTE");
207 fgCutNameVector.push_back("BCUTM");
208 fgCutNameVector.push_back("DCUTE");
209 fgCutNameVector.push_back("DCUTM");
210 fgCutNameVector.push_back("PPCUTM");
211 fgCutNameVector.push_back("TOFMAX");
212 fgCutNameVector.push_back("NONE");
213}
214
215//
216// public methods
217//
218
219//_____________________________________________________________________________
220void TG4G3CutVector::SetCut(TG4G3Cut cut, G4double cutValue)
221{
223
224 if (cut >= kNoG3Cuts) {
225 TG4Globals::Exception("TG4G3CutVector", "SetG3Cut", "Inconsistent cut.");
226 }
227
228 fCutVector[cut] = cutValue;
229 if (cutValue > 0.) {
230 fIsCut = true;
231 }
232
233 // Update the selected flags
234 if (cut == kBCUTE) {
235 fIsBDCut[kBE] = true;
236 }
237 else if (cut == kBCUTM) {
238 fIsBDCut[kBM] = true;
239 }
240 else if (cut == kDCUTE) {
241 fIsBDCut[kDE] = true;
242 }
243 else if (cut == kDCUTM) {
244 fIsBDCut[kDM] = true;
245 }
246
247 // set the CUTGAM value also to BCUTE, BCUTM unless they were already set
248 if (cut == kCUTGAM) {
249 if (!fIsBDCut[kBE]) {
250 fCutVector[kBCUTE] = cutValue;
251 }
252 if (!fIsBDCut[kBM]) {
253 fCutVector[kBCUTM] = cutValue;
254 }
255 }
256
257 // Set the CUTELE value also to DCUTE, DCUTM unless they were already set
258 if (cut == kCUTELE) {
259 if (!fIsBDCut[kDE]) {
260 fCutVector[kDCUTE] = cutValue;
261 }
262 if (!fIsBDCut[kDM]) {
263 fCutVector[kDCUTM] = cutValue;
264 }
265 }
266
267 // Save whther the [B/D]CUT should be taken into account
271
275
276 // G4cout << "Flags after SetCut " << cut << " value: " << cutValue << ": " << G4endl
277 // << "kB:" << fApplyBDCut[kB] << ", "
278 // << "kBEM:" << fApplyBDCut[kBEM] << ", "
279 // << "kD:" << fApplyBDCut[kD] << ", "
280 // << "kDEM:" << fApplyBDCut[kDEM] << G4endl;
281}
282
283//_____________________________________________________________________________
285{
287
288 for (G4int i = 0; i < kNoG3Cuts; i++) {
290 }
291
292 fIsCut = true;
293}
294
295//_____________________________________________________________________________
297{
299
300#if __GNUC__ >= 3
301 std::ostringstream tmpStream;
302#else
303 std::strstream tmpStream;
304#endif
305
306 tmpStream << " G3 cut vector:" << G4endl;
307 if (fDeltaRaysOn)
308 tmpStream << " Delta rays On" << G4endl;
309 else
310 tmpStream << " Delta rays Off" << G4endl;
311
312 // energy cuts
313 for (G4int i = 0; i < kTOFMAX; i++) {
314
315 tmpStream << " " << fgCutNameVector[i] << " cut value (MeV): ";
316
317 if (i == kDCUTE && !fDeltaRaysOn)
318 tmpStream << fgkDCUTEOff / MeV << G4endl;
319 else if (i == kDCUTM && !fDeltaRaysOn)
320 tmpStream << fgkDCUTMOff / MeV << G4endl;
321 else
322 tmpStream << fCutVector[i] / MeV << G4endl;
323 }
324
325 // time cut
326 tmpStream << " " << fgCutNameVector[kTOFMAX]
327 << " cut value (s): " << fCutVector[kTOFMAX] / s << G4endl;
328
329 return tmpStream.str();
330}
331
332//_____________________________________________________________________________
334{
336
337 G4cout << Format();
338}
339
340//_____________________________________________________________________________
341G4double TG4G3CutVector::GetMinEkineForGamma(const G4Track& track) const
342{
350
351 // Special treatment of bremstrahlung threshold:
352 // apply the BCUT* in the first step only
353 if (track.GetCurrentStepNumber() == 1 &&
354 track.GetCreatorProcess() != nullptr &&
355 track.GetCreatorProcess()->GetProcessSubType() == fBremsstrahlung) {
356
357 // Cut for Bremstrahlung not set
358 if (! fApplyBDCut[kB]) {
359 return fCutVector[kCUTGAM];
360 }
361
362 if (! fApplyBDCut[kBEM]) {
363 // Bremstrahlung - BCUTE, BCUTM need not to be applied separately
364 return fCutVector[kBCUTE];
365 }
366 else {
367 // Bremstrahlung - BCUTE, BCUTM are different
368 auto processName = track.GetCreatorProcess()->GetProcessName();
369 if (processName == "eBrem") {
370 return fCutVector[kBCUTE];
371 }
372 else if (processName == "muBrems" || processName == "hBrems") {
373 return fCutVector[kBCUTM];
374 }
375 else {
376 return fCutVector[kCUTGAM];
377 }
378 }
379 }
380 else {
381 return fCutVector[kCUTGAM];
382 }
383}
384
385//_____________________________________________________________________________
386G4double TG4G3CutVector::GetMinEkineForElectron(const G4Track& track) const
387{
398
399 // Special treatment of delta rays threashold:
400 // apply the DCUT* in the first step only
401 if (track.GetCurrentStepNumber() == 1 &&
402 track.GetCreatorProcess() != nullptr &&
403 track.GetCreatorProcess()->GetProcessSubType() == fIonisation ) {
404
405 // Delta e- are switched off
406 if (! fDeltaRaysOn) {
407 return fgkDCUTEOff;
408 }
409
410 // Cut for Delta e- is not set
411 if (! fApplyBDCut[kD]) {
412 return fCutVector[kCUTELE];
413 }
414
415 if (! fApplyBDCut[kDEM]) {
416 // Delta e- - DCUTE, DCUTM need not to be applied separately
417 return fCutVector[kDCUTE];
418 }
419 else {
420 // Delta e- - DCUTE, DCUTM are different
421 auto processName = track.GetCreatorProcess()->GetProcessName();
422 if (processName == "eIoni") {
423 return fCutVector[kDCUTE];
424 }
425 else if (processName == "muIoni") {
426 return fCutVector[kDCUTM];
427 }
428 else {
429 return fCutVector[kCUTELE];
430 }
431 }
432 }
433 else {
434 // return CUTELE in other cases
435 return fCutVector[kCUTELE];
436 }
437}
438
439//_____________________________________________________________________________
441 const G4Track& /*track*/) const
442{
444
445 return fCutVector[kCUTHAD];
446}
447
448//_____________________________________________________________________________
450 const G4Track& /*track*/) const
451{
453
454 return fCutVector[kCUTNEU];
455}
456
457//_____________________________________________________________________________
458G4double TG4G3CutVector::GetMinEkineForMuon(const G4Track& /*track*/) const
459{
461
462 return fCutVector[kCUTMUO];
463}
464
465//_____________________________________________________________________________
467{
469
470 return fCutVector[kPPCUTM];
471}
Definition of the TG4G3CutVector class.
Definition of the TG4G3Defaults class.
Definition of the TG4Globals class and basic container types.
Vector of kinetic energy cut values with convenient set/get methods.
std::array< G4bool, 4 > fApplyBDCut
flag set if [B/D]CUT[E/M] cut is different from CUT[ELE/GAM]
G4bool fIsCut
flag if any value is set
G4double GetMinEkineForChargedHadron(const G4Track &track) const
static TG4G3Cut GetCut(const G4String &cutName)
TG4doubleVector fCutVector
vector of kinetic energy cut values
G4double GetMinEtotPair() const
static G4double Tolerance()
static TG4StringVector fgCutNameVector
vector of cut parameters names
static const G4double fgkDCUTMOff
cut for delta rays by mu (if off)
static G4bool CheckCutValue(TG4G3Cut cut, G4double value)
std::array< G4bool, 4 > fIsBDCut
flag to prevent overwiting [B/D]CUT[E/M] cut if set by user
G4double operator[](G4int index) const
G4double GetMinEkineForGamma(const G4Track &track) const
static const G4String & GetCutName(TG4G3Cut cut)
G4String Format() const
G4double GetMinEkineForMuon(const G4Track &track) const
G4double GetMinEkineForNeutralHadron(const G4Track &track) const
static const G4double fgkDCUTEOff
cut for delta rays by e- (if off)
void Print() const
G4bool fDeltaRaysOn
delta rays process control
TG4G3CutVector & operator=(const TG4G3CutVector &right)
G4double GetMinEkineForElectron(const G4Track &track) const
static void FillCutNameVector()
void SetCut(TG4G3Cut cut, G4double cutValue)
static const G4double fgkTolerance
tolerance for comparing cuts
static TG4G3Defaults * Instance()
G4double CutValue(G4int cut) const
static void Exception(const TString &className, const TString &methodName, const TString &text)
std::vector< G4String > TG4StringVector
Definition TG4Globals.h:49
TG4G3Cut
Enumeration for G3 types of kinetic energy cuts.
Definition TG4G3Cut.h:22
@ kCUTGAM
Definition TG4G3Cut.h:27
@ kDCUTM
Definition TG4G3Cut.h:67
@ kDCUTE
Definition TG4G3Cut.h:62
@ kCUTHAD
Definition TG4G3Cut.h:42
@ kNoG3Cuts
Invalid value.
Definition TG4G3Cut.h:80
@ kBCUTM
Definition TG4G3Cut.h:57
@ kCUTNEU
Definition TG4G3Cut.h:37
@ kCUTMUO
Definition TG4G3Cut.h:47
@ kCUTELE
Definition TG4G3Cut.h:32
@ kPPCUTM
Definition TG4G3Cut.h:72
@ kBCUTE
Definition TG4G3Cut.h:52
@ kTOFMAX
Definition TG4G3Cut.h:77