Geant4  10.00.p01
B5RunAction.cc
Go to the documentation of this file.
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 "B5Analysis.hh"
33 
34 #include "G4Run.hh"
35 #include "G4UnitsTable.hh"
36 #include "G4SystemOfUnits.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
41  : G4UserRunAction()
42 {
43  // Create analysis manager
44  // The choice of analysis technology is done via selectin of a namespace
45  // in B5Analysis.hh
46  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
47  G4cout << "Using " << analysisManager->GetType() << G4endl;
48 
49  // Default settings
50  analysisManager->SetVerboseLevel(1);
51  analysisManager->SetFileName("B5");
52 
53  // Book histograms, ntuple
54  //
55 
56  // Creating 1D histograms
57  analysisManager
58  ->CreateH1("Chamber1","Drift Chamber 1 # Hits", 50, 0., 50); // h1 Id = 0
59  analysisManager
60  ->CreateH1("Chamber2","Drift Chamber 2 # Hits", 50, 0., 50); // h1 Id = 1
61 
62  // Creating 2D histograms
63  analysisManager
64  ->CreateH2("Chamber1 XY","Drift Chamber 1 X vs Y", // h2 Id = 0
65  50, -1000., 1000, 50, -300., 300.);
66  analysisManager
67  ->CreateH2("Chamber2 XY","Drift Chamber 2 X vs Y", // h2 Id = 1
68  50, -1500., 1500, 50, -300., 300.);
69 
70  // Creating ntuple
71  //
72  analysisManager->CreateNtuple("B5", "Hits");
73  analysisManager->CreateNtupleIColumn("Dc1Hits"); // column Id = 0
74  analysisManager->CreateNtupleIColumn("Dc2Hits"); // column Id = 1
75  analysisManager->CreateNtupleDColumn("ECEnergy"); // column Id = 2
76  analysisManager->CreateNtupleDColumn("HCEnergy"); // column Id = 3
77  analysisManager->CreateNtupleDColumn("Time1"); // column Id = 4
78  analysisManager->CreateNtupleDColumn("Time2"); // column Id = 5
79  analysisManager->FinishNtuple();
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
86  delete G4AnalysisManager::Instance();
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
92 {
93  //inform the runManager to save random number seed
94  //G4RunManager::GetRunManager()->SetRandomNumberStore(true);
95 
96  // Get analysis manager
97  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
98 
99  // Open an output file
100  // The default file name is set in B5RunAction::B5RunAction(),
101  // it can be overwritten in a macro
102  analysisManager->OpenFile();
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
107 void B5RunAction::EndOfRunAction(const G4Run* /*run*/)
108 {
109  // save histograms & ntuple
110  //
111  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
112  analysisManager->Write();
113  analysisManager->CloseFile();
114 
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void BeginOfRunAction(const G4Run *)
Definition: B5RunAction.cc:91
G4int CreateNtupleIColumn(const G4String &name)
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
void SetVerboseLevel(G4int verboseLevel)
G4int CreateNtuple(const G4String &name, const G4String &title)
G4bool SetFileName(const G4String &fileName)
G4GLOB_DLL std::ostream G4cout
Definition: G4Run.hh:46
Definition of the B5RunAction class.
Selection of the analysis technology.
G4String GetType() const
virtual ~B5RunAction()
Definition: B5RunAction.cc:84
#define G4endl
Definition: G4ios.hh:61
G4int CreateNtupleDColumn(const G4String &name)
virtual void EndOfRunAction(const G4Run *)
Definition: B5RunAction.cc:107
G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear")