Geant4  10.02.p02
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 HBOOK ID for P1
107  // ( default value = firstHistoID + 200 if firstHistoID > 0;
108  // otherwise = 201 )
109  G4bool SetP1HbookIdOffset(G4int offset);
110  G4int GetP1HbookIdOffset() const;
111 
112  // Set the offset of NTUPLE ID for ntuples
113  // ( default value = firstNtupleID if firstNtupleID > 0; otherwise = 1)
114  G4bool SetNtupleHbookIdOffset(G4int offset);
115  G4int GetNtupleHbookIdOffset() const;
116 
117  // Access methods
118  //
119  tools::hbook::h1* GetH1(G4int id, G4bool warn = true,
120  G4bool onlyIfActive = true) const;
121  tools::hbook::h2* GetH2(G4int id, G4bool warn = true,
122  G4bool onlyIfActive = true) const;
123  tools::hbook::p1* GetP1(G4int id, G4bool warn = true,
124  G4bool onlyIfActive = true) const;
125  tools::hbook::wntuple* GetNtuple() const;
126  tools::hbook::wntuple* GetNtuple(G4int ntupleId) const;
127 
128  // Iterators
129  std::vector<tools::hbook::h1*>::iterator BeginH1();
130  std::vector<tools::hbook::h1*>::iterator EndH1();
131  std::vector<tools::hbook::h1*>::const_iterator BeginConstH1() const;
132  std::vector<tools::hbook::h1*>::const_iterator EndConstH1() const;
133 
134  std::vector<tools::hbook::h2*>::iterator BeginH2();
135  std::vector<tools::hbook::h2*>::iterator EndH2();
136  std::vector<tools::hbook::h2*>::const_iterator BeginConstH2() const;
137  std::vector<tools::hbook::h2*>::const_iterator EndConstH2() const;
138 
139  std::vector<tools::hbook::p1*>::iterator BeginP1();
140  std::vector<tools::hbook::p1*>::iterator EndP1();
141  std::vector<tools::hbook::p1*>::const_iterator BeginConstP1() const;
142  std::vector<tools::hbook::p1*>::const_iterator EndConstP1() const;
143 
144  std::vector<tools::hbook::wntuple*>::iterator BeginNtuple();
145  std::vector<tools::hbook::wntuple*>::iterator EndNtuple();
146  std::vector<tools::hbook::wntuple*>::const_iterator BeginConstNtuple() const;
147  std::vector<tools::hbook::wntuple*>::const_iterator EndConstNtuple() const;
148 
149  protected:
150  // virtual methods from base class
151  virtual G4bool OpenFileImpl(const G4String& fileName);
152  virtual G4bool WriteImpl();
153  virtual G4bool CloseFileImpl();
154  virtual G4bool PlotImpl();
155  virtual G4bool MergeImpl(tools::histo::hmpi* hmpi);
156  virtual G4bool IsOpenFileImpl() const;
157 
158  private:
159  // static data members
160  //
161  static ExG4HbookAnalysisManager* fgInstance;
162 
163  // methods
164  //
165  void Reset();
166 
167  ExG4HbookH1Manager* fH1Manager;
168  ExG4HbookH2Manager* fH2Manager;
169  ExG4HbookH3DummyManager* fH3Manager;
170  ExG4HbookP1Manager* fP1Manager;
171  ExG4HbookP2DummyManager* fP2Manager;
172  ExG4HbookNtupleManager* fNtupleManager;
173  std::shared_ptr<ExG4HbookFileManager> fFileManager;
174 };
175 
177 
178 #endif
179 
180 #endif
virtual G4bool MergeImpl(tools::histo::hmpi *hmpi)=0
tools::hbook::wntuple G4Ntuple
Definition: g4hbook_defs.hh:61
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::hbook::h2 G4H2
Definition: g4hbook_defs.hh:51
virtual G4bool PlotImpl()=0
Manager class for P2 with dummy implementation.
bool G4bool
Definition: G4Types.hh:79
virtual G4bool OpenFileImpl(const G4String &fileName)=0
virtual G4bool IsOpenFileImpl() const =0
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:66
Manager class for H3 with dummy implementation.
tools::hbook::h1 G4AnaH1
Definition: g4hbook_defs.hh:44
virtual G4bool CloseFileImpl()=0
tools::hbook::p1 G4P1
Definition: g4hbook_defs.hh:56