]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4Limits.cxx
Example macro corrected
[u/mrichter/AliRoot.git] / TGeant4 / TG4Limits.cxx
1 // $Id$
2 // Category: global
3 //
4 // See the class description in the header file.
5
6 #include "TG4Limits.h"
7 #include "TG4G3CutVector.h"
8 #include "TG4G3ControlVector.h"
9
10 TG4Limits::TG4Limits()
11   : G4UserLimits(),              
12     // default values of G4UserLimits data members are set: 
13     // fMaxStep (DBL_MAX), fMaxTrack(DBL_MAX),fMaxTime(DBL_MAX),
14     // fMinEkine(0.), fMinRange(0.)
15     fIsCut(false),
16     fIsControl(false) 
17 {
18 //
19   fCutVector = new TG4G3CutVector();
20   fControlVector = new TG4G3ControlVector();
21 }
22
23 TG4Limits::TG4Limits(const TG4Limits& right)
24   : G4UserLimits(right) 
25 {
26 //    
27   // allocation
28   fCutVector = new TG4G3CutVector();
29   fControlVector = new TG4G3ControlVector();
30
31   // copy stuff
32   *this = right;
33 }  
34
35 TG4Limits::~TG4Limits() {
36 //
37   delete fCutVector;
38   delete fControlVector;
39 }
40
41 // operators
42
43 TG4Limits& TG4Limits::operator=(const TG4Limits& right)
44 {
45   // check assignement to self
46   if (this == &right) return *this;
47
48   // base class assignement
49   G4UserLimits::operator=(right);
50
51   *fCutVector  = *right.fCutVector;
52   *fControlVector = *right.fControlVector;
53
54   return *this;  
55 }    
56           
57 // private methods
58
59 G4double TG4Limits::GetUserMinEkine(const G4Track& track)
60 {
61 // Returns the kinetic energy cut for the particle
62 // associated with the specified track.
63 // ---
64
65   if (fIsCut)
66     return fCutVector->GetMinEkine(track);
67   else 
68     return fMinEkine;
69 }
70
71 // public methods
72
73 void TG4Limits::SetG3Cut(TG4G3Cut cut, G4double cutValue)
74 {
75 // Sets the cut value for the specified cut.
76 // ---
77
78   fCutVector->SetG3Cut(cut, cutValue);
79   fIsCut = true;
80 }
81
82 void TG4Limits::SetG3Control(TG4G3Control control, G4double flagValue)
83 {
84 // Sets the process control value for the specified flag.
85 // ---
86
87   fControlVector->SetG3Control(control, flagValue);
88   if (flagValue - kUnset > 0.01) fIsControl = true;
89 }
90
91 void TG4Limits::SetG3DefaultCuts()
92 {
93 // Sets the G3 default cut values for all cuts.
94 // ---
95
96   fCutVector->SetG3Defaults();
97   fIsCut = true;  
98 }
99
100 void TG4Limits::SetG3DefaultControls()
101 {
102 // Sets the G3 default process control values for all flags.
103 // ---
104
105   fControlVector->SetG3Defaults();
106   fIsControl = true;
107 }
108
109 G4double TG4Limits::GetMinEkineForGamma(const G4Track& track) const
110 {
111 // Returns the cut value for gamma.
112 // ---
113
114   if (fIsCut)
115     return fCutVector->GetMinEkine(track);
116   else 
117     return fMinEkine;
118 }
119
120 G4double TG4Limits::GetMinEkineForElectron(const G4Track& track) const
121 {
122 // Returns the cut value for e-.
123 // ---
124
125   if (fIsCut)
126     return fCutVector->GetMinEkineForElectron(track);
127   else 
128     return fMinEkine;
129 }
130
131 G4double TG4Limits::GetMinEkineForHadron(const G4Track& track) const
132 {
133 // Returns the cut value for charged hadron.
134 // ---
135
136   if (fIsCut)
137     return fCutVector->GetMinEkineForHadron(track);
138   else 
139     return fMinEkine;
140 }
141
142 G4double TG4Limits::GetMinEkineForNeutralHadron(const G4Track& track) const
143 {
144 // Returns the cut value for neutral hadron.
145 // ---
146
147   if (fIsCut)
148     return fCutVector->GetMinEkineForNeutralHadron(track);
149   else 
150     return fMinEkine;
151 }
152
153 G4double TG4Limits::GetMinEkineForMuon(const G4Track& track) const
154 {
155 // Returns the cut value for neutral muon.
156 // ---
157
158   if (fIsCut)
159     return fCutVector->GetMinEkineForMuon(track);
160   else 
161     return fMinEkine;
162 }
163
164 G4double TG4Limits::GetMinEkineForOther(const G4Track& track) const
165 {
166  // Returns 0.
167 // ---
168
169  return fMinEkine;
170 }
171
172 G4int TG4Limits::GetControl(G4VProcess* process) const 
173 {
174 // Returns the flag value for the particle associated with
175 // the specified process.
176 // ---
177
178   if (fIsControl)
179     return fControlVector->GetControl(process);
180   else 
181     return kUnset;
182 }