Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ContinuousGainOfEnergy.cc
이 파일의 문서화 페이지로 가기
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 // $Id: G4ContinuousGainOfEnergy.cc 91870 2015-08-07 15:21:40Z gcosmo $
27 //
28 
30 
31 #include "G4PhysicalConstants.hh"
32 #include "G4SystemOfUnits.hh"
33 #include "G4Step.hh"
34 #include "G4ParticleDefinition.hh"
35 #include "G4VEmModel.hh"
36 #include "G4VEmFluctuationModel.hh"
37 #include "G4VParticleChange.hh"
38 #include "G4AdjointCSManager.hh"
39 #include "G4LossTableManager.hh"
40 #include "G4SystemOfUnits.hh"
41 #include "G4PhysicalConstants.hh"
42 
44 //
46  G4ProcessType type): G4VContinuousProcess(name, type)
47 {
48 
49 
50  linLossLimit=0.05;
53  is_integral = false;
54 
55  //Will be properly set in SetDirectParticle()
56  IsIon=false;
57  massRatio =1.;
58  chargeSqRatio=1.;
60 
61  //Some initialization
62  currentCoupleIndex=9999999;
64  currentMaterialIndex=9999999;
65  currentTcut=0.;
67  preStepRange=0.;
69 
70  currentCouple=0;
71 }
72 
74 //
76 {
77 
78 }
80 //
81 
83  const G4ParticleDefinition& )
84 {//theDirectEnergyLossProcess->PreparePhysicsTable(part);
85 
86 ;
87 }
88 
90 //
91 
93 {//theDirectEnergyLossProcess->BuildPhysicsTable(part);
94 ;
95 }
96 
98 //
101  if (theDirectPartDef->GetParticleType()== "nucleus") {
102  IsIon=true;
105  chargeSqRatio=q*q;
106 
107 
108  }
109 
110 }
111 
113 //
114 //
116  const G4Step& step)
117 {
118 
119  //Caution in this method the step length should be the true step length
120  // A problem is that this is compute by the multiple scattering that does not know the energy at the end of the adjoint step. This energy is used during the
121  //Forward sim. Nothing we can really do against that at this time. This is inherent to the MS method
122  //
123 
124 
125 
127 
128  // Get the actual (true) Step length
129  //----------------------------------
130  G4double length = step.GetStepLength();
131  G4double degain = 0.0;
132 
133 
134 
135  // Compute this for weight change after continuous energy loss
136  //-------------------------------------------------------------
138 
139 
140 
141  // For the fluctuation we generate a new dynamic particle with energy =preEnergy+egain
142  // and then compute the fluctuation given in the direct case.
143  //-----------------------------------------------------------------------
144  G4DynamicParticle* dynParticle = new G4DynamicParticle();
145  *dynParticle = *(track.GetDynamicParticle());
146  dynParticle->SetDefinition(theDirectPartDef);
147  G4double Tkin = dynParticle->GetKineticEnergy();
148 
149 
150  size_t n=1;
151  if (is_integral ) n=10;
152  n=1;
153  G4double dlength= length/n;
154  for (size_t i=0;i<n;i++) {
155  if (Tkin != preStepKinEnergy && IsIon) {
158 
159  }
160 
162  if( dlength <= linLossLimit * r ) {
163  degain = DEDX_before*dlength;
164  }
165  else {
166  G4double x = r + dlength;
167  //degain = theDirectEnergyLossProcess->GetKineticEnergy(x,currentCouple) - theDirectEnergyLossProcess->GetKineticEnergy(r,currentCouple);
169  if (IsIon){
173 
174  // Loop checking, 07-Aug-2015, Vladimir Ivanchenko
175  G4int ii=0;
176  const G4int iimax = 100;
177  while (std::abs(x-x1)>0.01*x) {
182  ++ii;
183  if(ii >= iimax) { break; }
184  }
185  }
186 
187  degain=E-Tkin;
188 
189 
190 
191  }
192  //G4cout<<degain<<G4endl;
193  G4double tmax = currentModel->MaxSecondaryKinEnergy(dynParticle);
194  tmax = std::min(tmax,currentTcut);
195 
196 
197  dynParticle->SetKineticEnergy(Tkin+degain);
198 
199  // Corrections, which cannot be tabulated for ions
200  //----------------------------------------
201  G4double esecdep=0;//not used in most models
202  currentModel->CorrectionsAlongStep(currentCouple, dynParticle, degain,esecdep, dlength);
203 
204  // Sample fluctuations
205  //-------------------
206 
207 
208  G4double deltaE =0.;
209  if (lossFluctuationFlag ) {
211  SampleFluctuations(currentCouple,dynParticle,tmax,dlength,degain)-degain;
212  }
213 
214  G4double egain=degain+deltaE;
215  if (egain <=0) egain=degain;
216  Tkin+=egain;
217  dynParticle->SetKineticEnergy(Tkin);
218  }
219 
220 
221 
222 
223 
224  delete dynParticle;
225 
226  if (IsIon){
229 
230  }
231 
233 
234 
235  G4double weight_correction=DEDX_after/DEDX_before;
236 
237 
239 
240 
241  //Caution!!!
242  // It is important to select the weight of the post_step_point
243  // as the current weight and not the weight of the track, as t
244  // the weight of the track is changed after having applied all
245  // the along_step_do_it.
246 
247  // G4double new_weight=weight_correction*track.GetWeight(); //old
248  G4double new_weight=weight_correction*step.GetPostStepPoint()->GetWeight();
251 
252 
253  return &aParticleChange;
254 
255 }
257 //
259 {
260  if(val && !lossFluctuationArePossible) return;
261  lossFluctuationFlag = val;
262 }
264 //
265 
266 
267 
269  G4double , G4double , G4double& )
270 {
271  G4double x = DBL_MAX;
272  x=.1*mm;
273 
274 
276 
280  G4double emax_model=currentModel->HighEnergyLimit();
281  if (IsIon) {
285  }
286 
287 
289  /*if (preStepKinEnergy< 0.05*MeV) maxE =2.*preStepKinEnergy;
290  else if (preStepKinEnergy< 0.1*MeV) maxE =1.5*preStepKinEnergy;
291  else if (preStepKinEnergy< 0.5*MeV) maxE =1.25*preStepKinEnergy;*/
292 
293  if (preStepKinEnergy < currentTcut) maxE = std::min(currentTcut,maxE);
294 
295  maxE=std::min(emax_model*1.001,maxE);
296 
298 
299  if (IsIon) {
302  }
303 
305 
307 
308 
309 
310  x=r1-preStepRange;
311  x=std::max(r1-preStepRange,0.001*mm);
312 
313  return x;
314 
315 
316 }
317 #include "G4EmCorrections.hh"
319 //
320 
322 {
323 
326 }
Float_t x
Definition: compare.C:6
G4double GetKineticEnergy() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
const XML_Char * name
Definition: expat.h:151
G4ContinuousGainOfEnergy(const G4String &name="EnergyGain", G4ProcessType type=fElectromagnetic)
G4double GetRange(G4double &kineticEnergy, const G4MaterialCutsCouple *)
G4double GetDEDX(G4double &kineticEnergy, const G4MaterialCutsCouple *)
G4ParticleDefinition * theDirectPartDef
void SetKineticEnergy(G4double aEnergy)
void SetDirectParticle(G4ParticleDefinition *p)
static constexpr double mm
Definition: G4SIunits.hh:115
G4double MaxSecondaryKinEnergy(const G4DynamicParticle *dynParticle)
Definition: G4VEmModel.hh:492
virtual G4double GetChargeSquareRatio(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
Definition: G4VEmModel.cc:389
Float_t x1[n_points_granero]
Definition: compare.C:5
const char * p
Definition: xmltok.h:285
const G4String & GetParticleType() const
G4double GetPDGCharge() const
virtual G4double GetContinuousStepLimit(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &currentSafety)
void SetDynamicMassCharge(G4double massratio, G4double charge2ratio)
G4double EffectiveChargeSquareRatio(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
G4double GetPDGMass() const
G4ParticleChange aParticleChange
Definition: G4VProcess.hh:289
static constexpr double proton_mass_c2
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4EmCorrections * EmCorrections()
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
virtual void Initialize(const G4Track &)
const G4MaterialCutsCouple * currentCouple
G4ProcessType
G4double GetStepLength() const
G4VEmFluctuationModel * GetModelOfFluctuations()
Definition: G4VEmModel.hh:568
virtual void CorrectionsAlongStep(const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double &eloss, G4double &niel, G4double length)
Definition: G4VEmModel.cc:406
double energy
Definition: plottest35.C:25
G4double GetKineticEnergy(G4double &range, const G4MaterialCutsCouple *)
Definition: G4Step.hh:76
G4StepPoint * GetPostStepPoint() const
void ProposeEnergy(G4double finalEnergy)
void PreparePhysicsTable(const G4ParticleDefinition &)
int G4int
Definition: G4Types.hh:78
void SetParentWeightByProcess(G4bool)
void ProposeParentWeight(G4double finalWeight)
G4double GetKineticEnergy() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
G4VEnergyLossProcess * theDirectEnergyLossProcess
static G4LossTableManager * Instance()
void BuildPhysicsTable(const G4ParticleDefinition &)
void DefineMaterial(const G4MaterialCutsCouple *couple)
G4double GetWeight() const
Char_t n[5]
G4VEmModel * SelectModelForMaterial(G4double kinEnergy, size_t &idx) const
G4VParticleChange * AlongStepDoIt(const G4Track &, const G4Step &)
double maxE
Definition: plot_hist.C:8
G4double HighEnergyLimit() const
Definition: G4VEmModel.hh:609
#define DBL_MAX
Definition: templates.hh:83
const G4DynamicParticle * GetDynamicParticle() const
void SetDynamicMassCharge(const G4Track &track, G4double energy)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments