35 #include "DetectorConstruction.hh"
37 #include "EventAction.hh"
38 #include "HistoManager.hh"
39 #include "PrimaryGeneratorAction.hh"
52 fParticle(0), fEkin(0.)
54 for (
G4int i=0; i<3; ++i) { fStatus[i] = 0; fTotEdep[i] = 0.; }
57 fEdeposit[i] = 0.; fEmin[i] =
joule; fEmax[i] = 0.;
79 std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
80 if ( it == fProcCounter.end()) {
81 fProcCounter[procName] = 1;
84 fProcCounter[procName]++;
92 std::map<G4String, ParticleData>::iterator it = fParticleDataMap[k].find(name);
93 if ( it == fParticleDataMap[k].end()) {
94 (fParticleDataMap[k])[name] = ParticleData(1, Ekin, Ekin, Ekin);
97 ParticleData&
data = it->second;
102 if (Ekin < emin) data.fEmin = Ekin;
104 if (Ekin > emax) data.fEmax = Ekin;
114 if (e < fEmin[i]) fEmin[i] = e;
115 if (e > fEmax[i]) fEmax[i] = e;
125 if (e < fTotEdep[1]) fTotEdep[1] = e;
126 if (e > fTotEdep[2]) fTotEdep[2] = e;
141 const Run* localRun =
static_cast<const Run*
>(run);
144 fParticle = localRun->fParticle;
145 fEkin = localRun->fEkin;
150 for (
G4int i=1; i<=nbOfAbsor; ++i) {
151 fEdeposit[i] += localRun->fEdeposit[i];
154 min = localRun->fEmin[i]; max = localRun->fEmax[i];
155 if (fEmin[i] > min) fEmin[i] =
min;
156 if (fEmax[i] < max) fEmax[i] =
max;
159 for (
G4int i=0; i<3; ++i) fStatus[i] += localRun->fStatus[i];
162 fTotEdep[0] += localRun->fTotEdep[0];
164 min = localRun->fTotEdep[1]; max = localRun->fTotEdep[2];
165 if (fTotEdep[1] > min) fTotEdep[1] =
min;
166 if (fTotEdep[2] < max) fTotEdep[2] =
max;
169 std::map<G4String,G4int>::const_iterator itp;
170 for ( itp = localRun->fProcCounter.begin();
171 itp != localRun->fProcCounter.end(); ++itp ) {
174 G4int localCount = itp->second;
175 if ( fProcCounter.find(procName) == fProcCounter.end()) {
176 fProcCounter[procName] = localCount;
179 fProcCounter[procName] += localCount;
184 for (
G4int k=0; k<=nbOfAbsor; ++k) {
185 std::map<G4String,ParticleData>::const_iterator itc;
186 for (itc = localRun->fParticleDataMap[k].begin();
187 itc != localRun->fParticleDataMap[k].end(); ++itc) {
190 const ParticleData& localData = itc->second;
191 if ( fParticleDataMap[k].find(name) == fParticleDataMap[k].end()) {
192 (fParticleDataMap[k])[name]
193 = ParticleData(localData.fCount,
199 ParticleData&
data = (fParticleDataMap[k])[name];
200 data.fCount += localData.fCount;
201 data.fEmean += localData.fEmean;
203 if (emin < data.fEmin) data.fEmin = emin;
205 if (emax > data.fEmax) data.fEmax =
emax;
225 G4cout <<
"\n ======================== run summary =====================\n";
227 <<
"\n The run is " <<
numberOfEvent <<
" "<< partName <<
" of "
229 <<
" through " << nbOfAbsor <<
" absorbers: \n";
230 for (
G4int i=1; i<= nbOfAbsor; i++) {
234 G4cout << std::setw(5) << i
235 << std::setw(10) <<
G4BestUnit(thickness,
"Length") <<
" of "
236 << material->
GetName() <<
" (density: "
248 std::map<G4String,G4int>::iterator it;
249 for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
251 G4int count = it->second;
252 G4String space =
" ";
if (++index%3 == 0) space =
"\n";
253 G4cout <<
" " << std::setw(20) << procName <<
"="<< std::setw(7) << count
260 for (
G4int i=1; i<= nbOfAbsor; i++) {
264 <<
"\n Edep in absorber " << i <<
" = "
275 <<
"\n Edep in all absorbers = " <<
G4BestUnit(fTotEdep[0],
"Energy")
283 for (
G4int k=1; k<= nbOfAbsor; k++) {
284 G4cout <<
"\n List of generated particles in absorber " << k <<
":" <<
G4endl;
286 std::map<G4String,ParticleData>::iterator itc;
287 for (itc = fParticleDataMap[k].begin();
288 itc != fParticleDataMap[k].end(); itc++) {
290 ParticleData
data = itc->second;
291 G4int count = data.fCount;
296 G4cout <<
" " << std::setw(13) << name <<
": " << std::setw(7) << count
297 <<
" Emean = " << std::setw(wid) <<
G4BestUnit(eMean,
"Energy")
305 G4cout <<
"\n List of particles emerging from absorbers :" <<
G4endl;
307 std::map<G4String,ParticleData>::iterator itc;
308 for (itc = fParticleDataMap[0].begin();
309 itc != fParticleDataMap[0].end(); itc++) {
311 ParticleData
data = itc->second;
312 G4int count = data.fCount;
317 G4cout <<
" " << std::setw(13) << name <<
": " << std::setw(7) << count
318 <<
" Emean = " << std::setw(wid) <<
G4BestUnit(eMean,
"Energy")
328 G4double transmit = 100.*fStatus[1]/dNofEvents;
329 G4double reflected = 100.*fStatus[2]/dNofEvents;
333 <<
"\n Nb of events with primary absorbed = " << absorbed <<
" %,"
334 <<
" transmit = " << transmit <<
" %,"
335 <<
" reflected = " << reflected <<
" %" <<
G4endl;
341 G4double binWidth = analysisManager->GetH1Width(ih)
342 *analysisManager->GetH1Unit(ih);
344 analysisManager->ScaleH1(ih,fac);
347 fProcCounter.clear();
348 for (
G4int k=0; k<= nbOfAbsor; k++) fParticleDataMap[k].clear();
virtual void Merge(const G4Run *)
void CountProcesses(G4String procName)
static constexpr double mm
const G4String & GetName() const
G4double GetDensity() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4String & GetParticleName() const
G4Material * GetAbsorMaterial(G4int i)
const XML_Char const XML_Char * data
void AddEdep(G4double val)
G4GLOB_DLL std::ostream G4cout
const G4String & GetProcessName() const
static const G4double emax
G4double GetAbsorThickness(G4int i)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double energy(const ThreeVector &p, const G4double m)
static constexpr double joule
void AddTrackStatus(G4int i)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static const G4double fac
Detector construction class to define materials and geometry.
static constexpr double MeV
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
void AddTotEdep(G4double e)
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager
void ParticleCount(G4String, G4double)