54{
55 theEnergies.clear();
56
58
59#ifdef VERBOSE_ENERSPLIT
63#endif
66 return theEnergies.size();
67 }
69 theEnergies.push_back(edep);
70 return theEnergies.size();
71 }
72
73 if( !thePhantomParam ) GetPhantomParam(
TRUE);
74
75 if( aStep == 0 )
return FALSE;
76
77
79
82 G4double kinEnergyPre = kinEnergyPreOrig;
83
86 unsigned int ii;
87 for( ii = 0; ii < rnsl.size(); ii++ ){
89 slSum += sl;
90#ifdef VERBOSE_ENERSPLIT
91 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter1 step length geom " << sl <<
G4endl;
92#endif
93 }
94
95#ifdef VERBOSE_ENERSPLIT
96 if( verbose )
97 G4cout <<
"G4EnergySplitter RN: step length geom TOTAL " << slSum
98 << " true TOTAL " << stepLength
99 << " ratio " << stepLength/slSum
102 <<
" Number of geom steps " << rnsl.size() <<
G4endl;
103#endif
104
105 if( theNIterations == 0 ) {
106 for( ii = 0; ii < rnsl.size(); ii++ ){
108 G4double edepStep = edep * sl/slSum;
109#ifdef VERBOSE_ENERSPLIT
110 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii
111 <<
" edep " << edepStep <<
G4endl;
112#endif
113
114 theEnergies.push_back(edepStep);
115
116 }
117 } else {
118
119#ifdef VERBOSE_ENERSPLIT
120
121 if(verbose) {
123 for( ii = 0; ii < rnsl.size(); ii++ ){
125 slSum += sl;
126 }
127 for( ii = 0; ii < rnsl.size(); ii++ ){
128 G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes "<< ii
129 << " RN: iter0 corrected energy lost " << edep*rnsl[ii].second/slSum
131 }
132 }
133#endif
134
135 G4double slRatio = stepLength/slSum;
136#ifdef VERBOSE_ENERSPLIT
137 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes RN: iter 0, step ratio " << slRatio <<
G4endl;
138#endif
139
140
143 std::vector<G4double> stepLengths;
144 for( int iiter = 1; iiter <= theNIterations; iiter++ ) {
145
146 if( iiter == 1 ) {
147 for( ii = 0; ii < rnsl.size(); ii++ ){
149 stepLengths.push_back( sl * slRatio );
150#ifdef VERBOSE_ENERSPLIT
151 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter" << iiter <<
" corrected step length " << sl*slRatio <<
G4endl;
152#endif
153 }
154
155 for( ii = 0; ii < rnsl.size(); ii++ ){
158 if( kinEnergyPre > 0. ) {
159 dEdx = emcalc.
GetDEDX(kinEnergyPre, part, mate);
160 }
161 G4double elost = stepLengths[ii] * dEdx;
162
163#ifdef VERBOSE_ENERSPLIT
164 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter1 energy lost " << elost
165 << " energy at interaction " << kinEnergyPre
166 << " = stepLength " << stepLengths[ii]
167 <<
" * dEdx " << dEdx <<
G4endl;
168#endif
169 kinEnergyPre -= elost;
170 theEnergies.push_back( elost );
171 totalELost += elost;
172 }
173
174 } else{
175
176
177
178 slSum = 0.;
179 kinEnergyPre = kinEnergyPreOrig;
180 for( ii = 0; ii < rnsl.size(); ii++ ){
182 stepLengths[ii] = theElossExt->
TrueStepLength( kinEnergyPre, rnsl[ii].second , mate, part );
183 kinEnergyPre -= theEnergies[ii];
184
185#ifdef VERBOSE_ENERSPLIT
186 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes" << ii
187 << " RN: iter" << iiter << " step length geom " << stepLengths[ii]
188 <<
" geom2true " << rnsl[ii].second / stepLengths[ii] <<
G4endl;
189#endif
190
191 slSum += stepLengths[ii];
192 }
193
194
196#ifdef VERBOSE_ENERSPLIT
197 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes" << ii <<
" RN: iter" << iiter <<
" step ratio " << slRatio <<
G4endl;
198#endif
199 for( ii = 0; ii < rnsl.size(); ii++ ){
200 stepLengths[ii] *= slratio;
201#ifdef VERBOSE_ENERSPLIT
202 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter" << iiter <<
" corrected step length " << stepLengths[ii] <<
G4endl;
203#endif
204 }
205
206
208 totalELost = 0.;
209 for( ii = 0; ii < rnsl.size(); ii++ ){
212 if( kinEnergyPre > 0. ) {
213 dEdx = emcalc.
GetDEDX(kinEnergyPre, part, mate);
214 }
215 G4double elost = stepLengths[ii] * dEdx;
216#ifdef VERBOSE_ENERSPLIT
217 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter" << iiter <<
" energy lost " << elost
218 << " energy at interaction " << kinEnergyPre
219 << " = stepLength " << stepLengths[ii]
220 <<
" * dEdx " << dEdx <<
G4endl;
221#endif
222 kinEnergyPre -= elost;
223 theEnergies[ii] = elost;
224 totalELost += elost;
225 }
226
227 }
228
229
230 G4double enerRatio = (edep/totalELost);
231
232#ifdef VERBOSE_ENERSPLIT
233 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter" << iiter <<
" energy ratio " << enerRatio <<
G4endl;
234#endif
235
236#ifdef VERBOSE_ENERSPLIT
238#endif
239 for( ii = 0; ii < theEnergies.size(); ii++ ){
240 theEnergies[ii] *= enerRatio;
241#ifdef VERBOSE_ENERSPLIT
242 elostTot += theEnergies[ii];
243 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes "<< ii <<
" RN: iter" << iiter <<
" corrected energy lost " << theEnergies[ii]
244 << " orig elost " << theEnergies[ii]/enerRatio
245 << " energy before interaction " << kinEnergyPreOrig-elostTot+theEnergies[ii]
246 << " energy after interaction " << kinEnergyPreOrig-elostTot
248#endif
249 }
250 }
251
252 }
253
254 return theEnergies.size();
255}
G4DLLIMPORT std::ostream G4cout
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=0)
const G4String & GetName() const
G4double GetPDGCharge() const
G4Material * GetMaterial(size_t nx, size_t ny, size_t nz) const
G4Material * GetMaterial() const
G4double GetKineticEnergy() const
G4Track * GetTrack() const
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
G4double GetTotalEnergyDeposit() const
G4ParticleDefinition * GetDefinition() const