35 #include "PrimaryGeneratorAction.hh"
36 #include "HistoManager.hh"
46 fParticle(0), fEkin(0.),
47 fDecayCount(0), fTimeCount(0), fPrimaryTime(0.),
48 fTimeWindow1(0.), fTimeWindow2(0.)
50 fEkinTot[0] = fPbalance[0] = fEventTime[0] = fEvisEvent[0] = 0. ;
51 fEkinTot[1] = fPbalance[1] = fEventTime[1] = fEvisEvent[1] =
DBL_MAX;
52 fEkinTot[2] = fPbalance[2] = fEventTime[2] = fEvisEvent[2] = 0. ;
71 std::map<G4String, ParticleData>::iterator it = fParticleDataMap.find(name);
72 if ( it == fParticleDataMap.end()) {
73 fParticleDataMap[
name] = ParticleData(1, Ekin, Ekin, Ekin);
76 ParticleData&
data = it->second;
81 if (Ekin < emin) data.fEmin = Ekin;
83 if (Ekin > emax) data.fEmax = Ekin;
100 std::map<G4String, ActivityData>::iterator it = fActivityMap.find(name);
101 if ( it == fActivityMap.end()) {
102 G4int n1(0), n2(0), nd(0);
106 fActivityMap[
name] = ActivityData(n1, n2, nd);
109 ActivityData& data = it->second;
110 if(life1) data.fNlife_t1++;
111 if(life2) data.fNlife_t2++;
112 if(decay) data.fNdecay_t1t2++;
123 if (fDecayCount == 1) fEkinTot[1] = fEkinTot[2] = Ekin;
124 if (Ekin < fEkinTot[1]) fEkinTot[1] = Ekin;
125 if (Ekin > fEkinTot[2]) fEkinTot[2] = Ekin;
127 fPbalance[0] += Pbal;
129 if (fDecayCount == 1) fPbalance[1] = fPbalance[2] = Pbal;
130 if (Pbal < fPbalance[1]) fPbalance[1] = Pbal;
131 if (Pbal > fPbalance[2]) fPbalance[2] = Pbal;
139 fEventTime[0] += time;
140 if (fTimeCount == 1) fEventTime[1] = fEventTime[2] = time;
141 if (time < fEventTime[1]) fEventTime[1] = time;
142 if (time > fEventTime[2]) fEventTime[2] = time;
149 fPrimaryTime += ptime;
156 fEvisEvent[0] += Evis;
157 if (fTimeCount == 1) fEvisEvent[1] = fEvisEvent[2] = Evis;
158 if (Evis < fEvisEvent[1]) fEvisEvent[1] = Evis;
159 if (Evis > fEvisEvent[2]) fEvisEvent[2] = Evis;
166 const Run* localRun =
static_cast<const Run*
>(run);
170 fParticle = localRun->fParticle;
171 fEkin = localRun->fEkin;
175 fDecayCount += localRun->fDecayCount;
176 fTimeCount += localRun->fTimeCount;
177 fPrimaryTime += localRun->fPrimaryTime;
179 fEkinTot[0] += localRun->fEkinTot[0];
180 fPbalance[0] += localRun->fPbalance[0];
181 fEventTime[0] += localRun->fEventTime[0];
182 fEvisEvent[0] += localRun->fEvisEvent[0];
185 min = localRun->fEkinTot[1]; max = localRun->fEkinTot[2];
186 if (fEkinTot[1] > min) fEkinTot[1] =
min;
187 if (fEkinTot[2] < max) fEkinTot[2] =
max;
189 min = localRun->fPbalance[1]; max = localRun->fPbalance[2];
190 if (fPbalance[1] > min) fPbalance[1] =
min;
191 if (fPbalance[2] < max) fPbalance[2] =
max;
193 min = localRun->fEventTime[1]; max = localRun->fEventTime[2];
194 if (fEventTime[1] > min) fEventTime[1] =
min;
195 if (fEventTime[2] < max) fEventTime[2] =
max;
197 min = localRun->fEvisEvent[1]; max = localRun->fEvisEvent[2];
198 if (fEvisEvent[1] > min) fEvisEvent[1] =
min;
199 if (fEvisEvent[2] < max) fEvisEvent[2] =
max;
202 std::map<G4String,ParticleData>::const_iterator itn;
203 for (itn = localRun->fParticleDataMap.begin();
204 itn != localRun->fParticleDataMap.end(); ++itn) {
207 const ParticleData& localData = itn->second;
208 if ( fParticleDataMap.find(name) == fParticleDataMap.end()) {
209 fParticleDataMap[
name]
210 = ParticleData(localData.fCount,
216 ParticleData& data = fParticleDataMap[
name];
217 data.fCount += localData.fCount;
218 data.fEmean += localData.fEmean;
220 if (emin < data.fEmin) data.fEmin = emin;
222 if (emax > data.fEmax) data.fEmax =
emax;
227 fTimeWindow1 = localRun->fTimeWindow1;
228 fTimeWindow2 = localRun->fTimeWindow2;
230 std::map<G4String,ActivityData>::const_iterator ita;
231 for (ita = localRun->fActivityMap.begin();
232 ita != localRun->fActivityMap.end(); ++ita) {
235 const ActivityData& localData = ita->second;
236 if ( fActivityMap.find(name) == fActivityMap.end()) {
238 = ActivityData(localData.fNlife_t1,
240 localData.fNdecay_t1t2);
242 ActivityData& data = fActivityMap[
name];
243 data.fNlife_t1 += localData.fNlife_t1;
244 data.fNlife_t2 += localData.fNlife_t2;
245 data.fNdecay_t1t2 += localData.fNdecay_t1t2;
259 G4cout <<
"\n ======================== run summary ======================";
260 G4cout <<
"\n The run was " << nbEvents <<
" " << partName <<
" of "
262 G4cout <<
"\n ===========================================================\n";
264 if (nbEvents == 0) {
return; }
273 std::map<G4String,ParticleData>::iterator it;
274 for (it = fParticleDataMap.begin(); it != fParticleDataMap.end(); it++) {
276 ParticleData data = it->second;
277 G4int count = data.fCount;
282 G4cout <<
" " << std::setw(15) << name <<
": " << std::setw(7) << count
283 <<
" Emean = " << std::setw(wid) <<
G4BestUnit(eMean,
"Energy")
292 if (fDecayCount > 0) {
293 G4double Ebmean = fEkinTot[0]/fDecayCount;
294 G4double Pbmean = fPbalance[0]/fDecayCount;
296 G4cout <<
"\n Ekin Total (Q single decay): mean = "
297 << std::setw(wid) <<
G4BestUnit(Ebmean,
"Energy")
298 <<
"\t( " <<
G4BestUnit(fEkinTot[1],
"Energy")
299 <<
" --> " <<
G4BestUnit(fEkinTot[2],
"Energy")
302 G4cout <<
"\n Momentum balance (excluding gamma desexcitation): mean = "
303 << std::setw(wid) <<
G4BestUnit(Pbmean,
"Energy")
304 <<
"\t( " <<
G4BestUnit(fPbalance[1],
"Energy")
305 <<
" --> " <<
G4BestUnit(fPbalance[2],
"Energy")
311 if (fTimeCount > 0) {
312 G4double Tmean = fEventTime[0]/fTimeCount;
313 G4double halfLife = Tmean*std::log(2.);
315 G4cout <<
"\n Total time of life (full chain): mean = "
316 << std::setw(wid) <<
G4BestUnit(Tmean,
"Time")
318 << std::setw(wid) <<
G4BestUnit(halfLife,
"Time")
320 <<
" --> " <<
G4BestUnit(fEventTime[2],
"Time")
326 if (fTimeCount > 0) {
327 G4double Evmean = fEvisEvent[0]/fTimeCount;
329 G4cout <<
"\n Total visible energy (full chain) : mean = "
330 << std::setw(wid) <<
G4BestUnit(Evmean,
"Energy")
331 <<
" ( " <<
G4BestUnit(fEvisEvent[1],
"Energy")
332 <<
" --> " <<
G4BestUnit(fEvisEvent[2],
"Energy")
338 G4double pTimeMean = fPrimaryTime/nbEvents;
341 G4double Activity_perUnitOfMass = 0.0;
343 { Activity_perUnitOfMass = nAtoms_perUnitOfMass/pTimeMean; }
345 G4cout <<
"\n Activity of " << partName <<
" = "
346 << std::setw(wid) << Activity_perUnitOfMass*
g/
becquerel
347 <<
" Bq/g (" << Activity_perUnitOfMass*
g/
curie
354 if (fTimeWindow2 > 0.) {
355 G4double dt = fTimeWindow2 - fTimeWindow1;
356 G4cout <<
" Activities in time window [t1, t2] = ["
358 <<
G4BestUnit(fTimeWindow2,
"Time") <<
"] (delta time = "
361 std::map<G4String,ActivityData>::iterator ita;
362 for (ita = fActivityMap.begin(); ita != fActivityMap.end(); ita++) {
364 ActivityData data = ita->second;
365 G4int n1 = data.fNlife_t1;
366 G4int n2 = data.fNlife_t2;
367 G4int ndecay = data.fNdecay_t1t2;
370 G4cout <<
" " << std::setw(15) << name <<
": "
371 <<
" n(t1) = " << std::setw(7) << n1
372 <<
"\tn(t2) = " << std::setw(7) << n2
373 <<
"\t decays = " << std::setw(7) << ndecay
374 <<
" ---> <actv> = " <<
G4BestUnit(actv,
"Activity") <<
"\n";
383 analysisManager->ScaleH1(1,factor);
384 analysisManager->ScaleH1(2,factor);
385 analysisManager->ScaleH1(3,factor);
386 analysisManager->ScaleH1(4,factor);
387 analysisManager->ScaleH1(5,factor);
391 fParticleDataMap.clear();
392 fActivityMap.clear();
virtual void Merge(const G4Run *)
void PrimaryTiming(G4double)
void CountInTimeWindow(G4String, G4bool, G4bool, G4bool)
static constexpr double becquerel
void EventTiming(G4double)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4String & GetParticleName() const
void SetTimeWindow(G4double, G4double)
const XML_Char const XML_Char * data
G4GLOB_DLL std::ostream G4cout
ParticleList decay(Cluster *const c)
Carries out a cluster decay.
G4int GetAtomicMass() const
static const G4double emax
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double energy(const ThreeVector &p, const G4double m)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
static constexpr double curie
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager
static constexpr double mole
void ParticleCount(G4String, G4double)