Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/medical/dna/dnaphysics/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 // $Id$
33 //
36 
37 #include "RunAction.hh"
38 #include "Analysis.hh"
39 
40 #include "G4Run.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45 {}
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50 {}
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 {
56  // Book histograms, ntuple
57 
58  // Create analysis manager
59  // The choice of analysis technology is done via selection of a namespace
60  // in Analysis.hh
61 
62  G4cout << "##### Create analysis manager " << " " << this << G4endl;
63  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
64 
65  G4cout << "Using " << analysisManager->GetType()
66  << " analysis manager"
67  << G4endl;
68 
69  analysisManager->SetVerboseLevel(1);
70 
71  // Open an output file
72 
73  G4String fileName = "dna";
74  analysisManager->OpenFile(fileName);
75 
76  // Creating ntuple
77 
78  analysisManager->CreateNtuple("dna", "dnaphysics");
79  analysisManager->CreateNtupleDColumn("flagParticle");
80  analysisManager->CreateNtupleDColumn("flagProcess");
81  analysisManager->CreateNtupleDColumn("x");
82  analysisManager->CreateNtupleDColumn("y");
83  analysisManager->CreateNtupleDColumn("z");
84  analysisManager->CreateNtupleDColumn("totalEnergyDeposit");
85  analysisManager->CreateNtupleDColumn("stepLength");
86  analysisManager->CreateNtupleDColumn("kineticEnergyDifference");
87  analysisManager->CreateNtupleDColumn("kineticEnergy");
88  analysisManager->CreateNtupleDColumn("cosTheta");
89  analysisManager->CreateNtupleIColumn("eventID");
90  analysisManager->CreateNtupleIColumn("trackID");
91  analysisManager->CreateNtupleIColumn("parentID");
92  analysisManager->CreateNtupleIColumn("stepID");
93  analysisManager->FinishNtuple();
94 }
95 
96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97 
98 void RunAction::EndOfRunAction(const G4Run* aRun)
99 {
100  G4int nofEvents = aRun->GetNumberOfEvent();
101  if ( nofEvents == 0 ) return;
102 
103  // print histogram statistics
104 
105  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
106 
107  // save histograms
108 
109  analysisManager->Write();
110  analysisManager->CloseFile();
111 
112  // complete cleanup
113 
114  delete G4AnalysisManager::Instance();
115 }
#define G4endl
Definition: G4ios.hh:61
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
Definition: G4Run.hh:46
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout