36 #include "DetectorConstruction.hh"
37 #include "PrimaryGeneratorAction.hh"
38 #include "EmAcceptance.hh"
48 :
G4Run(),fDet(det),fKin(kin),
59 f_dEdL.resize(f_nLbin);
60 fSumELongit.resize(f_nLbin);
61 fSumELongitCumul.resize(f_nLbin);
62 fSumE2Longit.resize(f_nLbin);
63 fSumE2LongitCumul.resize(f_nLbin);
66 f_dEdR.resize(f_nRbin);
67 fSumERadial.resize(f_nRbin);
68 fSumERadialCumul.resize(f_nRbin);
69 fSumE2Radial.resize(f_nRbin);
70 fSumE2RadialCumul.resize(f_nRbin);
79 for (
G4int i=0; i<f_nLbin; i++)
80 fSumELongit[i]=fSumE2Longit[i]=fSumELongitCumul[i]=fSumE2LongitCumul[i]=0.;
82 for (
G4int j=0; j<f_nRbin; j++)
83 fSumERadial[j]=fSumE2Radial[j]=fSumERadialCumul[j]=fSumE2RadialCumul[j]=0.;
86 fSumChargTrLength=fSum2ChargTrLength=fSumNeutrTrLength=fSum2NeutrTrLength=0.;
100 for (
G4int i=0; i<f_nLbin; i++)
103 for (
G4int j=0; j<f_nRbin; j++)
107 fChargTrLength = fNeutrTrLength = 0.;
117 for (
G4int i=0; i<f_nLbin; i++)
119 fSumELongit[i] += f_dEdL[i];
120 fSumE2Longit[i] += f_dEdL[i]*f_dEdL[i];
121 dLCumul += f_dEdL[i];
122 fSumELongitCumul[i] += dLCumul;
123 fSumE2LongitCumul[i] += dLCumul*dLCumul;
127 for (
G4int j=0; j<f_nRbin; j++)
129 fSumERadial[j] += f_dEdR[j];
130 fSumE2Radial[j] += f_dEdR[j]*f_dEdR[j];
131 dRCumul += f_dEdR[j];
132 fSumERadialCumul[j] += dRCumul;
133 fSumE2RadialCumul[j] += dRCumul*dRCumul;
136 fSumChargTrLength += fChargTrLength;
137 fSum2ChargTrLength += fChargTrLength*fChargTrLength;
138 fSumNeutrTrLength += fNeutrTrLength;
139 fSum2NeutrTrLength += fNeutrTrLength*fNeutrTrLength;
149 analysisManager->FillH1(1, 100.*dLCumul/(Ekin+mass));
150 analysisManager->FillH1(2, fChargTrLength/radl);
151 analysisManager->FillH1(3, fNeutrTrLength/radl);
156 for (
G4int i=0; i<f_nLbin; i++) {
158 analysisManager->FillP1(0, bin, norm*f_dEdL[i]/dLradl);
161 for (
G4int j=0; j<f_nRbin; j++) {
163 analysisManager->FillP1(1, bin, norm*f_dEdR[j]/dRradl);
171 const Run* localRun =
static_cast<const Run*
>(run);
173 fChargedStep += localRun->fChargedStep;
174 fNeutralStep += localRun->fNeutralStep;
176 for (
G4int i=0; i<f_nLbin; i++) {
177 fSumELongit[i] += localRun->fSumELongit[i];
178 fSumE2Longit[i] += localRun->fSumE2Longit[i];
179 fSumELongitCumul[i] += localRun->fSumELongitCumul[i];
180 fSumE2LongitCumul[i] += localRun->fSumE2LongitCumul[i];
183 for (
G4int j=0; j<f_nRbin; j++) {
184 fSumERadial[j] += localRun->fSumERadial[j];
185 fSumE2Radial[j] += localRun->fSumE2Radial[j];
186 fSumERadialCumul[j] += localRun->fSumERadialCumul[j];
187 fSumE2RadialCumul[j] += localRun->fSumE2RadialCumul[j];
190 fSumChargTrLength += localRun->fSumChargTrLength;
191 fSum2ChargTrLength += localRun->fSum2ChargTrLength;
192 fSumNeutrTrLength += localRun->fSumNeutrTrLength;
193 fSum2NeutrTrLength += localRun->fSum2NeutrTrLength;
205 assert(NbOfEvents*kinEnergy > 0);
207 fChargedStep /=
G4double(NbOfEvents);
208 fNeutralStep /=
G4double(NbOfEvents);
211 G4double norme = 100./(NbOfEvents*(kinEnergy+mass));
217 MyVector MeanELongit(f_nLbin), rmsELongit(f_nLbin);
218 MyVector MeanELongitCumul(f_nLbin), rmsELongitCumul(f_nLbin);
223 for (i=0; i<f_nLbin; i++) {
224 MeanELongit[i] = norme*fSumELongit[i];
226 norme*std::sqrt(std::abs(NbOfEvents*fSumE2Longit[i]
227 - fSumELongit[i]*fSumELongit[i]));
229 MeanELongitCumul[i] = norme*fSumELongitCumul[i];
230 rmsELongitCumul[i] = norme*std::sqrt(std::abs(NbOfEvents*
231 fSumE2LongitCumul[i] - fSumELongitCumul[i]*fSumELongitCumul[i]));
233 analysisManager->FillH1(4, bin,MeanELongit[i]/dLradl);
234 analysisManager->FillH1(5, bin, rmsELongit[i]/dLradl);
236 analysisManager->FillH1(6, bin,MeanELongitCumul[i]);
237 analysisManager->FillH1(7, bin, rmsELongitCumul[i]);
244 MyVector MeanERadial(f_nRbin), rmsERadial(f_nRbin);
245 MyVector MeanERadialCumul(f_nRbin), rmsERadialCumul(f_nRbin);
247 for (i=0; i<f_nRbin; i++) {
248 MeanERadial[i] = norme*fSumERadial[i];
249 rmsERadial[i] = norme*std::sqrt(std::abs(NbOfEvents*fSumE2Radial[i]
250 - fSumERadial[i]*fSumERadial[i]));
252 MeanERadialCumul[i] = norme*fSumERadialCumul[i];
254 norme*std::sqrt(std::abs(NbOfEvents*fSumE2RadialCumul[i]
255 - fSumERadialCumul[i]*fSumERadialCumul[i]));
258 analysisManager->FillH1(8, bin,MeanERadial[i]/dRradl);
259 analysisManager->FillH1(9, bin, rmsERadial[i]/dRradl);
261 analysisManager->FillH1(10, bin,MeanERadialCumul[i]);
262 analysisManager->FillH1(11, bin, rmsERadialCumul[i]);
269 if ((MeanERadialCumul[0] <= EMoliere) &&
270 (MeanERadialCumul[f_nRbin-1] >= EMoliere)) {
272 while( (imin < f_nRbin-1) && (MeanERadialCumul[imin] < EMoliere) )
274 G4double ratio = (EMoliere - MeanERadialCumul[imin]) /
275 (MeanERadialCumul[imin+1] - MeanERadialCumul[imin]);
276 iMoliere = 1. + imin + ratio;
282 G4double MeanChargTrLength = norme*fSumChargTrLength;
284 norme*std::sqrt(std::fabs(NbOfEvents*fSum2ChargTrLength
285 - fSumChargTrLength*fSumChargTrLength));
287 G4double MeanNeutrTrLength = norme*fSumNeutrTrLength;
289 norme*std::sqrt(std::fabs(NbOfEvents*fSum2NeutrTrLength
290 - fSumNeutrTrLength*fSumNeutrTrLength));
293 std::ios::fmtflags mode =
G4cout.flags();
294 G4cout.setf(std::ios::fixed,std::ios::floatfield);
299 G4cout <<
" LOGITUDINAL PROFILE "
300 <<
" CUMULATIVE LOGITUDINAL PROFILE" <<
G4endl <<
G4endl;
302 G4cout <<
" bin " <<
" Mean rms "
303 <<
" bin " <<
" Mean rms \n" <<
G4endl;
305 for (i=0; i<f_nLbin; i++) {
306 G4double inf=i*dLradl, sup=inf+dLradl;
308 G4cout << std::setw(8) << inf <<
"->"
309 << std::setw(5) << sup <<
" radl: "
310 << std::setw(7) << MeanELongit[i] <<
"% "
311 << std::setw(9) << rmsELongit[i] <<
"% "
312 <<
" 0->" << std::setw(5) << sup <<
" radl: "
313 << std::setw(7) << MeanELongitCumul[i] <<
"% "
314 << std::setw(7) << rmsELongitCumul[i] <<
"% "
320 G4cout <<
" RADIAL PROFILE "
321 <<
" CUMULATIVE RADIAL PROFILE" << G4endl <<
G4endl;
323 G4cout <<
" bin " <<
" Mean rms "
324 <<
" bin " <<
" Mean rms \n" <<
G4endl;
326 for (i=0; i<f_nRbin; i++) {
327 G4double inf=i*dRradl, sup=inf+dRradl;
329 G4cout << std::setw(8) << inf <<
"->"
330 << std::setw(5) << sup <<
" radl: "
331 << std::setw(7) << MeanERadial[i] <<
"% "
332 << std::setw(9) << rmsERadial[i] <<
"% "
333 <<
" 0->" << std::setw(5) << sup <<
" radl: "
334 << std::setw(7) << MeanERadialCumul[i] <<
"% "
335 << std::setw(7) << rmsERadialCumul[i] <<
"% "
342 G4cout <<
" Total number of events: " << NbOfEvents <<
"\n"
343 <<
" Mean number of charged steps: " << fChargedStep <<
G4endl;
344 G4cout <<
" Mean number of neutral steps: " << fNeutralStep
347 G4cout <<
" energy deposit : "
348 << std::setw(7) << MeanELongitCumul[f_nLbin-1] <<
" % E0 +- "
349 << std::setw(7) << rmsELongitCumul[f_nLbin-1] <<
" % E0" <<
G4endl;
350 G4cout <<
" charged traklen: "
351 << std::setw(7) << MeanChargTrLength <<
" radl +- "
352 << std::setw(7) << rmsChargTrLength <<
" radl" <<
G4endl;
353 G4cout <<
" neutral traklen: "
354 << std::setw(7) << MeanNeutrTrLength <<
" radl +- "
355 << std::setw(7) << rmsNeutrTrLength <<
" radl" <<
G4endl;
357 if (iMoliere > 0. ) {
360 G4cout <<
"\n " << EMoliere <<
" % confinement: radius = "
361 << RMoliere1 <<
" radl ("
365 G4cout.setf(mode,std::ios::floatfield);
374 G4double e = MeanELongitCumul[nLbin-1]/100.;
375 G4double r = rmsELongitCumul[nLbin-1]/100.;
The primary generator action class with particle gun.
virtual void Merge(const G4Run *)
void EmAcceptanceGauss(const G4String &title, G4int stat, G4double avr, G4double avr0, G4double rms, G4double limit)
void InitializePerEvent()
void BeginOfAcceptance(const G4String &title, G4int stat)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
G4Material * GetMaterial()
std::vector< G4double > MyVector
G4double GetRadlen() const
G4double GetPDGMass() const
G4ParticleGun * GetParticleGun()
G4ParticleDefinition * GetParticleDefinition() const
Detector construction class to define materials and geometry.
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager
G4double GetParticleEnergy() const