Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/medical/dna/spower/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 #include "Run.hh"
30 #include "DetectorConstruction.hh"
31 #include "PrimaryGeneratorAction.hh"
32 
33 #include "G4Material.hh"
34 #include "G4SystemOfUnits.hh"
35 #include "G4UnitsTable.hh"
36 
37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
38 
39 Run::Run(const DetectorConstruction* detector)
40 : G4Run(),
41  fDetector(detector),
42  fParticle(0), fEkin(0.),
43  fSP(0.), fSP2(0.)
44 {}
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
48 Run::~Run()
49 {}
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 {
55  fParticle = particle;
56  fEkin = energy;
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63  fSP += t;
64  fSP2 += t*t;
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
69 void Run::Merge(const G4Run* run)
70 {
71  const Run* localRun = static_cast<const Run*>(run);
72 
73  // pass information about primary particle
74  fParticle = localRun->fParticle;
75  fEkin = localRun->fEkin;
76 
77  // accumulate sums
78  fSP += localRun->fSP;
79  fSP2 += localRun->fSP2;
80 
81  G4Run::Merge(run);
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
86 void Run::EndOfRun()
87 {
88  std::ios::fmtflags mode = G4cout.flags();
89  G4cout.setf(std::ios::fixed,std::ios::floatfield);
90  G4int prec = G4cout.precision(2);
91 
92  //run conditions
93  //
94  G4Material* material = fDetector->GetAbsorMaterial();
95  G4double density = material->GetDensity();
96  G4String partName = fParticle->GetParticleName();
97 
98  G4cout << "\n ======================== run summary =====================\n";
99  G4cout
100  << "\n The run is " << numberOfEvent << " "<< partName << " of "
101  << G4BestUnit(fEkin,"Energy") << " through a sphere of radius "
102  << G4BestUnit(fDetector->GetAbsorRadius(),"Length") << "of "
103  << material->GetName() << " (density: "
104  << G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
105 
106  if (numberOfEvent == 0) {
107  G4cout.setf(mode,std::ios::floatfield);
108  G4cout.precision(prec);
109  return;
110  }
111 
112  //compute stopping power
113  //
115  G4double rms = fSP2 - fSP*fSP;
116 
117  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
118 
119  G4cout
120  << "\n total Stopping Power (keV/um) = "<< fSP/(keV/um)
121  << " +- " << rms/(keV/um)
122  << G4endl;
123 
124  //output file
125  //
126  FILE* myFile;
127  myFile=fopen("spower.txt","a");
128  fprintf(myFile,"%e %e %e \n",
129  fEkin/eV,
130  fSP/(keV/um),
131  rms/(keV/um));
132  fclose(myFile);
133 
134  //reset default formats
135  //
136  G4cout.setf(mode,std::ios::floatfield);
137  G4cout.precision(prec);
138 
139 }
static const double prec
Definition: RanecuEngine.cc:58
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
DetectorConstruction * fDetector
G4int numberOfEvent
Definition: G4Run.hh:59
void AddSP(G4double x)
static constexpr double keV
Definition: G4SIunits.hh:216
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
static constexpr double um
Definition: G4SIunits.hh:113
const G4String & GetName() const
Definition: G4Material.hh:179
fclose(fg1)
double G4double
Definition: G4Types.hh:76
double energy
Definition: plottest35.C:25
virtual void Merge(const G4Run *)
static constexpr double eV
Definition: G4SIunits.hh:215
Definition: G4Run.hh:46
G4ParticleDefinition * fParticle
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
Simple detector construction with a box volume placed in a world.
G4double GetDensity() const
Definition: G4Material.hh:181