Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 
31 
32 #include "G4Step.hh"
33 #include "G4StepPoint.hh"
34 #include "G4VParticleChange.hh"
35 
36 #include "G4Material.hh"
37 #include "G4NistManager.hh"
39 #include "G4Navigator.hh"
40 #include "G4GeometryTolerance.hh"
41 
42 #include "G4SystemOfUnits.hh"
44 
45 
49  if (verboseLevel>1) {
50  G4cout << GetProcessName() << " is created "<< G4endl;
51  }
52  bNucleiOrElectronFlag = +0;
53  bBothOrCrystalOrDetectorPhysics = +0;
54  fParticleChangeForNothing = new G4ParticleChangeForNothing();
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
58 
61  G4VContinuousDiscreteProcess* toRegister)
63  fRegisteredProcess = toRegister;
64  if (verboseLevel>1) {
65  G4cout << GetProcessName() << " is created "<< G4endl;
66  }
67  theProcessType = fRegisteredProcess->GetProcessType();
68  theProcessSubType = fRegisteredProcess->GetProcessSubType();
69  enableAtRestDoIt = fRegisteredProcess->isAtRestDoItIsEnabled();
70  enableAlongStepDoIt = fRegisteredProcess->isAlongStepDoItIsEnabled();
71  enablePostStepDoIt = fRegisteredProcess->isPostStepDoItIsEnabled();
72  bNucleiOrElectronFlag = +0;
73  bBothOrCrystalOrDetectorPhysics = +0;
74  fParticleChangeForNothing = new G4ParticleChangeForNothing();
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
78 
81  G4ProcessType aProcessType)
82 :G4VContinuousDiscreteProcess(aName,aProcessType){
83  if (verboseLevel>1) {
84  G4cout << GetProcessName() << " is created "<< G4endl;
85  }
86  theProcessType = aProcessType;
87  bNucleiOrElectronFlag = +0;
88  bBothOrCrystalOrDetectorPhysics = +0;
89  fParticleChangeForNothing = new G4ParticleChangeForNothing();
90 }
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
93 
95  ;
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
99 
103  ;
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
107 
110  fRegisteredProcess = toRegister;
111  theProcessType = fRegisteredProcess->GetProcessType();
112  theProcessSubType = fRegisteredProcess->GetProcessSubType();
113  enableAtRestDoIt = fRegisteredProcess->isAtRestDoItIsEnabled();
114  enableAlongStepDoIt = fRegisteredProcess->isAlongStepDoItIsEnabled();
115  enablePostStepDoIt = fRegisteredProcess->isPostStepDoItIsEnabled();
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
119 
122  G4int flag,
123  G4int region){
124  fRegisteredProcess = toRegister;
125  theProcessType = fRegisteredProcess->GetProcessType();
126  theProcessSubType = fRegisteredProcess->GetProcessSubType();
127  enableAtRestDoIt = fRegisteredProcess->isAtRestDoItIsEnabled();
128  enableAlongStepDoIt = fRegisteredProcess->isAlongStepDoItIsEnabled();
129  enablePostStepDoIt = fRegisteredProcess->isPostStepDoItIsEnabled();
130  bNucleiOrElectronFlag = flag;
131  bBothOrCrystalOrDetectorPhysics = region;
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
135 
137  bNucleiOrElectronFlag = flag;
138 }
139 
140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
141 
143  return bNucleiOrElectronFlag;
144 }
145 
146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
147 
149  ExExChParticleUserInfo* chanInfo =
151 
152  if(chanInfo){
153  if((chanInfo->GetInTheCrystal() == true) &&
154  (bBothOrCrystalOrDetectorPhysics == 1 ||
155  bBothOrCrystalOrDetectorPhysics == 0)){
156  return 1;
157  }
158  if((chanInfo->GetInTheCrystal() == false) &&
159  (bBothOrCrystalOrDetectorPhysics == 2 ||
160  bBothOrCrystalOrDetectorPhysics == 0)){
161  return 2;
162  }
163  }
164  else {
165  G4cout << G4endl << "XWrapperDiscreteProcess::";
166  G4cout << "ERROR - no ExExChParticleUserInfo object Detected";
167  G4cout << G4endl;
168  }
169 
170  return 0;
171 }
172 
173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
175  //Retrieve nuclei and electron density
176  //from ExExChParticleUserInfo object
177  G4double vDensity = 1.;
178 
179  if(ItHasToWork(aTrack) == 1){
180  ExExChParticleUserInfo* chanInfo =
182 
183  if(chanInfo){
184  if(bNucleiOrElectronFlag == +1){
185  vDensity = chanInfo->GetNucleiDensity();
186  }
187  else if(bNucleiOrElectronFlag == -1){
188  vDensity = chanInfo->GetElectronDensity();
189  }
190  else{
191  vDensity = (chanInfo->GetNucleiDensity()
192  + chanInfo->GetElectronDensity())/2.;
193  }
194  }
195  }
196 
197  return vDensity;
198 }
199 
200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
201 
204  //Retrieve nuclei and electron density
205  //from ExExChParticleUserInfo object
206 
207  G4double vDensityPreviousStep = 1.;
208 
209  if(ItHasToWork(aTrack) == 1){
210  ExExChParticleUserInfo* chanInfo =
212 
213  if(bNucleiOrElectronFlag == +1){
214  vDensityPreviousStep = chanInfo->GetNucleiDensityPreviousStep();
215  }
216  else if(bNucleiOrElectronFlag == -1){
217  vDensityPreviousStep = chanInfo->GetElectronDensityPreviousStep();
218  }
219  else{
220  vDensityPreviousStep =
221  (chanInfo->GetNucleiDensityPreviousStep()
222  + chanInfo->GetElectronDensityPreviousStep())/2.;
223  }
224  }
225 
226  return vDensityPreviousStep;
227 }
228 
229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
230 
231 
232 
233 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
234 
235 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
236 
237 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
238 
239 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
240 
241 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
242 
243 
244 
245 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
246 
248  fRegisteredProcess->StartTracking(aTrack);
252 }
253 
254 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
255 
257 GetMeanFreePath(const G4Track& aTrack,
258  G4double previousStepSize,
260  if(ItHasToWork(aTrack) == 2){
261  return fRegisteredProcess->PostStepGetPhysicalInteractionLength(aTrack,
262  previousStepSize,
263  condition);
264  }
265  return DBL_MAX;
266 }
267 
268 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
269 
272  G4double previousStepSize,
274 
275  if(ItHasToWork(aTrack) == 1){
276  G4double vDensity = GetDensity(aTrack);
277  G4double vDensityPreviousStep = GetDensityPreviousStep(aTrack);
278 
279  if ( (previousStepSize < 0.0) ||
281  // beginning of tracking (or just after DoIt of this process)
283  } else if ( previousStepSize > 0.0) {
284  // subtract NumberOfInteractionLengthLeft
286  * vDensityPreviousStep);
287  } else {
288  // zero step DO NOTHING
289  }
290 
291  G4double regIntLength =
292  fRegisteredProcess->PostStepGetPhysicalInteractionLength(aTrack,
293  previousStepSize * vDensityPreviousStep,
294  condition);
295  G4double regIntNumber =
296  fRegisteredProcess->GetNumberOfInteractionLengthLeft();
297  if(regIntNumber!=0){
298  currentInteractionLength = regIntLength / regIntNumber;
299  }
300  else{
301  return DBL_MAX;
302  }
303  theNumberOfInteractionLengthLeft = regIntNumber;
304 
307  if ( vDensity == 0. ) return DBL_MAX;
308  currentInteractionLength /= vDensity;
310  }
311  else if(ItHasToWork(aTrack) == 2){
312  return fRegisteredProcess->PostStepGetPhysicalInteractionLength(aTrack,
313  previousStepSize,
314  condition);
315  }
316  else{
317  return DBL_MAX;
318  }
319 }
320 
321 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
322 
325  G4double previousStepSize,
326  G4double currentMinimumStep,
327  G4double& currentSafety,
328  G4GPILSelection* selection){
329 
330  if(ItHasToWork(aTrack) == 1){
331  G4double vDensityPreviousStep = GetDensityPreviousStep(aTrack);
332 
333  return fRegisteredProcess->AlongStepGetPhysicalInteractionLength(aTrack,
334  previousStepSize * vDensityPreviousStep,
335  currentMinimumStep,
336  currentSafety,
337  selection);
338  }
339  else if(ItHasToWork(aTrack) == 2){
340  return fRegisteredProcess->AlongStepGetPhysicalInteractionLength(aTrack,
341  previousStepSize,
342  currentMinimumStep,
343  currentSafety,
344  selection);
345  }
346  else{
347  return DBL_MAX;
348  }
349 }
350 
351 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
352 
354 PostStepDoIt(const G4Track& aTrack,
355  const G4Step& aStep ){
356 
357  if(ItHasToWork(aTrack) == 1){
358  G4double vDensity = GetDensity(aTrack);
359  G4double vStepLengthSaved = aStep.GetStepLength();
360  const_cast<G4Step&>(aStep).SetStepLength(
361  aStep.GetStepLength() * vDensity);
362  pParticleChange = fRegisteredProcess->PostStepDoIt(aTrack, aStep);
363  const_cast<G4Step&>(aStep).SetStepLength(vStepLengthSaved);
364  return pParticleChange;
365  }
366  else if(ItHasToWork(aTrack) == 2){
367  return fRegisteredProcess->PostStepDoIt(aTrack, aStep);
368  }
369  pParticleChange = fParticleChangeForNothing;
370  return pParticleChange;
371 }
372 
373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
374 
376 AlongStepDoIt(const G4Track& aTrack,
377  const G4Step& aStep ){
378 
379  if(ItHasToWork(aTrack) == 1){
380  G4double vDensity = GetDensity(aTrack);
381  G4double vStepLengthSaved = aStep.GetStepLength();
382  const_cast<G4Step&>(aStep).SetStepLength(
383  aStep.GetStepLength() * vDensity);
384  pParticleChange = fRegisteredProcess->AlongStepDoIt(aTrack, aStep);
385  const_cast<G4Step&>(aStep).SetStepLength(vStepLengthSaved);
386  return pParticleChange;
387  }
388  else if(ItHasToWork(aTrack) == 2){
389  return fRegisteredProcess->AlongStepDoIt(aTrack, aStep);
390  }
391  pParticleChange = fParticleChangeForNothing;
392  return pParticleChange;
393 }
394 
395 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
396 
399  G4double,
400  G4double,
401  G4double& ){
402  return DBL_MAX;
403 }
404 
405 //....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
Definition of the XWrapperContinuousDiscreteProcess class.
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
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