Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/medical/dna/svalue/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 "HistoManager.hh"
32 #include "PrimaryGeneratorAction.hh"
33 
34 #include "G4Material.hh"
35 #include "G4SystemOfUnits.hh"
36 #include "G4UnitsTable.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
40 Run::Run(const DetectorConstruction* detector)
41 : G4Run(),
42  fDetector(detector),
43  fParticle(0), fEkin(0.),
44  fEdeposit(0.), fEdeposit2(0.),
45  fTrackLen(0.), fTrackLen2(0.),
46  fProjRange(0.), fProjRange2(0.),
47  fNbOfSteps(0), fNbOfSteps2(0),
48  fStepSize(0.), fStepSize2(0.)
49 {}
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
53 Run::~Run()
54 {}
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 {
60  fParticle = particle;
61  fEkin = energy;
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
66 void Run::AddEdep (G4double e)
67 {
68  fEdeposit += e;
69  fEdeposit2 += e*e;
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {
76  fTrackLen += t;
77  fTrackLen2 += t*t;
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
83 {
84  fProjRange += x;
85  fProjRange2 += x*x;
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
90 void Run::AddStepSize (G4int nb, G4double st)
91 {
92  fNbOfSteps += nb;
93  fNbOfSteps2 += nb*nb;
94  fStepSize += st ;
95  fStepSize2 += st*st;
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
100 void Run::Merge(const G4Run* run)
101 {
102  const Run* localRun = static_cast<const Run*>(run);
103 
104  // pass information about primary particle
105  fParticle = localRun->fParticle;
106  fEkin = localRun->fEkin;
107 
108  // accumulate sums
109  fEdeposit += localRun->fEdeposit;
110  fEdeposit2 += localRun->fEdeposit2;
111  fTrackLen += localRun->fTrackLen;
112  fTrackLen2 += localRun->fTrackLen2;
113  fProjRange += localRun->fProjRange;
114  fProjRange2 += localRun->fProjRange2;
115  fNbOfSteps += localRun->fNbOfSteps ;
116  fNbOfSteps2 += localRun->fNbOfSteps2;
117  fStepSize += localRun->fStepSize;
118  fStepSize2 += localRun->fStepSize2;
119 
120  G4Run::Merge(run);
121 }
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
124 
125 void Run::EndOfRun()
126 {
127  std::ios::fmtflags mode = G4cout.flags();
128  G4cout.setf(std::ios::fixed,std::ios::floatfield);
129  G4int prec = G4cout.precision(2);
130 
131  //run conditions
132  //
133  G4Material* material = fDetector->GetAbsorMaterial();
134  G4double density = material->GetDensity();
135  G4String partName = fParticle->GetParticleName();
136 
137  G4cout << "\n ======================== run summary =====================\n";
138  G4cout
139  << "\n The run is " << numberOfEvent << " "<< partName << " of "
140  << G4BestUnit(fEkin,"Energy") << " through a sphere of radius "
141  << G4BestUnit(fDetector->GetAbsorRadius(),"Length") << "of "
142  << material->GetName() << " (density: "
143  << G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
144 
145  if (numberOfEvent == 0) {
146  G4cout.setf(mode,std::ios::floatfield);
147  G4cout.precision(prec);
148  return;
149  }
150 
153  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
154 
155  G4cout.precision(3);
156  G4cout
157  << "\n Total Energy deposited = " << G4BestUnit(fEdeposit,"Energy")
158  << " +- " << G4BestUnit( rms,"Energy")
159  << G4endl;
160 
161  G4double sValue=fEdeposit/fDetector->GetAbsorMass();
162  G4double rmsSValue=rms/fDetector->GetAbsorMass();
163 
164  G4cout.precision(3);
165  G4cout
166  << "\n S value = " << sValue/gray << " Gy/Bq.s "
167  << " +- " << rmsSValue/gray
168  << " Gy/Bq.s "
169  << G4endl;
170 
171  //compute track length of primary track
172  //
174  rms = fTrackLen2 - fTrackLen*fTrackLen;
175  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
176 
177  G4cout.precision(3);
178  G4cout
179  << "\n Track length of primary track = " << G4BestUnit(fTrackLen,"Length")
180  << " +- " << G4BestUnit( rms,"Length");
181 
182  //compute projected range of primary track
183  //
186  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
187 
188  G4cout
189  << "\n Projected range = " << G4BestUnit(fProjRange,"Length")
190  << " +- " << G4BestUnit( rms,"Length")
191  << G4endl;
192 
193  //nb of steps and step size of primary track
194  //
195  G4double dNofEvents = double(numberOfEvent);
196  G4double fNbSteps = fNbOfSteps/dNofEvents,
197  fNbSteps2 = fNbOfSteps2/dNofEvents;
198  rms = fNbSteps2 - fNbSteps*fNbSteps;
199  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
200 
201  G4cout.precision(2);
202  G4cout << "\n Nb of steps of primary track = " << fNbSteps << " +- " << rms
203  << G4endl;
204 
206  rms = fStepSize2 - fStepSize*fStepSize;
207  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
208 
209  G4cout.precision(3);
210  G4cout
211  << "\n Step size = " << G4BestUnit(fStepSize,"Length")
212  << " +- " << G4BestUnit( rms,"Length")
213  << G4endl;
214 
215  // normalize histograms of longitudinal energy profile
216  //
217  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
218  G4int ih = 1;
219  G4double binWidth = analysisManager->GetH1Width(ih);
220  G4double fac = (1./(numberOfEvent*binWidth))*(mm/MeV);
221  analysisManager->ScaleH1(ih,fac);
222 
223  // reset default formats
224  G4cout.setf(mode,std::ios::floatfield);
225  G4cout.precision(prec);
226 
227  //output file
228  FILE *myFile;
229  myFile = fopen ("s.txt","a");
230  fprintf (myFile, "%e %e %e %e \n", fDetector->GetAbsorRadius()/nm,fEkin/eV,
231  sValue/gray, rmsSValue/gray );
232  fclose (myFile);
233 
234 }
Float_t x
Definition: compare.C:6
static const double prec
Definition: RanecuEngine.cc:58
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
DetectorConstruction * fDetector
static constexpr double MeV
Definition: G4SIunits.hh:214
G4int numberOfEvent
Definition: G4Run.hh:59
static constexpr double nm
Definition: G4SIunits.hh:112
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
static constexpr double gray
Definition: G4SIunits.hh:309
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
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
Definition: G4Run.hh:46
G4ParticleDefinition * fParticle
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
static const G4double fac
G4GLOB_DLL std::ostream G4cout
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
void AddStepSize(G4int nb, G4double st)
Simple detector construction with a box volume placed in a world.
G4double GetDensity() const
Definition: G4Material.hh:181