Geant4  10.02
XWrapperDiscreteProcess.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 
28 
29 #include "G4Step.hh"
30 #include "G4StepPoint.hh"
31 #include "G4VParticleChange.hh"
32 
33 #include "G4Material.hh"
34 #include "G4NistManager.hh"
36 #include "G4Navigator.hh"
37 #include "G4GeometryTolerance.hh"
38 
39 #include "G4SystemOfUnits.hh"
41 
43 :G4VDiscreteProcess(aName){
44  if (verboseLevel>1) {
45  G4cout << GetProcessName() << " is created "<< G4endl;
46  }
50 }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
53 
56  G4VDiscreteProcess* toRegister)
57 :G4VDiscreteProcess("XWrapperDiscreteProcess"){
58  fRegisteredProcess = toRegister;
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
70 
72  ;
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
76 
79 G4VDiscreteProcess(right){
80  ;
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
84 
86  fRegisteredProcess = toRegister;
92 }
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
95 
97  G4int flag,
98  G4int region){
99  fRegisteredProcess = toRegister;
100  bNucleiOrElectronFlag = flag;
107 }
108 
109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
110 
112  bNucleiOrElectronFlag = flag;
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
116 
118  return bNucleiOrElectronFlag;
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
122 
124  ExExChParticleUserInfo* chanInfo =
126 
127  if(chanInfo){
128  if((chanInfo->GetInTheCrystal() == true) &&
131  return 1;
132  }
133  if((chanInfo->GetInTheCrystal() == false) &&
136  return 2;
137  }
138  }
139  else {
140  G4cout << G4endl << "XWrapperDiscreteProcess::";
141  G4cout << "ERROR - no ExExChParticleUserInfo object Detected";
142  G4cout << G4endl;
143  }
144 
145  return 0;
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
150  //Retrieve nuclei and electron density
151  //from ExExChParticleUserInfo object
152  G4double vDensity = 1.;
153 
154  if(ItHasToWork(aTrack)){
155  ExExChParticleUserInfo* chanInfo =
157 
158  if(chanInfo){
159  if(bNucleiOrElectronFlag == +1){
160  vDensity = chanInfo->GetNucleiDensity();
161  }
162  else if(bNucleiOrElectronFlag == -1){
163  vDensity = chanInfo->GetElectronDensity();
164  }
165  else{
166  vDensity = (chanInfo->GetNucleiDensity()
167  + chanInfo->GetElectronDensity())/2.;
168  }
169  }
170  }
171 
172  return vDensity;
173 }
174 
175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
176 
179  //Retrieve nuclei and electron density
180  //from ExExChParticleUserInfo object
181 
182  G4double vDensityPreviousStep = 1.;
183 
184  if(ItHasToWork(aTrack)){
185  ExExChParticleUserInfo* chanInfo =
187 
188  if(bNucleiOrElectronFlag == +1){
189  vDensityPreviousStep = chanInfo->GetNucleiDensityPreviousStep();
190  }
191  else if(bNucleiOrElectronFlag == -1){
192  vDensityPreviousStep = chanInfo->GetElectronDensityPreviousStep();
193  }
194  else{
195  vDensityPreviousStep =
196  (chanInfo->GetNucleiDensityPreviousStep()
197  + chanInfo->GetElectronDensityPreviousStep())/2.;
198  }
199  }
200 
201  return vDensityPreviousStep;
202 }
203 
204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
205 
206 
207 
208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
209 
210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
213 
214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
217 
218 
219 
220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
221 
227 }
228 
229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
230 
232  G4double, //previousStepSize,
234  return DBL_MAX;
235 }
236 
237 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
238 
241  G4double previousStepSize,
243  if(ItHasToWork(aTrack) == 1){
244  G4double vDensity = GetDensity(aTrack);
245  G4double vDensityPreviousStep = GetDensityPreviousStep(aTrack);
246 
247  if ( (previousStepSize < 0.0) ||
249  // beginning of tracking (or just after DoIt of this process)
251  } else if ( previousStepSize > 0.0) {
252  // subtract NumberOfInteractionLengthLeft
254  * vDensityPreviousStep);
255  } else {
256  // zero step DO NOTHING
257  }
258 
259  G4double regIntLength =
261  previousStepSize * vDensityPreviousStep,
262  condition);
263  G4double regIntNumber =
265  if(regIntNumber!=0){
266  currentInteractionLength = regIntLength / regIntNumber;
267  }
268  else{
269  return DBL_MAX;
270  }
271  theNumberOfInteractionLengthLeft = regIntNumber;
272 
275  if ( vDensity == 0. ) return DBL_MAX;
276  currentInteractionLength /= vDensity;
278  }
279  else if(ItHasToWork(aTrack) == 2){
281  previousStepSize,
282  condition);
283  }
284  else{
285  return DBL_MAX;
286  }
287 }
288 
289 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
290 
292  const G4Step& aStep ){
293  if(ItHasToWork(aTrack) == 1){
294  return fRegisteredProcess->PostStepDoIt(aTrack, aStep);
295  }
296  else if(ItHasToWork(aTrack) == 2){
297  return fRegisteredProcess->PostStepDoIt(aTrack, aStep);
298  }
300  return pParticleChange;
301 }
302 
303 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
304 
305 
307 IsApplicable(const G4ParticleDefinition& aParticleDefinition){
308  return fRegisteredProcess->IsApplicable(aParticleDefinition);
309 }
310 
311 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
312 
314 BuildPhysicsTable(const G4ParticleDefinition& aParticleDefinition){
315  fRegisteredProcess->BuildPhysicsTable(aParticleDefinition);
316 }
317 
318 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
319 
321 PreparePhysicsTable(const G4ParticleDefinition& aParticleDefinition){
322  fRegisteredProcess->PreparePhysicsTable(aParticleDefinition);
323 }
324 
325 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
326 
328 StorePhysicsTable(const G4ParticleDefinition* aParticleDefinition,
329  const G4String& aString,
330  G4bool aBool){
331  return fRegisteredProcess->StorePhysicsTable(aParticleDefinition,
332  aString,
333  aBool);
334 }
335 
336 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
337 
339 RetrievePhysicsTable(const G4ParticleDefinition* aParticleDefinition,
340  const G4String& aString,
341  G4bool aBool){
342  return fRegisteredProcess->RetrievePhysicsTable(aParticleDefinition,
343  aString,
344  aBool);
345 }
346 
347 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double condition(const G4ErrorSymMatrix &m)
G4VDiscreteProcess * fRegisteredProcess
G4ProcessType theProcessType
Definition: G4VProcess.hh:340
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double, G4ForceCondition *)
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
G4int verboseLevel
Definition: G4VProcess.hh:368
G4bool isAlongStepDoItIsEnabled() const
Definition: G4VProcess.hh:526
G4bool isPostStepDoItIsEnabled() const
Definition: G4VProcess.hh:532
G4int ItHasToWork(const G4Track &)
G4bool isAtRestDoItIsEnabled() const
Definition: G4VProcess.hh:520
G4double theNumberOfInteractionLengthLeft
Definition: G4VProcess.hh:293
G4int theProcessSubType
Definition: G4VProcess.hh:343
G4ProcessType GetProcessType() const
Definition: G4VProcess.hh:414
G4bool enableAtRestDoIt
Definition: G4VProcess.hh:350
int G4int
Definition: G4Types.hh:78
virtual G4bool IsApplicable(const G4ParticleDefinition &)
G4double GetDensityPreviousStep(const G4Track &)
G4VUserTrackInformation * GetUserInformation() const
virtual void StartTracking(G4Track *)
Definition: G4VProcess.cc:101
G4double GetNumberOfInteractionLengthLeft() const
Definition: G4VProcess.hh:453
G4GLOB_DLL std::ostream G4cout
virtual void PreparePhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:217
bool G4bool
Definition: G4Types.hh:79
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
G4double currentInteractionLength
Definition: G4VProcess.hh:297
virtual void PreparePhysicsTable(const G4ParticleDefinition &)
Definition: G4Step.hh:76
G4bool enablePostStepDoIt
Definition: G4VProcess.hh:352
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
Definition: G4VProcess.hh:236
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4int bBothOrCrystalOrDetectorPhysics
Decide whether to use nuclei (+1) or electron (-1) or both (0)
G4double GetDensity(const G4Track &)
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:210
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:283
virtual G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *)
#define G4endl
Definition: G4ios.hh:61
virtual void ResetNumberOfInteractionLengthLeft()
G4bool enableAlongStepDoIt
Definition: G4VProcess.hh:351
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
Definition: G4VProcess.hh:231
void RegisterProcess(G4VDiscreteProcess *)
void SubtractNumberOfInteractionLengthLeft(G4double previousStepSize)
Definition: G4VProcess.hh:544
G4double theInitialNumberOfInteractionLength
Definition: G4VProcess.hh:300
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
double G4double
Definition: G4Types.hh:76
XWrapperDiscreteProcess(const G4String &processName="XWrapperDiscreteProcess")
G4ForceCondition
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
#define DBL_MAX
Definition: templates.hh:83
G4int GetProcessSubType() const
Definition: G4VProcess.hh:426
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
virtual G4bool IsApplicable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:205
G4ParticleChangeForNothing * fParticleChangeForNothing
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)