34 #include "RunAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
72 fNbCharged = fNbNeutral = 0;
73 fEnergyCharged = fEnergyNeutral = 0.;
75 fEmax[0] = fEmax[1] = 0.;
83 if ( analysisManager->IsActive() ) {
84 analysisManager->OpenFile();
97 if (nbEvents == 0)
return;
109 G4cout <<
"\n ======================== run summary ======================\n";
110 G4cout <<
"\n The run was " << nbEvents <<
" " << partName <<
" of "
111 <<
G4BestUnit(ePrimary,
"Energy") <<
" through "
113 << material->
GetName() <<
" (density: "
115 G4cout <<
"\n ===========================================================\n";
120 if ( analysisManager->IsActive() ) {
121 analysisManager->Write();
122 analysisManager->CloseFile();
131 G4double trackLPerEvent = fTrackLength/nbEvents;
132 G4double nbStepPerEvent = double(fNbSteps)/nbEvents;
133 G4double stepSize = fTrackLength/fNbSteps;
136 <<
"\n TrackLength= "
138 <<
"\t nb of steps= " << nbStepPerEvent
139 <<
" stepSize= " <<
G4BestUnit(stepSize,
"Length")
144 G4double energyPerEvent = fEnergyCharged/nbEvents;
145 G4double nbPerEvent = double(fNbCharged)/nbEvents;
147 if (fNbCharged) meanEkin = fEnergyCharged/fNbCharged;
150 <<
"\n d-rays : eLoss/primary= "
152 <<
"\t nb of d-rays= " << nbPerEvent
153 <<
" <Tkin>= " <<
G4BestUnit(meanEkin,
"Energy")
154 <<
" Tmin= " <<
G4BestUnit(fEmin[0],
"Energy")
155 <<
" Tmax= " <<
G4BestUnit(fEmax[0],
"Energy")
160 energyPerEvent = fEnergyNeutral/nbEvents;
161 nbPerEvent = double(fNbNeutral)/nbEvents;
163 if (fNbNeutral) meanEkin = fEnergyNeutral/fNbNeutral;
166 <<
"\n gamma : eLoss/primary= "
168 <<
"\t nb of gammas= " << nbPerEvent
169 <<
" <Tkin>= " <<
G4BestUnit(meanEkin,
"Energy")
170 <<
" Tmin= " <<
G4BestUnit(fEmin[1],
"Energy")
171 <<
" Tmax= " <<
G4BestUnit(fEmax[1],
"Energy")
179 energyPerEvent = fEnergyDeposit/nbEvents;
183 G4double etry = ePrimary - energyPerEvent;
186 G4double dEtable = ePrimary - efinal;
188 if (dEtable > 0.) ratio = energyPerEvent/dEtable;
191 <<
"\n deposit : eLoss/primary= "
193 <<
"\t <dEcut > table= "
195 <<
" ---> simul/reference= " << ratio
200 G4double energyTotal = fEnergyDeposit + fEnergyCharged + fEnergyNeutral;
201 energyPerEvent = energyTotal/nbEvents;
204 r1 = r0 - trackLPerEvent;
205 etry = ePrimary - energyPerEvent;
208 dEtable = ePrimary - efinal;
210 if (dEtable > 0.) ratio = energyPerEvent/dEtable;
213 <<
"\n total : eLoss/primary= "
215 <<
"\t <dEfull> table= "
217 <<
" ---> simul/reference= " << ratio
233 G4double Energy = Etry, dE = 0., dEdx;
235 G4double err = 1., errmax = 0.00001;
236 G4int iter = 0 , itermax = 10;
237 while (err > errmax && iter < itermax) {
242 dEdx = emCal.
GetDEDX(Energy,particle,material);
244 err = std::abs(dE)/Energy;
246 if (iter == itermax) {
248 <<
"\n ---> warning: RunAction::GetEnergyFromRestRange() did not converge"
250 <<
" Energy = " <<
G4BestUnit(Energy,
"Energy")
252 <<
" iter = " << iter <<
G4endl;
265 G4double Energy = Etry, dE = 0., dEdx;
267 G4double err = 1., errmax = 0.00001;
268 G4int iter = 0 , itermax = 10;
269 while (err > errmax && iter < itermax) {
276 err = std::abs(dE)/Energy;
278 if (iter == itermax) {
280 <<
"\n ---> warning: RunAction::GetEnergyFromCSDARange() did not converge"
282 <<
" Energy = " <<
G4BestUnit(Energy,
"Energy")
284 <<
" iter = " << iter <<
G4endl;
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)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetRandomNumberStore(G4bool flag)
const G4String & GetParticleName() const
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=0)
G4double GetCSDARange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=0)
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
G4Material * GetMaterial()
void EndOfRunAction(const G4Run *)
G4double GetRangeFromRestricteDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=0)
ExG4HbookAnalysisManager G4AnalysisManager
static void showEngineStatus()
static G4RunManager * GetRunManager()
G4ParticleGun * GetParticleGun()
G4ParticleDefinition * GetParticleDefinition() const
G4double GetEnergyFromRestrictedRange(G4double, G4ParticleDefinition *, G4Material *, G4double)
G4double GetPDGCharge() const
G4double GetParticleEnergy() const