Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
exMPI02/src/Analysis.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 //
26 // $Id: Analysis.cc 88353 2015-02-16 08:54:08Z gcosmo $
27 //
30 
31 #include "TFile.h"
32 #include "TH1.h"
33 #include "TH2.h"
34 #include "TROOT.h"
35 #include "G4SystemOfUnits.hh"
36 #include "Analysis.hh"
37 #include "G4AutoLock.hh"
38 
41 
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 {
47  if ( ! the_analysis ) the_analysis = new Analysis;
48  return the_analysis;
49 }
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 {
54  G4AutoLock l(&rootm);
55  // define histograms
56  fincident_map = new TH2D("incident map", "Incident Distributuon",
57  50, -5., 5.,
58  50, -5., 5.);
59  fincident_map-> GetXaxis()-> SetTitle("X (cm)");
60  fincident_map-> GetYaxis()-> SetTitle("Y (cm)");
62 
63  fincident_x_hist = new TH1D("incident x", "Incident X", 100, -5., 5.);
64  fincident_x_hist-> GetXaxis()-> SetTitle("X (cm)");
66 
67  fdose_map = new TH2D("dose map", "Dose Distribution",
68  500, 0., 50.,
69  200, -10., 10.);
70  fdose_map-> GetXaxis()-> SetTitle("Z (cm)");
71  fdose_map-> GetYaxis()-> SetTitle("X (cm)");
72  fdose_map-> SetStats(0);
73 
74  fdose_hist = new TH1D("dose", "Dose Distribution", 500, 0., 50.);
75  fdose_hist-> GetXaxis()-> SetTitle("Z (cm)");
76  fdose_hist-> GetYaxis()-> SetTitle("Dose (GeV)");
77  fdose_hist-> SetFillColor(kBlue);
78  fdose_hist-> SetStats(0);
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 {
84  delete fincident_map;
85  delete fincident_x_hist;
86  delete fdose_map;
87  delete fdose_hist;
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 {
93  return;
94 }
95 
96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 {
99  fincident_map-> Reset();
101  fdose_map-> Reset();
102  fdose_hist-> Reset();
103 
104  return;
105 }
106 
107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 void Analysis::Save(const G4String& fname)
109 {
110  G4AutoLock l(&rootm);
111  TFile* file = new TFile(fname.c_str(), "RECREATE", "Geant4 ROOT analysis");
112 
113  fincident_map-> Write();
114  fincident_x_hist-> Write();
115  fdose_map-> Write();
116  fdose_hist-> Write();
117 
118  file-> Close();
119 
120  delete file;
121 
122  return;
123 }
124 
125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127 {
128  if ( ! fincidentFlag ) {
129  fincident_map-> Fill(p.x()/cm, p.y()/cm);
130  fincident_x_hist-> Fill(p.x()/cm);
131 
132  fincidentFlag = true;
133  }
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138 {
139  const G4double Z0 = 25.*cm;
140  const G4double dxy = 10.*mm;
141 
142  if ( std::abs(p.y()) < dxy ) {
143  fdose_map-> Fill((p.z()+Z0)/cm, p.x()/cm, dedx/GeV);
144 
145  if ( std::abs(p.x()) < dxy ) {
146  fdose_hist-> Fill((p.z()+Z0)/cm, dedx/GeV);
147  }
148  }
149 }
ntupleExperimental Fill(depthExp, EdepExp)
G4Mutex rootm
static constexpr double mm
Definition: G4SIunits.hh:115
const char * p
Definition: xmltok.h:285
gr1 GetXaxis() -> SetTitle("Distance from the centre (cm)")
double z() const
leg SetFillColor(0)
gr1 SetTitle("Dose rate distribution")
#define G4ThreadLocal
Definition: tls.hh:69
void FillIncident(const G4ThreeVector &p)
double G4double
Definition: G4Types.hh:76
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:88
void Save(const G4String &fname)
ntupleExperimental Reset()
G4ThreadLocal Analysis * the_analysis
gr1 GetYaxis() -> SetTitle("Normalised dose rate distribution")
static Analysis * GetAnalysis()
void FillDose(const G4ThreeVector &p, G4double dedx)
int G4int
Definition: G4Types.hh:78
TFile * file
static constexpr double cm
Definition: G4SIunits.hh:119
double x() const
double y() const
h1 SetStats(kFALSE)
static constexpr double GeV
Definition: G4SIunits.hh:217
std::mutex G4Mutex
Definition: G4Threading.hh:84