Geant4  10.01
ExG4HbookAnalysisManager.hh
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 // $Id$
27 //
30 
31 // Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
32 
33 #ifdef G4_USE_HBOOK
34 
35 #ifndef ExG4HbookAnalysisManager_h
36 #define ExG4HbookAnalysisManager_h 1
37 
38 #include "G4VAnalysisManager.hh"
39 #include "globals.hh"
40 
41 #include <tools/hbook/wfile>
42 #include <tools/hbook/h1>
43 #include <tools/hbook/h2>
44 #include <tools/hbook/p1>
45 #include <tools/hbook/wntuple>
46 
47 #include <vector>
48 #include <map>
49 
50 #define setpawc setpawc_
51 #define setntuc setntuc_
52 //#define ntuc ntuc_
53 
54 class ExG4HbookAnalysisManager;
55 
56 namespace G4Hbook {
57  typedef tools::hbook::h1 G4AnaH1;
58  typedef tools::hbook::h1 G4H1;
59  typedef tools::hbook::h2 G4AnaH2;
60  typedef tools::hbook::h2 G4H2;
61  typedef tools::hbook::p1 G4P1;
62  typedef tools::hbook::wntuple G4Ntuple;
63  typedef ExG4HbookAnalysisManager G4AnalysisManager;
64 }
65 
66 class ExG4HbookFileManager;
67 class ExG4HbookH1Manager;
68 class ExG4HbookH2Manager;
70 class ExG4HbookP1Manager;
72 class ExG4HbookNtupleManager;
73 
79 
80 class ExG4HbookAnalysisManager : public G4VAnalysisManager
81 {
82  public:
83  ExG4HbookAnalysisManager();
84  virtual ~ExG4HbookAnalysisManager();
85 
86  // static methods
87  static ExG4HbookAnalysisManager* Create(G4bool isMaster = true);
88  static ExG4HbookAnalysisManager* Instance();
89 
90  // HBOOK does not allow IDs the same IDs for H1 and H2,
91  // and also IDs starting from 0; thats why there is defined an offset
92  // with respect to the G4AnalysisManager generic Ids.
93  // The default values of these offsets can be changed by the user.
94  //
95  // Set the offset of HBOOK ID for H1
96  // ( default value = firstHistoID if firstHistoID > 0; otherwise = 1)
97  G4bool SetH1HbookIdOffset(G4int offset);
98  G4int GetH1HbookIdOffset() const;
99 
100  // Set the offset of HBOOK ID for H2
101  // ( default value = firstHistoID + 100 if firstHistoID > 0;
102  // otherwise = 101 )
103  G4bool SetH2HbookIdOffset(G4int offset);
104  G4int GetH2HbookIdOffset() const;
105 
106  // Set the offset of NTUPLE ID for ntuples
107  // ( default value = firstNtupleID if firstNtupleID > 0; otherwise = 1)
108  G4bool SetNtupleHbookIdOffset(G4int offset);
109  G4int GetNtupleHbookIdOffset() const;
110 
111  // Access methods
112  //
113  tools::hbook::h1* GetH1(G4int id, G4bool warn = true,
114  G4bool onlyIfActive = true) const;
115  tools::hbook::h2* GetH2(G4int id, G4bool warn = true,
116  G4bool onlyIfActive = true) const;
117  tools::hbook::wntuple* GetNtuple() const;
118  tools::hbook::wntuple* GetNtuple(G4int ntupleId) const;
119 
120  // Iterators
121  std::vector<tools::hbook::h1*>::iterator BeginH1();
122  std::vector<tools::hbook::h1*>::iterator EndH1();
123  std::vector<tools::hbook::h1*>::const_iterator BeginConstH1() const;
124  std::vector<tools::hbook::h1*>::const_iterator EndConstH1() const;
125 
126  std::vector<tools::hbook::h2*>::iterator BeginH2();
127  std::vector<tools::hbook::h2*>::iterator EndH2();
128  std::vector<tools::hbook::h2*>::const_iterator BeginConstH2() const;
129  std::vector<tools::hbook::h2*>::const_iterator EndConstH2() const;
130 
131  std::vector<tools::hbook::wntuple*>::iterator BeginNtuple();
132  std::vector<tools::hbook::wntuple*>::iterator EndNtuple();
133  std::vector<tools::hbook::wntuple*>::const_iterator BeginConstNtuple() const;
134  std::vector<tools::hbook::wntuple*>::const_iterator EndConstNtuple() const;
135 
136  protected:
137  // virtual methods from base class
138  virtual G4bool OpenFileImpl(const G4String& fileName);
139  virtual G4bool WriteImpl();
140  virtual G4bool CloseFileImpl();
141 
142  private:
143  // static data members
144  //
145  static ExG4HbookAnalysisManager* fgInstance;
146 
147  // methods
148  //
149  void Reset();
150 
151  ExG4HbookH1Manager* fH1Manager;
152  ExG4HbookH2Manager* fH2Manager;
153  ExG4HbookH3DummyManager* fH3Manager;
154  ExG4HbookP1Manager* fP1Manager;
155  ExG4HbookP2DummyManager* fP2Manager;
156  ExG4HbookNtupleManager* fNtupleManager;
157  ExG4HbookFileManager* fFileManager;
158 };
159 
161 
162 #endif
163 
164 #endif
tools::hbook::wntuple G4Ntuple
Definition: g4hbook_defs.hh:56
tools::hbook::h2 G4AnaH2
Definition: g4hbook_defs.hh:50
virtual G4bool WriteImpl()=0
tools::hbook::h1 G4H1
Definition: g4hbook_defs.hh:45
int G4int
Definition: G4Types.hh:78
tools::histo::p1d G4P1
Definition: g4csv_defs.hh:62
tools::hbook::h2 G4H2
Definition: g4hbook_defs.hh:51
Manager class for P2 with dummy implementation.
bool G4bool
Definition: G4Types.hh:79
virtual G4bool OpenFileImpl(const G4String &fileName)=0
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:61
Manager class for H3 with dummy implementation.
tools::hbook::h1 G4AnaH1
Definition: g4hbook_defs.hh:44
virtual G4bool CloseFileImpl()=0