Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/exoticphysics/monopole/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 71376 2013-06-14 07:44:50Z maire $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "Run.hh"
35 #include "PrimaryGeneratorAction.hh"
36 #include "DetectorConstruction.hh"
37 #include "G4EmCalculator.hh"
38 #include "G4SystemOfUnits.hh"
39 #include "G4UnitsTable.hh"
40 #include <iomanip>
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45  :fDetector(det), fPrimary(prim)
46 {
47  fAnalysisManager = G4AnalysisManager::Instance();
48 
49  G4double length = fDetector->GetAbsorSizeX();
50  fOffsetX = -0.5 * length;
51 
52  fVerboseLevel = 1;
53  fNevt = 0;
54  fProjRange = fProjRange2 = 0.;
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
59 Run::~Run()
60 {}
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
64 void Run::Merge(const G4Run* run)
65 {
66  const Run* localRun = static_cast<const Run*>(run);
67 
68  fNevt += localRun->GetNumberOfEvent();
69  fProjRange += localRun->fProjRange;
70  fProjRange2 += localRun->fProjRange2;
71 
72  G4Run::Merge(run);
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
77 void Run::EndOfRun(double binLength)
78 {
79 
80 #ifndef G4MULTITHREADED
81  fNevt += this->GetNumberOfEvent();
82 #endif
83 
84  G4int nEvents = fNevt;
85  if (nEvents == 0) { return; }
86 
87  //run conditions
88  //
89  const G4Material* material = fDetector->GetAbsorMaterial();
90  G4double density = material->GetDensity();
91  G4String matName = material->GetName();
92  const G4ParticleDefinition* part =
94  G4String particle = part->GetParticleName();
96 
97  if(GetVerbose() > 0){
98  G4cout << "\n The run consists of " << nEvents << " "<< particle << " of "
99  << G4BestUnit(energy,"Energy") << " through "
100  << G4BestUnit(fDetector->GetAbsorSizeX(),"Length") << " of "
101  << matName << " (density: "
102  << G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
103  //G4cout<<"Proj "<<fProjRange<<" "<<fProjRange2<<G4endl;
104  };
105 
106  //compute projected range and straggling
107 
108  fProjRange /= nEvents; fProjRange2 /= nEvents;
110  if (rms>0.) { rms = std::sqrt(rms); }
111  else { rms = 0.; }
112 
113  if(GetVerbose() > 0){
114  G4cout.precision(5);
115  G4cout << " Projected Range= " << G4BestUnit(fProjRange, "Length")
116  << " rms= " << G4BestUnit(rms, "Length")
117  << "\n" << G4endl;
118  };
119 
120  G4double ekin[100], dedxproton[100], dedxmp[100];
121  G4EmCalculator calc;
122  //calc.SetVerbose(2);
123  G4int i;
124  for(i = 0; i < 100; ++i) {
125  ekin[i] = std::pow(10., 0.1*G4double(i)) * keV;
126  dedxproton[i] =
127  calc.ComputeElectronicDEDX(ekin[i], "proton", matName);
128  dedxmp[i] =
129  calc.ComputeElectronicDEDX(ekin[i], "monopole", matName);
130  }
131 
132  if(GetVerbose() > 0){
133  G4cout << "### Stopping Powers" << G4endl;
134  for(i=0; i<100; ++i) {
135  G4cout << " E(MeV)= " << ekin[i] << " dedxp(MeV/mm)= " << dedxproton[i]
136  << " dedxmp(MeV/mm)= " << dedxmp[i]
137  << G4endl;
138  }
139  }
140  G4cout << "### End of stopping power table" << G4endl;
141 
142  // normalize histogram
143  G4double fac = (mm/MeV) / (nEvents * binLength);
144  fAnalysisManager->ScaleH1(1,fac);
145 
146  if(GetVerbose() > 0){
147  G4cout << "Range table for " << matName << G4endl;
148  }
149 
150  for(i=0; i<100; ++i) {
151  G4double e = std::log10(ekin[i] / MeV) + 0.05;
152  fAnalysisManager->FillH1(2, e, dedxproton[i]);
153  fAnalysisManager->FillH1(3, e, dedxmp[i]);
154  fAnalysisManager->FillH1(4, e,
155  std::log10(calc.GetRange(ekin[i],"proton",matName)/mm));
156  fAnalysisManager->FillH1(5, e,
157  std::log10(calc.GetRange(ekin[i],"monopole",matName)/mm));
158  }
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162 
163 
164 void Run::FillHisto(G4int histoId, G4double v1, G4double v2)
165 {
166  fAnalysisManager->FillH1(histoId, v1, v2);
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction * fPrimary
DetectorConstruction * fDetector
static constexpr double MeV
Definition: G4SIunits.hh:214
static constexpr double keV
Definition: G4SIunits.hh:216
static constexpr double mm
Definition: G4SIunits.hh:115
G4AnalysisManager * fAnalysisManager
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
G4double ComputeElectronicDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *mat, G4double cut=DBL_MAX)
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
const G4String & GetName() const
Definition: G4Material.hh:179
void FillHisto(G4int id, G4double x, G4double weight=1.0)
double G4double
Definition: G4Types.hh:76
TString part[npart]
Definition: Style.C:32
double energy
Definition: plottest35.C:25
virtual void Merge(const G4Run *)
The primary generator action class with particle gun.
Definition: G4Run.hh:46
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4double GetParticleEnergy() const
static const G4double fac
G4GLOB_DLL std::ostream G4cout
G4double GetRange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
G4ParticleDefinition * GetParticleDefinition() const
Simple detector construction with a box volume placed in a world.
G4double GetDensity() const
Definition: G4Material.hh:181