Geant4  10.02.p02
XWrapperContinousDiscreteProcess.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 
42 
46  if (verboseLevel>1) {
47  G4cout << GetProcessName() << " is created "<< G4endl;
48  }
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
58  G4VContinuousDiscreteProcess* toRegister)
60  fRegisteredProcess = toRegister;
61  if (verboseLevel>1) {
62  G4cout << GetProcessName() << " is created "<< G4endl;
63  }
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
75 
78  G4ProcessType aProcessType)
79 :G4VContinuousDiscreteProcess(aName,aProcessType){
80  if (verboseLevel>1) {
81  G4cout << GetProcessName() << " is created "<< G4endl;
82  }
83  theProcessType = aProcessType;
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
90 
92  ;
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
96 
100  ;
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
104 
107  fRegisteredProcess = toRegister;
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
116 
119  G4int flag,
120  G4int region){
121  fRegisteredProcess = toRegister;
127  bNucleiOrElectronFlag = flag;
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
132 
134  bNucleiOrElectronFlag = flag;
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
138 
140  return bNucleiOrElectronFlag;
141 }
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
144 
146  ExExChParticleUserInfo* chanInfo =
148 
149  if(chanInfo){
150  if((chanInfo->GetInTheCrystal() == true) &&
153  return 1;
154  }
155  if((chanInfo->GetInTheCrystal() == false) &&
158  return 2;
159  }
160  }
161  else {
162  G4cout << G4endl << "XWrapperDiscreteProcess::";
163  G4cout << "ERROR - no ExExChParticleUserInfo object Detected";
164  G4cout << G4endl;
165  }
166 
167  return 0;
168 }
169 
170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
172  //Retrieve nuclei and electron density
173  //from ExExChParticleUserInfo object
174  G4double vDensity = 1.;
175 
176  if(ItHasToWork(aTrack) == 1){
177  ExExChParticleUserInfo* chanInfo =
179 
180  if(chanInfo){
181  if(bNucleiOrElectronFlag == +1){
182  vDensity = chanInfo->GetNucleiDensity();
183  }
184  else if(bNucleiOrElectronFlag == -1){
185  vDensity = chanInfo->GetElectronDensity();
186  }
187  else{
188  vDensity = (chanInfo->GetNucleiDensity()
189  + chanInfo->GetElectronDensity())/2.;
190  }
191  }
192  }
193 
194  return vDensity;
195 }
196 
197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
198 
201  //Retrieve nuclei and electron density
202  //from ExExChParticleUserInfo object
203 
204  G4double vDensityPreviousStep = 1.;
205 
206  if(ItHasToWork(aTrack) == 1){
207  ExExChParticleUserInfo* chanInfo =
209 
210  if(bNucleiOrElectronFlag == +1){
211  vDensityPreviousStep = chanInfo->GetNucleiDensityPreviousStep();
212  }
213  else if(bNucleiOrElectronFlag == -1){
214  vDensityPreviousStep = chanInfo->GetElectronDensityPreviousStep();
215  }
216  else{
217  vDensityPreviousStep =
218  (chanInfo->GetNucleiDensityPreviousStep()
219  + chanInfo->GetElectronDensityPreviousStep())/2.;
220  }
221  }
222 
223  return vDensityPreviousStep;
224 }
225 
226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
227 
228 
229 
230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
233 
234 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
235 
236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
237 
238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
239 
240 
241 
242 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
243 
249 }
250 
251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
252 
254 GetMeanFreePath(const G4Track& aTrack,
255  G4double previousStepSize,
257  if(ItHasToWork(aTrack) == 2){
259  previousStepSize,
260  condition);
261  }
262  return DBL_MAX;
263 }
264 
265 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
266 
269  G4double previousStepSize,
271 
272  if(ItHasToWork(aTrack) == 1){
273  G4double vDensity = GetDensity(aTrack);
274  G4double vDensityPreviousStep = GetDensityPreviousStep(aTrack);
275 
276  if ( (previousStepSize < 0.0) ||
278  // beginning of tracking (or just after DoIt of this process)
280  } else if ( previousStepSize > 0.0) {
281  // subtract NumberOfInteractionLengthLeft
283  * vDensityPreviousStep);
284  } else {
285  // zero step DO NOTHING
286  }
287 
288  G4double regIntLength =
290  previousStepSize * vDensityPreviousStep,
291  condition);
292  G4double regIntNumber =
294  if(regIntNumber!=0){
295  currentInteractionLength = regIntLength / regIntNumber;
296  }
297  else{
298  return DBL_MAX;
299  }
300  theNumberOfInteractionLengthLeft = regIntNumber;
301 
304  if ( vDensity == 0. ) return DBL_MAX;
305  currentInteractionLength /= vDensity;
307  }
308  else if(ItHasToWork(aTrack) == 2){
310  previousStepSize,
311  condition);
312  }
313  else{
314  return DBL_MAX;
315  }
316 }
317 
318 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
319 
322  G4double previousStepSize,
323  G4double currentMinimumStep,
324  G4double& currentSafety,
325  G4GPILSelection* selection){
326 
327  if(ItHasToWork(aTrack) == 1){
328  G4double vDensityPreviousStep = GetDensityPreviousStep(aTrack);
329 
331  previousStepSize * vDensityPreviousStep,
332  currentMinimumStep,
333  currentSafety,
334  selection);
335  }
336  else if(ItHasToWork(aTrack) == 2){
338  previousStepSize,
339  currentMinimumStep,
340  currentSafety,
341  selection);
342  }
343  else{
344  return DBL_MAX;
345  }
346 }
347 
348 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
349 
351 PostStepDoIt(const G4Track& aTrack,
352  const G4Step& aStep ){
353 
354  if(ItHasToWork(aTrack) == 1){
355  G4double vDensity = GetDensity(aTrack);
356  G4double vStepLengthSaved = aStep.GetStepLength();
357  const_cast<G4Step&>(aStep).SetStepLength(
358  aStep.GetStepLength() * vDensity);
360  const_cast<G4Step&>(aStep).SetStepLength(vStepLengthSaved);
361  return pParticleChange;
362  }
363  else if(ItHasToWork(aTrack) == 2){
364  return fRegisteredProcess->PostStepDoIt(aTrack, aStep);
365  }
367  return pParticleChange;
368 }
369 
370 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
371 
373 AlongStepDoIt(const G4Track& aTrack,
374  const G4Step& aStep ){
375 
376  if(ItHasToWork(aTrack) == 1){
377  G4double vDensity = GetDensity(aTrack);
378  G4double vStepLengthSaved = aStep.GetStepLength();
379  const_cast<G4Step&>(aStep).SetStepLength(
380  aStep.GetStepLength() * vDensity);
382  const_cast<G4Step&>(aStep).SetStepLength(vStepLengthSaved);
383  return pParticleChange;
384  }
385  else if(ItHasToWork(aTrack) == 2){
386  return fRegisteredProcess->AlongStepDoIt(aTrack, aStep);
387  }
389  return pParticleChange;
390 }
391 
392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
393 
396  G4double,
397  G4double,
398  G4double& ){
399  return DBL_MAX;
400 }
401 
402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
virtual G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *)
G4double condition(const G4ErrorSymMatrix &m)
G4ProcessType theProcessType
Definition: G4VProcess.hh:340
void RegisterProcess(G4VContinuousDiscreteProcess *)
G4int verboseLevel
Definition: G4VProcess.hh:368
G4double GetStepLength() const
G4bool isAlongStepDoItIsEnabled() const
Definition: G4VProcess.hh:526
G4bool isPostStepDoItIsEnabled() const
Definition: G4VProcess.hh:532
virtual G4VParticleChange * AlongStepDoIt(const G4Track &, const G4Step &)
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 G4double AlongStepGetPhysicalInteractionLength(const G4Track &, G4double previousStepSize, G4double currentMinimumStep, G4double &currentSafety, G4GPILSelection *selection)
G4VUserTrackInformation * GetUserInformation() const
virtual void StartTracking(G4Track *)
Definition: G4VProcess.cc:101
G4double GetNumberOfInteractionLengthLeft() const
Definition: G4VProcess.hh:453
G4GLOB_DLL std::ostream G4cout
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
G4double currentInteractionLength
Definition: G4VProcess.hh:297
XWrapperContinuousDiscreteProcess(const G4String &processName="XWrapperContinuousDiscreteProcess")
Definition: G4Step.hh:76
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
G4bool enablePostStepDoIt
Definition: G4VProcess.hh:352
virtual G4double GetContinuousStepLimit(const G4Track &, G4double, G4double, G4double &)
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4ParticleChangeForNothing * fParticleChangeForNothing
virtual G4VParticleChange * AlongStepDoIt(const G4Track &, const G4Step &)
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &, G4double, G4double, G4double &, G4GPILSelection *)
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:283
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double, G4ForceCondition *)
#define G4endl
Definition: G4ios.hh:61
G4bool enableAlongStepDoIt
Definition: G4VProcess.hh:351
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
void SubtractNumberOfInteractionLengthLeft(G4double previousStepSize)
Definition: G4VProcess.hh:544
G4double theInitialNumberOfInteractionLength
Definition: G4VProcess.hh:300
double G4double
Definition: G4Types.hh:76
G4ForceCondition
#define DBL_MAX
Definition: templates.hh:83
G4int GetProcessSubType() const
Definition: G4VProcess.hh:426
G4GPILSelection
G4ProcessType