Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
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 
46 :G4VDiscreteProcess(aName){
47  if (verboseLevel>1) {
48  G4cout << GetProcessName() << " is created "<< G4endl;
49  }
50  bNucleiOrElectronFlag = +0;
51  bBothOrCrystalOrDetectorPhysics = +0;
52  fParticleChangeForNothing = new G4ParticleChangeForNothing();
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
56 
59  G4VDiscreteProcess* toRegister)
60 :G4VDiscreteProcess("XWrapperDiscreteProcess"){
61  fRegisteredProcess = toRegister;
62  theProcessType = fRegisteredProcess->GetProcessType();
63  theProcessSubType = fRegisteredProcess->GetProcessSubType();
64  enableAtRestDoIt = fRegisteredProcess->isAtRestDoItIsEnabled();
65  enableAlongStepDoIt = fRegisteredProcess->isAlongStepDoItIsEnabled();
66  enablePostStepDoIt = fRegisteredProcess->isPostStepDoItIsEnabled();
67  bNucleiOrElectronFlag = +0;
68  bBothOrCrystalOrDetectorPhysics = +0;
69  fParticleChangeForNothing = new G4ParticleChangeForNothing();
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
73 
75  ;
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
79 
82 G4VDiscreteProcess(right){
83  ;
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
87 
89  fRegisteredProcess = toRegister;
90  theProcessType = fRegisteredProcess->GetProcessType();
91  theProcessSubType = fRegisteredProcess->GetProcessSubType();
92  enableAtRestDoIt = fRegisteredProcess->isAtRestDoItIsEnabled();
93  enableAlongStepDoIt = fRegisteredProcess->isAlongStepDoItIsEnabled();
94  enablePostStepDoIt = fRegisteredProcess->isPostStepDoItIsEnabled();
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
98 
100  G4int flag,
101  G4int region){
102  fRegisteredProcess = toRegister;
103  bNucleiOrElectronFlag = flag;
104  bBothOrCrystalOrDetectorPhysics = region;
105  theProcessType = fRegisteredProcess->GetProcessType();
106  theProcessSubType = fRegisteredProcess->GetProcessSubType();
107  enableAtRestDoIt = fRegisteredProcess->isAtRestDoItIsEnabled();
108  enableAlongStepDoIt = fRegisteredProcess->isAlongStepDoItIsEnabled();
109  enablePostStepDoIt = fRegisteredProcess->isPostStepDoItIsEnabled();
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
113 
115  bNucleiOrElectronFlag = flag;
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
119 
121  return bNucleiOrElectronFlag;
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
125 
127  ExExChParticleUserInfo* chanInfo =
129 
130  if(chanInfo){
131  if((chanInfo->GetInTheCrystal() == true) &&
132  (bBothOrCrystalOrDetectorPhysics == 1 ||
133  bBothOrCrystalOrDetectorPhysics == 0)){
134  return 1;
135  }
136  if((chanInfo->GetInTheCrystal() == false) &&
137  (bBothOrCrystalOrDetectorPhysics == 2 ||
138  bBothOrCrystalOrDetectorPhysics == 0)){
139  return 2;
140  }
141  }
142  else {
143  G4cout << G4endl << "XWrapperDiscreteProcess::";
144  G4cout << "ERROR - no ExExChParticleUserInfo object Detected";
145  G4cout << G4endl;
146  }
147 
148  return 0;
149 }
150 
151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
153  //Retrieve nuclei and electron density
154  //from ExExChParticleUserInfo object
155  G4double vDensity = 1.;
156 
157  if(ItHasToWork(aTrack)){
158  ExExChParticleUserInfo* chanInfo =
160 
161  if(chanInfo){
162  if(bNucleiOrElectronFlag == +1){
163  vDensity = chanInfo->GetNucleiDensity();
164  }
165  else if(bNucleiOrElectronFlag == -1){
166  vDensity = chanInfo->GetElectronDensity();
167  }
168  else{
169  vDensity = (chanInfo->GetNucleiDensity()
170  + chanInfo->GetElectronDensity())/2.;
171  }
172  }
173  }
174 
175  return vDensity;
176 }
177 
178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
179 
182  //Retrieve nuclei and electron density
183  //from ExExChParticleUserInfo object
184 
185  G4double vDensityPreviousStep = 1.;
186 
187  if(ItHasToWork(aTrack)){
188  ExExChParticleUserInfo* chanInfo =
190 
191  if(bNucleiOrElectronFlag == +1){
192  vDensityPreviousStep = chanInfo->GetNucleiDensityPreviousStep();
193  }
194  else if(bNucleiOrElectronFlag == -1){
195  vDensityPreviousStep = chanInfo->GetElectronDensityPreviousStep();
196  }
197  else{
198  vDensityPreviousStep =
199  (chanInfo->GetNucleiDensityPreviousStep()
200  + chanInfo->GetElectronDensityPreviousStep())/2.;
201  }
202  }
203 
204  return vDensityPreviousStep;
205 }
206 
207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
208 
209 
210 
211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
214 
215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
218 
219 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
220 
221 
222 
223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
224 
226  fRegisteredProcess->StartTracking(aTrack);
230 }
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
233 
235  G4double, //previousStepSize,
237  return DBL_MAX;
238 }
239 
240 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
241 
244  G4double previousStepSize,
246  if(ItHasToWork(aTrack) == 1){
247  G4double vDensity = GetDensity(aTrack);
248  G4double vDensityPreviousStep = GetDensityPreviousStep(aTrack);
249 
250  if ( (previousStepSize < 0.0) ||
252  // beginning of tracking (or just after DoIt of this process)
254  } else if ( previousStepSize > 0.0) {
255  // subtract NumberOfInteractionLengthLeft
257  * vDensityPreviousStep);
258  } else {
259  // zero step DO NOTHING
260  }
261 
262  G4double regIntLength =
263  fRegisteredProcess->PostStepGetPhysicalInteractionLength(aTrack,
264  previousStepSize * vDensityPreviousStep,
265  condition);
266  G4double regIntNumber =
267  fRegisteredProcess->GetNumberOfInteractionLengthLeft();
268  if(regIntNumber!=0){
269  currentInteractionLength = regIntLength / regIntNumber;
270  }
271  else{
272  return DBL_MAX;
273  }
274  theNumberOfInteractionLengthLeft = regIntNumber;
275 
278  if ( vDensity == 0. ) return DBL_MAX;
279  currentInteractionLength /= vDensity;
281  }
282  else if(ItHasToWork(aTrack) == 2){
283  return fRegisteredProcess->PostStepGetPhysicalInteractionLength(aTrack,
284  previousStepSize,
285  condition);
286  }
287  else{
288  return DBL_MAX;
289  }
290 }
291 
292 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
293 
295  const G4Step& aStep ){
296  if(ItHasToWork(aTrack) == 1){
297  return fRegisteredProcess->PostStepDoIt(aTrack, aStep);
298  }
299  else if(ItHasToWork(aTrack) == 2){
300  return fRegisteredProcess->PostStepDoIt(aTrack, aStep);
301  }
302  pParticleChange = fParticleChangeForNothing;
303  return pParticleChange;
304 }
305 
306 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
307 
308 
310 IsApplicable(const G4ParticleDefinition& aParticleDefinition){
311  return fRegisteredProcess->IsApplicable(aParticleDefinition);
312 }
313 
314 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
315 
317 BuildPhysicsTable(const G4ParticleDefinition& aParticleDefinition){
318  fRegisteredProcess->BuildPhysicsTable(aParticleDefinition);
319 }
320 
321 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
322 
324 PreparePhysicsTable(const G4ParticleDefinition& aParticleDefinition){
325  fRegisteredProcess->PreparePhysicsTable(aParticleDefinition);
326 }
327 
328 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
329 
331 StorePhysicsTable(const G4ParticleDefinition* aParticleDefinition,
332  const G4String& aString,
333  G4bool aBool){
334  return fRegisteredProcess->StorePhysicsTable(aParticleDefinition,
335  aString,
336  aBool);
337 }
338 
339 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
340 
342 RetrievePhysicsTable(const G4ParticleDefinition* aParticleDefinition,
343  const G4String& aString,
344  G4bool aBool){
345  return fRegisteredProcess->RetrievePhysicsTable(aParticleDefinition,
346  aString,
347  aBool);
348 }
349 
350 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double condition(const G4ErrorSymMatrix &m)
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
G4double GetDensity(const G4Track &)
Definition of the XWrapperDiscreteProcess class.
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
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)