Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4RootAnalysisManager.hh
이 파일의 문서화 페이지로 가기
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 106985 2017-10-31 10:07:18Z 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;
48 
49 namespace tools {
50 namespace wroot {
51 class directory;
52 }
53 }
54 
55 enum class G4NtupleMergeMode {
56  kNone,
57  kMain,
58  kSlave
59 };
60 
62 {
63  public:
64  explicit G4RootAnalysisManager(G4bool isMaster = true);
65  virtual ~G4RootAnalysisManager();
66 
67  // static methods
69  static G4bool IsInstance();
70 
71  // Access methods
73  tools::wroot::ntuple* GetNtuple(G4int ntupleId) const;
74 
75  // Iterators
76  std::vector<tools::wroot::ntuple*>::iterator BeginNtuple();
77  std::vector<tools::wroot::ntuple*>::iterator EndNtuple();
78  std::vector<tools::wroot::ntuple*>::const_iterator BeginConstNtuple() const;
79  std::vector<tools::wroot::ntuple*>::const_iterator EndConstNtuple() const;
80 
81  // MT/MPI
82  void SetNtupleMerging(G4bool mergeNtuples,
83  G4int nofReducedNtupleFiles = 0,
84  G4bool rowWise = 0,
85  unsigned int basketSize = fgkDefaultBasketSize);
86 
87  protected:
88  // virtual methods from base class
89  virtual G4bool OpenFileImpl(const G4String& fileName) final;
90  virtual G4bool WriteImpl() final;
91  virtual G4bool CloseFileImpl() final;
92  virtual G4bool IsOpenFileImpl() const final;
93 
94  private:
95  // constants
96  static constexpr unsigned int fgkDefaultBasketSize = 32000;
97 
98  // static data members
101 
102  // methods
103  void SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles);
104  void ClearNtupleManagers();
105  void CreateNtupleManagers();
107 
108  template <typename T>
109  G4bool WriteT(const std::vector<T*>& htVector,
110  const std::vector<G4HnInformation*>& hnVector,
111  tools::wroot::directory* directory,
112  const G4String& hnType);
113  G4bool WriteH1();
114  G4bool WriteH2();
115  G4bool WriteH3();
116  G4bool WriteP1();
117  G4bool WriteP2();
119  G4bool Reset();
120 
121  // data members
127  std::shared_ptr<G4RootFileManager> fFileManager;
128 };
129 
130 #include "G4RootAnalysisManager.icc"
131 
132 #endif
G4RootPNtupleManager * fSlaveNtupleManager
std::vector< tools::wroot::ntuple * >::const_iterator EndConstNtuple() const
std::vector< tools::wroot::ntuple * >::iterator BeginNtuple()
static constexpr unsigned int fgkDefaultBasketSize
virtual G4bool IsOpenFileImpl() const final
TTree * ntuple
std::shared_ptr< G4RootFileManager > fFileManager
virtual G4bool OpenFileImpl(const G4String &fileName) final
G4bool WriteT(const std::vector< T * > &htVector, const std::vector< G4HnInformation * > &hnVector, tools::wroot::directory *directory, const G4String &hnType)
tools::wroot::ntuple * GetNtuple() const
#define G4ThreadLocal
Definition: tls.hh:69
virtual G4bool WriteImpl() final
bool G4bool
Definition: G4Types.hh:79
void SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles)
virtual G4bool CloseFileImpl() final
G4NtupleMergeMode fNtupleMergeMode
std::vector< tools::wroot::ntuple * >::iterator EndNtuple()
int G4int
Definition: G4Types.hh:78
G4RootAnalysisManager(G4bool isMaster=true)
static G4RootAnalysisManager * Instance()
G4RootNtupleManager * fNtupleManager
std::vector< tools::wroot::ntuple * >::const_iterator BeginConstNtuple() const
static G4ThreadLocal G4RootAnalysisManager * fgInstance
void SetNtupleMerging(G4bool mergeNtuples, G4int nofReducedNtupleFiles=0, G4bool rowWise=0, unsigned int basketSize=fgkDefaultBasketSize)
static G4RootAnalysisManager * fgMasterInstance