34 #include "RunAction.hh"
36 #include "DetectorConstruction.hh"
37 #include "PrimaryGeneratorAction.hh"
38 #include "HistoManager.hh"
53 fDetector(det), fPrimary(prim), fHistoManager(0)
75 fTotalCount = fGammaCount = 0;
76 fSumTrack = fSumTrack2 = 0.;
77 for (
G4int i=0; i<3; i++) { fPbalance[i] = 0. ; }
78 for (
G4int i=0; i<3; i++) { fNbGamma[i] = 0 ; }
83 if ( analysisManager->IsActive() ) {
84 analysisManager->OpenFile();
92 fParticleCount[
name]++;
95 if (fParticleCount[name] == 1) fEmin[
name] = fEmax[
name] = Ekin;
96 if (Ekin < fEmin[name]) fEmin[
name] = Ekin;
97 if (Ekin > fEmax[name]) fEmax[
name] = Ekin;
104 fNuclChannelCount[
name]++;
105 fNuclChannelQ[
name] += Q;
112 fPbalance[0] += Pbal;
114 if (fTotalCount == 1) fPbalance[1] = fPbalance[2] = Pbal;
115 if (Pbal < fPbalance[1]) fPbalance[1] = Pbal;
116 if (Pbal > fPbalance[2]) fPbalance[2] = Pbal;
124 fNbGamma[0] += nGamma;
126 if (fGammaCount == 1) fNbGamma[1] = fNbGamma[2] = nGamma;
127 if (nGamma < fNbGamma[1]) fNbGamma[1] = nGamma;
128 if (nGamma > fNbGamma[2]) fNbGamma[2] = nGamma;
135 if (NbOfEvents == 0)
return;
137 G4int prec = 5, wid = prec + 2;
148 G4cout <<
"\n The run consists of " << NbOfEvents <<
" "<< Particle <<
" of "
151 << material->
GetName() <<
" (density: "
155 G4cout <<
"\n Process calls frequency --->";
156 std::map<const G4VProcess*,G4int>::iterator it;
157 for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
159 G4int count = it->second;
160 G4cout <<
"\t" << procName <<
"= " << count;
161 if (procName ==
"Transportation") survive = count;
165 G4cout <<
"\n\n Nb of incident particles surviving after "
170 if (fTotalCount == 0) fTotalCount = 1;
174 G4double MeanFreePath = fSumTrack /fTotalCount;
175 G4double MeanTrack2 = fSumTrack2/fTotalCount;
176 G4double rms = std::sqrt(std::fabs(MeanTrack2 - MeanFreePath*MeanFreePath));
178 if(MeanFreePath > 0.0) { CrossSection = 1./MeanFreePath; }
181 if(massicMFP > 0.0) { massicCS = 1./massicMFP; }
185 <<
"\tmassic: " <<
G4BestUnit(massicMFP,
"Mass/Surface")
186 <<
"\n CrossSection:\t" << CrossSection*
cm <<
" cm^-1 "
187 <<
"\t\tmassic: " <<
G4BestUnit(massicCS,
"Surface/Mass")
194 G4double crossSection = CrossSection/nbAtoms;
195 G4cout <<
" crossSection per atom:\t"
200 G4cout <<
"\n Verification : "
201 <<
"crossSections from G4HadronicProcessStore:";
207 for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
217 G4cout <<
"\n" << std::setw(20) << procName <<
"= "
218 <<
G4BestUnit(massSigma,
"Surface/Mass") <<
"\t"
222 G4cout <<
"\n" << std::setw(20) <<
"total" <<
"= "
226 for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
233 G4cout <<
"\n" << std::setw(20) << procName <<
"= "
236 G4cout <<
"\n" << std::setw(20) <<
"total" <<
"= "
244 std::map<G4String,G4int>::iterator ic;
245 for (ic = fNuclChannelCount.begin(); ic != fNuclChannelCount.end(); ic++) {
247 G4int count = ic->second;
250 G4cout <<
" " << std::setw(50) << name <<
": " << std::setw(7) << count
251 <<
" Q = " << std::setw(wid) <<
G4BestUnit(Q,
"Energy")
257 if (fGammaCount > 0) {
258 G4cout <<
"\n" << std::setw(58) <<
"Number of gamma: N = "
259 << fNbGamma[1] <<
" --> " << fNbGamma[2] <<
G4endl;
263 <<
"\n --> NOTE: XXXX because neutronHP is unable to return target nucleus"
268 G4cout <<
"\n List of generated particles: \n" <<
G4endl;
270 std::map<G4String,G4int>::iterator ip;
271 for (ip = fParticleCount.begin(); ip != fParticleCount.end(); ip++) {
273 G4int count = ip->second;
277 G4cout <<
" " << std::setw(13) << name <<
": " << std::setw(7) << count
278 <<
" Emean = " << std::setw(wid) <<
G4BestUnit(eMean,
"Energy")
286 if (fTotalCount > 1) {
287 G4double Pbmean = fPbalance[0]/fTotalCount;
288 G4cout <<
"\n Momentum balance: Pmean = "
289 << std::setw(wid) <<
G4BestUnit(Pbmean,
"Energy")
290 <<
"\t( " <<
G4BestUnit(fPbalance[1],
"Energy")
291 <<
" --> " <<
G4BestUnit(fPbalance[2],
"Energy")
299 fProcCounter.clear();
301 fNuclChannelCount.clear();
302 fNuclChannelQ.clear();
304 fParticleCount.clear();
305 fEmean.clear(); fEmin.clear(); fEmax.clear();
311 if ( analysisManager->IsActive() ) {
312 analysisManager->Write();
313 analysisManager->CloseFile();
void BeginOfRunAction(const G4Run *)
static G4HadronicProcessStore * Instance()
const G4String & GetName() const
G4double GetDensity() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetRandomNumberStore(G4bool flag)
const G4Element * GetElement(G4int iel) const
const G4String & GetParticleName() const
double precision function energy(A, Z)
G4GLOB_DLL std::ostream G4cout
void CountNuclearChannel(G4String, G4double)
G4int GetNumberOfEvent() const
G4Material * GetMaterial()
void EndOfRunAction(const G4Run *)
ExG4HbookAnalysisManager G4AnalysisManager
const G4String & GetProcessName() const
static void showEngineStatus()
G4double GetTotNbOfAtomsPerVolume() const
static G4RunManager * GetRunManager()
G4ParticleGun * GetParticleGun()
void ParticleCount(G4String, G4double)
G4double GetCrossSectionPerVolume(const G4ParticleDefinition *particle, G4double kineticEnergy, const G4VProcess *process, const G4Material *material)
G4ParticleDefinition * GetParticleDefinition() const
size_t GetNumberOfElements() const
G4double GetCrossSectionPerAtom(const G4ParticleDefinition *particle, G4double kineticEnergy, const G4VProcess *process, const G4Element *element, const G4Material *material=0)
G4double GetParticleEnergy() const