Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/exoticphysics/dmparticle/src/Run.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$
30 
31 #include "Run.hh"
32 #include "G4Step.hh"
33 #include "G4Run.hh"
34 #include "G4LossTableManager.hh"
35 #include "G4ElectronIonPair.hh"
36 #include "G4SystemOfUnits.hh"
37 #include "G4PhysicalConstants.hh"
38 #include "TestParameters.hh"
39 #include "Randomize.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
43 Run::Run()
44  : G4Run(), fParam(TestParameters::GetPointer())
45 {
47  fEvt = fNbins = 0;
48 }
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
52 Run::~Run()
53 {}
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
57 void Run::BeginOfRun()
58 {
59  // initilise scoring
61  fEvt = 0;
62 
63  SetVerbose(1);
64 
67 
68  fEgas.resize(fNbins,0.0);
69  fEdep.reset();
70 
71  if(fVerbose > 0)
72  {
73  G4cout << " BinsE= " << fNbins
74  << " Emax(keV)= " << fMaxEnergy/keV << G4endl;
75  }
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
80 void Run::EndOfRun()
81 {
82  G4int nEvt = GetNumberOfEvent();
83 
84  G4double norm = (nEvt > 0) ? 1.0/(G4double)nEvt : 0.0;
85 
86  fTotStepGas *= norm;
87  fOverflow *= norm;
88 
89  G4double y1 = fEdep.mean();
90  G4double y2 = fEdep.rms();
91 
92  //G4double de = fMaxEnergy/G4double(fNbins);
93  //G4double x1 = -de*0.5;
94 
95  G4cout << " ====================================================" << G4endl;
96  G4cout << " Beam Particle: "
97  << fParam->GetBeamParticle()->GetParticleName() << G4endl
98  << " Ekin(GeV) = " << fParam->GetBeamEnergy()/GeV
99  << G4endl
100  << " Z(mm) = " << fParam->GetPositionZ()/mm
101  << G4endl;
102  G4cout << " ================== run summary =====================" << G4endl;
103  G4int prec = G4cout.precision(5);
104  G4cout << " End of Run TotNbofEvents = "
105  << nEvt << G4endl;
106 
107  G4cout << G4endl;
108  G4cout << " Mean energy deposit in absorber = " <<
109  y1/GeV << " +- " << y2*std::sqrt(norm)/GeV << " GeV; ";
110  if(y1 > 0.0) { G4cout << " RMS/Emean = " << y2/y1; }
111  G4cout << G4endl;
112  G4cout << " Mean number of steps in absorber= "
113  << fTotStepGas
114  << G4endl;
115  G4cout << G4endl;
116  /*
117  G4cout << " ====== Energy deposit distribution Noverflows= " << fOverflow
118  << " ====== " << G4endl ;
119  G4cout << " bin nb Elow entries normalized " << G4endl;
120 
121  x1 = 0.0;
122 
123  for(G4int j=0; j<fNbins; ++j)
124  {
125  G4cout << std::setw(5) << j << std::setw(10) << x1/keV
126  << std::setw(12) << fEgas[j] << std::setw(12) << fEgas[j]*norm
127  << G4endl ;
128  x1 += de;
129  }
130  */
131  G4cout.precision(prec);
132 
133  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
134 
135  // normalize histograms
136 
137  analysisManager->ScaleH1(1,norm);
138 
139  G4cout << " ================== run end ==========================" << G4endl;
140 }
141 
142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143 
144 void Run::BeginOfEvent()
145 {
146  fTotEdep = 0.0;
147  fStepGas = 0;
148  ++fEvt;
149 }
150 
151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152 
153 void Run::EndOfEvent()
154 {
155  /*
156  G4cout << "fStepGas = " << fStepGas << " fTotStepGas= " << fTotStepGas
157  << " fTotEdep= " << fTotEdep << " fNbins= " << fNbins
158  << " fMaxEnergy= " << fMaxEnergy << G4endl;
159  */
161 
163 
164  if(idx < 0) { fEgas[0] += 1.0; }
165  if(idx >= fNbins) { fOverflow += 1.0; }
166  else { fEgas[idx] += 1.0; }
167 
168  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
169 
170  // fill histo
171 
172  analysisManager->FillH1(1,fTotEdep/GeV,1.0);
173  fEdep.fill(fTotEdep, 1.0);
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
177 //
178 // Allows one to accumulate data from different threads
179 
180 void Run::Merge( const G4Run* run )
181 {
182  const Run* localRun = static_cast<const Run*>(run);
183 
184  fTotStepGas += localRun->fTotStepGas;
185  fOverflow += localRun->fOverflow;
186 
187  G4StatDouble* stat = const_cast<G4StatDouble*>(localRun->GetStat());
188 
189  fEdep.add(stat);
190 
191  for( G4int j = 0; j < fNbins; ++j )
192  {
193  fEgas[j] += localRun->fEgas[j];
194  }
195 
196  G4Run::Merge(run);
197 }
198 
199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
200 //
201 // Is called from TargetSD
202 
203 void Run::AddEnergy( G4double edep, const G4Step* step )
204 {
205  if( 1 < fVerbose )
206  {
207  G4cout << "Run::AddEnergy: e(keV)= " << edep/keV
208  << G4endl;
209  }
210  fTotEdep += edep;
211 
212  if( step )
213  {
214  if( 1 == step->GetTrack()->GetTrackID())
215  {
216  fStepGas += 1.0;
217  }
218  }
219 }
220 
221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
222 
const G4ParticleDefinition * GetBeamParticle() const
static const double prec
Definition: RanecuEngine.cc:58
Float_t y1[n_points_granero]
Definition: compare.C:5
static constexpr double keV
Definition: G4SIunits.hh:216
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
G4int GetTrackID() const
Float_t y2[n_points_geant4]
Definition: compare.C:26
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
Definition: G4Step.hh:76
Double_t edep
Definition: G4Run.hh:46
int G4lrint(double ad)
Definition: templates.hh:151
const G4StatDouble * GetStat() const
int G4int
Definition: G4Types.hh:78
Float_t norm
G4GLOB_DLL std::ostream G4cout
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
static constexpr double GeV
Definition: G4SIunits.hh:217