34 #include "RunAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
91 if ( analysisManager->IsActive() ) {
92 analysisManager->OpenFile();
103 std::map<G4String,G4int>::iterator it =
fProcCounter.find(procName);
215 if (nbEvents == 0)
return;
227 G4cout <<
"\n ======================== run summary ======================\n";
228 G4cout <<
"\n The run was " << nbEvents <<
" " << partName <<
" of "
229 <<
G4BestUnit(ePrimary,
"Energy") <<
" through "
231 << material->
GetName() <<
" (density: "
245 G4int count = procCounter.second;
246 G4String space =
" ";
if (++index%4 == 0) space =
"\n";
247 G4cout <<
" " << std::setw(15) << procName <<
"="<< std::setw(7) << count
259 <<
"\n TrackLength = "
261 <<
" nb of steps = " << nbStepPerEvent
262 <<
" stepSize = " <<
G4BestUnit(stepSize,
"Length")
272 <<
"\n Energy continuously deposited along primary track"
273 <<
" (restricted dE/dx) dE1 = "
285 G4double etry = ePrimary - energyPerEvent;
288 G4double dEtable = ePrimary - efinal;
290 if (dEtable > 0.) ratio = energyPerEvent/dEtable;
293 <<
"\n Evaluation of dE1 from reading restricted Range table : dE1_table = "
295 <<
" ---> dE1/dE1_table = " << ratio
300 G4cout <<
"\n Energy transfered to secondary particles :" <<
G4endl;
301 std::map<G4String,MinMaxData>::iterator it1;
304 MinMaxData
data = it1->second;
305 energyPerEvent = data.fVsum/nbEvents;
309 G4cout <<
" " << std::setw(17) <<
"due to " + name <<
": dE2 = "
310 << std::setw(6) <<
G4BestUnit(energyPerEvent,
"Energy")
321 <<
"\n Total energy transfered to secondaries : dE3 = sum of dE2 = "
332 <<
"\n Total energy lost by incident particle : dE4 = dE1 + dE3 = "
343 <<
"\n calcul of dE4 from energy balance : dE4_bal = E_in - E_out = "
352 r1 = r0 - trackLPerEvent;
353 etry = ePrimary - energyPerEvent;
356 dEtable = ePrimary - efinal;
358 if (dEtable > 0.) ratio = energyPerEvent/dEtable;
361 <<
"\n Evaluation of dE4 from reading full Range table : dE4_table = "
363 <<
" ---> dE4/dE4_table = " << ratio
368 G4cout <<
"\n Energy spectrum of secondary particles :" <<
G4endl;
369 std::map<G4String,MinMaxData>::iterator it2;
372 MinMaxData
data = it2->second;
373 G4int count = data.fCount;
378 G4cout <<
" " << std::setw(13) << name <<
": " << std::setw(7) << count
379 <<
" Emean = " << std::setw(6) <<
G4BestUnit(eMean,
"Energy")
393 <<
"\n Energy continuously deposited along secondary tracks"
394 <<
" (restricted dE/dx) dE5 = "
405 <<
"\n Total energy deposited : dE6 = dE1 + dE5 = "
416 fProcCounter.clear();
422 if ( analysisManager->IsActive() ) {
423 analysisManager->Write();
424 analysisManager->CloseFile();
440 G4double err = 1., errmax = 0.00001;
441 G4int iter = 0 , itermax = 10;
442 while (err > errmax && iter < itermax) {
447 dEdx = emCal.
GetDEDX(Energy,particle,material);
449 err = std::abs(dE)/Energy;
451 if (iter == itermax) {
453 <<
"\n ---> warning: RunAction::GetEnergyFromRestRange() did not converge"
455 <<
" Energy = " <<
G4BestUnit(Energy,
"Energy")
457 <<
" iter = " << iter <<
G4endl;
472 G4double err = 1., errmax = 0.00001;
473 G4int iter = 0 , itermax = 10;
474 while (err > errmax && iter < itermax) {
481 err = std::abs(dE)/Energy;
483 if (iter == itermax) {
485 <<
"\n ---> warning: RunAction::GetEnergyFromCSDARange() did not converge"
487 <<
" Energy = " <<
G4BestUnit(Energy,
"Energy")
489 <<
" iter = " << iter <<
G4endl;
G4double GetRangeFromRestricteDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
void TotalEnergyLost(G4double energy)
std::map< G4String, MinMaxData > fEkinOfSecondaries
void EndOfRunAction(const G4Run *)
ProcessesCount * fProcCounter
void EnergyTransferedByProcess(G4String procName, G4double energy)
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
const G4String & GetParticleName() const
G4double GetPDGCharge() const
G4ParticleGun * GetParticleGun()
static const G4double emax
void EnergyBalance(G4double energy)
HistoManager * fHistoManager
G4double GetEnergyFromCSDARange(G4double, G4ParticleDefinition *, G4Material *, G4double)
G4double GetEnergyFromRestrictedRange(G4double, G4ParticleDefinition *, G4Material *, G4double)
void BeginOfRunAction(const G4Run *)
G4int GetNumberOfEvent() const
const XML_Char const XML_Char * data
const G4String & GetName() const
std::map< G4String, MinMaxData > fEtransfByProcess
void CountProcesses(G4String)
const G4ParticleDefinition const G4Material *G4double range
void TrackLength(G4double step)
G4double ComputeTotalDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, G4double cut=DBL_MAX)
The primary generator action class with particle gun.
G4CsvAnalysisManager G4AnalysisManager
void TotalEnergyDeposit(G4double energy)
DetectorConstruction * fDetector
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void EnergyDeposited(G4double edepPrim, G4double edepSecond)
G4double GetParticleEnergy() const
G4double GetCSDARange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double fEnergyTransfered
PrimaryGeneratorAction * fPrimary
void EnergyTransfered(G4double energy)
G4GLOB_DLL std::ostream G4cout
G4ParticleDefinition * GetParticleDefinition() const
G4Material * GetMaterial()
static void showEngineStatus()
Simple detector construction with a box volume placed in a world.
void EnergySpectrumOfSecondaries(G4String particleName, G4double ekin)
G4double GetDensity() const