source: trunk/source/processes/electromagnetic/adjoint/src/G4ContinuousGainOfEnergy.cc@ 1036

Last change on this file since 1036 was 966, checked in by garnier, 17 years ago

fichier ajoutes

File size: 5.6 KB
RevLine 
[966]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#include "G4ContinuousGainOfEnergy.hh"
27#include "G4Step.hh"
28#include "G4ParticleDefinition.hh"
29#include "G4VEmModel.hh"
30#include "G4VEmFluctuationModel.hh"
31#include "G4VParticleChange.hh"
32#include "G4UnitsTable.hh"
33
34
35///////////////////////////////////////////////////////
36//
37G4ContinuousGainOfEnergy::G4ContinuousGainOfEnergy(const G4String& name,
38 G4ProcessType type): G4VContinuousProcess(name, type)
39{
40
41 linLossLimit=0.05;
42 lossFluctuationArePossible =true;
43 lossFluctuationFlag=true;
44 is_integral = false;
45
46}
47
48///////////////////////////////////////////////////////
49//
50G4ContinuousGainOfEnergy::~G4ContinuousGainOfEnergy()
51{
52
53}
54///////////////////////////////////////////////////////
55//
56
57void G4ContinuousGainOfEnergy::PreparePhysicsTable(
58 const G4ParticleDefinition& )
59{//theDirectEnergyLossProcess->PreparePhysicsTable(part);
60
61;
62}
63
64///////////////////////////////////////////////////////
65//
66
67void G4ContinuousGainOfEnergy::BuildPhysicsTable(const G4ParticleDefinition&)
68{//theDirectEnergyLossProcess->BuildPhysicsTable(part);
69;
70}
71
72
73
74
75///////////////////////////////////////////////////////
76//
77//
78G4VParticleChange* G4ContinuousGainOfEnergy::AlongStepDoIt(const G4Track& track,
79 const G4Step& step)
80{
81
82 aParticleChange.Initialize(track);
83
84 // Get the actual (true) Step length
85 //----------------------------------
86 G4double length = step.GetStepLength();
87 G4double degain = 0.0;
88
89
90
91
92 // Compute this for weight change after continuous energy loss
93 //-------------------------------------------------------------
94 G4double DEDX_before =
95 theDirectEnergyLossProcess
96 ->GetDEDX(preStepKinEnergy, currentCouple);
97
98
99
100 // For the fluctuation we generate a new dynamic particle with energy =preEnergy+egain
101 // and then compute the fluctuation given in the direct case.
102 //-----------------------------------------------------------------------
103 G4DynamicParticle* dynParticle = new G4DynamicParticle();
104 *dynParticle = *(track.GetDynamicParticle());
105 G4double Tkin = dynParticle->GetKineticEnergy();
106
107 size_t n=1;
108 if (is_integral ) n=10;
109 G4double dlength= length/n;
110 for (size_t i=0;i<n;i++) {
111 G4double r = theDirectEnergyLossProcess->GetRange(Tkin, currentCouple);
112 if( dlength <= linLossLimit * r ) {
113 degain = DEDX_before*dlength;
114 }
115 else {
116 G4double x = r + length;
117 degain = theDirectEnergyLossProcess->GetKineticEnergy(x,currentCouple) - theDirectEnergyLossProcess->GetKineticEnergy(r,currentCouple);
118 }
119 G4VEmModel* currentModel = theDirectEnergyLossProcess->SelectModelForMaterial(Tkin+degain,currentMaterialIndex);
120 G4double tmax = currentModel->MaxSecondaryKinEnergy(dynParticle);
121 tmax = std::min(tmax,currentTcut);
122
123
124
125 // Sample fluctuations
126 //-------------------
127
128 G4double deltaE =0.;
129 if (lossFluctuationFlag ) {
130 deltaE = currentModel->GetModelOfFluctuations()->
131 SampleFluctuations(currentMaterial,dynParticle,tmax,length,degain)-degain;
132 }
133 Tkin+=degain+deltaE;
134 dynParticle->SetKineticEnergy(Tkin);
135
136 }
137
138
139
140 // Corrections, which cannot be tabulated
141 // probably this should be also changed
142 // at this time it does nothing so we can leave it
143 //CorrectionsAlongStep(currentCouple, dynParticle, egain, length);
144
145 delete dynParticle;
146
147
148 G4double DEDX_after = theDirectEnergyLossProcess->GetDEDX(Tkin, currentCouple);
149 G4double weight_correction=DEDX_after/DEDX_before; //probably not needed
150 weight_correction=1.;
151
152 aParticleChange.ProposeEnergy(Tkin);
153
154 //we still need to register in the particleChange the modification of the weight of the particle
155 G4double new_weight=weight_correction*track.GetWeight();
156 aParticleChange.SetParentWeightByProcess(true);
157 aParticleChange.ProposeParentWeight(new_weight);
158
159
160 return &aParticleChange;
161
162}
163///////////////////////////////////////////////////////
164//
165void G4ContinuousGainOfEnergy::SetLossFluctuations(G4bool val)
166{
167 if(val && !lossFluctuationArePossible) return;
168 lossFluctuationFlag = val;
169}
Note: See TracBrowser for help on using the repository browser.