Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/electromagnetic/TestEm2/src/RunAction.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: RunAction.cc 109103 2018-03-27 07:39:04Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "RunAction.hh"
35 
36 #include "DetectorConstruction.hh"
37 #include "PrimaryGeneratorAction.hh"
38 #include "RunActionMessenger.hh"
39 #include "Run.hh"
40 #include "EmAcceptance.hh"
41 
42 #include "G4Run.hh"
43 #include "G4RunManager.hh"
44 #include "G4SystemOfUnits.hh"
45 
46 #include "Randomize.hh"
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
51  :G4UserRunAction(),
52  fDet(det),fKin(kin),fAnalysisManager(nullptr),fRun(nullptr),
53  fVerbose(0), fEdeptrue(1.), fRmstrue(1.), fLimittrue(DBL_MAX)
54 {
56  fHistoName[0] = "testem2";
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63  delete fRunMessenger;
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69 {
70  // Create analysis manager
71  // The choice of analysis technology is done via selection of a namespace
72  //
73 
74  fAnalysisManager = G4AnalysisManager::Instance();
75 
76  // Open an output file
77  //
79 
80  fAnalysisManager->OpenFile(fHistoName[0]);
81 
82  fAnalysisManager->SetVerboseLevel(1);
83  G4String extension = fAnalysisManager->GetFileType();
84  fHistoName[1] = fHistoName[0] + "." + extension;
85 
86  // Creating histograms
87  //
89  G4int nLbin = fDet->GetnLtot();
90  G4int nRbin = fDet->GetnRtot();
91  G4double dLradl = fDet->GetdLradl();
92  G4double dRradl = fDet->GetdRradl();
93 
94  fAnalysisManager->SetFirstHistoId(1);
95  fAnalysisManager->CreateH1( "h1","total energy deposit(percent of Einc)",
96  110,0.,110.);
97 
98  fAnalysisManager->CreateH1( "h2","total charged tracklength (radl)",
99  110,0.,110.*Ekin/GeV);
100 
101  fAnalysisManager->CreateH1( "h3","total neutral tracklength (radl)",
102  110,0.,1100.*Ekin/GeV);
103 
104  fAnalysisManager->CreateH1( "h4","longit energy profile (% of E inc)",
105  nLbin,0.,nLbin*dLradl);
106 
107  fAnalysisManager->CreateP1( "p4","longit energy profile (% of E inc)",
108  nLbin,0.,nLbin*dLradl, 0., 1000.);
109 
110  fAnalysisManager->CreateH1( "h5","rms on longit Edep (% of E inc)",
111  nLbin,0.,nLbin*dLradl);
112 
113  G4double Zmin=0.5*dLradl, Zmax=Zmin+nLbin*dLradl;
114  fAnalysisManager->CreateH1( "h6","cumul longit energy dep (% of E inc)",
115  nLbin,Zmin,Zmax);
116 
117  fAnalysisManager->CreateH1( "h7","rms on cumul longit Edep (% of E inc)",
118  nLbin,Zmin,Zmax);
119 
120  fAnalysisManager->CreateH1( "h8","radial energy profile (% of E inc)",
121  nRbin,0.,nRbin*dRradl);
122 
123  fAnalysisManager->CreateP1( "p8","radial energy profile (% of E inc)",
124  nRbin,0.,nRbin*dRradl, 0., 1000.);
125 
126  fAnalysisManager->CreateH1( "h9","rms on radial Edep (% of E inc)",
127  nRbin,0.,nRbin*dRradl);
128 
129  G4double Rmin=0.5*dRradl, Rmax=Rmin+nRbin*dRradl;
130  fAnalysisManager->CreateH1("h10","cumul radial energy dep (% of E inc)",
131  nRbin,Rmin,Rmax);
132 
133  fAnalysisManager->CreateH1("h11","rms on cumul radial Edep (% of E inc)",
134  nRbin,Rmin,Rmax);
135 
136  G4cout << "\n----> Histogram file is opened in " << fHistoName[1] << G4endl;
137 }
138 
139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
140 
142 {
143  fHistoName[0] = val;
144 }
145 
146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147 
149 {
150  fRun = new Run(fDet, fKin);
152  return fRun;
153 }
154 
155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
156 
158 {
159  // show Rndm status
160  if (isMaster) G4Random::showEngineStatus();
161 
162  //histograms
163  //
164  BookHisto();
165 }
166 
167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168 
169 void RunAction::EndOfRunAction(const G4Run*)
170 {
171  //compute and print statistic
172  //
174 
175  // show Rndm status
176  if (isMaster) G4Random::showEngineStatus();
177 
178  // save histos and close analysis
179  fAnalysisManager->Write();
180  fAnalysisManager->CloseFile();
181 }
182 
183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
184 
186 {
187  fEdeptrue = Value(0);
188  fRmstrue = Value(1);
189  fLimittrue= Value(2);
190 }
191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
192 
194 {
195  fVerbose = val;
196  if (fRun) fRun->SetVerbose(val);
197 }
198 
199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#define G4endl
Definition: G4ios.hh:61
int Zmin
int Zmax
double G4double
Definition: G4Types.hh:76
The primary generator action class with particle gun.
Definition: G4Run.hh:46
int G4int
Definition: G4Types.hh:78
G4double GetParticleEnergy() const
G4GLOB_DLL std::ostream G4cout
#define DBL_MAX
Definition: templates.hh:83
static constexpr double GeV
Definition: G4SIunits.hh:217
Simple detector construction with a box volume placed in a world.