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()) {
243 "Cannot write ROOT file.");
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;
263 "Cannot open ROOT file.");
265 G4cout <<
"### Histo::Save: Opended file <" << nam <<
"> for "
266 << fNHisto <<
" histograms " <<
G4endl;
269 fHisto[0] = fAnalysisManager->
CreateH1(
"10",
270 "Energy deposit at radius (mm) normalised on 1st channel",
271 fNBinsR, 0., fAbsorberR/
mm);
273 fHisto[1] = fAnalysisManager->
CreateH1(
"11",
274 "Energy deposit at radius (mm) normalised to integral",
275 fNBinsR, 0., fAbsorberR/
mm);
277 fHisto[2] = fAnalysisManager->
CreateH1(
"12",
278 "Energy deposit (MeV/kg/electron) at radius (mm)",
279 fNBinsR, 0., fAbsorberR/
mm);
281 fHisto[3] = fAnalysisManager->
CreateH1(
"13",
282 "Energy profile (MeV/kg/electron) over Z (mm)",fNBinsZ,0.,fAbsorberZ/
mm);
284 fHisto[4] = fAnalysisManager->
CreateH1(
"14",
285 "Energy profile (MeV/kg/electron) over Z (mm) at Central Voxel",
286 fNBinsZ, 0., fAbsorberZ/
mm);
288 fHisto[5] = fAnalysisManager->
CreateH1(
"15",
289 "Energy (MeV) of fGamma produced in the target",
290 fNBinsE, 0., fMaxEnergy/
MeV);
292 fHisto[6] = fAnalysisManager->
CreateH1(
"16",
293 "Energy (MeV) of fGamma before phantom",fNBinsE,0.,fMaxEnergy/
MeV);
295 fHisto[7] = fAnalysisManager->
CreateH1(
"17",
296 "Energy (MeV) of electrons produced in phantom",fNBinsE,0.,fMaxEnergy/
MeV);
298 fHisto[8] = fAnalysisManager->
CreateH1(
"18",
299 "Energy (MeV) of electrons produced in target",fNBinsE,0.,fMaxEnergy/
MeV);
301 fHisto[9] = fAnalysisManager->
CreateH1(
"19",
302 "Gamma Energy Fluence (MeV/cm2) at radius(mm) in front of phantom",
303 fNBinsR, 0., fAbsorberR/
mm);
312 if(fAnalysisManager) {
329 if(fAnalysisManager) {
339 if(fAnalysisManager) {
361 G4cout <<
"TrackingAction: Primary "
365 <<
"; pos= " << pos <<
"; dir= " << dir <<
G4endl;
369 }
else if (0 < pid && particle == fElectron) {
371 G4cout <<
"TrackingAction: Secondary electron " <<
G4endl;
374 if(pv == fPhantom) { AddPhantomElectron(dp); }
375 else if(pv == fTarget1 || pv == fTarget2) { AddTargetElectron(dp); }
378 }
else if (0 < pid && particle == fPositron) {
380 G4cout <<
"TrackingAction: Secondary positron " <<
G4endl;
385 }
else if (0 < pid && particle == fGamma) {
387 G4cout <<
"TrackingAction: Secondary gamma; parentID= " << pid
391 if(pv == fPhantom) { AddPhantomPhoton(dp); }
392 else if(pv == fTarget1 || pv == fTarget2) { AddTargetPhoton(dp); }
404 if(bin >= fNBinsE) { bin = fNBinsE-1; }
407 if(bin1 >= fNBinsR) { bin1 = fNBinsR-1; }
408 if(fAnalysisManager) {
409 fAnalysisManager->
FillH1(fHisto[6],e,1.0);
410 fAnalysisManager->
FillH1(fHisto[9],r,e*fVolumeR[bin1]);
423 G4cout <<
"Histo: edep(MeV)= " << edep/
MeV <<
" at binz= " << nzbin
424 <<
" r1= " << r1 <<
" z1= " << z1
425 <<
" r2= " << r2 <<
" z2= " << z2
426 <<
" r0= " << r0 <<
" z0= " << z0
429 if(nzbin == fScoreBin) {
431 if(bin >= fNBinsR) { bin = fNBinsR-1; }
432 double w = edep*fVolumeR[
bin];
434 if(fAnalysisManager) {
435 fAnalysisManager->
FillH1(fHisto[0],r0,w);
436 fAnalysisManager->
FillH1(fHisto[1],r0,w);
437 fAnalysisManager->
FillH1(fHisto[2],r0,w);
441 if(bin1 >= fNBinsZ) { bin1 = fNBinsZ-1; }
443 if(bin2 >= fNBinsZ) { bin2 = fNBinsZ-1; }
445 if(fAnalysisManager) {
446 fAnalysisManager->
FillH1(fHisto[3],z0,edep);
449 if(r2 > fStepR) { w *= (fStepR - r1)/(r2 - r1); }
450 fAnalysisManager->
FillH1(fHisto[4],z0,w);
469 G4double rr2 = r1 + dr*(zz2-zz1)/dz;
470 for(bin=bin1; bin<=bin2; bin++) {
471 if(fAnalysisManager) {
474 { fAnalysisManager->
FillH1(fHisto[3],zf,de); }
477 if(rr2 > fStepR) w *= (fStepR - rr1)/(rr2 - rr1);
478 { fAnalysisManager->
FillH1(fHisto[4],zf,w); }
484 rr2 = rr1 + dr*(zz2 - zz1)/dz;
void SetNumberDivR(G4int val)
G4int GetParentID() const
void AddPhantomGamma(G4double e, G4double r)
static Histo * GetPointer()
static constexpr double mm
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
G4bool OpenFile(const G4String &fileName="")
const G4String & GetParticleName() const
void ScoreNewTrack(const G4Track *aTrack)
G4double GetKineticEnergy() const
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
const G4ParticleDefinition * GetParticleDefinition() const
static constexpr double cm3
const G4ThreeVector & GetVertexPosition() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
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()
static constexpr double MeV
static constexpr double pi
void AddPhantomStep(G4double e, G4double r1, G4double z1, G4double r2, G4double z2, G4double r0, G4double z0)
static const G4double pos