35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
38 #include "EmAcceptance.hh"
57 fParticle(0), fEkin(0.),
58 fChargedStep(0), fNeutralStep(0),
59 fN_gamma(0), fN_elec(0), fN_pos(0),
65 fSumEAbs[k] = fSum2EAbs[k] = fSumLAbs[k] = fSum2LAbs[k] = 0.;
66 fEnergyDeposit[k].clear();
67 fEdeptrue[k] = fRmstrue[k] = 1.;
74 fEnergyFlow.resize(nbPlanes);
75 fLateralEleak.resize(nbPlanes);
76 for (
G4int k=0; k<nbPlanes; k++) {fEnergyFlow[k] = fLateralEleak[k] = 0.; }
98 if(fApplyLimit) fEnergyDeposit[
kAbs].push_back(EAbs);
99 fSumEAbs[
kAbs] += EAbs; fSum2EAbs[
kAbs] += EAbs*EAbs;
100 fSumLAbs[
kAbs] += LAbs; fSum2LAbs[
kAbs] += LAbs*LAbs;
107 fEnergyFlow[plane] += Eflow;
114 fLateralEleak[cell] += Eflow;
145 const Run* localRun =
static_cast<const Run*
>(run);
148 fParticle = localRun->fParticle;
149 fEkin = localRun->fEkin;
154 fSumEAbs[k] += localRun->fSumEAbs[k];
155 fSum2EAbs[k] += localRun->fSum2EAbs[k];
156 fSumLAbs[k] += localRun->fSumLAbs[k];
157 fSum2LAbs[k] += localRun->fSum2LAbs[k];
161 for (
G4int k=0; k<nbPlanes; k++) {
162 fEnergyFlow[k] += localRun->fEnergyFlow[k];
163 fLateralEleak[k] += localRun->fLateralEleak[k];
167 fChargedStep += localRun->fChargedStep;
168 fNeutralStep += localRun->fNeutralStep;
170 fN_gamma += localRun->fN_gamma;
171 fN_elec += localRun->fN_elec;
172 fN_pos += localRun->fN_pos;
174 fApplyLimit = localRun->fApplyLimit;
177 fEdeptrue[k] = localRun->fEdeptrue[k];
178 fRmstrue[k] = localRun->fRmstrue[k];
179 fLimittrue[k] = localRun->fLimittrue[k];
191 if(norm > 0) norm = 1./norm;
194 fChargedStep *= norm;
195 fNeutralStep *= norm;
202 G4double MeanEAbs,MeanEAbs2,rmsEAbs,resolution,rmsres;
203 G4double MeanLAbs,MeanLAbs2,rmsLAbs;
205 std::ios::fmtflags mode =
G4cout.flags();
207 G4cout <<
"\n------------------------------------------------------------\n";
208 G4cout << std::setw(14) <<
"material"
209 << std::setw(17) <<
"Edep RMS"
210 << std::setw(33) <<
"sqrt(E0(GeV))*rmsE/Emean"
211 << std::setw(23) <<
"total tracklen \n \n";
215 MeanEAbs = fSumEAbs[k]*norm;
216 MeanEAbs2 = fSum2EAbs[k]*norm;
217 rmsEAbs = std::sqrt(std::abs(MeanEAbs2 - MeanEAbs*MeanEAbs));
226 for(
G4int i=0; i<nEvt; i++) {
227 G4double e = (fEnergyDeposit[k])[i];
228 if(std::abs(e - MeanEAbs) < lim) {
235 if(norm1 > 0.0) norm1 = 1.0/norm1;
236 MeanEAbs = sume*norm1;
237 MeanEAbs2 = sume2*norm1;
238 rmsEAbs = std::sqrt(std::abs(MeanEAbs2 - MeanEAbs*MeanEAbs));
241 resolution= 100.*sqbeam*rmsEAbs/MeanEAbs;
242 rmsres = resolution*qnorm;
245 fSumEAbs[k] = MeanEAbs;
246 fSum2EAbs[k] = rmsEAbs;
248 MeanLAbs = fSumLAbs[k]*norm;
249 MeanLAbs2 = fSum2LAbs[k]*norm;
250 rmsLAbs = std::sqrt(std::abs(MeanLAbs2 - MeanLAbs*MeanLAbs));
256 << std::setprecision(5)
257 << std::setw(6) <<
G4BestUnit(MeanEAbs,
"Energy") <<
" : "
258 << std::setprecision(4)
259 << std::setw(5) <<
G4BestUnit( rmsEAbs,
"Energy")
260 << std::setw(10) << resolution <<
" +- "
261 << std::setw(5) << rmsres <<
" %"
262 << std::setprecision(3)
263 << std::setw(10) <<
G4BestUnit(MeanLAbs,
"Length") <<
" +- "
264 << std::setw(4) <<
G4BestUnit( rmsLAbs,
"Length")
267 G4cout <<
"\n------------------------------------------------------------\n";
269 G4cout <<
" Beam particle "
275 G4cout << std::setprecision(6)
276 <<
" Mean number of charged steps " << fChargedStep <<
G4endl;
277 G4cout <<
" Mean number of neutral steps " << fNeutralStep <<
G4endl;
278 G4cout <<
"------------------------------------------------------------\n";
284 for (
G4int Id=1; Id<=Idmax+1; Id++) {
285 analysis->FillH1(2*kMaxAbsor+1, (
G4double)Id, fEnergyFlow[Id]);
286 analysis->FillH1(2*kMaxAbsor+2, (
G4double)Id, fLateralEleak[Id]);
295 for (
G4int Id=1; Id<=Idmax; Id++) {
296 G4int iAbsor = Id%nbOfAbsor;
if (iAbsor==0) iAbsor = nbOfAbsor;
297 EdepTot[iAbsor] += (fEnergyFlow[Id] - fEnergyFlow[Id+1] - fLateralEleak[Id]);
300 G4cout << std::setprecision(3)
301 <<
"\n Energy deposition from Energy flow balance : \n"
302 << std::setw(10) <<
" material \t Total Edep \n \n";
305 for (
G4int k=1; k<=nbOfAbsor; k++) {
308 <<
"\t " <<
G4BestUnit(EdepTot [k],
"Energy") <<
"\n";
311 G4cout <<
"\n------------------------------------------------------------\n"
323 MeanEAbs = fSumEAbs[j];
324 rmsEAbs = fSum2EAbs[j];
327 fEdeptrue[j], fRmstrue[j], fLimittrue[j]);
329 fRmstrue[j], fRmstrue[j], 2.0*fLimittrue[j]);
337 analysis->ScaleH1(ih,norm/
MeV);
340 G4cout.setf(mode,std::ios::floatfield);
348 if (i>=0 && i<kMaxAbsor) {
349 fEdeptrue [i] = edep;
G4ParticleDefinition * GetDefinition() const
virtual void Merge(const G4Run *)
void EmAcceptanceGauss(const G4String &title, G4int stat, G4double avr, G4double avr0, G4double rms, G4double limit)
const G4String & GetName() const
void SumEnergyFlow(G4int plane, G4double Eflow)
void BeginOfAcceptance(const G4String &title, G4int stat)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetEdepAndRMS(G4int, G4double, G4double, G4double)
const G4String & GetParticleName() const
G4Material * GetAbsorMaterial(G4int i)
void SumLateralEleak(G4int cell, G4double Eflow)
G4GLOB_DLL std::ostream G4cout
void AddSecondaryTrack(const G4Track *)
static G4Positron * Positron()
G4double energy(const ThreeVector &p, const G4double m)
static constexpr double GeV
static G4Electron * Electron()
Detector construction class to define materials and geometry.
static constexpr double MeV
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager
void SetApplyLimit(G4bool)