35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
48 fDetector(det), fParticle(0), fEkin(0.),
49 fTotalCount(0), fGammaCount(0),
50 fSumTrack(0.), fSumTrack2(0.),
53 for (
G4int i=0; i<3; i++) { fPbalance[i] = 0. ; }
54 for (
G4int i=0; i<3; i++) { fNbGamma[i] = 0 ; }
81 std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
82 if ( it == fProcCounter.end()) {
83 fProcCounter[procName] = 1;
86 fProcCounter[procName]++;
94 fSumTrack += trackl; fSumTrack2 += trackl*trackl;
101 std::map<G4String, NuclChannel>::iterator it = fNuclChannelMap.find(name);
102 if ( it == fNuclChannelMap.end()) {
103 fNuclChannelMap[
name] = NuclChannel(1, Q);
106 NuclChannel&
data = it->second;
116 std::map<G4String, ParticleData>::iterator it = fParticleDataMap.find(name);
117 if ( it == fParticleDataMap.end()) {
118 fParticleDataMap[
name] = ParticleData(1, Ekin, Ekin, Ekin);
121 ParticleData&
data = it->second;
126 if (Ekin < emin) data.fEmin = Ekin;
128 if (Ekin > emax) data.fEmax = Ekin;
135 fPbalance[0] += Pbal;
137 if (fTotalCount == 1) fPbalance[1] = fPbalance[2] = Pbal;
138 if (Pbal < fPbalance[1]) fPbalance[1] = Pbal;
139 if (Pbal > fPbalance[2]) fPbalance[2] = Pbal;
147 fNbGamma[0] += nGamma;
149 if (fGammaCount == 1) fNbGamma[1] = fNbGamma[2] = nGamma;
150 if (nGamma < fNbGamma[1]) fNbGamma[1] = nGamma;
151 if (nGamma > fNbGamma[2]) fNbGamma[2] = nGamma;
158 const Run* localRun =
static_cast<const Run*
>(run);
162 fParticle = localRun->fParticle;
163 fEkin = localRun->fEkin;
167 fTotalCount += localRun->fTotalCount;
168 fGammaCount += localRun->fGammaCount;
169 fSumTrack += localRun->fSumTrack;
170 fSumTrack2 += localRun->fSumTrack2;
174 std::map<G4String,G4int>::const_iterator itp;
175 for ( itp = localRun->fProcCounter.begin();
176 itp != localRun->fProcCounter.end(); ++itp ) {
179 G4int localCount = itp->second;
180 if ( fProcCounter.find(procName) == fProcCounter.end()) {
181 fProcCounter[procName] = localCount;
184 fProcCounter[procName] += localCount;
189 std::map<G4String,NuclChannel>::const_iterator itc;
190 for (itc = localRun->fNuclChannelMap.begin();
191 itc != localRun->fNuclChannelMap.end(); ++itc) {
194 const NuclChannel& localData = itc->second;
195 if ( fNuclChannelMap.find(name) == fNuclChannelMap.end()) {
196 fNuclChannelMap[
name]
197 = NuclChannel(localData.fCount, localData.fQ);
200 NuclChannel&
data = fNuclChannelMap[
name];
201 data.fCount += localData.fCount;
202 data.fQ += localData.fQ;
207 std::map<G4String,ParticleData>::const_iterator itn;
208 for (itn = localRun->fParticleDataMap.begin();
209 itn != localRun->fParticleDataMap.end(); ++itn) {
212 const ParticleData& localData = itn->second;
213 if ( fParticleDataMap.find(name) == fParticleDataMap.end()) {
214 fParticleDataMap[
name]
215 = ParticleData(localData.fCount,
221 ParticleData&
data = fParticleDataMap[
name];
222 data.fCount += localData.fCount;
223 data.fEmean += localData.fEmean;
225 if (emin < data.fEmin) data.fEmin = emin;
227 if (emax > data.fEmax) data.fEmax =
emax;
250 << material->
GetName() <<
" (density: "
259 std::map<G4String,G4int>::iterator it;
260 for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
262 G4int count = it->second;
263 G4cout <<
"\t" << procName <<
"= " << count;
264 if (procName ==
"Transportation") survive = count;
269 G4cout <<
"\n Nb of incident particles surviving after "
274 if (fTotalCount == 0) fTotalCount = 1;
278 G4double MeanFreePath = fSumTrack /fTotalCount;
279 G4double MeanTrack2 = fSumTrack2/fTotalCount;
280 G4double rms = std::sqrt(std::fabs(MeanTrack2 - MeanFreePath*MeanFreePath));
282 if(MeanFreePath > 0.0) { CrossSection = 1./MeanFreePath; }
283 G4double massicMFP = MeanFreePath*density;
285 if(massicMFP > 0.0) { massicCS = 1./massicMFP; }
289 <<
"\tmassic: " <<
G4BestUnit(massicMFP,
"Mass/Surface")
290 <<
"\n CrossSection:\t" << CrossSection*
cm <<
" cm^-1 "
291 <<
"\t\tmassic: " <<
G4BestUnit(massicCS,
"Surface/Mass")
298 G4double crossSection = CrossSection/nbAtoms;
299 G4cout <<
" crossSection per atom:\t"
304 G4cout <<
"\n Verification: "
305 <<
"crossSections from G4HadronicProcessStore:";
312 for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
322 G4cout <<
"\n" << std::setw(20) << procName <<
"= "
323 <<
G4BestUnit(massSigma,
"Surface/Mass") <<
"\t"
327 G4cout <<
"\n" << std::setw(20) <<
"total" <<
"= "
331 for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
338 G4cout <<
"\n" << std::setw(20) << procName <<
"= "
341 G4cout <<
"\n" << std::setw(20) <<
"total" <<
"= "
348 std::map<G4String,NuclChannel>::iterator ic;
349 for (ic = fNuclChannelMap.begin(); ic != fNuclChannelMap.end(); ic++) {
351 NuclChannel
data = ic->second;
352 G4int count = data.fCount;
355 G4cout <<
" " << std::setw(50) << name <<
": " << std::setw(7) << count
356 <<
" Q = " << std::setw(wid) <<
G4BestUnit(Q,
"Energy")
362 if (print && (fGammaCount > 0)) {
363 G4cout <<
"\n" << std::setw(58) <<
"Number of gamma: N = "
364 << fNbGamma[1] <<
" --> " << fNbGamma[2] <<
G4endl;
367 if (print && fTargetXXX) {
369 <<
"\n --> NOTE: XXXX because neutronHP is unable to return target nucleus"
377 std::map<G4String,ParticleData>::iterator itn;
378 for (itn = fParticleDataMap.begin(); itn != fParticleDataMap.end(); itn++) {
380 ParticleData
data = itn->second;
381 G4int count = data.fCount;
386 G4cout <<
" " << std::setw(13) << name <<
": " << std::setw(7) << count
387 <<
" Emean = " << std::setw(wid) <<
G4BestUnit(eMean,
"Energy")
395 if (fTotalCount > 1) {
396 G4double Pbmean = fPbalance[0]/fTotalCount;
397 G4cout <<
"\n Momentum balance: Pmean = "
398 << std::setw(wid) <<
G4BestUnit(Pbmean,
"Energy")
399 <<
"\t( " <<
G4BestUnit(fPbalance[1],
"Energy")
400 <<
" --> " <<
G4BestUnit(fPbalance[2],
"Energy")
410 fProcCounter.clear();
411 fNuclChannelMap.clear();
412 fParticleDataMap.clear();
virtual void Merge(const G4Run *)
void CountProcesses(G4String procName)
void SetTargetXXX(G4bool)
static G4HadronicProcessStore * Instance()
const G4String & GetName() const
G4double GetDensity() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4Element * GetElement(G4int iel) const
const G4String & GetParticleName() const
const XML_Char const XML_Char * data
void CountNuclearChannel(G4String, G4double)
G4GLOB_DLL std::ostream G4cout
void SumTrack(G4double track)
G4Material * GetMaterial()
static constexpr double cm
const G4String & GetProcessName() const
void print(G4double elem)
static const G4double emax
G4double GetTotNbOfAtomsPerVolume() const
G4double energy(const ThreeVector &p, const G4double m)
G4double GetCrossSectionPerVolume(const G4ParticleDefinition *particle, G4double kineticEnergy, const G4VProcess *process, const G4Material *material)
Detector construction class to define materials and geometry.
size_t GetNumberOfElements() const
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
virtual void Merge(const G4Run *)
static G4ProcessTable * GetProcessTable()
G4VProcess * FindProcess(const G4String &processName, const G4String &particleName) const
G4double GetCrossSectionPerAtom(const G4ParticleDefinition *particle, G4double kineticEnergy, const G4VProcess *process, const G4Element *element, const G4Material *material=0)
void ParticleCount(G4String, G4double)