Geant4  10.02.p02
G4RootAnalysisManager.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: G4RootAnalysisManager.hh 92972 2015-09-23 14:36:03Z gcosmo $
27 
28 // The main manager for Root analysis.
29 // It delegates most of functions to the object specific managers.
30 
31 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
32 
33 #ifndef G4RootAnalysisManager_h
34 #define G4RootAnalysisManager_h 1
35 
37 #include "globals.hh"
38 
39 #include "tools/wroot/ntuple"
40 #include "tools/histo/hmpi"
41 
42 #include <memory>
43 
44 class G4RootFileManager;
46 
47 namespace tools {
48 namespace wroot {
49 class directory;
50 }
51 }
52 
54 {
55  public:
56  explicit G4RootAnalysisManager(G4bool isMaster = true);
57  virtual ~G4RootAnalysisManager();
58 
59  // static methods
61  static G4bool IsInstance();
62 
63  // Access methods
64  tools::wroot::ntuple* GetNtuple() const;
65  tools::wroot::ntuple* GetNtuple(G4int ntupleId) const;
66 
67  // Iterators
68  std::vector<tools::wroot::ntuple*>::iterator BeginNtuple();
69  std::vector<tools::wroot::ntuple*>::iterator EndNtuple();
70  std::vector<tools::wroot::ntuple*>::const_iterator BeginConstNtuple() const;
71  std::vector<tools::wroot::ntuple*>::const_iterator EndConstNtuple() const;
72 
73  protected:
74  // virtual methods from base class
75  virtual G4bool OpenFileImpl(const G4String& fileName) final;
76  virtual G4bool WriteImpl() final;
77  virtual G4bool CloseFileImpl() final;
78  virtual G4bool IsOpenFileImpl() const final;
79 
80  private:
81  // static data members
84 
85  // methods
86  template <typename T>
87  G4bool WriteT(const std::vector<T*>& htVector,
88  const std::vector<G4HnInformation*>& hnVector,
89  tools::wroot::directory* directory,
90  const G4String& hnType);
91  G4bool WriteH1();
92  G4bool WriteH2();
93  G4bool WriteH3();
94  G4bool WriteP1();
95  G4bool WriteP2();
96  G4bool Reset();
97 
98  // data members
100  std::shared_ptr<G4RootFileManager> fFileManager;
101 };
102 
103 #include "G4RootAnalysisManager.icc"
104 
105 #endif
virtual G4bool OpenFileImpl(const G4String &fileName) final
static G4RootAnalysisManager * fgMasterInstance
G4bool WriteT(const std::vector< T * > &htVector, const std::vector< G4HnInformation * > &hnVector, tools::wroot::directory *directory, const G4String &hnType)
std::vector< tools::wroot::ntuple * >::const_iterator BeginConstNtuple() const
virtual G4bool IsOpenFileImpl() const final
static G4ThreadLocal G4RootAnalysisManager * fgInstance
virtual G4bool CloseFileImpl() final
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4RootNtupleManager * fNtupleManager
bool G4bool
Definition: G4Types.hh:79
G4RootAnalysisManager(G4bool isMaster=true)
std::vector< tools::wroot::ntuple * >::const_iterator EndConstNtuple() const
virtual G4bool WriteImpl() final
static G4RootAnalysisManager * Instance()
std::vector< tools::wroot::ntuple * >::iterator EndNtuple()
std::vector< tools::wroot::ntuple * >::iterator BeginNtuple()
std::shared_ptr< G4RootFileManager > fFileManager
tools::wroot::ntuple * GetNtuple() const