Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/electromagnetic/TestEm8/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: Run.cc 75577 2013-11-04 12:03:26Z vnivanch $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "Run.hh"
35 #include "G4Step.hh"
36 #include "G4Run.hh"
37 #include "G4LossTableManager.hh"
38 #include "G4ElectronIonPair.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4PhysicalConstants.hh"
41 #include "TestParameters.hh"
42 #include "Randomize.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
46 Run::Run()
47  : G4Run(), fElIonPair(0), fParam(TestParameters::GetPointer())
48 {
51  = fStepGas = fCluster = fMaxEnergy = 0.0;
52  fEvt = fNbins = 0;
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
59 Run::~Run()
60 {}
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {
66  // initilise scoring
68  = fStepGas = fCluster = 0.0;
69  fEvt = 0;
70 
73 
74  SetVerbose(1);
75 
78 
79  fEgas.resize(fNbins,0.0);
80  fEdep.reset();
81 
82  if(fVerbose > 0) {
83  G4int binsCluster = fParam->GetNumberBinsCluster();
84  G4cout << " BinsCluster= " << binsCluster << " BinsE= " << fNbins
85  << " Emax(keV)= " << fMaxEnergy/keV << G4endl;
86  G4cout << " WidthALICE(keV)= " << fWidthALICE/keV
87  << " FactorALICE= " << fFactorALICE << G4endl;
88 
89  }
90 }
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 
94 void Run::EndOfRun()
95 {
96  G4int nEvt = GetNumberOfEvent();
97  G4double norm = (nEvt > 0) ? 1.0/(G4double)nEvt : 0.0;
98 
99  fTotStepGas *= norm;
100  fTotCluster *= norm;
101  fMeanCluster *= norm;
102  fOverflow *= norm;
103 
104  G4double y1 = fEdep.mean();
105  G4double y2 = fEdep.rms();
106 
108  G4double x1 = -de*0.5;
109 
111 
112  G4cout << " ====================================================" << G4endl;
113  G4cout << " Beam Particle: "
114  << fParam->GetBeamParticle()->GetParticleName() << G4endl
115  << " Ekin(MeV) = " << fParam->GetBeamEnergy()/MeV
116  << G4endl
117  << " Z(mm) = " << fParam->GetPositionZ()/mm
118  << G4endl;
119  G4cout << " ================== run summary =====================" << G4endl;
120  G4int prec = G4cout.precision(5);
121  G4cout << " End of Run TotNbofEvents = "
122  << nEvt << G4endl;
123  G4cout << " Energy(keV) per ADC channel = "
124  << 1.0/(keV*fFactorALICE) << G4endl;
125 
126  G4cout << G4endl;
127  G4cout << " Mean energy deposit in absorber = " <<
128  y1/keV << " +- " << y2*std::sqrt(norm)/keV << " keV; ";
129  if(y1 > 0.0) { G4cout << " RMS/Emean = " << y2/y1; }
130  G4cout << G4endl;
131  G4cout << " Mean number of steps in absorber= "
132  << fTotStepGas << "; mean number of ion-clusters = "
133  << fTotCluster << " MeanCluster= " << fMeanCluster
134  << G4endl;
135  G4cout << G4endl;
136 
137  G4cout << " ====== Energy deposit distribution Noverflows= " << fOverflow
138  << " ====== " << G4endl ;
139  G4cout << " bin nb Elow entries normalized " << G4endl;
140 
141  std::ofstream fileOut("distribution.out", std::ios::out );
142  fileOut.setf( std::ios::scientific, std::ios::floatfield );
143 
144  x1 = 0.0;
145 
146  fileOut << fNbins << G4endl;
147 
148  for(G4int j=0; j<fNbins; ++j)
149  {
150  G4cout << std::setw(5) << j << std::setw(10) << x1/keV
151  << std::setw(12) << fEgas[j] << std::setw(12) << fEgas[j]*norm
152  << G4endl ;
153  fileOut << x1/keV << "\t" << fEgas[j] << G4endl;
154  x1 += de;
155  }
156  G4cout.precision(prec);
157 
158  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
159  // normalize histograms
160  G4double normf = fParam->GetNormFactor();
161  analysisManager->ScaleH1(1,norm);
162  analysisManager->ScaleH1(2,norm);
163  analysisManager->ScaleH1(3,norm*normf);
164 
165  G4cout << " ================== run end ==========================" << G4endl;
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169 
171 {
172  fTotEdep = 0.0;
173  fStepGas = 0;
174  fCluster = 0;
175  ++fEvt;
176 }
177 
178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
179 
181 {
184 
185  if(fWidthALICE > 0.0) {
187  fTotEdep += x;
188  fTotEdep = std::max(fTotEdep, 0.0);
189  }
190 
191  G4int idx = G4int(fTotEdep*fNbins/fMaxEnergy);
192 
193  if(idx < 0) { fEgas[0] += 1.0; }
194  if(idx >= fNbins) { fOverflow += 1.0; }
195  else { fEgas[idx] += 1.0; }
196 
197  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
198  // fill histo
199  analysisManager->FillH1(1,fTotEdep/keV,1.0);
200  analysisManager->FillH1(2,fCluster,1.0);
201  analysisManager->FillH1(3,fTotEdep*fFactorALICE,1.0);
202  fEdep.fill(fTotEdep, 1.0);
203 }
204 
205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
206 
207 void Run::Merge(const G4Run* run)
208 {
209  const Run* localRun = static_cast<const Run*>(run);
210 
211  fTotStepGas += localRun->fTotStepGas;
212  fTotCluster += localRun->fTotCluster;
213  fMeanCluster += localRun->fMeanCluster;
214  fOverflow += localRun->fOverflow;
215 
216  G4StatDouble* stat = const_cast<G4StatDouble*>(localRun->GetStat());
217 
218  fEdep.add(stat);
219 
220  for(G4int j=0; j<fNbins; ++j)
221  {
222  fEgas[j] += localRun->fEgas[j];
223  }
224 
225  G4Run::Merge(run);
226 }
227 
228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
229 
230 void Run::AddEnergy(G4double edep, const G4Step* step)
231 {
232  if(1 < fVerbose) {
233  G4cout << "Run::AddEnergy: e(keV)= " << edep/keV
234  << G4endl;
235  }
236  fTotEdep += edep;
237  if(step) {
238  if(1 == step->GetTrack()->GetTrackID()) { fStepGas += 1.0; }
239 
242  }
243 }
244 
245 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Float_t x
Definition: compare.C:6
T max(const T t1, const T t2)
brief Return the largest of the two arguments
const G4ParticleDefinition * GetBeamParticle() const
static const double prec
Definition: RanecuEngine.cc:58
static constexpr double MeV
Definition: G4SIunits.hh:214
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
Float_t x1[n_points_granero]
Definition: compare.C:5
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
G4int SampleNumberOfIonsAlongStep(const G4Step *)
G4int GetTrackID() const
Float_t y2[n_points_geant4]
Definition: compare.C:26
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
G4ElectronIonPair * ElectronIonPair()
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
ThreeVector shoot(const G4int Ap, const G4int Af)
Double_t edep
Definition: G4Run.hh:46
const G4StatDouble * GetStat() const
int G4int
Definition: G4Types.hh:78
Float_t norm
G4GLOB_DLL std::ostream G4cout
static G4LossTableManager * Instance()
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
G4double MeanNumberOfIonsAlongStep(const G4ParticleDefinition *, const G4Material *, G4double edepTotal, G4double edepNIEL=0.0)