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] = "dna";
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","dna");
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("size");
75  analysisManager->CreateNtupleDColumn("diffKin");
76 
77  factoryOn = true;
78 
79  G4cout << "\n----> Histogram file is opened in " << fileName[1] << G4endl;
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
84 void HistoManager::save()
85 {
86  if (factoryOn) {
87  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
88  analysisManager->Write();
89  analysisManager->CloseFile();
90  G4cout << "\n----> Histograms are saved in " << fileName[1] << G4endl;
91 
92  delete G4AnalysisManager::Instance();
93  factoryOn = false;
94  }
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 
100 {
101  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
102  analysisManager->FillNtupleIColumn(icol,ival);
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
108 {
109  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
110  analysisManager->FillNtupleFColumn(icol,fval);
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114 
116 {
117  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
118  analysisManager->FillNtupleDColumn(icol,dval);
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
122 
124 {
125  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
126  analysisManager->AddNtupleRow();
127 }