34 #include "RunAction.hh"
36 #include "DetectorConstruction.hh"
37 #include "PrimaryGeneratorAction.hh"
38 #include "HistoManager.hh"
54 fDetector(det), fPrimary(prim), fProcCounter(0), fHistoManager(HistM)
73 fHistoManager->
book();
81 size_t nbProc = fProcCounter->size();
83 while ((i<nbProc)&&((*fProcCounter)[i]->GetName()!=procName)) i++;
84 if (i == nbProc) fProcCounter->push_back(
new OneProcessCount(procName));
86 (*fProcCounter)[i]->Count();
94 if (NbOfEvents == 0)
return;
96 std::ios::fmtflags mode =
G4cout.flags();
107 G4cout <<
"\n The run consists of " << NbOfEvents <<
" "<< particle <<
" of "
110 << material->
GetName() <<
" (density: "
115 G4cout <<
"\n Number of process calls --->";
116 for (
size_t i=0; i< fProcCounter->size();i++) {
117 G4String procName = (*fProcCounter)[i]->GetName();
118 if (procName !=
"Transportation") {
119 G4int count = (*fProcCounter)[i]->GetCounter();
120 G4cout <<
"\t" << procName <<
" : " << count;
128 G4double totalCrossSection = countTot/(NbOfEvents*length);
129 G4double MeanFreePath = 1./totalCrossSection;
133 G4cout <<
"\n Simulation: "
134 <<
"total CrossSection = " << totalCrossSection*
cm <<
" /cm"
135 <<
"\t MeanFreePath = " <<
G4BestUnit(MeanFreePath,
"Length")
136 <<
"\t massicCrossSection = " << massCrossSection*
g/
cm2 <<
" cm2/g"
141 if(particle ==
"mu+" || particle ==
"mu-") {
142 totalCrossSection = 0.;
143 for (
size_t i=0; i< fProcCounter->size();i++) {
144 G4String procName = (*fProcCounter)[i]->GetName();
145 if (procName !=
"Transportation") {
146 totalCrossSection += ComputeTheory(procName, NbOfEvents);
150 MeanFreePath = 1./totalCrossSection;
151 massCrossSection = totalCrossSection/
density;
154 <<
"total CrossSection = " << totalCrossSection*
cm <<
" /cm"
155 <<
"\t MeanFreePath = " <<
G4BestUnit(MeanFreePath,
"Length")
156 <<
"\t massicCrossSection = " << massCrossSection*
g/
cm2 <<
" cm2/g"
160 G4cout.setf(mode,std::ios::floatfield);
164 while (fProcCounter->size()>0){
166 fProcCounter->pop_back();
171 fHistoManager->
save();
186 if (process ==
"muIoni") {
id = 11; cut = GetEnergyCut(material,1);}
187 else if (process ==
"muPairProd") {
id = 12; cut = 2*(GetEnergyCut(material,1)
189 else if (process ==
"muBrems") {
id = 13; cut = GetEnergyCut(material,0);}
190 else if (process ==
"muonNuclear"){
id = 14; }
191 if (
id == 0) {
return 0.; }
193 G4int nbOfBins = 100;
205 histoTh = analysisManager->GetH1(fHistoManager->
GetHistoID(
id));
207 nbOfBins = fHistoManager->
GetNbins(
id);
208 binMin = fHistoManager->
GetVmin (
id);
209 binMax = fHistoManager->
GetVmax (
id);
220 const G4double ln10 = std::log(10.);
223 for (
G4int ibin=0; ibin<nbOfBins; ibin++) {
224 lgeps = binMin + (ibin+0.5)*binWidth;
225 etransf = ekin*std::pow(10.,lgeps);
226 sigmaE = crossSections.
CR_Macroscopic(process,material,ekin,etransf);
227 dsigma = sigmaE*etransf*binWidth*ln10;
228 if (etransf > cut) sigmaTot +=
dsigma;
231 histoTh->fill(lgeps, NbProcess);
250 (index < table->GetTableSize())) index++;
std::vector< OneProcessCount * > ProcessesCount
const std::vector< G4double > * GetEnergyCutsVector(size_t pcIdx) const
void BeginOfRunAction(const G4Run *)
G4double CR_Macroscopic(const G4String &, G4Material *, G4double, G4double)
const G4String & GetName() const
G4double GetDensity() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
Definition of the MuCrossSections class.
void SetRandomNumberStore(G4bool flag)
void CountProcesses(G4String procName)
G4double GetVmin(G4int id)
const G4String & GetParticleName() const
G4double GetVmax(G4int id)
double precision function energy(A, Z)
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
G4Material * GetMaterial()
void EndOfRunAction(const G4Run *)
ExG4HbookAnalysisManager G4AnalysisManager
G4int GetHistoID(G4int id)
static void showEngineStatus()
G4bool HistoExist(G4int id)
static G4RunManager * GetRunManager()
static G4ProductionCutsTable * GetProductionCutsTable()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
G4ParticleGun * GetParticleGun()
G4ParticleDefinition * GetParticleDefinition() const
G4double GetBinWidth(G4int id)
G4double GetParticleEnergy() const
const G4Material * GetMaterial() const