Geant4  10.02.p02
AnalysisManager.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 // Authors: Susanna Guatelli, susanna@uow.edu.au,
27 // Authors: Jeremy Davis, jad028@uowmail.edu.au
28 //
29 
30 #include <stdlib.h>
31 #include "AnalysisManager.hh"
32 #include "G4UnitsTable.hh"
33 #include "G4SystemOfUnits.hh"
34 
36 {
37  factoryOn = false;
38 
39 // Initialization
40 // histograms
41  //for (G4int k=0; k<MaxHisto; k++) fHistId[k] = 0;
42 
43 // Initialization ntuple
44  for (G4int k=0; k<MaxNtCol; k++) fNtColId[k] = 0;
45 
46  //h10 = 0;
47  //h20 = 0;
48 }
49 
51 {
52 }
53 
55 {
56  G4AnalysisManager* manager = G4AnalysisManager::Instance();
57 
58  manager->SetVerboseLevel(2);
59 
60  // Create a root file
61  G4String fileName = "radioprotection.root";
62 
63  // Create directories
64  manager->SetNtupleDirectoryName("radioprotection_ntuple");
65 
66 
67  G4bool fileOpen = manager->OpenFile(fileName);
68  if (!fileOpen) {
69  G4cout << "\n---> HistoManager::book(): cannot open "
70  << fileName << G4endl;
71  return;
72  }
73 
74  manager->SetFirstNtupleId(1);
75 
76  //Create Primary Energy Ntuple
77  manager -> CreateNtuple("101", "Primary Energy");
78  fNtColId[0] = manager -> CreateNtupleDColumn("Ek");
79  manager -> FinishNtuple();
80 
81  //Create Energy Deposition within SV Ntuple
82  manager -> CreateNtuple("102", "Edep");
83  fNtColId[1] = manager -> CreateNtupleDColumn("edep");
84  manager -> FinishNtuple();
85 
86  //creating a ntuple, containing the information about secondary particles
87  manager -> CreateNtuple("103", "secondary");
88  fNtColId[2] = manager -> CreateNtupleDColumn("AA");
89  fNtColId[3] = manager -> CreateNtupleDColumn("ZZ");
90  fNtColId[4] = manager -> CreateNtupleDColumn("KE");
91  manager -> FinishNtuple();
92 
93 
94  factoryOn = true;
95 }
96 
97 
99 {
100  G4AnalysisManager* manager = G4AnalysisManager::Instance();
101  manager -> FillNtupleDColumn(1, fNtColId[0], energy);
102  manager -> AddNtupleRow(1);
103 }
104 
106 {
107  G4AnalysisManager* manager = G4AnalysisManager::Instance();
108  manager -> FillNtupleDColumn(2, fNtColId[1], edep);
109  manager -> AddNtupleRow(2);
110 }
111 
113 {
114 
115  G4AnalysisManager* manager = G4AnalysisManager::Instance();
116  manager -> FillNtupleDColumn(3, fNtColId[2], AA);
117  manager -> FillNtupleDColumn(3, fNtColId[3], charge);
118  manager -> FillNtupleDColumn(3, fNtColId[4], energy);
119  manager -> AddNtupleRow(3);
120 }
121 
123 {
124  if (factoryOn)
125  {
126  G4AnalysisManager* manager = G4AnalysisManager::Instance();
127  manager -> Write();
128  manager -> CloseFile();
129 
130  delete G4AnalysisManager::Instance();
131  factoryOn = false;
132  }
133 }
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
void FillSecondaries(G4int AA, G4double charge, G4double energy)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4int fNtColId[MaxNtCol]
bool G4bool
Definition: G4Types.hh:79
void StoreEnergyDeposition(G4double edep)
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:66
const G4int MaxNtCol
G4double energy(const ThreeVector &p, const G4double m)
virtual ~AnalysisManager()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetPrimaryEnergy(G4double energy)