34 #include "RunAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
70 fNbCharged = fNbNeutral = 0;
71 fEnergyCharged = fEnergyNeutral = 0.;
73 fEmax[0] = fEmax[1] = 0.;
81 if ( analysisManager->IsActive() ) {
82 analysisManager->OpenFile();
95 if (nbEvents == 0)
return;
107 G4cout <<
"\n ======================== run summary ======================\n";
108 G4cout <<
"\n The run was " << nbEvents <<
" " << partName <<
" of "
109 <<
G4BestUnit(ePrimary,
"Energy") <<
" through "
111 << material->
GetName() <<
" (density: "
113 G4cout <<
"\n ===========================================================\n";
118 if ( analysisManager->IsActive() ) {
119 analysisManager->Write();
120 analysisManager->CloseFile();
129 G4double trackLPerEvent = fTrackLength/nbEvents;
130 G4double nbStepPerEvent = double(fNbSteps)/nbEvents;
131 G4double stepSize = fTrackLength/fNbSteps;
134 <<
"\n TrackLength= "
136 <<
"\t nb of steps= " << nbStepPerEvent
137 <<
" stepSize= " <<
G4BestUnit(stepSize,
"Length")
142 G4double energyPerEvent = fEnergyCharged/nbEvents;
143 G4double nbPerEvent = double(fNbCharged)/nbEvents;
145 if (fNbCharged) meanEkin = fEnergyCharged/fNbCharged;
148 <<
"\n d-rays : eLoss/primary= "
150 <<
"\t nb of d-rays= " << nbPerEvent
151 <<
" <Tkin>= " <<
G4BestUnit(meanEkin,
"Energy")
152 <<
" Tmin= " <<
G4BestUnit(fEmin[0],
"Energy")
153 <<
" Tmax= " <<
G4BestUnit(fEmax[0],
"Energy")
158 energyPerEvent = fEnergyNeutral/nbEvents;
159 nbPerEvent = double(fNbNeutral)/nbEvents;
161 if (fNbNeutral) meanEkin = fEnergyNeutral/fNbNeutral;
164 <<
"\n gamma : eLoss/primary= "
166 <<
"\t nb of gammas= " << nbPerEvent
167 <<
" <Tkin>= " <<
G4BestUnit(meanEkin,
"Energy")
168 <<
" Tmin= " <<
G4BestUnit(fEmin[1],
"Energy")
169 <<
" Tmax= " <<
G4BestUnit(fEmax[1],
"Energy")
177 energyPerEvent = fEnergyDeposit/nbEvents;
181 G4double etry = ePrimary - energyPerEvent;
184 G4double dEtable = ePrimary - efinal;
186 if (dEtable > 0.) ratio = energyPerEvent/dEtable;
189 <<
"\n deposit : eLoss/primary= "
191 <<
"\t <dEcut > table= "
193 <<
" ---> simul/reference= " << ratio
198 G4double energyTotal = fEnergyDeposit + fEnergyCharged + fEnergyNeutral;
199 energyPerEvent = energyTotal/nbEvents;
202 r1 = r0 - trackLPerEvent;
203 etry = ePrimary - energyPerEvent;
206 dEtable = ePrimary - efinal;
208 if (dEtable > 0.) ratio = energyPerEvent/dEtable;
211 <<
"\n total : eLoss/primary= "
213 <<
"\t <dEfull> table= "
215 <<
" ---> simul/reference= " << ratio
233 G4double err = 1., errmax = 0.00001;
234 G4int iter = 0 , itermax = 10;
235 while (err > errmax && iter < itermax) {
240 dEdx = emCal.
GetDEDX(Energy,particle,material);
242 err = std::abs(dE)/Energy;
244 if (iter == itermax) {
246 <<
"\n ---> warning: RunAction::GetEnergyFromRestRange() did not converge"
248 <<
" Energy = " <<
G4BestUnit(Energy,
"Energy")
250 <<
" iter = " << iter <<
G4endl;
265 G4double err = 1., errmax = 0.00001;
266 G4int iter = 0 , itermax = 10;
267 while (err > errmax && iter < itermax) {
274 err = std::abs(dE)/Energy;
276 if (iter == itermax) {
278 <<
"\n ---> warning: RunAction::GetEnergyFromCSDARange() did not converge"
280 <<
" Energy = " <<
G4BestUnit(Energy,
"Energy")
282 <<
" iter = " << iter <<
G4endl;
The primary generator action class with particle gun.
G4double GetEnergyFromCSDARange(G4double, G4ParticleDefinition *, G4Material *, G4double)
void BeginOfRunAction(const G4Run *)
const G4String & GetName() const
G4double GetDensity() const
G4double ComputeTotalDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, G4double cut=DBL_MAX)
G4double GetCSDARange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetRandomNumberStore(G4bool flag)
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
const G4ParticleDefinition const G4Material *G4double range
G4int GetNumberOfEvent() const
G4Material * GetMaterial()
G4double GetRangeFromRestricteDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
void EndOfRunAction(const G4Run *)
static void showEngineStatus()
static G4RunManager * GetRunManager()
G4ParticleGun * GetParticleGun()
G4ParticleDefinition * GetParticleDefinition() const
G4double GetEnergyFromRestrictedRange(G4double, G4ParticleDefinition *, G4Material *, G4double)
Detector construction class to define materials and geometry.
G4double GetPDGCharge() const
G4CsvAnalysisManager G4AnalysisManager
G4double GetParticleEnergy() const