Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/medical/dna/slowing/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 //
26 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publications:
29 // Phys. Med. 31 (2015) 861-874
30 // Med. Phys. 37 (2010) 4692-4708
31 // The Geant4-DNA web site is available at http://geant4-dna.org
32 //
33 // $Id$
34 //
37 
38 #include "Run.hh"
39 #include "DetectorConstruction.hh"
40 #include "HistoManager.hh"
41 #include "PrimaryGeneratorAction.hh"
42 
43 #include "G4Material.hh"
44 #include "G4SystemOfUnits.hh"
45 #include "G4UnitsTable.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
49 Run::Run(const DetectorConstruction* detector)
50 : G4Run(),
51  fDetector(detector),
52  fParticle(0), fEkin(0.),
53  fEdeposit(0.), fEdeposit2(0.)
54 {}
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
58 Run::~Run()
59 {}
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {
65  fParticle = particle;
66  fEkin = energy;
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
71 void Run::AddEdep (G4double e)
72 {
73  fEdeposit += e;
74  fEdeposit2 += e*e;
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
79 void Run::Merge(const G4Run* run)
80 {
81  const Run* localRun = static_cast<const Run*>(run);
82 
83  // pass information about primary particle
84  fParticle = localRun->fParticle;
85  fEkin = localRun->fEkin;
86 
87  // accumulate sums
88  fEdeposit += localRun->fEdeposit;
89  fEdeposit2 += localRun->fEdeposit2;
90 
91  G4Run::Merge(run);
92 }
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
95 
96 void Run::EndOfRun()
97 {
98  std::ios::fmtflags mode = G4cout.flags();
99  G4cout.setf(std::ios::fixed,std::ios::floatfield);
100  G4int prec = G4cout.precision(2);
101 
102  //run conditions
103  //
104  G4String partName = fParticle->GetParticleName();
105  G4Material* material = fDetector->GetAbsorMaterial();
106  G4double density = material->GetDensity();
107 
108  G4cout << "\n ======================== run summary =====================\n";
109  G4cout
110  << "\n The run is " << numberOfEvent << " "<< partName << " of "
111  << G4BestUnit(fEkin,"Energy") << " through a volume of "
112  << material->GetName() << " (density: "
113  << G4BestUnit(density,"Volumic Mass") << ") of mass "
114  << G4BestUnit(fDetector->GetAbsorMass(),"Mass")
115  << G4endl;
116 
117  if (numberOfEvent == 0) {
118  G4cout.setf(mode,std::ios::floatfield);
119  G4cout.precision(prec);
120  return;
121  }
122 
123  G4cout.precision(3);
124  G4cout
125  << "\n Total Energy deposited = " << G4BestUnit(fEdeposit,"Energy")
126  << G4endl;
127 
128  /*
129  G4double dose=fEdeposit/fDetector->GetAbsorMass();
130  G4double rmsDose=rms/fDetector->GetAbsorMass();
131 
132  G4cout.precision(3);
133  G4cout
134  << "\n Dose = " << dose/gray << " Gy "
135  << G4endl;
136  */
137 
138  G4cout << G4endl;
139 
140  // normalize histograms
141  //
142  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
143  G4double fac = 1./(numberOfEvent*(fEkin/eV));
144  analysisManager->ScaleH1(1,fac);
145  analysisManager->ScaleH1(2,fac);
146  analysisManager->ScaleH1(3,fac);
147 
148 }
149 
150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double prec
Definition: RanecuEngine.cc:58
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
DetectorConstruction * fDetector
G4int numberOfEvent
Definition: G4Run.hh:59
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
const G4String & GetName() const
Definition: G4Material.hh:179
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
Simple detector construction with a box volume placed in a world.
G4double GetDensity() const
Definition: G4Material.hh:181