34 #include "RunAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "PhysicsList.hh"
38 #include "PrimaryGeneratorAction.hh"
53 fAnalysisManager(0), fDetector(det), fPhysics(phys), fKinematic(kin),
55 fEdeptot(0.), fEniel(0.), fNbPrimarySteps(0), fRange(0)
74 if(!fAnalysisManager) { BookHisto(); }
82 fProjRange = fProjRange2 = 0.;
83 fEdeptot = fEniel = 0.;
87 if (fAnalysisManager->IsActive()) {
88 fAnalysisManager->OpenFile();
96 if (nbBins < nbmin) nbBins = nbmin;
97 fAnalysisManager->SetH1(1, nbBins, 0., length,
"mm");
106 if (nbofEvents == 0)
return;
116 G4cout <<
"\n The run consists of " << nbofEvents <<
" "<< particle <<
" of "
119 << material->
GetName() <<
" (density: "
125 fProjRange /= fRange;
126 fProjRange2 /= fRange;
128 G4double rms = fProjRange2 - fProjRange*fProjRange;
129 if (rms>0.) rms = std::sqrt(rms);
else rms = 0.;
137 G4cout <<
" Mean number of primary steps = "<< nstep <<
G4endl;
141 fEdeptot /= nbofEvents;
144 fEniel /= nbofEvents;
151 if (tallyNumber > 0) {
153 G4cout <<
"\n---------------------------------------------------------\n";
154 G4cout <<
" Cumulated Doses : \tEdep \tEdep/Ebeam \tDose" <<
G4endl;
155 for (
G4int j=1; j <= tallyNumber; j++) {
156 G4double Edep = fTallyEdep[j], ratio = 100*Edep/Ebeam;
159 G4cout <<
" tally " << j <<
": \t \t"
164 G4cout <<
"\n---------------------------------------------------------\n";
168 if (fAnalysisManager->IsActive() ) {
171 for (
G4int j=1; j<3; j++) {
172 G4double binWidth = fAnalysisManager->GetH1Width(j);
174 fAnalysisManager->ScaleH1(j, fac);
176 fAnalysisManager->ScaleH1(3, 1./nbofEvents);
179 fAnalysisManager->Write();
180 fAnalysisManager->CloseFile();
181 delete fAnalysisManager;
182 fAnalysisManager = 0;
192 void RunAction::BookHisto()
197 fAnalysisManager = G4AnalysisManager::Instance();
198 fAnalysisManager->SetFileName(
"testem7");
199 fAnalysisManager->SetVerboseLevel(1);
200 fAnalysisManager->SetActivation(
true);
203 const G4int kMaxHisto = 4;
204 const G4String id[] = {
"0",
"1",
"2",
"3" };
207 "Edep (MeV/mm) along absorber ",
208 "Edep (MeV/mm) along absorber zoomed",
219 for (
G4int k=0; k<kMaxHisto; k++) {
220 G4int ih = fAnalysisManager->CreateH1(
id[k], title[k], nbins, vmin, vmax);
222 if (k == 1) activ =
true;
223 fAnalysisManager->SetH1Activation(ih, activ);
G4StepLimiter * GetStepMaxProcess()
void BeginOfRunAction(const G4Run *)
G4double GetTallyMass(G4int n)
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)
double precision function energy(A, Z)
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
void EndOfRunAction(const G4Run *)
static void showEngineStatus()
subroutine title(NA, NB, NCA, NCB)
G4ParticleGun * GetParticleGun()
G4ParticleDefinition * GetParticleDefinition() const
G4double GetParticleEnergy() const