35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
52 :fDetector(det),fKinematic(kin), fProcCounter(0), fMateWall(0),fMateCavity(0)
65 fSurfaceCavity =
CLHEP::pi*fCavityRadius*fCavityRadius;
66 fVolumeCavity = fSurfaceCavity*fCavityThickness;
69 fMassCavity = fVolumeCavity*fDensityCavity;
77 fEsecondary = fEsecondary2 = 0.;
82 fPartFlowCavity[0] = fPartFlowCavity[1] = 0;
83 fEnerFlowCavity[0] = fEnerFlowCavity[1] = 0.;
87 fEdepCavity = fEdepCavity2 = fTrkSegmCavity = 0.;
92 fOldEmean = fOldDose = 0.;
96 fStepWall = fStepWall2 = fStepCavity = fStepCavity2 =0.;
97 fNbStepWall = fNbStepCavity = 0;
102 if ( analysisManager->IsActive() ) {
103 analysisManager->OpenFile();
117 std::ios::fmtflags mode =
G4cout.flags();
118 G4cout.setf(std::ios::fixed,std::ios::floatfield);
129 G4cout <<
"\n ======================== run summary ======================\n";
134 <<
G4BestUnit(energy,
"Energy") <<
" through 2*"
135 <<
G4BestUnit(fWallThickness,
"Length") <<
" of "
136 << fMateWall->
GetName() <<
" (density: "
139 G4cout <<
"\n the cavity is "
140 <<
G4BestUnit(fCavityThickness,
"Length") <<
" of "
141 << fMateCavity->
GetName() <<
" (density: "
142 <<
G4BestUnit(fDensityCavity,
"Volumic Mass") <<
"); Mass = "
145 G4cout<<
"\n ============================================================\n";
149 G4cout <<
"\n Process calls frequency --->";
150 for (
size_t i=0; i< fProcCounter->size();i++) {
151 G4String procName = (*fProcCounter)[i]->GetName();
152 G4int count = (*fProcCounter)[i]->GetCounter();
153 G4cout <<
" " << procName <<
"= " << count;
160 G4cout <<
"\n Gamma crossSections in wall material :";
162 for (
size_t i=0; i< fProcCounter->size();i++) {
163 G4String procName = (*fProcCounter)[i]->GetName();
166 procName,fMateWall)/fDensityWall;
167 if (massSigma > 0.) {
169 G4cout <<
" " << procName <<
"= "
178 if (fNbSec == 0)
return;
179 G4double meanEsecond = fEsecondary/fNbSec,meanEsecond2= fEsecondary2/fNbSec;
180 G4double varianceEsec = meanEsecond2 - meanEsecond*meanEsecond;
182 if (varianceEsec>0.) dToverT = std::sqrt(varianceEsec/fNbSec)/meanEsecond;
188 <<
"\n Mean energy of secondary e- = " <<
G4BestUnit(meanEsecond,
"Energy")
189 <<
" +- " << 100*dToverT <<
" %"
190 <<
" (--> range in wall material = " <<
G4BestUnit(csdaRange,
"Length")
198 G4cout <<
" Mass_energy_transfer coef: "
206 dedxWall /= fDensityWall;
209 dedxCavity /= fDensityCavity;
212 <<
"\n StoppingPower in wall = "
215 <<
G4BestUnit(dedxCavity,
"Energy*Surface/Mass")
221 <<
"\n Charged particle flow in cavity :"
222 <<
"\n Enter --> nbParticles = " << fPartFlowCavity[0]
223 <<
"\t Energy = " <<
G4BestUnit (fEnerFlowCavity[0],
"Energy")
224 <<
"\n Exit --> nbParticles = " << fPartFlowCavity[1]
225 <<
"\t Energy = " <<
G4BestUnit (fEnerFlowCavity[1],
"Energy")
228 if (fPartFlowCavity[0] == 0)
return;
237 if (fNbEventCavity == 0)
return;
238 G4double meanEdep = fEdepCavity/fNbEventCavity;
239 G4double meanEdep2 = fEdepCavity2/fNbEventCavity;
240 G4double varianceEdep = meanEdep2 - meanEdep*meanEdep;
242 if(varianceEdep>0.) dEoverE=std::sqrt(varianceEdep/fNbEventCavity)/meanEdep;
246 G4double doseCavity = fEdepCavity/fMassCavity;
250 G4double meantrack = fTrkSegmCavity/fPartFlowCavity[0];
254 <<
"\n Total edep in cavity = " <<
G4BestUnit(fEdepCavity,
"Energy")
255 <<
" +- " << 100*dEoverE <<
" %"
256 <<
"\t Total charged trackLength = " <<
G4BestUnit(fTrkSegmCavity,
"Length")
257 <<
" (mean value = " <<
G4BestUnit(meantrack,
"Length") <<
")"
258 <<
"\n Total dose in cavity = " << doseCavity/(
MeV/
mg) <<
" MeV/mg"
259 <<
"\n Dose/EnergyFluence = " <<
G4BestUnit(doseOverBeam,
"Surface/Mass")
264 G4double ratio = doseOverBeam/massTransfCoef;
265 G4double error = ratio*std::sqrt(dEoverE*dEoverE + dToverT*dToverT);
269 <<
"\n (Dose/EnergyFluence)/Mass_energy_transfer = " << ratio
270 <<
" +- " << error <<
G4endl;
274 fStepWall /= fNbStepWall; fStepWall2 /= fNbStepWall;
275 G4double rms = fStepWall2 - fStepWall*fStepWall;
276 if (rms>0.) rms = std::sqrt(rms);
else rms = 0.;
280 <<
"\n StepSize of ch. tracks in wall = "
282 <<
"\t (nbSteps/track = " << double(fNbStepWall)/fNbSec <<
")";
284 fStepCavity /= fNbStepCavity; fStepCavity2 /= fNbStepCavity;
285 rms = fStepCavity2 - fStepCavity*fStepCavity;
286 if (rms>0.) rms = std::sqrt(rms);
else rms = 0.;
289 <<
"\n StepSize of ch. tracks in cavity = "
291 <<
"\t (nbSteps/track = "<<double(fNbStepCavity)/fPartFlowCavity[0] <<
")";
296 G4cout.setf(mode,std::ios::floatfield);
300 while (fProcCounter->size()>0){
302 fProcCounter->pop_back();
312 if (NbofEvents == 0)
return;
317 if (fNbSec > 0) meanEsecond = fEsecondary/fNbSec;
320 if (fOldEmean > 0.) rateEmean = 100*(meanEsecond/fOldEmean - 1.);
321 fOldEmean = meanEsecond;
331 G4double doseCavity = fEdepCavity/fMassCavity;
332 G4double doseOverBeam = doseCavity*surfaceBeam/(NbofEvents*beamEnergy);
335 if (fOldDose > 0.) rateDose = 100*(doseOverBeam/fOldDose - 1.);
336 fOldDose = doseOverBeam;
338 std::ios::fmtflags mode =
G4cout.flags();
339 G4cout.setf(std::ios::fixed,std::ios::floatfield);
342 G4cout <<
"\n ---> NbofEvents= " << NbofEvents
343 <<
" NbOfelectr= " << fNbSec
344 <<
" Tkin= " <<
G4BestUnit(meanEsecond,
"Energy")
345 <<
" (" << rateEmean <<
" %)"
346 <<
" NbOfelec in cav= " << fPartFlowCavity[0]
347 <<
" Dose/EnFluence= " <<
G4BestUnit(doseOverBeam,
"Surface/Mass")
348 <<
" (" << rateDose <<
" %)"
352 G4cout.setf(mode,std::ios::floatfield);
360 const Run* localRun =
static_cast<const Run*
>(run);
362 fPartFlowCavity[0]+= localRun->fPartFlowCavity[0];
363 fPartFlowCavity[1]+= localRun->fPartFlowCavity[1];
364 fEnerFlowCavity[0]+= localRun->fEnerFlowCavity[0];
365 fEnerFlowCavity[1]+= localRun->fEnerFlowCavity[1];
366 fEdepCavity += localRun->fEdepCavity;
367 fEdepCavity2 += localRun->fEdepCavity2;
368 fTrkSegmCavity += localRun->fTrkSegmCavity;
369 fNbEventCavity += localRun->fNbEventCavity;
371 fStepWall += localRun->fStepWall;
372 fStepWall2 += localRun->fStepWall2;
373 fStepCavity += localRun->fStepCavity;
374 fStepCavity2 += localRun->fStepCavity2;
375 fNbStepWall += localRun->fNbStepWall;
376 fNbStepCavity += localRun->fNbStepCavity;
378 fEsecondary += localRun->fEsecondary;
379 fEsecondary2 += localRun->fEsecondary2;
381 fNbSec += localRun->fNbSec;
387 std::vector<OneProcessCount*>::iterator it;
388 for ( it = localRun->fProcCounter->begin();it !=localRun->fProcCounter->end();
405 size_t nbProc = fProcCounter->size();
407 while ((i<nbProc)&&((*fProcCounter)[i]->GetName()!=procName)) i++;
408 if (i == nbProc) fProcCounter->push_back(
new OneProcessCount(procName));
410 (*fProcCounter)[i]->Count();
std::vector< OneProcessCount * > ProcessesCount
The primary generator action class with particle gun.
virtual void Merge(const G4Run *)
void CountProcesses(G4String procName)
G4Material * GetCavityMaterial()
static constexpr double mg
G4Material * GetWallMaterial()
const G4String & GetName() const
G4double GetDensity() const
G4double GetCSDARange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4String & GetParticleName() const
G4double GetWallThickness()
void SurveyConvergence(G4int)
G4GLOB_DLL std::ostream G4cout
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double GetCavityThickness()
G4ParticleGun * GetParticleGun()
G4double energy(const ThreeVector &p, const G4double m)
G4double ComputeCrossSectionPerVolume(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, G4double cut=0.0)
G4ParticleDefinition * GetParticleDefinition() const
G4double GetCavityRadius()
static G4Electron * Electron()
Detector construction class to define materials and geometry.
static constexpr double MeV
static PROLOG_HANDLER error
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager
static constexpr double pi
G4double GetParticleEnergy() const