Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/medical/dna/neuron/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 // and papers
31 // M. Batmunkh et al. J Radiat Res Appl Sci 8 (2015) 498-507
32 // O. Belov et al. Physica Medica 32 (2016) 1510-1520
33 // The Geant4-DNA web site is available at http://geant4-dna.org
34 //
35 // -------------------------------------------------------------------
36 // November 2016
37 // -------------------------------------------------------------------
38 //
39 // $ID$
42 
43 #include "RunAction.hh"
44 #include "G4Run.hh"
45 #include "TrackingAction.hh"
46 #include "G4ParticleDefinition.hh"
47 #include "G4RunManager.hh"
48 #include "Analysis.hh"
49 #include "G4Threading.hh"
50 #include "CommandLineParser.hh"
51 //#include "NeuronLoadDataFile.hh"
52 #include "Run.hh"
53 #include "Randomize.hh"
54 #include <iomanip>
55 #include "G4UnitsTable.hh"
56 #include "G4SystemOfUnits.hh"
57 #include "G4UImanager.hh"
58 #include "DetectorConstruction.hh"
59 #include "PrimaryGeneratorAction.hh"
60 #include "G4RunManager.hh"
61 #include "G4UImanager.hh"
62 
63 using namespace G4DNAPARSER;
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 : G4UserRunAction(), //fpTrackingAction(0), fInitialized(0),
69  fDebug(false),
70 fDetector(det),fPrimary(prim),fRun(0)
71 {
72  //CreateHistogram();
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  //delete G4AnalysisManager::Instance();
80 }
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  fRun = new Run(fDetector);
86  return fRun;
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
91 void RunAction::BeginOfRunAction(const G4Run* /*run*/)
92 {
93 
95 
96  // keep run condition
97  if ( fPrimary ) {
98  G4ParticleDefinition* particle
101  fRun->SetPrimary(particle, energy);
102  }
103 
104 /*
105  G4cout << "##### Create analysis manager " << " " << this << G4endl;
106  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
107  analysisManager->SetFirstHistoId(1);
108 // if(!analysisManager->IsActive()) {return; }
109 
110  G4cout << "Using " << analysisManager->GetType() <<
111  " analysis manager" << G4endl;
112  // Open an output file
113  analysisManager->OpenFile("neuronG4");
114  G4cout << "\n----> Histogram file is opened in neuronG4" <<
115  "." << analysisManager->GetFileType() << G4endl;
116 // -----------------------------------------------------
117  //Declare ntuples
118  //
119  // Create 1st ntuple (id = 1)
120  //
121  analysisManager->CreateNtuple("ntuple0", "Soma3D");
122  analysisManager->CreateNtupleDColumn("ind");
123  analysisManager->CreateNtupleDColumn("dist");
124  analysisManager->CreateNtupleDColumn("edep");
125  analysisManager->CreateNtupleDColumn("dose");
126  analysisManager->FinishNtuple();
127  //G4cout << "Ntuple-1 created" << G4endl;
128 
129  // Create 2nd ntuple (id = 2)
130  //
131  analysisManager->CreateNtuple("ntuple1", "Dend3D");
132  analysisManager->CreateNtupleDColumn("indD");
133  analysisManager->CreateNtupleDColumn("distD");
134  analysisManager->CreateNtupleDColumn("edepD");
135  analysisManager->CreateNtupleDColumn("doseD");
136  analysisManager->FinishNtuple();
137  //G4cout << "Ntuple-2 created" << G4endl;
138 
139  // Create 3rd ntuple (id = 3)
140  //
141  analysisManager->CreateNtuple("ntuple2", "Axon3D");
142  analysisManager->CreateNtupleDColumn("indA");
143  analysisManager->CreateNtupleDColumn("distA");
144  analysisManager->CreateNtupleDColumn("edepA");
145  analysisManager->CreateNtupleDColumn("doseA");
146  analysisManager->FinishNtuple();
147  //G4cout << "Ntuple-3 created" << G4endl;
148 
149  // Create 4rd ntuple (id = 4)
150  //
151  analysisManager->CreateNtuple("ntuple3", "Outputs per event");
152  analysisManager->CreateNtupleDColumn("EdepAll");
153  analysisManager->CreateNtupleDColumn("EdepMed");
154  analysisManager->CreateNtupleDColumn("EdepSlice");
155  analysisManager->CreateNtupleDColumn("EdepNeuron");
156  analysisManager->FinishNtuple();
157  //G4cout << "Ntuple-4 created" << G4endl;
158  // ............................
159  G4cout << "All Ntuples have been created " << G4endl;
160 */
161 }
162 
163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164 
165 void RunAction::EndOfRunAction(const G4Run* /*run*/)
166 {
167 
168  if (isMaster) fRun->EndOfRun();
169 
170 // save histogramms
171 /* G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
172  //save histograms
173  analysisManager->Write();
174  analysisManager->CloseFile();
175  // Complete clean-up
176  delete G4AnalysisManager::Instance();
177 */
178 
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
182 
184 {
185  // Book histograms, ntuple
186 
187  // Create analysis manager
188  // The choice of analysis technology is done via selection of a namespace
189  // in Analysis.hh
190 
191  CommandLineParser* parser = CommandLineParser::GetParser();
192  Command* command(0);
193  if((command = parser->GetCommandIfActive("-out"))==0) return;
194 //
195 // Declare ntuples
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
199 
201 {
202  CommandLineParser* parser = CommandLineParser::GetParser();
203  Command* commandLine(0);
204  if((commandLine = parser->GetCommandIfActive("-out"))==0) return;
205 
206  // print histogram statistics
207  //
208  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
209  // if(!analysisManager->IsActive()) {return; }
210 
211  // save histograms
212  //
213  analysisManager->Write();
214  analysisManager->CloseFile();
215 
216  if(fDebug)
217  {
218  G4cout << "================ ROOT FILES HAVE BEEN WRITTEN"
219  << G4endl;
220  }
221 }
222 
223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
224 
225 void RunAction::PrintRunInfo(const G4Run* run)
226 {
227  G4cout << "================ Run is = "
228  << run->GetRunID() << G4endl;
229  G4cout << "================ Run type is = "
231  G4cout << "================ Event processed = "
233  G4cout << "================ Nevent = "
234  << run->GetNumberOfEvent() << G4endl;
235 }
236 
237 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
#define G4endl
Definition: G4ios.hh:61
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
double G4double
Definition: G4Types.hh:76
static RunInitManager * Instance()
G4int GetRunID() const
Definition: G4Run.hh:76
double energy
Definition: plottest35.C:25
The primary generator action class with particle gun.
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
CommandLineParser * parser(0)
Definition: G4Run.hh:46
G4int GetNumberOfEventToBeProcessed() const
Definition: G4Run.hh:83
Command * GetCommandIfActive(const G4String &marker)
G4double GetParticleEnergy() const
G4GLOB_DLL std::ostream G4cout
RMType GetRunManagerType() const
G4ParticleDefinition * GetParticleDefinition() const
Simple detector construction with a box volume placed in a world.