56{
57 theEnergies.clear();
58
60
61#ifdef VERBOSE_ENERSPLIT
65#endif
68 return theEnergies.size();
69 }
71 theEnergies.push_back(edep);
72 return theEnergies.size();
73 }
74
75 if( !thePhantomParam ) GetPhantomParam(
TRUE);
76
77 if( aStep == 0 )
return FALSE;
78
79
81
84 G4double kinEnergyPre = kinEnergyPreOrig;
85
88 unsigned int ii;
89 for( ii = 0; ii < rnsl.size(); ii++ ){
91 slSum += sl;
92#ifdef VERBOSE_ENERSPLIT
93 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter1 step length geom " << sl <<
G4endl;
94#endif
95 }
96
97#ifdef VERBOSE_ENERSPLIT
98 if( verbose )
99 G4cout <<
"G4EnergySplitter RN: step length geom TOTAL " << slSum
100 << " true TOTAL " << stepLength
101 << " ratio " << stepLength/slSum
104 <<
" Number of geom steps " << rnsl.size() <<
G4endl;
105#endif
106
107 if( theNIterations == 0 ) {
108 for( ii = 0; ii < rnsl.size(); ii++ ){
110 G4double edepStep = edep * sl/slSum;
111#ifdef VERBOSE_ENERSPLIT
112 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii
113 <<
" edep " << edepStep <<
G4endl;
114#endif
115
116 theEnergies.push_back(edepStep);
117
118 }
119 } else {
120
121#ifdef VERBOSE_ENERSPLIT
122
123 if(verbose) {
125 for( ii = 0; ii < rnsl.size(); ii++ ){
127 slSum += sl;
128 }
129 for( ii = 0; ii < rnsl.size(); ii++ ){
130 G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes "<< ii
131 << " RN: iter0 corrected energy lost " << edep*rnsl[ii].second/slSum
133 }
134 }
135#endif
136
137 G4double slRatio = stepLength/slSum;
138#ifdef VERBOSE_ENERSPLIT
139 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes RN: iter 0, step ratio " << slRatio <<
G4endl;
140#endif
141
142
145 std::vector<G4double> stepLengths;
146 for( int iiter = 1; iiter <= theNIterations; iiter++ ) {
147
148 if( iiter == 1 ) {
149 for( ii = 0; ii < rnsl.size(); ii++ ){
151 stepLengths.push_back( sl * slRatio );
152#ifdef VERBOSE_ENERSPLIT
153 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter" << iiter <<
" corrected step length " << sl*slRatio <<
G4endl;
154#endif
155 }
156
157 for( ii = 0; ii < rnsl.size(); ii++ ){
160 if( kinEnergyPre > 0. ) {
161 dEdx = emcalc.
GetDEDX(kinEnergyPre, part, mate);
162 }
163 G4double elost = stepLengths[ii] * dEdx;
164
165#ifdef VERBOSE_ENERSPLIT
166 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter1 energy lost " << elost
167 << " energy at interaction " << kinEnergyPre
168 << " = stepLength " << stepLengths[ii]
169 <<
" * dEdx " << dEdx <<
G4endl;
170#endif
171 kinEnergyPre -= elost;
172 theEnergies.push_back( elost );
173 totalELost += elost;
174 }
175
176 } else{
177
178
179
180 slSum = 0.;
181 kinEnergyPre = kinEnergyPreOrig;
182 for( ii = 0; ii < rnsl.size(); ii++ ){
184 stepLengths[ii] = theElossExt->
TrueStepLength( kinEnergyPre, rnsl[ii].second , mate, part );
185 kinEnergyPre -= theEnergies[ii];
186
187#ifdef VERBOSE_ENERSPLIT
188 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes" << ii
189 << " RN: iter" << iiter << " step length geom " << stepLengths[ii]
190 <<
" geom2true " << rnsl[ii].second / stepLengths[ii] <<
G4endl;
191#endif
192
193 slSum += stepLengths[ii];
194 }
195
196
198#ifdef VERBOSE_ENERSPLIT
199 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes" << ii <<
" RN: iter" << iiter <<
" step ratio " << slRatio <<
G4endl;
200#endif
201 for( ii = 0; ii < rnsl.size(); ii++ ){
202 stepLengths[ii] *= slratio;
203#ifdef VERBOSE_ENERSPLIT
204 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter" << iiter <<
" corrected step length " << stepLengths[ii] <<
G4endl;
205#endif
206 }
207
208
210 totalELost = 0.;
211 for( ii = 0; ii < rnsl.size(); ii++ ){
214 if( kinEnergyPre > 0. ) {
215 dEdx = emcalc.
GetDEDX(kinEnergyPre, part, mate);
216 }
217 G4double elost = stepLengths[ii] * dEdx;
218#ifdef VERBOSE_ENERSPLIT
219 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter" << iiter <<
" energy lost " << elost
220 << " energy at interaction " << kinEnergyPre
221 << " = stepLength " << stepLengths[ii]
222 <<
" * dEdx " << dEdx <<
G4endl;
223#endif
224 kinEnergyPre -= elost;
225 theEnergies[ii] = elost;
226 totalELost += elost;
227 }
228
229 }
230
231
232 G4double enerRatio = (edep/totalELost);
233
234#ifdef VERBOSE_ENERSPLIT
235 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes"<< ii <<
" RN: iter" << iiter <<
" energy ratio " << enerRatio <<
G4endl;
236#endif
237
238#ifdef VERBOSE_ENERSPLIT
240#endif
241 for( ii = 0; ii < theEnergies.size(); ii++ ){
242 theEnergies[ii] *= enerRatio;
243#ifdef VERBOSE_ENERSPLIT
244 elostTot += theEnergies[ii];
245 if(verbose)
G4cout <<
"G4EnergySplitter::SplitEnergyInVolumes "<< ii <<
" RN: iter" << iiter <<
" corrected energy lost " << theEnergies[ii]
246 << " orig elost " << theEnergies[ii]/enerRatio
247 << " energy before interaction " << kinEnergyPreOrig-elostTot+theEnergies[ii]
248 << " energy after interaction " << kinEnergyPreOrig-elostTot
250#endif
251 }
252 }
253
254 }
255
256 return theEnergies.size();
257}
G4GLOB_DLL std::ostream G4cout
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
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