Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/advanced/microbeam/src/RunAction.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 publication:
29 // Med. Phys. 37 (2010) 4692-4708
30 // The Geant4-DNA web site is available at http://geant4-dna.org
31 //
32 // If you use this example, please cite the following publication:
33 // Rad. Prot. Dos. 133 (2009) 2-11
34 
35 #include "G4UImanager.hh"
36 #include "Randomize.hh"
37 
38 #include "RunAction.hh"
39 #include "Analysis.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42 
44 :fDetector(det)
45 {
46  fSaveRndm = 0;
47 }
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50 
52 {
53  delete[] fDose3DDose;
54  delete[] fMapVoxels;
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
58 
60 {
61  // Read phantom - Singleton
62  CellParameterisation* fMyCellParameterisation = CellParameterisation::Instance();
63 
64  // Histograms
65  // Get/create analysis manager
66  G4cout << "##### Create analysis manager " << " " << this << G4endl;
67 
68  G4AnalysisManager* man = G4AnalysisManager::Instance();
69 
70  G4cout << "Using " << man->GetType() << " analysis manager" << G4endl;
71 
72  // Open an output file
73  man->OpenFile("microbeam");
74  man->SetFirstNtupleId(1);
75 
76  //Declare ntuples
77  //
78  // Create 1st ntuple (id = 1)
79  //
80  man->CreateNtuple("ntuple0", "Stopping power");
81  man->CreateNtupleDColumn("e");
82  man->CreateNtupleDColumn("sp");
83  man->FinishNtuple();
84  //G4cout << "Ntuple-1 created" << G4endl;
85 
86  //
87  // Create 2nd ntuple (id = 2)
88  //
89  man->CreateNtuple("ntuple1", "Beam position");
90  man->CreateNtupleDColumn("x");
91  man->CreateNtupleDColumn("y");
92  man->FinishNtuple();
93  //G4cout << "Ntuple-2 created" << G4endl;
94 
95  //
96  // Create 3rd ntuple (id = 3)
97  //
98  man->CreateNtuple("ntuple2", "Range");
99  man->CreateNtupleDColumn("x");
100  man->CreateNtupleDColumn("y");
101  man->CreateNtupleDColumn("z");
102  man->FinishNtuple();
103  //G4cout << "Ntuple-3 created" << G4endl;
104 
105  //
106  // Create 4th ntuple (id = 4)
107  //
108  man->CreateNtuple("ntuple3", "Doses");
109  man->CreateNtupleDColumn("doseN");
110  man->CreateNtupleDColumn("doseC");
111  man->FinishNtuple();
112  //G4cout << "Ntuple-4 created" << G4endl;
113 
114  //
115  // Create 5th ntuple (id = 5)
116  //
117  man->CreateNtuple("ntuple4", "3D");
118  man->CreateNtupleDColumn("x");
119  man->CreateNtupleDColumn("y");
120  man->CreateNtupleDColumn("z");
121  man->CreateNtupleDColumn("doseV");
122  man->FinishNtuple();
123  //G4cout << "Ntuple-3 created" << G4endl;
124 
125  G4cout << "All Ntuples have been created " << G4endl;
126 
127  // save Rndm status
128  if (fSaveRndm > 0)
129  {
131  CLHEP::HepRandom::saveEngineStatus("beginOfRun.rndm");
132  }
133 
134  fNumEvent = 0;
135  fNbOfHitsGas = 0;
136 
137  // ABSORBED DOSES INITIALIZATION
138  fDoseN = 0;
139  fDoseC = 0;
140 
144 
147 
148  for (G4int i=0; i<fNbOfPixels; i++)
149  {
150  fMapVoxels [i]=fMyCellParameterisation->GetVoxelThreeVector(i);
151  fDose3DDose[i]=0;
152  }
153 
154 }
155 
156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
157 
158 void RunAction::EndOfRunAction(const G4Run* /*aRun*/)
159 {
160  G4AnalysisManager* man = G4AnalysisManager::Instance();
161 
162  // save Rndm status
163  if (fSaveRndm == 1)
164  {
166  CLHEP::HepRandom::saveEngineStatus("endOfRun.rndm");
167  }
168 
169  for (G4int i=0; i<fNbOfPixels; i++)
170  {
171  if (fDose3DDose[i]>0)
172  {
173  G4ThreeVector v;
174  v = fMapVoxels[i];
175  man->FillNtupleDColumn(5,0,v.x());
176  man->FillNtupleDColumn(5,1,v.y());
177  man->FillNtupleDColumn(5,2,v.z());
178  man->FillNtupleDColumn(5,3,fDose3DDose[i]);
179  man->AddNtupleRow(5);
180  }
181  }
182 
183  G4cout << "-> Total number of particles detected by the gas detector : " << GetNbOfHitsGas() << G4endl;
184  G4cout << G4endl;
185 
186  //save histograms
187  man->Write();
188  man->CloseFile();
189 
190  // Complete clean-up
191  delete G4AnalysisManager::Instance();
192 
193 }
#define G4endl
Definition: G4ios.hh:61
double z() const
static void saveEngineStatus(const char filename[]="Config.conf")
Definition: Random.cc:275
G4ThreeVector GetVoxelThreeVector(G4int i) const
double G4double
Definition: G4Types.hh:76
static CellParameterisation * Instance()
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
Definition: G4Run.hh:46
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
double x() const
double y() const
static void showEngineStatus()
Definition: Random.cc:303
Simple detector construction with a box volume placed in a world.