35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
46 fDetector(det), fParticle(0), fEkin(0.)
48 fEnergyDeposit = fEnergyDeposit2 = 0.;
49 fEnergyFlow = fEnergyFlow2 = 0.;
70 std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
71 if ( it == fProcCounter.end()) {
72 fProcCounter[procName] = 1;
75 fProcCounter[procName]++;
83 std::map<G4String, ParticleData>::iterator it = fParticleDataMap1.find(name);
84 if ( it == fParticleDataMap1.end()) {
85 fParticleDataMap1[
name] = ParticleData(1, Ekin, Ekin, Ekin);
88 ParticleData&
data = it->second;
93 if (Ekin < emin) data.fEmin = Ekin;
95 if (Ekin > emax) data.fEmax = Ekin;
103 fEnergyDeposit += edep;
104 fEnergyDeposit2 += edep*edep;
111 fEnergyFlow += eflow;
112 fEnergyFlow2 += eflow*eflow;
118 std::map<G4String, ParticleData>::iterator it = fParticleDataMap2.find(name);
119 if ( it == fParticleDataMap2.end()) {
120 fParticleDataMap2[
name] = ParticleData(1, Ekin, Ekin, Ekin);
123 ParticleData& data = it->second;
128 if (Ekin < emin) data.fEmin = Ekin;
130 if (Ekin > emax) data.fEmax = Ekin;
138 const Run* localRun =
static_cast<const Run*
>(run);
142 fParticle = localRun->fParticle;
143 fEkin = localRun->fEkin;
147 fEnergyDeposit += localRun->fEnergyDeposit;
148 fEnergyDeposit2 += localRun->fEnergyDeposit2;
149 fEnergyFlow += localRun->fEnergyFlow;
150 fEnergyFlow2 += localRun->fEnergyFlow2;
153 std::map<G4String,G4int>::const_iterator itp;
154 for ( itp = localRun->fProcCounter.begin();
155 itp != localRun->fProcCounter.end(); ++itp ) {
158 G4int localCount = itp->second;
159 if ( fProcCounter.find(procName) == fProcCounter.end()) {
160 fProcCounter[procName] = localCount;
163 fProcCounter[procName] += localCount;
168 std::map<G4String,ParticleData>::const_iterator itc;
169 for (itc = localRun->fParticleDataMap1.begin();
170 itc != localRun->fParticleDataMap1.end(); ++itc) {
173 const ParticleData& localData = itc->second;
174 if ( fParticleDataMap1.find(name) == fParticleDataMap1.end()) {
175 fParticleDataMap1[
name]
176 = ParticleData(localData.fCount,
182 ParticleData& data = fParticleDataMap1[
name];
183 data.fCount += localData.fCount;
184 data.fEmean += localData.fEmean;
186 if (emin < data.fEmin) data.fEmin = emin;
188 if (emax > data.fEmax) data.fEmax =
emax;
193 std::map<G4String,ParticleData>::const_iterator itn;
194 for (itn = localRun->fParticleDataMap2.begin();
195 itn != localRun->fParticleDataMap2.end(); ++itn) {
198 const ParticleData& localData = itn->second;
199 if ( fParticleDataMap2.find(name) == fParticleDataMap2.end()) {
200 fParticleDataMap2[
name]
201 = ParticleData(localData.fCount,
207 ParticleData& data = fParticleDataMap2[
name];
208 data.fCount += localData.fCount;
209 data.fEmean += localData.fEmean;
211 if (emin < data.fEmin) data.fEmin = emin;
213 if (emax > data.fEmax) data.fEmax =
emax;
236 << material->
GetName() <<
" (density: "
245 std::map<G4String,G4int>::iterator it;
246 for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
248 G4int count = it->second;
249 G4String space =
" ";
if (++index%3 == 0) space =
"\n";
250 G4cout <<
" " << std::setw(20) << procName <<
"="<< std::setw(7) << count
259 std::map<G4String,ParticleData>::iterator itc;
260 for (itc = fParticleDataMap1.begin(); itc != fParticleDataMap1.end(); itc++) {
262 ParticleData data = itc->second;
263 G4int count = data.fCount;
268 G4cout <<
" " << std::setw(13) << name <<
": " << std::setw(7) << count
269 <<
" Emean = " << std::setw(wid) <<
G4BestUnit(eMean,
"Energy")
278 fEnergyDeposit /= TotNbofEvents; fEnergyDeposit2 /= TotNbofEvents;
279 G4double rmsEdep = fEnergyDeposit2 - fEnergyDeposit*fEnergyDeposit;
280 if (rmsEdep>0.) rmsEdep = std::sqrt(rmsEdep);
283 G4cout <<
"\n Mean energy deposit per event = "
284 <<
G4BestUnit(fEnergyDeposit,
"Energy") <<
"; rms = "
290 fEnergyFlow /= TotNbofEvents; fEnergyFlow2 /= TotNbofEvents;
291 G4double rmsEflow = fEnergyFlow2 - fEnergyFlow*fEnergyFlow;
292 if (rmsEflow>0.) rmsEflow = std::sqrt(rmsEflow);
295 G4cout <<
" Mean energy flow per event = "
296 <<
G4BestUnit(fEnergyFlow,
"Energy") <<
"; rms = "
302 G4cout <<
"\n List of particles emerging from the absorber :" <<
G4endl;
304 std::map<G4String,ParticleData>::iterator itn;
305 for (itn = fParticleDataMap2.begin(); itn != fParticleDataMap2.end(); itn++) {
307 ParticleData data = itn->second;
308 G4int count = data.fCount;
312 G4double Eflow = data.fEmean/TotNbofEvents;
314 G4cout <<
" " << std::setw(13) << name <<
": " << std::setw(7) << count
315 <<
" Emean = " << std::setw(wid) <<
G4BestUnit(eMean,
"Energy")
323 for (
G4int ih=1; ih<14; ih++) {
324 G4double binWidth = analysisManager->GetH1Width(ih);
325 G4double unit = analysisManager->GetH1Unit(ih);
329 analysisManager->ScaleH1(ih,fac);
333 fProcCounter.clear();
334 fParticleDataMap2.clear();
virtual void Merge(const G4Run *)
void CountProcesses(G4String procName)
static constexpr double mm
const G4String & GetName() const
G4double GetDensity() const
void ParticleFlux(G4String, G4double)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4String & GetParticleName() const
const XML_Char const XML_Char * data
void AddEdep(G4double val)
G4GLOB_DLL std::ostream G4cout
G4Material * GetMaterial()
const G4String & GetProcessName() const
static const G4double emax
G4double energy(const ThreeVector &p, const G4double m)
static const G4double fac
Detector construction class to define materials and geometry.
static constexpr double MeV
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager
void AddEflow(G4double eflow)
void ParticleCount(G4String, G4double)