]>
Commit | Line | Data |
---|---|---|
2817d3e2 | 1 | // $Id$ |
2 | // Category: physics | |
3 | // | |
4 | // See the class description in the header file. | |
5 | ||
6 | #include "TG4SpecialCuts.h" | |
832ff774 | 7 | #include "TG4G3CutVector.h" |
2817d3e2 | 8 | #include "TG4Limits.h" |
9 | ||
10 | #include <G4UserLimits.hh> | |
11 | ||
12 | #include <G4EnergyLossTables.hh> | |
13 | ||
72095f7c | 14 | //_____________________________________________________________________________ |
832ff774 | 15 | TG4SpecialCuts::TG4SpecialCuts(TG4G3ParticleWSP particle, |
16 | TG4G3CutVector* cutVector, | |
2817d3e2 | 17 | const G4String& processName) |
18 | : G4UserSpecialCuts(processName), | |
19 | fCutVector(cutVector) | |
20 | { | |
21 | // | |
22 | switch (particle) { | |
23 | case kGamma: | |
832ff774 | 24 | fPtrMinEkineInCutVector = &TG4G3CutVector::GetMinEkineForGamma; |
2817d3e2 | 25 | fPtrMinEkineInLimits = &TG4Limits::GetMinEkineForGamma; |
26 | break; | |
27 | case kElectron: case kEplus: | |
832ff774 | 28 | fPtrMinEkineInCutVector = &TG4G3CutVector::GetMinEkineForElectron; |
2817d3e2 | 29 | fPtrMinEkineInLimits = &TG4Limits::GetMinEkineForElectron; |
30 | break; | |
31 | case kChargedHadron: | |
832ff774 | 32 | fPtrMinEkineInCutVector = &TG4G3CutVector::GetMinEkineForHadron; |
2817d3e2 | 33 | fPtrMinEkineInLimits = &TG4Limits::GetMinEkineForHadron; |
34 | break; | |
35 | case kNeutralHadron: | |
832ff774 | 36 | fPtrMinEkineInCutVector = &TG4G3CutVector::GetMinEkineForNeutralHadron; |
2817d3e2 | 37 | fPtrMinEkineInLimits = &TG4Limits::GetMinEkineForNeutralHadron; |
38 | break; | |
39 | case kMuon: | |
832ff774 | 40 | fPtrMinEkineInCutVector = &TG4G3CutVector::GetMinEkineForMuon; |
2817d3e2 | 41 | fPtrMinEkineInLimits = &TG4Limits::GetMinEkineForMuon; |
42 | break; | |
43 | case kAny: | |
832ff774 | 44 | fPtrMinEkineInCutVector = &TG4G3CutVector::GetMinEkineForOther; |
2817d3e2 | 45 | fPtrMinEkineInLimits = &TG4Limits::GetMinEkineForOther; |
46 | break; | |
47 | case kNofParticlesWSP: | |
48 | TG4Globals::Exception("TG4SpecialCuts: Wrong particle specification."); | |
49 | break; | |
50 | } | |
51 | } | |
52 | ||
72095f7c | 53 | //_____________________________________________________________________________ |
2817d3e2 | 54 | TG4SpecialCuts::TG4SpecialCuts() { |
55 | // | |
56 | } | |
57 | ||
72095f7c | 58 | //_____________________________________________________________________________ |
2817d3e2 | 59 | TG4SpecialCuts::TG4SpecialCuts(const TG4SpecialCuts& right) { |
60 | // | |
61 | TG4Globals::Exception( | |
62 | "TG4SpecialCuts is protected from copying."); | |
63 | } | |
64 | ||
72095f7c | 65 | //_____________________________________________________________________________ |
2817d3e2 | 66 | TG4SpecialCuts::~TG4SpecialCuts() { |
67 | // | |
68 | } | |
69 | ||
70 | // operators | |
71 | ||
72095f7c | 72 | //_____________________________________________________________________________ |
2817d3e2 | 73 | TG4SpecialCuts& TG4SpecialCuts::operator=(const TG4SpecialCuts& right) |
74 | { | |
75 | // check assignement to self | |
76 | if (this == &right) return *this; | |
77 | ||
78 | TG4Globals::Exception( | |
79 | "TG4SpecialCuts is protected from assigning."); | |
80 | ||
81 | return *this; | |
82 | } | |
83 | ||
84 | // public methods | |
85 | ||
72095f7c | 86 | //_____________________________________________________________________________ |
2817d3e2 | 87 | G4double TG4SpecialCuts::PostStepGetPhysicalInteractionLength( |
88 | const G4Track& track, G4double previousStepSize, | |
89 | G4ForceCondition* condition) | |
90 | { | |
91 | // Returns the Step-size (actual length) which is allowed | |
92 | // by this process. | |
93 | // --- | |
94 | ||
95 | // set condition | |
96 | *condition = NotForced; | |
97 | ||
98 | G4double proposedStep = DBL_MAX; | |
99 | G4UserLimits* limits | |
100 | = track.GetVolume()->GetLogicalVolume()->GetUserLimits(); | |
101 | if (limits) { | |
102 | // max track length | |
103 | proposedStep | |
104 | = (limits->GetUserMaxTrackLength(track) - track.GetTrackLength()); | |
105 | if (proposedStep < 0.) return 0.; | |
106 | ||
107 | // max time limit | |
108 | G4double beta | |
109 | = (track.GetDynamicParticle()->GetTotalMomentum()) / | |
110 | (track.GetTotalEnergy()); | |
111 | G4double time | |
112 | = (limits->GetUserMaxTime(track) - track.GetGlobalTime()); | |
113 | G4double temp = beta*c_light*time; | |
114 | if (temp < 0.) return 0.; | |
115 | if (proposedStep > temp) proposedStep = temp; | |
116 | ||
117 | // min remaining range | |
118 | G4ParticleDefinition* particle = track.GetDefinition(); | |
be7c1e4b | 119 | if (particle->GetPDGCharge() != 0.) { |
120 | G4double kinEnergy = track.GetKineticEnergy(); | |
121 | G4Material* material = track.GetMaterial(); | |
122 | G4double rangeNow | |
123 | = G4EnergyLossTables::GetRange(particle, kinEnergy, material); | |
124 | temp = (rangeNow - limits->GetUserMinRange(track)); | |
2817d3e2 | 125 | if (temp < 0.) return 0.; |
be7c1e4b | 126 | if (proposedStep > temp) proposedStep = temp; |
127 | ||
128 | // min kinetic energy (from limits) | |
129 | // the kin energy cut can be applied only in case | |
130 | // G4EnergyLossTables are defined for the particle | |
131 | if (G4EnergyLossTables::GetDEDXTable(particle)) { | |
132 | TG4Limits* tg4Limits = dynamic_cast<TG4Limits*>(limits); | |
133 | if (!tg4Limits) { | |
134 | G4String text = "TG4SpecialCuts::PostStepGetPhysicalInteractionLength:\n"; | |
135 | text = text + " Unknown limits type."; | |
136 | TG4Globals::Exception(text); | |
137 | } | |
138 | G4double minEkine | |
139 | = (tg4Limits->*fPtrMinEkineInLimits)(track); | |
140 | G4EnergyLossTables::GetTables(particle); | |
141 | G4double minR | |
142 | = G4EnergyLossTables::GetRange(particle, minEkine, material); | |
143 | temp = rangeNow - minR; | |
144 | if (temp < 0.) return 0.; | |
145 | if (proposedStep > temp) proposedStep = temp; | |
146 | } | |
2817d3e2 | 147 | } |
148 | ||
149 | } | |
150 | else if (fCutVector) { | |
151 | // min kinetic energy (from cut vector) | |
152 | // the kin energy cut can be applied only in case | |
153 | // G4EnergyLossTables are defined for the particle | |
154 | G4ParticleDefinition* particle = track.GetDefinition(); | |
155 | if (G4EnergyLossTables::GetDEDXTable(particle)) { | |
156 | G4double kinEnergy = track.GetKineticEnergy(); | |
157 | G4Material* material = track.GetMaterial(); | |
158 | G4double rangeNow | |
159 | = G4EnergyLossTables::GetRange(particle, kinEnergy, material); | |
160 | G4double minEkine | |
161 | = (fCutVector->*fPtrMinEkineInCutVector)(track); | |
162 | G4double minR | |
163 | = G4EnergyLossTables::GetRange(particle, minEkine, material); | |
164 | G4double temp = rangeNow - minR; | |
165 | if (temp < 0.) return 0.; | |
166 | if (proposedStep > temp) proposedStep = temp; | |
167 | } | |
168 | } | |
169 | return proposedStep; | |
170 | } | |
171 | ||
72095f7c | 172 | //_____________________________________________________________________________ |
2817d3e2 | 173 | G4VParticleChange* TG4SpecialCuts::PostStepDoIt(const G4Track& track, |
57f88f6f | 174 | const G4Step& step) |
2817d3e2 | 175 | { |
176 | // Kills the current particle, if requested by G4UserLimits. | |
177 | // --- | |
178 | ||
179 | aParticleChange.Initialize(track); | |
180 | aParticleChange.SetEnergyChange(0.) ; | |
181 | aParticleChange.SetLocalEnergyDeposit(track.GetKineticEnergy()) ; | |
182 | aParticleChange.SetStatusChange(fStopAndKill); | |
183 | return &aParticleChange; | |
184 | } |