4 // Author: I. Hrivnacova
8 // See the class description in the header file.
10 #include "TG4Limits.h"
14 const G4double TG4Limits::fgkDefaultMaxStep = DBL_MAX;
15 G4int TG4Limits::fgCounter = 0;
17 //_____________________________________________________________________________
18 TG4Limits::TG4Limits(const TG4G3CutVector& cuts,
19 const TG4G3ControlVector& controls)
21 // default values of G4UserLimits data members are set:
22 // fMaxStep (DBL_MAX), fMaxTrack(DBL_MAX),fMaxTime(DBL_MAX),
23 // fMinEkine(0.), fMinRange(0.)
31 Initialize(cuts, controls);
34 //_____________________________________________________________________________
35 TG4Limits::TG4Limits(const G4String& name,
36 const TG4G3CutVector& cuts,
37 const TG4G3ControlVector& controls)
39 // default values of G4UserLimits data members are set:
40 // fMaxStep (DBL_MAX), fMaxTrack(DBL_MAX),fMaxTime(DBL_MAX),
41 // fMinEkine(0.), fMinRange(0.)
49 Initialize(cuts, controls);
52 //_____________________________________________________________________________
53 TG4Limits::TG4Limits()
55 // default values of G4UserLimits data members are set:
56 // fMaxStep (DBL_MAX), fMaxTrack(DBL_MAX),fMaxTime(DBL_MAX),
57 // fMinEkine(0.), fMinRange(0.)
63 fMaxStep = fgkDefaultMaxStep;
68 //_____________________________________________________________________________
69 TG4Limits::TG4Limits(const TG4Limits& right)
79 //_____________________________________________________________________________
80 TG4Limits::~TG4Limits() {
86 //_____________________________________________________________________________
87 TG4Limits& TG4Limits::operator=(const TG4Limits& right)
89 // check assignement to self
90 if (this == &right) return *this;
92 // base class assignement
93 G4UserLimits::operator=(right);
96 fIsCut = right.fIsCut;
97 fIsControl = right.fIsControl;
98 fCutVector = right.fCutVector;
99 fControlVector = right.fControlVector;
106 //_____________________________________________________________________________
107 void TG4Limits::Initialize(const TG4G3CutVector& cuts,
108 const TG4G3ControlVector& controls)
113 fMaxStep = fgkDefaultMaxStep;
114 fMaxTime = cuts[kTOFMAX];
116 fControlVector.Update(controls);
117 // only controls different from passed controls (default) are set
119 fIsCut = fCutVector.IsCut();
120 fIsControl = fControlVector.IsControl();
128 //_____________________________________________________________________________
129 G4double TG4Limits::GetUserMinEkine(const G4Track& track)
131 // Returns the kinetic energy cut parameter.
132 // !! The cuts values defined if fCutVector are applied
133 // only via TG4SpecialCuts process.
139 //_____________________________________________________________________________
140 void TG4Limits::SetG3Cut(TG4G3Cut cut, G4double cutValue)
142 // Sets the cut value for the specified cut.
145 fCutVector.SetCut(cut, cutValue);
148 if (cut == kTOFMAX) fMaxTime = cutValue;
151 //_____________________________________________________________________________
152 void TG4Limits::SetG3Control(TG4G3Control control,
153 TG4G3ControlValue controlValue)
155 // Sets the process control value for the specified control.
159 = fControlVector.SetControl(control, controlValue, fCutVector);
161 if (result) fIsControl = true;
165 //_____________________________________________________________________________
166 void TG4Limits::SetG3DefaultCuts()
168 // Sets the G3 default cut values for all cuts.
171 fCutVector.SetG3Defaults();
175 //_____________________________________________________________________________
176 G4bool TG4Limits::Update(const TG4G3ControlVector& controls)
178 // Updates controls in a special way.
179 // Returns true if some control in fControlVector is after update
183 //G4bool result = fCutVector.Update(cutVector);
184 //if (result) fIsCut = true;
186 fControlVector.Update(controls);
187 fIsControl = fControlVector.IsControl();
192 //_____________________________________________________________________________
193 void TG4Limits::SetG3DefaultControls()
195 // Sets the G3 default process control values for all flags.
198 fControlVector.SetG3Defaults();
202 //_____________________________________________________________________________
203 void TG4Limits::Print() const
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;
215 if (!fIsCut) G4cout << " No special cuts. "<< G4endl;
216 if (!fIsControl) G4cout << " No special controls. "<< G4endl;
218 if (fIsCut) fCutVector.Print();
219 if (fIsControl) fControlVector.Print();
222 //_____________________________________________________________________________
223 G4double TG4Limits::GetMinEkineForGamma(const G4Track& track) const
225 // Returns the cut value for gamma.
229 return fCutVector.GetMinEkineForGamma(track);
234 //_____________________________________________________________________________
235 G4double TG4Limits::GetMinEkineForElectron(const G4Track& track) const
237 // Returns the cut value for e-.
241 return fCutVector.GetMinEkineForElectron(track);
246 //_____________________________________________________________________________
247 G4double TG4Limits::GetMinEkineForEplus(const G4Track& track) const
249 // Returns the cut value for e-.
253 return fCutVector.GetMinEkineForEplus(track);
258 //_____________________________________________________________________________
259 G4double TG4Limits::GetMinEkineForChargedHadron(const G4Track& track) const
261 // Returns the cut value for charged hadron.
265 return fCutVector.GetMinEkineForChargedHadron(track);
270 //_____________________________________________________________________________
271 G4double TG4Limits::GetMinEkineForNeutralHadron(const G4Track& track) const
273 // Returns the cut value for neutral hadron.
277 return fCutVector.GetMinEkineForNeutralHadron(track);
282 //_____________________________________________________________________________
283 G4double TG4Limits::GetMinEkineForMuon(const G4Track& track) const
285 // Returns the cut value for neutral muon.
289 return fCutVector.GetMinEkineForMuon(track);
294 //_____________________________________________________________________________
295 G4double TG4Limits::GetMinEkineForOther(const G4Track& track) const
301 return fCutVector.GetMinEkineForOther(track);
306 //_____________________________________________________________________________
307 TG4G3ControlValue TG4Limits::GetControl(G4VProcess* process) const
309 // Returns the flag value for the particle associated with
310 // the specified process.
314 return fControlVector.GetControlValue(process);