Geant4  10.01
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"
40 
41 
43 :G4VDiscreteProcess(aName){
44  if (verboseLevel>1) {
45  G4cout << GetProcessName() << " is created "<< G4endl;
46  }
48 }
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51 
54  G4VDiscreteProcess* toRegister)
55 :G4VDiscreteProcess("XWrapperDiscreteProcess"){
56  fRegisteredProcess = toRegister;
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60 
62  ;
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
66 
69 G4VDiscreteProcess(right){
70  ;
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
74 
76  fRegisteredProcess = toRegister;
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
80 
82  G4int flag){
83  fRegisteredProcess = toRegister;
84  bNucleiOrElectronFlag = flag;
85 }
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
88 
90  bNucleiOrElectronFlag = flag;
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
94 
96  return bNucleiOrElectronFlag;
97 }
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
100 
102  //Retrieve nuclei and electron density
103  //from ExExChParticleUserInfo object
104  ExExChParticleUserInfo* chanInfo =
106 
107  G4double vDensity = 1.;
108 
109  if(chanInfo){
110  if(bNucleiOrElectronFlag == +1){
111  vDensity = chanInfo->GetNucleiDensity();
112  }
113  else if(bNucleiOrElectronFlag == -1){
114  vDensity = chanInfo->GetElectronDensity();
115  }
116  else{
117  vDensity = (chanInfo->GetNucleiDensity()
118  + chanInfo->GetElectronDensity())/2.;
119  }
120  }
121  else {
122  G4cout << G4endl << "XWrapperDiscreteProcess::";
123  G4cout << "ERROR - no ExExChParticleUserInfo object Detected";
124  G4cout << G4endl;
125  }
126 
127  return vDensity;
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
131 
134  //Retrieve nuclei and electron density
135  //from ExExChParticleUserInfo object
136  ExExChParticleUserInfo* chanInfo =
138 
139  G4double vDensityPreviousStep = 1.;
140 
141  if(chanInfo){
142  if(bNucleiOrElectronFlag == +1){
143  vDensityPreviousStep = chanInfo->GetNucleiDensityPreviousStep();
144  }
145  else if(bNucleiOrElectronFlag == -1){
146  vDensityPreviousStep = chanInfo->GetElectronDensityPreviousStep();
147  }
148  else{
149  vDensityPreviousStep =
150  (chanInfo->GetNucleiDensityPreviousStep()
151  + chanInfo->GetElectronDensityPreviousStep())/2.;
152  }
153  }
154  else {
155  G4cout << G4endl << "XWrapperDiscreteProcess::";
156  G4cout << "ERROR - no ExExChParticleUserInfo object Detected";
157  G4cout << G4endl;
158  }
159 
160  return vDensityPreviousStep;
161 }
162 
163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
164 
165 
166 
167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
170 
171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
172 
173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
174 
175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
176 
177 
178 
179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
180 
186 }
187 
188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
189 
191  G4double, //previousStepSize,
193  return DBL_MAX;
194 }
195 
196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
197 
200  G4double previousStepSize,
202 
203  G4double vDensity = GetDensity(aTrack);
204  G4double vDensityPreviousStep = GetDensityPreviousStep(aTrack);
205 
206  if ( (previousStepSize < 0.0) || (theNumberOfInteractionLengthLeft<=0.0)) {
207  // beginning of tracking (or just after DoIt of this process)
209  } else if ( previousStepSize > 0.0) {
210  // subtract NumberOfInteractionLengthLeft
212  * vDensityPreviousStep);
213  } else {
214  // zero step DO NOTHING
215  }
216 
217  G4double regIntLength =
219  previousStepSize * vDensityPreviousStep,
220  condition);
221  G4double regIntNumber =
223  currentInteractionLength = regIntLength / regIntNumber;
224  theNumberOfInteractionLengthLeft = regIntNumber;
225 
228  currentInteractionLength /= vDensity;
230 }
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
233 
235  const G4Step& aStep ){
236  return fRegisteredProcess->PostStepDoIt(aTrack, aStep);
237 }
238 
239 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
240 
241 
243 IsApplicable(const G4ParticleDefinition& aParticleDefinition){
244  return fRegisteredProcess->IsApplicable(aParticleDefinition);
245 }
246 
247 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
248 
250 BuildPhysicsTable(const G4ParticleDefinition& aParticleDefinition){
251  fRegisteredProcess->BuildPhysicsTable(aParticleDefinition);
252 }
253 
254 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
255 
257 PreparePhysicsTable(const G4ParticleDefinition& aParticleDefinition){
258  fRegisteredProcess->PreparePhysicsTable(aParticleDefinition);
259 }
260 
261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
262 
264 StorePhysicsTable(const G4ParticleDefinition* aParticleDefinition,
265  const G4String& aString,
266  G4bool aBool){
267  return fRegisteredProcess->StorePhysicsTable(aParticleDefinition,
268  aString,
269  aBool);
270 }
271 
272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
273 
275 RetrievePhysicsTable(const G4ParticleDefinition* aParticleDefinition,
276  const G4String& aString,
277  G4bool aBool){
278  return fRegisteredProcess->RetrievePhysicsTable(aParticleDefinition,
279  aString,
280  aBool);
281 }
282 
283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double condition(const G4ErrorSymMatrix &m)
G4VDiscreteProcess * fRegisteredProcess
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double, G4ForceCondition *)
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
G4int verboseLevel
Definition: G4VProcess.hh:368
G4double theNumberOfInteractionLengthLeft
Definition: G4VProcess.hh:293
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
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
Definition: G4VProcess.hh:236
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4double GetDensity(const G4Track &)
G4int bNucleiOrElectronFlag
Decide whether to use nuclei (+1) or electron (-1) or both (0)
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:210
virtual G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *)
#define G4endl
Definition: G4ios.hh:61
virtual void ResetNumberOfInteractionLengthLeft()
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
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
virtual G4bool IsApplicable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:205
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)