Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #include "HistoManager.hh"
27 #include "G4UnitsTable.hh"
28 
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 
32 {
33  fileName[0] = "microdosimetry";
34  factoryOn = false;
35 }
36 
37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
38 
40 {
41 }
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
45 void HistoManager::book()
46 {
47  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
48  analysisManager->SetVerboseLevel(1);
49 
50  G4String extension = analysisManager->GetFileType();
51  fileName[1] = fileName[0] + "." + extension;
52 
53  // open output file
54 
55  G4bool fileOpen = analysisManager->OpenFile(fileName[0]);
56  if (!fileOpen) {
57  G4cout << "\n---> HistoManager::book(): cannot open " << fileName[1]
58  << G4endl;
59  return;
60  }
61 
62  // create ntuple
63 
64  analysisManager->SetFirstHistoId(1);
65 
66  analysisManager->CreateNtuple("ntuple","micro");
67 
68  analysisManager->CreateNtupleDColumn("flagParticle");
69  analysisManager->CreateNtupleDColumn("flagProcess");
70  analysisManager->CreateNtupleDColumn("x");
71  analysisManager->CreateNtupleDColumn("y");
72  analysisManager->CreateNtupleDColumn("z");
73  analysisManager->CreateNtupleDColumn("edep");
74  analysisManager->CreateNtupleDColumn("stepLength");
75 
76  factoryOn = true;
77 
78  G4cout << "\n----> Histogram file is opened in " << fileName[1] << G4endl;
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
83 void HistoManager::save()
84 {
85  if (factoryOn) {
86  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
87  analysisManager->Write();
88  analysisManager->CloseFile();
89  G4cout << "\n----> Histograms are saved in " << fileName[1] << G4endl;
90 
91  delete G4AnalysisManager::Instance();
92  factoryOn = false;
93  }
94 }
95 
96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97 
99 {
100  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
101  analysisManager->FillNtupleIColumn(icol,ival);
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 
107 {
108  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
109  analysisManager->FillNtupleFColumn(icol,fval);
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113 
115 {
116  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
117  analysisManager->FillNtupleDColumn(icol,dval);
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
123 {
124  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
125  analysisManager->AddNtupleRow();
126 }