35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
52 :
G4Run(),fDetector(det), fKinematic(kin), fProcCounter(0),
53 fEdepCavity(0.), fEdepCavity2(0.),
54 fTrkSegmCavity(0.), fNbEventCavity(0),
55 fStepWall(0.), fStepWall2(0.),
56 fStepCavity(0.), fStepCavity2(0.),
57 fNbStepWall(0), fNbStepCavity(0),
58 fEnergyGun(0.), fMassWall(0.),
59 fMassCavity(0.),fIsMaster(isMaster)
74 fMassCavity = cavityThickness*densityCavity;
83 G4double effWallThick = factor*RangeWall;
84 if ((effWallThick > wallThickness)||(effWallThick <= 0.))
85 effWallThick = wallThickness;
86 fMassWall = 2*effWallThick*densityWall;
88 G4double massTotal = fMassWall + fMassCavity;
89 G4double fMassWallRatio = fMassWall/massTotal;
92 G4double massRatio = fMassCavity/fMassWall;
102 std::ios::fmtflags mode =
G4cout.flags();
103 G4cout.setf(std::ios::fixed,std::ios::floatfield);
106 G4cout <<
"\n ===================== run conditions =====================\n";
109 <<
G4BestUnit(fEnergyGun,
"Energy") <<
" through 2*"
110 <<
G4BestUnit(effWallThick,
"Length") <<
" of "
111 << mateWall->
GetName() <<
" (density: "
112 <<
G4BestUnit(densityWall,
"Volumic Mass") <<
"); Mass/cm2 = "
116 G4cout <<
"\n the cavity is "
117 <<
G4BestUnit(cavityThickness,
"Length") <<
" of "
118 << mateCavity->
GetName() <<
" (density: "
119 <<
G4BestUnit(densityCavity,
"Volumic Mass") <<
"); Mass/cm2 = "
121 <<
" --> massRatio = "<< std::setprecision(6) << massRatio <<
G4endl;
125 <<
"; range in cavity: " <<
G4BestUnit(RangeCavity,
"Length")
128 G4cout <<
"\n ==========================================================\n";
134 dedxWall /= densityWall;
137 dedxCavity /= densityCavity;
139 G4cout << std::setprecision(4)
140 <<
"\n StoppingPower in wall = "
143 <<
G4BestUnit(dedxCavity,
"Energy*Surface/Mass")
152 fPartFlowCavity[0] = fPartFlowCavity[1] = 0;
153 fEnerFlowCavity[0] = fEnerFlowCavity[1] = 0.;
157 fEdepCavity = fEdepCavity2 = fTrkSegmCavity = 0.;
162 fStepWall = fStepWall2 = fStepCavity = fStepCavity2 =0.;
163 fNbStepWall = fNbStepCavity = 0;
167 G4cout.setf(mode,std::ios::floatfield);
173 if ( analysisManager->IsActive() ) {
174 analysisManager->OpenFile();
191 size_t nbProc = fProcCounter->size();
193 while ((i<nbProc)&&((*fProcCounter)[i]->GetName()!=procName)) i++;
194 if (i == nbProc) fProcCounter->push_back(
new OneProcessCount(procName));
196 (*fProcCounter)[i]->Count();
203 if (NbofEvents == 0)
return;
213 G4double Icavity = Ncavity/fMassCavity;
215 G4double Itot = NbofEvents/(fMassWall+fMassCavity);
216 G4double energyFluence = fEnergyGun*Itot;
220 G4double doseCavity = fEdepCavity/fMassCavity;
221 G4double ratio = doseCavity/energyFluence;
224 std::ios::fmtflags mode =
G4cout.flags();
225 G4cout.setf(std::ios::fixed,std::ios::floatfield);
228 G4cout <<
"\n--->evntNb= " << NbofEvents
229 <<
" Nwall= " << Nwall
230 <<
" Ncav= " << Ncavity
231 <<
" Ic/Iw= " << Iratio
232 <<
" Ne-_cav= " << fPartFlowCavity[0]
233 <<
" doseCavity/Ebeam= " << ratio
234 <<
" (100*(ratio-1) = " << err <<
" %)"
238 G4cout.setf(mode,std::ios::floatfield);
248 std::ios::fmtflags mode =
G4cout.flags();
249 G4cout.setf(std::ios::fixed,std::ios::floatfield);
257 G4cout <<
"\n Process calls frequency --->";
258 for (
size_t i=0; i< fProcCounter->size();i++) {
259 G4String procName = (*fProcCounter)[i]->GetName();
260 G4int count = (*fProcCounter)[i]->GetCounter();
261 G4cout <<
" " << procName <<
"= " << count;
268 <<
"\n Charged particle flow in cavity :"
269 <<
"\n Enter --> nbParticles = " << fPartFlowCavity[0]
270 <<
"\t Energy = " <<
G4BestUnit (fEnerFlowCavity[0],
"Energy")
271 <<
"\n Exit --> nbParticles = " << fPartFlowCavity[1]
272 <<
"\t Energy = " <<
G4BestUnit (fEnerFlowCavity[1],
"Energy")
275 if (fPartFlowCavity[0] == 0)
return;
282 G4double Icavity = Ncavity/fMassCavity;
285 G4double energyFluence = fEnergyGun*Itot;
289 <<
"\n beamFluence in wall = " << Nwall
290 <<
"\t in cavity = " << Ncavity
291 <<
"\t Icav/Iwall = " << Iratio
292 <<
"\t energyFluence = " << energyFluence/(
MeV*
cm2/
mg) <<
" MeV*cm2/mg"
297 if (fNbEventCavity == 0)
return;
298 G4double meanEdep = fEdepCavity/fNbEventCavity;
299 G4double meanEdep2 = fEdepCavity2/fNbEventCavity;
300 G4double varianceEdep = meanEdep2 - meanEdep*meanEdep;
302 if(varianceEdep>0.) dEoverE = std::sqrt(varianceEdep/fNbEventCavity)/meanEdep;
306 G4double doseCavity = fEdepCavity/fMassCavity;
308 G4double ratio = doseCavity/energyFluence,
error = ratio*dEoverE;
311 <<
"\n Total edep in cavity = " <<
G4BestUnit(fEdepCavity,
"Energy")
312 <<
" +- " << 100*dEoverE <<
" %"
313 <<
"\n Total dose in cavity = " << doseCavity/(
MeV*
cm2/
mg) <<
" MeV*cm2/mg"
314 <<
" +- " << 100*dEoverE <<
" %"
315 <<
"\n\n DoseCavity/EnergyFluence = " << ratio
316 <<
" +- " << error << G4endl;
320 G4double meantrack = fTrkSegmCavity/fPartFlowCavity[0];
324 <<
"\n Total charged trackLength in cavity = "
326 <<
" (mean value = " <<
G4BestUnit(meantrack,
"Length") <<
")"
331 fStepWall /= fNbStepWall; fStepWall2 /= fNbStepWall;
332 G4double rms = fStepWall2 - fStepWall*fStepWall;
333 if (rms>0.) rms = std::sqrt(rms);
else rms = 0.;
337 <<
"\n StepSize of ch. tracks in wall = "
339 <<
"\t (nbSteps/track = " << double(fNbStepWall)/nbTrackWall <<
")";
341 fStepCavity /= fNbStepCavity; fStepCavity2 /= fNbStepCavity;
342 rms = fStepCavity2 - fStepCavity*fStepCavity;
343 if (rms>0.) rms = std::sqrt(rms);
else rms = 0.;
346 <<
"\n StepSize of ch. tracks in cavity = "
348 <<
"\t (nbSteps/track = " <<double(fNbStepCavity)/fPartFlowCavity[0] <<
")";
353 G4cout.setf(mode,std::ios::floatfield);
357 while (fProcCounter->size()>0){
359 fProcCounter->pop_back();
372 const Run* localRun =
static_cast<const Run*
>(run);
375 fPartFlowCavity[0]+= localRun->fPartFlowCavity[0];
376 fPartFlowCavity[1]+= localRun->fPartFlowCavity[1];
377 fEnerFlowCavity[0]+= localRun->fEnerFlowCavity[0];
378 fEnerFlowCavity[1]+= localRun->fEnerFlowCavity[1];
379 fEdepCavity += localRun->fEdepCavity;
380 fEdepCavity2 += localRun->fEdepCavity2;
381 fTrkSegmCavity += localRun->fTrkSegmCavity;
382 fNbEventCavity += localRun->fNbEventCavity;
383 fStepWall += localRun->fStepWall;
384 fStepWall2 += localRun->fStepWall2;
385 fStepCavity += localRun->fStepCavity;
386 fStepCavity2 += localRun->fStepCavity2;
387 fNbStepWall += localRun->fNbStepWall;
388 fNbStepCavity += localRun->fNbStepCavity;
395 std::vector<OneProcessCount*>::iterator it;
396 for (it = localRun->fProcCounter->begin();
397 it !=localRun->fProcCounter->end(); it++ )
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
static constexpr double cm2
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)
void AddWallCount(G4int wc)
G4double GetCavityThickness()
static void showEngineStatus()
G4double GetWorldRadius()
G4ParticleGun * GetParticleGun()
void RunInitialisation(G4double, G4double)
G4ParticleDefinition * GetParticleDefinition() const
static G4Electron * Electron()
Detector construction class to define materials and geometry.
static constexpr double MeV
static PROLOG_HANDLER error
void AddCavityCount(G4int cc)
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager
G4double GetParticleEnergy() const