Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
B5RunAction.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 // $Id: B5RunAction.cc 74204 2013-10-01 07:04:43Z ihrivnac $
27 //
30 
31 #include "B5RunAction.hh"
32 #include "B5EventAction.hh"
33 #include "B5Analysis.hh"
34 
35 #include "G4Run.hh"
36 #include "G4UnitsTable.hh"
37 #include "G4SystemOfUnits.hh"
38 
39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
40 
42  : G4UserRunAction(),
43  fEventAction(eventAction)
44 {
45  // Create analysis manager
46  // The choice of analysis technology is done via selectin of a namespace
47  // in B5Analysis.hh
48  auto analysisManager = G4AnalysisManager::Instance();
49  G4cout << "Using " << analysisManager->GetType() << G4endl;
50 
51  // Default settings
52  analysisManager->SetNtupleMerging(true);
53  // Note: merging ntuples is available only with Root output
54  analysisManager->SetVerboseLevel(1);
55  analysisManager->SetFileName("B5");
56 
57  // Book histograms, ntuple
58  //
59 
60  // Creating 1D histograms
61  analysisManager
62  ->CreateH1("Chamber1","Drift Chamber 1 # Hits", 50, 0., 50); // h1 Id = 0
63  analysisManager
64  ->CreateH1("Chamber2","Drift Chamber 2 # Hits", 50, 0., 50); // h1 Id = 1
65 
66  // Creating 2D histograms
67  analysisManager
68  ->CreateH2("Chamber1 XY","Drift Chamber 1 X vs Y", // h2 Id = 0
69  50, -1000., 1000, 50, -300., 300.);
70  analysisManager
71  ->CreateH2("Chamber2 XY","Drift Chamber 2 X vs Y", // h2 Id = 1
72  50, -1500., 1500, 50, -300., 300.);
73 
74  // Creating ntuple
75  //
76  if ( fEventAction ) {
77  analysisManager->CreateNtuple("B5", "Hits");
78  analysisManager->CreateNtupleIColumn("Dc1Hits"); // column Id = 0
79  analysisManager->CreateNtupleIColumn("Dc2Hits"); // column Id = 1
80  analysisManager->CreateNtupleDColumn("ECEnergy"); // column Id = 2
81  analysisManager->CreateNtupleDColumn("HCEnergy"); // column Id = 3
82  analysisManager->CreateNtupleDColumn("Time1"); // column Id = 4
83  analysisManager->CreateNtupleDColumn("Time2"); // column Id = 5
84  analysisManager // column Id = 6
85  ->CreateNtupleDColumn("ECEnergyVector", fEventAction->GetEmCalEdep());
86  analysisManager // column Id = 7
87  ->CreateNtupleDColumn("HCEnergyVector", fEventAction->GetHadCalEdep());
88  analysisManager->FinishNtuple();
89  }
90 }
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 
95 {
96  delete G4AnalysisManager::Instance();
97 }
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100 
102 {
103  //inform the runManager to save random number seed
104  //G4RunManager::GetRunManager()->SetRandomNumberStore(true);
105 
106  // Get analysis manager
107  auto analysisManager = G4AnalysisManager::Instance();
108 
109  // Open an output file
110  // The default file name is set in B5RunAction::B5RunAction(),
111  // it can be overwritten in a macro
112  analysisManager->OpenFile();
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116 
117 void B5RunAction::EndOfRunAction(const G4Run* /*run*/)
118 {
119  // save histograms & ntuple
120  //
121  auto analysisManager = G4AnalysisManager::Instance();
122  analysisManager->Write();
123  analysisManager->CloseFile();
124 
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5EventAction * fEventAction
Definition: B5RunAction.hh:53
std::vector< G4double > & GetHadCalEdep()
virtual void BeginOfRunAction(const G4Run *)
Definition: B5RunAction.cc:101
Definition of the B5RunAction class.
#define G4endl
Definition: G4ios.hh:61
Selection of the analysis technology.
Definition of the B5EventAction class.
std::vector< G4double > & GetEmCalEdep()
Definition: G4Run.hh:46
Event action.
virtual void EndOfRunAction(const G4Run *)
Definition: B5RunAction.cc:117
B5RunAction(B5EventAction *eventAction)
Definition: B5RunAction.cc:41
virtual ~B5RunAction()
Definition: B5RunAction.cc:94
G4GLOB_DLL std::ostream G4cout