34 #include "RunAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "PhysicsList.hh"
38 #include "PrimaryGeneratorAction.hh"
52 : fAnalysisManager(0), fDetector(det), fPhysics(phys), fKinematic(kin),
54 fEdeptot(0.), fEniel(0.), fNbPrimarySteps(0), fRange(0)
73 if(!fAnalysisManager) { BookHisto(); }
81 fProjRange = fProjRange2 = 0.;
82 fEdeptot = fEniel = 0.;
86 if (fAnalysisManager->IsActive()) {
87 fAnalysisManager->OpenFile();
95 if (nbBins < nbmin) nbBins = nbmin;
96 fAnalysisManager->SetH1(1, nbBins, 0., length,
"mm");
105 if (nbofEvents == 0)
return;
115 G4cout <<
"\n The run consists of " << nbofEvents <<
" "<< particle <<
" of "
118 << material->
GetName() <<
" (density: "
124 fProjRange /= fRange;
125 fProjRange2 /= fRange;
127 G4double rms = fProjRange2 - fProjRange*fProjRange;
128 if (rms>0.) rms = std::sqrt(rms);
else rms = 0.;
136 G4cout <<
" Mean number of primary steps = "<< nstep <<
G4endl;
140 fEdeptot /= nbofEvents;
143 fEniel /= nbofEvents;
150 if (tallyNumber > 0) {
152 G4cout <<
"\n---------------------------------------------------------\n";
153 G4cout <<
" Cumulated Doses : \tEdep \tEdep/Ebeam \tDose" <<
G4endl;
154 for (
G4int j=1; j <= tallyNumber; j++) {
155 G4double Edep = fTallyEdep[j], ratio = 100*Edep/Ebeam;
158 G4cout <<
" tally " << j <<
": \t \t"
163 G4cout <<
"\n---------------------------------------------------------\n";
167 if (fAnalysisManager->IsActive() ) {
170 for (
G4int j=1; j<3; j++) {
171 G4double binWidth = fAnalysisManager->GetH1Width(j);
173 fAnalysisManager->ScaleH1(j, fac);
175 fAnalysisManager->ScaleH1(3, 1./nbofEvents);
178 fAnalysisManager->Write();
179 fAnalysisManager->CloseFile();
180 delete fAnalysisManager;
181 fAnalysisManager = 0;
191 void RunAction::BookHisto()
196 fAnalysisManager = G4AnalysisManager::Instance();
197 fAnalysisManager->SetFileName(
"testem7");
198 fAnalysisManager->SetVerboseLevel(1);
199 fAnalysisManager->SetActivation(
true);
202 const G4int kMaxHisto = 4;
203 const G4String id[] = {
"0",
"1",
"2",
"3" };
206 "Edep (MeV/mm) along absorber ",
207 "Edep (MeV/mm) along absorber zoomed",
218 for (
G4int k=0; k<kMaxHisto; k++) {
219 G4int ih = fAnalysisManager->CreateH1(
id[k], title[k], nbins, vmin, vmax);
221 if (k == 1) activ =
true;