Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/hadronic/Hadr01/src/HistoManager.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 // $Id: HistoManager.cc 109185 2018-04-03 07:20:46Z gcosmo $
30 //
31 //---------------------------------------------------------------------------
32 //
33 // ClassName: HistoManager
34 //
35 //
36 // Author: V.Ivanchenko 30/01/01
37 //
38 // Modified:
39 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko)
40 // 16.11.2006 Add beamFlag (V.Ivanchenko)
41 //
42 //----------------------------------------------------------------------------
43 //
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
47 
48 #include "HistoManager.hh"
49 #include "G4Track.hh"
50 #include "G4Step.hh"
51 #include "G4UnitsTable.hh"
52 #include "G4Neutron.hh"
53 #include "G4Proton.hh"
54 #include "G4AntiProton.hh"
55 #include "G4Gamma.hh"
56 #include "G4Electron.hh"
57 #include "G4Positron.hh"
58 #include "G4MuonPlus.hh"
59 #include "G4MuonMinus.hh"
60 #include "G4PionPlus.hh"
61 #include "G4PionMinus.hh"
62 #include "G4PionZero.hh"
63 #include "G4KaonPlus.hh"
64 #include "G4KaonMinus.hh"
65 #include "G4KaonZeroShort.hh"
66 #include "G4KaonZeroLong.hh"
67 #include "G4Deuteron.hh"
68 #include "G4Triton.hh"
69 #include "G4He3.hh"
70 #include "G4Alpha.hh"
71 #include "Histo.hh"
72 #include "globals.hh"
73 #include "G4SystemOfUnits.hh"
74 #include "G4PhysicalConstants.hh"
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
77 
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
81 
83 {
84  if(!fManager) {
85  static HistoManager manager;
86  fManager = &manager;
87  }
88  return fManager;
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
92 
94 : fPrimaryDef(nullptr),
95  fEdepMax(1.0*GeV),
96  fLength (300.*mm),
97  fPrimaryKineticEnergy(0.0),
98  fVerbose(0),
99  fNBinsE (100),
100  fNSlices(300),
101  fNHisto (25),
102  fBeamFlag(true),
103  fHistoBooked(false)
104 {
105  fHisto = new Histo();
106  fHisto->SetVerbose(fVerbose);
107  BookHisto();
109 }
110 
111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
112 
114 {
115  delete fHisto;
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
119 
121 {
122  fHistoBooked = true;
123  fHisto->Add1D("1","Energy deposition (MeV/mm/event) in the target",
124  fNSlices,0.0,fLength/mm,MeV/mm);
125  fHisto->Add1D("2","Log10 Energy (MeV) of gammas",fNBinsE,-5.,5.,1.0);
126  fHisto->Add1D("3","Log10 Energy (MeV) of electrons",fNBinsE,-5.,5.,1.0);
127  fHisto->Add1D("4","Log10 Energy (MeV) of positrons",fNBinsE,-5.,5.,1.0);
128  fHisto->Add1D("5","Log10 Energy (MeV) of protons",fNBinsE,-5.,5.,1.0);
129  fHisto->Add1D("6","Log10 Energy (MeV) of neutrons",fNBinsE,-5.,5.,1.0);
130  fHisto->Add1D("7","Log10 Energy (MeV) of charged pions",fNBinsE,-4.,6.,1.0);
131  fHisto->Add1D("8","Log10 Energy (MeV) of pi0",fNBinsE,-4.,6.,1.0);
132  fHisto->Add1D("9","Log10 Energy (MeV) of charged kaons",fNBinsE,-4.,6.,1.0);
133  fHisto->Add1D("10","Log10 Energy (MeV) of neutral kaons",fNBinsE,-4.,6.,1.0);
134  fHisto->Add1D("11","Log10 Energy (MeV) of deuterons and tritons",
135  fNBinsE,-5.,5.,1.0);
136  fHisto->Add1D("12","Log10 Energy (MeV) of He3 and alpha",fNBinsE,-5.,5.,1.0);
137  fHisto->Add1D("13","Log10 Energy (MeV) of Generic Ions",fNBinsE,-5.,5.,1.0);
138  fHisto->Add1D("14","Log10 Energy (MeV) of muons",fNBinsE,-4.,6.,1.0);
139  fHisto->Add1D("15","log10 Energy (MeV) of side-leaked neutrons",
140  fNBinsE,-5.,5.,1.0);
141  fHisto->Add1D("16","log10 Energy (MeV) of forward-leaked neutrons",
142  fNBinsE,-5.,5.,1.0);
143  fHisto->Add1D("17","log10 Energy (MeV) of backward-leaked neutrons",
144  fNBinsE,-5.,5.,1.0);
145  fHisto->Add1D("18","log10 Energy (MeV) of leaking protons",
146  fNBinsE,-4.,6.,1.0);
147  fHisto->Add1D("19","log10 Energy (MeV) of leaking charged pions",
148  fNBinsE,-4.,6.,1.0);
149  fHisto->Add1D("20","Log10 Energy (MeV) of pi+",fNBinsE,-4.,6.,1.0);
150  fHisto->Add1D("21","Log10 Energy (MeV) of pi-",fNBinsE,-4.,6.,1.0);
151  fHisto->Add1D("22",
152  "Energy deposition in the target normalized to beam energy",
153  110,0.0,1.1,1.0);
154  fHisto->Add1D("23",
155  "EM energy deposition in the target normalized to beam energy",
156  110,0.0,1.1,1.0);
157  fHisto->Add1D("24",
158  "Pion energy deposition in the target normalized to beam energy",
159  110,0.0,1.1,1.0);
160  fHisto->Add1D("25",
161  "Proton energy deposition in the target normalized to beam energy",
162  110,0.0,1.1,1.0);
163 }
164 
165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
166 
168 {
169  fAbsZ0 = -0.5*fLength;
170  fNevt = 0;
171  fNelec = 0;
172  fNposit = 0;
173  fNgam = 0;
174  fNstep = 0;
175  fNprot_leak = 0;
176  fNpiofNleak = 0;
177  fNions = 0;
178  fNdeut = 0;
179  fNalpha = 0;
180  fNkaons = 0;
181  fNmuons = 0;
182  fNcpions = 0;
183  fNpi0 = 0;
184  fNneutron = 0;
185  fNproton = 0;
186  fNaproton = 0;
187  fNneu_forw = 0;
188  fNneu_leak = 0;
189  fNneu_back = 0;
190 
191  fEdepSum = 0.0;
192  fEdepSum2 = 0.0;
193 
194  if(!fHistoBooked) { BookHisto(); }
195  fHisto->Book();
196 
197  if(fVerbose > 0) {
198  G4cout << "HistoManager: Histograms are booked and run has been started"
199  <<G4endl;
200  }
201 }
202 
203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
204 
206 {
207 
208  G4cout << "HistoManager: End of run actions are started" << G4endl;
209 
210  // Average values
211  G4cout<<"========================================================"<<G4endl;
212 
214  if(fNevt > 0) { x = 1.0/x; }
215 
216  G4double xe = x*(G4double)fNelec;
217  G4double xg = x*(G4double)fNgam;
218  G4double xp = x*(G4double)fNposit;
219  G4double xs = x*(G4double)fNstep;
220  G4double xn = x*(G4double)fNneutron;
221  G4double xpn = x*(G4double)fNproton;
222  G4double xap = x*(G4double)fNaproton;
223  G4double xnf = x*(G4double)fNneu_forw;
224  G4double xnb = x*(G4double)fNneu_leak;
225  G4double xnbw= x*(G4double)fNneu_back;
226  G4double xpl = x*(G4double)fNprot_leak;
227  G4double xal = x*(G4double)fNpiofNleak;
228  G4double xpc = x*(G4double)fNcpions;
229  G4double xp0 = x*(G4double)fNpi0;
230  G4double xpk = x*(G4double)fNkaons;
231  G4double xpm = x*(G4double)fNmuons;
232  G4double xid = x*(G4double)fNdeut;
233  G4double xia = x*(G4double)fNalpha;
234  G4double xio = x*(G4double)fNions;
235 
236  fEdepSum *= x;
237  fEdepSum2 *= x;
238  fEdepSum2 -= fEdepSum*fEdepSum;
239  if(fEdepSum2 > 0.0) { fEdepSum2 = std::sqrt(fEdepSum2); }
240  else { fEdepSum2 = 0.0; }
241 
242  G4cout << "Beam particle "
244  G4cout << "Beam Energy(MeV) "
246  G4cout << "Number of events "
247  << fNevt <<G4endl;
248  G4cout << std::setprecision(4) << "Average energy deposit (MeV) "
249  << fEdepSum/MeV
250  << " RMS(MeV) " << fEdepSum2/MeV << G4endl;
251  G4cout << std::setprecision(4) << "Average number of steps "
252  << xs << G4endl;
253  G4cout << std::setprecision(4) << "Average number of gamma "
254  << xg << G4endl;
255  G4cout << std::setprecision(4) << "Average number of e- "
256  << xe << G4endl;
257  G4cout << std::setprecision(4) << "Average number of e+ "
258  << xp << G4endl;
259  G4cout << std::setprecision(4) << "Average number of neutrons "
260  << xn << G4endl;
261  G4cout << std::setprecision(4) << "Average number of protons "
262  << xpn << G4endl;
263  G4cout << std::setprecision(4) << "Average number of antiprotons "
264  << xap << G4endl;
265  G4cout << std::setprecision(4) << "Average number of pi+ & pi- "
266  << xpc << G4endl;
267  G4cout << std::setprecision(4) << "Average number of pi0 "
268  << xp0 << G4endl;
269  G4cout << std::setprecision(4) << "Average number of kaons "
270  << xpk << G4endl;
271  G4cout << std::setprecision(4) << "Average number of muons "
272  << xpm << G4endl;
273  G4cout << std::setprecision(4) << "Average number of deuterons+tritons "
274  << xid << G4endl;
275  G4cout << std::setprecision(4) << "Average number of He3+alpha "
276  << xia << G4endl;
277  G4cout << std::setprecision(4) << "Average number of ions "
278  << xio << G4endl;
279  G4cout << std::setprecision(4) << "Average number of forward neutrons "
280  << xnf << G4endl;
281  G4cout << std::setprecision(4) << "Average number of reflected neutrons "
282  << xnb << G4endl;
283  G4cout << std::setprecision(4) << "Average number of leaked neutrons "
284  << xnbw << G4endl;
285  G4cout << std::setprecision(4) << "Average number of proton leak "
286  << xpl << G4endl;
287  G4cout << std::setprecision(4) << "Average number of pion leak "
288  << xal << G4endl;
289  G4cout<<"========================================================"<<G4endl;
290  G4cout<<G4endl;
291 
292  // normalise histograms
293  for(G4int i=0; i<fNHisto; i++) {
294  fHisto->ScaleH1(i,x);
295  }
296 
297  fHisto->Save();
298 }
299 
300 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
301 
303 {
304  fEdepEvt = 0.0;
305  fEdepEM = 0.0;
306  fEdepPI = 0.0;
307  fEdepP = 0.0;
308 }
309 
310 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
311 
313 {
314  fEdepSum += fEdepEvt;
316  fHisto->Fill(21,fEdepEvt/fPrimaryKineticEnergy,1.0);
317  fHisto->Fill(22,fEdepEM/fPrimaryKineticEnergy,1.0);
318  fHisto->Fill(23,fEdepPI/fPrimaryKineticEnergy,1.0);
319  fHisto->Fill(24,fEdepP/fPrimaryKineticEnergy,1.0);
320 }
321 
322 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
323 
325 {
326  const G4ParticleDefinition* pd = track->GetDefinition();
327  G4String name = pd->GetParticleName();
328  G4double e = track->GetKineticEnergy();
329 
330  // Primary track
331  if(0 == track->GetParentID()) {
332 
333  fNevt++;
335  fPrimaryDef = pd;
337  if(1 < fVerbose)
338  G4cout << "### Primary " << name
339  << " kinE(MeV)= " << e/MeV
340  << "; m(MeV)= " << pd->GetPDGMass()/MeV
341  << "; pos(mm)= " << track->GetPosition()/mm
342  << "; dir= " << track->GetMomentumDirection()
343  << G4endl;
344 
345  // Secondary track
346  } else {
347  if(1 < fVerbose)
348  G4cout << "=== Secondary " << name
349  << " kinE(MeV)= " << e/MeV
350  << "; m(MeV)= " << pd->GetPDGMass()/MeV
351  << "; pos(mm)= " << track->GetPosition()/mm
352  << "; dir= " << track->GetMomentumDirection()
353  << G4endl;
354  e = std::log10(e/MeV);
355  if(pd == G4Gamma::Gamma()) {
356  fNgam++;
357  fHisto->Fill(1,e,1.0);
358  } else if ( pd == G4Electron::Electron()) {
359  fNelec++;
360  fHisto->Fill(2,e,1.0);
361  } else if ( pd == G4Positron::Positron()) {
362  fNposit++;
363  fHisto->Fill(3,e,1.0);
364  } else if ( pd == G4Proton::Proton()) {
365  fNproton++;
366  fHisto->Fill(4,e,1.0);
367  } else if ( pd == fNeutron) {
368  fNneutron++;
369  fHisto->Fill(5,e,1.0);
370  } else if ( pd == G4AntiProton::AntiProton()) {
371  fNaproton++;
372  } else if ( pd == G4PionPlus::PionPlus() ) {
373  fNcpions++;
374  fHisto->Fill(6,e,1.0);
375  fHisto->Fill(19,e,1.0);
376 
377  } else if ( pd == G4PionMinus::PionMinus()) {
378  fNcpions++;
379  fHisto->Fill(6,e,1.0);
380  fHisto->Fill(20,e,1.0);
381 
382  } else if ( pd == G4PionZero::PionZero()) {
383  fNpi0++;
384  fHisto->Fill(7,e,1.0);
385  } else if ( pd == G4KaonPlus::KaonPlus() ||
386  pd == G4KaonMinus::KaonMinus()) {
387  fNkaons++;
388  fHisto->Fill(8,e,1.0);
389  } else if ( pd == G4KaonZeroShort::KaonZeroShort() ||
391  fNkaons++;
392  fHisto->Fill(9,e,1.0);
393  } else if ( pd == G4Deuteron::Deuteron() || pd == G4Triton::Triton()) {
394  fNdeut++;
395  fHisto->Fill(10,e,1.0);
396  } else if ( pd == G4He3::He3() || pd == G4Alpha::Alpha()) {
397  fNalpha++;
398  fHisto->Fill(11,e,1.0);
399  } else if ( pd->GetParticleType() == "nucleus") {
400  fNions++;
401  fHisto->Fill(12,e,1.0);
402  } else if ( pd == G4MuonPlus::MuonPlus() ||
403  pd == G4MuonMinus::MuonMinus()) {
404  fNmuons++;
405  fHisto->Fill(13,e,1.0);
406  }
407  }
408 }
409 
410 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
411 
413 {
414  fNstep++;
416  if(1 < fVerbose) {
417  G4cout << "TargetSD::ProcessHits: beta1= "
418  << step->GetPreStepPoint()->GetVelocity()/c_light
419  << " beta2= " << step->GetPostStepPoint()->GetVelocity()/c_light
420  << " weight= " << step->GetTrack()->GetWeight()
421  << G4endl;
422  }
423  if(fEdep >= DBL_MIN) {
424  const G4Track* track = step->GetTrack();
425 
426  G4ThreeVector pos =
427  (step->GetPreStepPoint()->GetPosition() +
428  step->GetPostStepPoint()->GetPosition())*0.5;
429 
430  G4double z = pos.z() - fAbsZ0;
431 
432  // scoring
433  fEdepEvt += fEdep;
434  fHisto->Fill(0,z,fEdep);
435  const G4ParticleDefinition* pd = track->GetDefinition();
436 
437  if(pd == G4Gamma::Gamma() || pd == G4Electron::Electron()
438  || pd == G4Positron::Positron()) {
439  fEdepEM += fEdep;
440  } else if ( pd == G4PionPlus::PionPlus() ||
441  pd == G4PionMinus::PionMinus()) {
442  fEdepPI += fEdep;
443  } else if ( pd == G4Proton::Proton() ||
444  pd == G4AntiProton::AntiProton()) {
445  fEdepP += fEdep;
446  }
447 
448  if(1 < fVerbose) {
449  G4cout << "HistoManager::AddEnergy: e(keV)= " << fEdep/keV
450  << "; z(mm)= " << z/mm
451  << "; step(mm)= " << step->GetStepLength()/mm
452  << " by " << pd->GetParticleName()
453  << " E(MeV)= " << track->GetKineticEnergy()/MeV
454  << G4endl;
455  }
456  }
457 }
458 
459 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
460 
462 {
463  const G4ParticleDefinition* pd = track->GetDefinition();
464  G4double e = std::log10(track->GetKineticEnergy()/MeV);
465 
466  G4ThreeVector pos = track->GetPosition();
467  G4ThreeVector dir = track->GetMomentumDirection();
468  G4double x = pos.x();
469  G4double y = pos.y();
470  G4double z = pos.z();
471 
472  G4bool isLeaking = false;
473 
474  // Forward
475  if(z > -fAbsZ0 && dir.z() > 0.0) {
476  isLeaking = true;
477  if(pd == fNeutron) {
478  ++fNneu_forw;
479  fHisto->Fill(15,e,1.0);
480  } else isLeaking = true;
481 
482  // Backward
483  } else if (z < fAbsZ0 && dir.z() < 0.0) {
484  isLeaking = true;
485  if(pd == fNeutron) {
486  ++fNneu_back;
487  fHisto->Fill(16,e,1.0);
488  } else isLeaking = true;
489 
490  // Side
491  } else if (std::abs(z) <= -fAbsZ0 && x*dir.x() + y*dir.y() > 0.0) {
492  isLeaking = true;
493  if(pd == fNeutron) {
494  ++fNneu_leak;
495  fHisto->Fill(14,e,1.0);
496  } else isLeaking = true;
497  }
498 
499  // protons and pions
500  if(isLeaking) {
501  if(pd == G4Proton::Proton()) {
502  fHisto->Fill(17,e,1.0);
503  ++fNprot_leak;
504  } else if (pd == G4PionPlus::PionPlus() ||
505  pd == G4PionMinus::PionMinus()) {
506  fHisto->Fill(18,e,1.0);
507  ++fNpiofNleak;
508  }
509  }
510 }
511 
512 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
513 
515 {
516  fVerbose = val;
517  fHisto->SetVerbose(val);
518 }
519 
520 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
521 
523 {
524  fHisto->Fill(id, x, w);
525 }
526 
527 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
528 
Float_t x
Definition: compare.C:6
static G4PionMinus * PionMinus()
Definition: G4PionMinus.cc:98
void Fill(G4int id, G4double x, G4double w)
static G4He3 * He3()
Definition: G4He3.cc:94
G4double GetKineticEnergy() const
const XML_Char * name
Definition: expat.h:151
static const G4double pos
static constexpr double MeV
Definition: G4SIunits.hh:214
G4StepPoint * GetPreStepPoint() const
static constexpr double keV
Definition: G4SIunits.hh:216
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
Float_t y
Definition: compare.C:6
Double_t z
static G4AntiProton * AntiProton()
Definition: G4AntiProton.cc:93
const G4String & GetParticleName() const
static G4PionPlus * PionPlus()
Definition: G4PionPlus.cc:98
const G4String & GetParticleType() const
double z() const
static G4MuonMinus * MuonMinus()
Definition: G4MuonMinus.cc:100
static G4Proton * Proton()
Definition: G4Proton.cc:93
static G4KaonMinus * KaonMinus()
Definition: G4KaonMinus.cc:113
G4ParticleDefinition * GetDefinition() const
G4double GetPDGMass() const
static G4KaonPlus * KaonPlus()
Definition: G4KaonPlus.cc:113
G4double GetVelocity() const
const G4ParticleDefinition * fPrimaryDef
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:94
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
G4double GetWeight() const
static G4KaonZeroLong * KaonZeroLong()
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4double GetStepLength() const
const G4ThreeVector & GetPosition() const
G4Track * GetTrack() const
const G4ThreeVector & GetPosition() const
static G4Alpha * Alpha()
Definition: G4Alpha.cc:89
G4double GetTotalEnergyDeposit() const
static G4Positron * Positron()
Definition: G4Positron.cc:94
Definition: G4Step.hh:76
G4StepPoint * GetPostStepPoint() const
static G4Electron * Electron()
Definition: G4Electron.cc:94
static G4KaonZeroShort * KaonZeroShort()
int G4int
Definition: G4Types.hh:78
static constexpr double c_light
static G4Triton * Triton()
Definition: G4Triton.cc:95
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
TDirectory * dir
#define DBL_MIN
Definition: templates.hh:75
static G4MuonPlus * MuonPlus()
Definition: G4MuonPlus.cc:99
G4GLOB_DLL std::ostream G4cout
double x() const
static G4PionZero * PionZero()
Definition: G4PionZero.cc:108
double y() const
const G4ThreeVector & GetMomentumDirection() const
const G4ParticleDefinition * fNeutron
static constexpr double GeV
Definition: G4SIunits.hh:217
G4int GetParentID() const