Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
radioprotection/src/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[1]
71  << G4endl;
72  return;
73  }
74 
75  manager->SetFirstNtupleId(1);
76 
77  //Create Primary Energy Ntuple
78  manager -> CreateNtuple("101", "Primary Energy");
79  fNtColId[0] = manager -> CreateNtupleDColumn("Ek");
80  manager -> FinishNtuple();
81 
82  //Create Energy Deposition within SV Ntuple
83  manager -> CreateNtuple("102", "Edep");
84  fNtColId[1] = manager -> CreateNtupleDColumn("edep");
85  manager -> FinishNtuple();
86 
87  //creating a ntuple, containing the information about secondary particles
88  manager -> CreateNtuple("103", "secondary");
89  fNtColId[2] = manager -> CreateNtupleDColumn("AA");
90  fNtColId[3] = manager -> CreateNtupleDColumn("ZZ");
91  fNtColId[4] = manager -> CreateNtupleDColumn("KE");
92  manager -> FinishNtuple();
93 
94 
95  factoryOn = true;
96 }
97 
98 
100 {
101  G4AnalysisManager* manager = G4AnalysisManager::Instance();
102  manager -> FillNtupleDColumn(1, fNtColId[0], energy);
103  manager -> AddNtupleRow(1);
104 }
105 
107 {
108  G4AnalysisManager* manager = G4AnalysisManager::Instance();
109  manager -> FillNtupleDColumn(2, fNtColId[1], edep);
110  manager -> AddNtupleRow(2);
111 }
112 
114 {
115 
116  G4AnalysisManager* manager = G4AnalysisManager::Instance();
117  manager -> FillNtupleDColumn(3, fNtColId[2], AA);
118  manager -> FillNtupleDColumn(3, fNtColId[3], charge);
119  manager -> FillNtupleDColumn(3, fNtColId[4], energy);
120  manager -> AddNtupleRow(3);
121 }
122 
124 {
125  if (factoryOn)
126  {
127  G4AnalysisManager* manager = G4AnalysisManager::Instance();
128  manager -> Write();
129  manager -> CloseFile();
130 
131  delete G4AnalysisManager::Instance();
132  factoryOn = false;
133  }
134 }
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
void FillSecondaries(G4int AA, G4double charge, G4double energy)
int G4int
Definition: G4Types.hh:78
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
const G4int MaxNtCol
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetPrimaryEnergy(G4double energy)