34 #include "RunAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
52 :fDetector(det),fKinematic(kin),fProcCounter(0),fHistoManager(0)
75 if (NbofEvents == 0)
return;
89 fMassCavity = cavityThickness*densityCavity;
98 G4double effWallThick = factor*RangeWall;
99 if ((effWallThick > wallThickness)||(effWallThick <= 0.))
100 effWallThick = wallThickness;
101 fMassWall = 2*effWallThick*densityWall;
103 G4double massTotal = fMassWall + fMassCavity;
104 G4double fMassWallRatio = fMassWall/massTotal;
107 G4double massRatio = fMassCavity/fMassWall;
114 std::ios::fmtflags mode =
G4cout.flags();
115 G4cout.setf(std::ios::fixed,std::ios::floatfield);
118 G4cout <<
"\n ======================== run conditions =====================\n";
120 G4cout <<
"\n The run will be " << NbofEvents <<
" "<< partName <<
" of "
121 <<
G4BestUnit(fEnergyGun,
"Energy") <<
" through 2*"
122 <<
G4BestUnit(effWallThick,
"Length") <<
" of "
123 << mateWall->
GetName() <<
" (density: "
124 <<
G4BestUnit(densityWall,
"Volumic Mass") <<
"); Mass/cm2 = "
128 G4cout <<
"\n the cavity is "
129 <<
G4BestUnit(cavityThickness,
"Length") <<
" of "
130 << mateCavity->
GetName() <<
" (density: "
131 <<
G4BestUnit(densityCavity,
"Volumic Mass") <<
"); Mass/cm2 = "
133 <<
" --> massRatio = " << std::setprecision(6) << massRatio <<
G4endl;
137 <<
"; range in cavity: " <<
G4BestUnit(RangeCavity,
"Length")
140 G4cout <<
"\n ============================================================\n";
146 dedxWall /= densityWall;
149 dedxCavity /= densityCavity;
151 G4cout << std::setprecision(4)
152 <<
"\n StoppingPower in wall = "
155 <<
G4BestUnit(dedxCavity,
"Energy*Surface/Mass")
164 fPartFlowCavity[0] = fPartFlowCavity[1] = 0;
165 fEnerFlowCavity[0] = fEnerFlowCavity[1] = 0.;
169 fEdepCavity = fEdepCavity2 = fTrkSegmCavity = 0.;
174 fStepWall = fStepWall2 = fStepCavity = fStepCavity2 =0.;
175 fNbStepWall = fNbStepCavity = 0;
180 if ( analysisManager->IsActive() ) {
181 analysisManager->OpenFile();
185 G4cout.setf(mode,std::ios::floatfield);
194 size_t nbProc = fProcCounter->size();
196 while ((i<nbProc)&&((*fProcCounter)[i]->GetName()!=procName)) i++;
197 if (i == nbProc) fProcCounter->push_back(
new OneProcessCount(procName));
199 (*fProcCounter)[i]->Count();
206 if (NbofEvents == 0)
return;
214 G4double Icavity = Ncavity/fMassCavity;
216 G4double Itot = NbofEvents/(fMassWall+fMassCavity);
217 G4double energyFluence = fEnergyGun*Itot;
221 G4double doseCavity = fEdepCavity/fMassCavity;
222 G4double ratio = doseCavity/energyFluence;
225 std::ios::fmtflags mode =
G4cout.flags();
226 G4cout.setf(std::ios::fixed,std::ios::floatfield);
229 G4cout <<
"\n--->evntNb= " << NbofEvents
230 <<
" Nwall= " << Nwall
231 <<
" Ncav= " << Ncavity
232 <<
" Ic/Iw= " << Iratio
233 <<
" Ne-_cav= " << fPartFlowCavity[0]
234 <<
" doseCavity/Ebeam= " << ratio
235 <<
" (100*(ratio-1) = " << err <<
" %)"
239 G4cout.setf(mode,std::ios::floatfield);
247 std::ios::fmtflags mode =
G4cout.flags();
248 G4cout.setf(std::ios::fixed,std::ios::floatfield);
252 if (NbofEvents == 0)
return;
256 G4cout <<
"\n Process calls frequency --->";
257 for (
size_t i=0; i< fProcCounter->size();i++) {
258 G4String procName = (*fProcCounter)[i]->GetName();
259 G4int count = (*fProcCounter)[i]->GetCounter();
260 G4cout <<
" " << procName <<
"= " << count;
267 <<
"\n Charged particle flow in cavity :"
268 <<
"\n Enter --> nbParticles = " << fPartFlowCavity[0]
269 <<
"\t Energy = " <<
G4BestUnit (fEnerFlowCavity[0],
"Energy")
270 <<
"\n Exit --> nbParticles = " << fPartFlowCavity[1]
271 <<
"\t Energy = " <<
G4BestUnit (fEnerFlowCavity[1],
"Energy")
274 if (fPartFlowCavity[0] == 0)
return;
281 G4double Icavity = Ncavity/fMassCavity;
283 G4double Itot = NbofEvents/(fMassWall+fMassCavity);
284 G4double energyFluence = fEnergyGun*Itot;
288 <<
"\n beamFluence in wall = " << Nwall
289 <<
"\t in cavity = " << Ncavity
290 <<
"\t Icav/Iwall = " << Iratio
291 <<
"\t energyFluence = " << energyFluence/(
MeV*
cm2/
mg) <<
" MeV*cm2/mg"
296 if (fNbEventCavity == 0)
return;
297 G4double meanEdep = fEdepCavity/fNbEventCavity;
298 G4double meanEdep2 = fEdepCavity2/fNbEventCavity;
299 G4double varianceEdep = meanEdep2 - meanEdep*meanEdep;
301 if(varianceEdep>0.) dEoverE = std::sqrt(varianceEdep/fNbEventCavity)/meanEdep;
305 G4double doseCavity = fEdepCavity/fMassCavity;
306 G4double ratio = doseCavity/energyFluence, error = ratio*dEoverE;
309 <<
"\n Total edep in cavity = " <<
G4BestUnit(fEdepCavity,
"Energy")
310 <<
" +- " << 100*dEoverE <<
" %"
311 <<
"\n Total dose in cavity = " << doseCavity/(
MeV*
cm2/
mg) <<
" MeV*cm2/mg"
312 <<
" +- " << 100*dEoverE <<
" %"
313 <<
"\n\n DoseCavity/EnergyFluence = " << ratio
314 <<
" +- " << error << G4endl;
318 G4double meantrack = fTrkSegmCavity/fPartFlowCavity[0];
322 <<
"\n Total charged trackLength in cavity = "
324 <<
" (mean value = " <<
G4BestUnit(meantrack,
"Length") <<
")"
329 fStepWall /= fNbStepWall; fStepWall2 /= fNbStepWall;
330 G4double rms = fStepWall2 - fStepWall*fStepWall;
331 if (rms>0.) rms = std::sqrt(rms);
else rms = 0.;
335 <<
"\n StepSize of ch. tracks in wall = "
337 <<
"\t (nbSteps/track = " << double(fNbStepWall)/nbTrackWall <<
")";
339 fStepCavity /= fNbStepCavity; fStepCavity2 /= fNbStepCavity;
340 rms = fStepCavity2 - fStepCavity*fStepCavity;
341 if (rms>0.) rms = std::sqrt(rms);
else rms = 0.;
344 <<
"\n StepSize of ch. tracks in cavity = "
346 <<
"\t (nbSteps/track = " << double(fNbStepCavity)/fPartFlowCavity[0] <<
")";
351 G4cout.setf(mode,std::ios::floatfield);
355 while (fProcCounter->size()>0){
357 fProcCounter->pop_back();
364 if ( analysisManager->IsActive() ) {
365 analysisManager->Write();
366 analysisManager->CloseFile();
std::vector< OneProcessCount * > ProcessesCount
G4Material * GetCavityMaterial()
void BeginOfRunAction(const G4Run *)
G4Material * GetWallMaterial()
const G4String & GetName() const
G4double GetDensity() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetRandomNumberStore(G4bool flag)
void CountProcesses(G4String procName)
const G4String & GetParticleName() const
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=0)
G4double GetWallThickness()
G4double GetCSDARange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=0)
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
void EndOfRunAction(const G4Run *)
ExG4HbookAnalysisManager G4AnalysisManager
G4double GetCavityThickness()
static void showEngineStatus()
static G4RunManager * GetRunManager()
G4double GetWorldRadius()
G4ParticleGun * GetParticleGun()
void RunInitialisation(G4double, G4double)
void SurveyConvergence(G4int)
G4ParticleDefinition * GetParticleDefinition() const
G4int GetNumberOfEventToBeProcessed() const
static G4Electron * Electron()
G4double GetParticleEnergy() const