Geant4  10.00.p01
HistoManager.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 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // and the DNA geometry given in the Geom_DNA example
29 // shall cite the following Geant4-DNA collaboration publications:
30 // [1] NIM B 298 (2013) 47-54
31 // [2] Med. Phys. 37 (2010) 4692-4708
32 // The Geant4-DNA web site is available at http://geant4-dna.org
33 //
34 
35 #include "HistoManager.hh"
36 #include "G4UnitsTable.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
41 {
42  fileName[0] = "dnageometry";
43  factoryOn = false;
44 }
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 {
50 }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
54 void HistoManager::book()
55 {
56  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
57  analysisManager->SetVerboseLevel(1);
58 
59  G4String extension = analysisManager->GetFileType();
60  fileName[1] = fileName[0] + "." + extension;
61 
62  // open output file
63 
64  G4bool fileOpen = analysisManager->OpenFile(fileName[0]);
65  if (!fileOpen) {
66  G4cout << "\n---> HistoManager::book(): cannot open " << fileName[1]
67  << G4endl;
68  return;
69  }
70 
71  // create ntuple
72 
73  analysisManager->SetFirstHistoId(1);
74 
75  analysisManager->CreateNtuple("ntuple","geom_dna");
76 
77  analysisManager->CreateNtupleDColumn("flagParticle");
78  analysisManager->CreateNtupleDColumn("flagProcess");
79  analysisManager->CreateNtupleDColumn("flagVolume");
80  analysisManager->CreateNtupleDColumn("x");
81  analysisManager->CreateNtupleDColumn("y");
82  analysisManager->CreateNtupleDColumn("z");
83  analysisManager->CreateNtupleDColumn("edep");
84  analysisManager->CreateNtupleDColumn("stepLength");
85 
86  factoryOn = true;
87 
88  G4cout << "\n----> Histogram file is opened in " << fileName[1] << G4endl;
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
93 void HistoManager::save()
94 {
95  if (factoryOn) {
96  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
97  analysisManager->Write();
98  analysisManager->CloseFile();
99  G4cout << "\n----> Histograms are saved in " << fileName[1] << G4endl;
100 
101  delete G4AnalysisManager::Instance();
102  factoryOn = false;
103  }
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107 
109 {
110  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
111  analysisManager->FillNtupleIColumn(icol,ival);
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
117 {
118  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
119  analysisManager->FillNtupleFColumn(icol,fval);
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
125 {
126  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
127  analysisManager->FillNtupleDColumn(icol,dval);
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131 
133 {
134  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
135  analysisManager->AddNtupleRow();
136 }
void AddNtupleRow()
void FillNtupleDColumn(G4int icol, G4double ival)
float G4float
Definition: G4Types.hh:77
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4bool factoryOn
Definition: HistoManager.hh:62
bool G4bool
Definition: G4Types.hh:79
G4String fileName[2]
Definition: HistoManager.hh:80
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void FillNtupleFColumn(G4int icol, G4float ival)
void FillNtupleIColumn(G4int icol, G4int ival)