55 Histo* Histo::fManager = 0;
75 fMaxEnergy = 50.0*
MeV;
89 fCheckVolume = fGasVolume = fPhantom = fTarget1 = fTarget2 = 0;
93 fStepZ = fStepR = fStepE = fNormZ = fSumR = 0.0;
94 fNevt = fNelec = fNposit = fNgam = fNstep = fNgamPh =
95 fNgamTar = fNeTar = fNePh = fNstepTarget = 0;
97 fHisto.resize(fNHisto, 0);
109 G4cout <<
"### Histo start initialisation nHisto= " << fNHisto <<
G4endl;
111 fNevt = fNelec = fNposit= fNgam = fNstep = fNgamPh = fNgamTar =
112 fNeTar = fNePh = fNstepTarget = 0;
116 fStepZ = fAbsorberZ/(
G4double)fNBinsZ;
117 fStepR = fAbsorberR/(
G4double)fNBinsR;
118 fStepE = fMaxEnergy/(
G4double)fNBinsE;
119 fScoreBin = (
G4int)(fScoreZ/fStepZ + 0.5);
121 G4cout <<
" "<< fNBinsR <<
" bins R stepR= " << fStepR/
mm <<
" mm "
123 G4cout <<
" "<< fNBinsZ <<
" bins Z stepZ= " << fStepZ/
mm <<
" mm "
125 G4cout <<
" "<< fNBinsE <<
" bins E stepE= " << fStepE/
MeV <<
" MeV "
127 G4cout <<
" "<< fScoreBin <<
"-th bin in Z is used for R distribution"
130 fVolumeR.resize(fNBinsR);
131 fEdep.resize(fNBinsR, 0.0);
132 fGammaE.resize(fNBinsE, 0.0);
136 for(
G4int i=0; i<fNBinsR; ++i) {
137 fVolumeR[i] =
cm*
cm/(
pi*(r2*r2 - r1*r1));
142 if(fHistName !=
"") {
143 if(!fAnalysisManager) {
148 G4cout <<
"Histo: Histograms are booked and run has been started"
151 }
else if(fVerbose > 0) {
152 G4cout <<
"Histo: Histograms are not booked because file name is not set"
162 G4cout <<
"Histo: End of run actions are started" <<
G4endl;
166 G4cout<<
"========================================================"<<
G4endl;
168 if(fNevt > 0) { x = 1.0/
x; }
179 G4cout <<
"Number of events "
180 << std::setprecision(8) << fNevt <<
G4endl;
182 << std::setprecision(4) <<
"Average number of e- "
185 << std::setprecision(4) <<
"Average number of gamma "
188 << std::setprecision(4) <<
"Average number of e+ "
191 << std::setprecision(4) <<
"Average number of steps in the phantom "
194 << std::setprecision(4) <<
"Average number of e- steps in the target "
197 << std::setprecision(4) <<
"Average number of g produced in the target "
200 << std::setprecision(4) <<
"Average number of e- produced in the target "
203 << std::setprecision(4) <<
"Average number of g produced in the phantom "
206 << std::setprecision(4) <<
"Average number of e- produced in the phantom "
209 << std::setprecision(4) <<
"Total fGamma fluence in front of the phantom "
211 G4cout<<
"========================================================"<<
G4endl;
216 for(
G4int i=0; i<fNBinsR; i++) {
221 if(fAnalysisManager) {
224 for(
G4int i=0; i<fNHisto; i++) {
225 fAnalysisManager->
GetH1(fHisto[i])->scale(x);
228 if(nr > 0.0) { nr = 1./nr; }
229 fAnalysisManager->
GetH1(fHisto[0])->scale(nr);
232 if(nr > 0.0) { nr = 1./nr; }
233 fAnalysisManager->
GetH1(fHisto[1])->scale(nr);
235 fAnalysisManager->
GetH1(fHisto[3])
236 ->scale(1000.0*
cm3/(
pi*fAbsorberR*fAbsorberR*fStepZ));
237 fAnalysisManager->
GetH1(fHisto[4])
238 ->scale(1000.0*
cm3*fVolumeR[0]/fStepZ);
241 if(!fAnalysisManager->
Write()) {
242 G4cout <<
"Histo::Save: FATAL ERROR writing ROOT file" <<
G4endl;
245 G4cout <<
"### Histo::Save: Histograms are saved" <<
G4endl;
246 if(fAnalysisManager->
CloseFile() && fVerbose > 0) {
249 delete fAnalysisManager;
250 fAnalysisManager = 0;
256 void Histo::BookHisto()
260 if(!fAnalysisManager->
OpenFile(nam)) {
261 G4cout <<
"Histo::bookHisto: ERROR open file <" << nam <<
">" <<
G4endl;
264 G4cout <<
"### Histo::Save: Opended file <" << nam <<
"> for "
265 << fNHisto <<
" histograms " <<
G4endl;
268 fHisto[0] = fAnalysisManager->
CreateH1(
"10",
269 "Energy deposit at radius (mm) normalised on 1st channel",
270 fNBinsR, 0., fAbsorberR/
mm);
272 fHisto[1] = fAnalysisManager->
CreateH1(
"11",
273 "Energy deposit at radius (mm) normalised to integral",
274 fNBinsR, 0., fAbsorberR/
mm);
276 fHisto[2] = fAnalysisManager->
CreateH1(
"12",
277 "Energy deposit (MeV/kg/electron) at radius (mm)",
278 fNBinsR, 0., fAbsorberR/
mm);
280 fHisto[3] = fAnalysisManager->
CreateH1(
"13",
281 "Energy profile (MeV/kg/electron) over Z (mm)",fNBinsZ,0.,fAbsorberZ/
mm);
283 fHisto[4] = fAnalysisManager->
CreateH1(
"14",
284 "Energy profile (MeV/kg/electron) over Z (mm) at Central Voxel",
285 fNBinsZ, 0., fAbsorberZ/
mm);
287 fHisto[5] = fAnalysisManager->
CreateH1(
"15",
288 "Energy (MeV) of fGamma produced in the target",
289 fNBinsE, 0., fMaxEnergy/
MeV);
291 fHisto[6] = fAnalysisManager->
CreateH1(
"16",
292 "Energy (MeV) of fGamma before phantom",fNBinsE,0.,fMaxEnergy/
MeV);
294 fHisto[7] = fAnalysisManager->
CreateH1(
"17",
295 "Energy (MeV) of electrons produced in phantom",fNBinsE,0.,fMaxEnergy/
MeV);
297 fHisto[8] = fAnalysisManager->
CreateH1(
"18",
298 "Energy (MeV) of electrons produced in target",fNBinsE,0.,fMaxEnergy/
MeV);
300 fHisto[9] = fAnalysisManager->
CreateH1(
"19",
301 "Gamma Energy Fluence (MeV/cm2) at radius(mm) in front of phantom",
302 fNBinsR, 0., fAbsorberR/
mm);
311 if(fAnalysisManager) {
328 if(fAnalysisManager) {
338 if(fAnalysisManager) {
360 G4cout <<
"TrackingAction: Primary "
364 <<
"; pos= " << pos <<
"; dir= " << dir <<
G4endl;
368 }
else if (0 < pid && particle == fElectron) {
370 G4cout <<
"TrackingAction: Secondary electron " <<
G4endl;
373 if(pv == fPhantom) { AddPhantomElectron(dp); }
374 else if(pv == fTarget1 || pv == fTarget2) { AddTargetElectron(dp); }
377 }
else if (0 < pid && particle == fPositron) {
379 G4cout <<
"TrackingAction: Secondary positron " <<
G4endl;
384 }
else if (0 < pid && particle == fGamma) {
386 G4cout <<
"TrackingAction: Secondary gamma; parentID= " << pid
390 if(pv == fPhantom) { AddPhantomPhoton(dp); }
391 else if(pv == fTarget1 || pv == fTarget2) { AddTargetPhoton(dp); }
403 if(bin >= fNBinsE) { bin = fNBinsE-1; }
406 if(bin1 >= fNBinsR) { bin1 = fNBinsR-1; }
407 if(fAnalysisManager) {
408 fAnalysisManager->
FillH1(fHisto[6],e,1.0);
409 fAnalysisManager->
FillH1(fHisto[9],r,e*fVolumeR[bin1]);
422 G4cout <<
"Histo: edep(MeV)= " << edep/
MeV <<
" at binz= " << nzbin
423 <<
" r1= " << r1 <<
" z1= " << z1
424 <<
" r2= " << r2 <<
" z2= " << z2
425 <<
" r0= " << r0 <<
" z0= " << z0
428 if(nzbin == fScoreBin) {
430 if(bin >= fNBinsR) { bin = fNBinsR-1; }
431 double w = edep*fVolumeR[
bin];
433 if(fAnalysisManager) {
434 fAnalysisManager->
FillH1(fHisto[0],r0,w);
435 fAnalysisManager->
FillH1(fHisto[1],r0,w);
436 fAnalysisManager->
FillH1(fHisto[2],r0,w);
440 if(bin1 >= fNBinsZ) { bin1 = fNBinsZ-1; }
442 if(bin2 >= fNBinsZ) { bin2 = fNBinsZ-1; }
444 if(fAnalysisManager) {
445 fAnalysisManager->
FillH1(fHisto[3],z0,edep);
448 if(r2 > fStepR) { w *= (fStepR - r1)/(r2 - r1); }
449 fAnalysisManager->
FillH1(fHisto[4],z0,w);
468 G4double rr2 = r1 + dr*(zz2-zz1)/dz;
469 for(bin=bin1; bin<=bin2; bin++) {
470 if(fAnalysisManager) {
473 { fAnalysisManager->
FillH1(fHisto[3],zf,de); }
476 if(rr2 > fStepR) w *= (fStepR - rr1)/(rr2 - rr1);
477 { fAnalysisManager->
FillH1(fHisto[4],zf,w); }
483 rr2 = rr1 + dr*(zz2 - zz1)/dz;
void SetNumberDivR(G4int val)
G4int GetParentID() const
void AddPhantomGamma(G4double e, G4double r)
static Histo * GetPointer()
G4double GetKineticEnergy() const
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
const G4DynamicParticle * GetDynamicParticle() const
const G4String & GetParticleName() const
void ScoreNewTrack(const G4Track *aTrack)
G4double GetKineticEnergy() const
G4GLOB_DLL std::ostream G4cout
const G4ParticleDefinition * GetParticleDefinition() const
const G4ThreeVector & GetVertexPosition() const
static G4Positron * Positron()
const G4ThreeVector & GetMomentumDirection() const
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static G4RootAnalysisManager * Instance()
G4VPhysicalVolume * GetVolume() const
static G4Electron * Electron()
void AddPhantomStep(G4double e, G4double r1, G4double z1, G4double r2, G4double z2, G4double r0, G4double z0)
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const