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;
181 G4cout << std::setprecision(4) <<
"Average number of e- "
183 G4cout << std::setprecision(4) <<
"Average number of gamma "
185 G4cout << std::setprecision(4) <<
"Average number of e+ "
187 G4cout << std::setprecision(4) <<
"Average number of steps in the phantom "
189 G4cout << std::setprecision(4) <<
"Average number of e- steps in the target "
191 G4cout << std::setprecision(4) <<
"Average number of g produced in the target "
193 G4cout << std::setprecision(4) <<
"Average number of e- produced in the target "
195 G4cout << std::setprecision(4) <<
"Average number of g produced in the phantom "
197 G4cout << std::setprecision(4) <<
"Average number of e- produced in the phantom "
199 G4cout << std::setprecision(4) <<
"Total fGamma fluence in front of the phantom "
202 G4cout<<
"========================================================"<<
G4endl;
207 for(
G4int i=0; i<fNBinsR; i++) {
212 if(fAnalysisManager) {
215 for(
G4int i=0; i<fNHisto; i++) {
216 fAnalysisManager->
GetH1(fHisto[i])->scale(x);
219 if(nr > 0.0) { nr = 1./nr; }
220 fAnalysisManager->
GetH1(fHisto[0])->scale(nr);
223 if(nr > 0.0) { nr = 1./nr; }
224 fAnalysisManager->
GetH1(fHisto[1])->scale(nr);
226 fAnalysisManager->
GetH1(fHisto[3])
227 ->scale(1000.0*
cm3/(
pi*fAbsorberR*fAbsorberR*fStepZ));
228 fAnalysisManager->
GetH1(fHisto[4])
229 ->scale(1000.0*
cm3*fVolumeR[0]/fStepZ);
232 if(!fAnalysisManager->
Write()) {
233 G4cout <<
"Histo::Save: FATAL ERROR writing ROOT file" <<
G4endl;
236 G4cout <<
"### Histo::Save: Histograms are saved" <<
G4endl;
237 if(fAnalysisManager->
CloseFile() && fVerbose > 0) {
240 delete fAnalysisManager;
241 fAnalysisManager = 0;
247 void Histo::BookHisto()
251 if(!fAnalysisManager->
OpenFile(nam)) {
252 G4cout <<
"Histo::bookHisto: ERROR open file <" << nam <<
">" <<
G4endl;
255 G4cout <<
"### Histo::Save: Opended file <" << nam <<
"> for "
256 << fNHisto <<
" histograms " <<
G4endl;
259 fHisto[0] = fAnalysisManager->
CreateH1(
"10",
260 "Energy deposit at radius (mm) normalised on 1st channel",fNBinsR,0.,fAbsorberR/
mm);
262 fHisto[1] = fAnalysisManager->
CreateH1(
"11",
263 "Energy deposit at radius (mm) normalised to integral",fNBinsR,0.,fAbsorberR/
mm);
265 fHisto[2] = fAnalysisManager->
CreateH1(
"12",
266 "Energy deposit (MeV/kg/electron) at radius (mm)",fNBinsR,0.,fAbsorberR/
mm);
268 fHisto[3] = fAnalysisManager->
CreateH1(
"13",
269 "Energy profile (MeV/kg/electron) over Z (mm)",fNBinsZ,0.,fAbsorberZ/
mm);
271 fHisto[4] = fAnalysisManager->
CreateH1(
"14",
272 "Energy profile (MeV/kg/electron) over Z (mm) at Central Voxel",fNBinsZ,0.,fAbsorberZ/
mm);
274 fHisto[5] = fAnalysisManager->
CreateH1(
"15",
275 "Energy (MeV) of fGamma produced in the target",fNBinsE,0.,fMaxEnergy/
MeV);
277 fHisto[6] = fAnalysisManager->
CreateH1(
"16",
278 "Energy (MeV) of fGamma before phantom",fNBinsE,0.,fMaxEnergy/
MeV);
280 fHisto[7] = fAnalysisManager->
CreateH1(
"17",
281 "Energy (MeV) of electrons produced in phantom",fNBinsE,0.,fMaxEnergy/
MeV);
283 fHisto[8] = fAnalysisManager->
CreateH1(
"18",
284 "Energy (MeV) of electrons produced in target",fNBinsE,0.,fMaxEnergy/
MeV);
286 fHisto[9] = fAnalysisManager->
CreateH1(
"19",
287 "Gamma Energy Fluence (MeV/cm2) at radius(mm) in front of phantom",fNBinsR,0.,fAbsorberR/
mm);
296 if(fAnalysisManager) {
313 if(fAnalysisManager) {
323 if(fAnalysisManager) {
345 G4cout <<
"TrackingAction: Primary "
349 <<
"; pos= " << pos <<
"; dir= " << dir <<
G4endl;
353 }
else if (0 < pid && particle == fElectron) {
355 G4cout <<
"TrackingAction: Secondary electron " <<
G4endl;
358 if(pv == fPhantom) { AddPhantomElectron(dp); }
359 else if(pv == fTarget1 || pv == fTarget2) { AddTargetElectron(dp); }
362 }
else if (0 < pid && particle == fPositron) {
364 G4cout <<
"TrackingAction: Secondary positron " <<
G4endl;
369 }
else if (0 < pid && particle == fGamma) {
371 G4cout <<
"TrackingAction: Secondary gamma; parentID= " << pid
375 if(pv == fPhantom) { AddPhantomPhoton(dp); }
376 else if(pv == fTarget1 || pv == fTarget2) { AddTargetPhoton(dp); }
388 if(bin >= fNBinsE) { bin = fNBinsE-1; }
391 if(bin1 >= fNBinsR) { bin1 = fNBinsR-1; }
392 if(fAnalysisManager) {
393 fAnalysisManager->
FillH1(fHisto[6],e,1.0);
394 fAnalysisManager->
FillH1(fHisto[9],r,e*fVolumeR[bin1]);
407 G4cout <<
"Histo: edep(MeV)= " << edep/
MeV <<
" at binz= " << nzbin
408 <<
" r1= " << r1 <<
" z1= " << z1
409 <<
" r2= " << r2 <<
" z2= " << z2
410 <<
" r0= " << r0 <<
" z0= " << z0
413 if(nzbin == fScoreBin) {
415 if(bin >= fNBinsR) { bin = fNBinsR-1; }
416 double w = edep*fVolumeR[
bin];
418 if(fAnalysisManager) {
419 fAnalysisManager->
FillH1(fHisto[0],r0,w);
420 fAnalysisManager->
FillH1(fHisto[1],r0,w);
421 fAnalysisManager->
FillH1(fHisto[2],r0,w);
425 if(bin1 >= fNBinsZ) { bin1 = fNBinsZ-1; }
427 if(bin2 >= fNBinsZ) { bin2 = fNBinsZ-1; }
429 if(fAnalysisManager) {
430 fAnalysisManager->
FillH1(fHisto[3],z0,edep);
433 if(r2 > fStepR) { w *= (fStepR - r1)/(r2 - r1); }
434 fAnalysisManager->
FillH1(fHisto[4],z0,w);
453 G4double rr2 = r1 + dr*(zz2-zz1)/dz;
454 for(bin=bin1; bin<=bin2; bin++) {
455 if(fAnalysisManager) {
458 { fAnalysisManager->
FillH1(fHisto[3],zf,de); }
461 if(rr2 > fStepR) w *= (fStepR - rr1)/(rr2 - rr1);
462 { fAnalysisManager->
FillH1(fHisto[4],zf,w); }
466 zz2 = std::min(z2, zz1+fStepZ);
468 rr2 = rr1 + dr*(zz2 - zz1)/dz;