ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RootFileManager.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4RootFileManager.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 
27 // The manager for Root output file operations.
28 
29 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
30 
31 #ifndef G4RootFileManager_h
32 #define G4RootFileManager_h 1
33 
34 #include "G4VFileManager.hh"
35 #include "globals.hh"
36 
37 #include <vector>
38 #include <memory>
39 
40 namespace tools {
41 namespace wroot {
42 class file;
43 class directory;
44 }
45 }
46 
48 {
49  public:
50  explicit G4RootFileManager(const G4AnalysisManagerState& state);
51  virtual ~G4RootFileManager();
52 
53  // Methods to manipulate file
54  virtual G4bool OpenFile(const G4String& fileName) final;
55  virtual G4bool WriteFile() final;
56  virtual G4bool CloseFile() final;
57 
60 
61  // Set methods
62  void SetNofNtupleFiles(G4int nofFiles);
63  void SetBasketSize(unsigned int basketSize);
64  void SetBasketEntries(unsigned int basketEntries);
65 
66  // Get methods
67  tools::wroot::directory* GetHistoDirectory() const;
68  tools::wroot::directory* GetNtupleDirectory() const;
69  std::shared_ptr<tools::wroot::file> GetNtupleFile(G4int index) const;
70  tools::wroot::directory* GetMainNtupleDirectory(G4int index) const;
71  unsigned int GetBasketSize() const;
72  unsigned int GetBasketEntries() const;
73 
74  private:
75  // methods
77  G4bool WriteFile(std::shared_ptr<tools::wroot::file> rfile,
78  const G4String& fileName);
79  G4bool CloseFile(std::shared_ptr<tools::wroot::file> rfile,
80  const G4String& fileName);
81 
82  // data members
83  std::shared_ptr<tools::wroot::file> fFile;
84  tools::wroot::directory* fHistoDirectory;
85  tools::wroot::directory* fNtupleDirectory;
87  std::vector<std::shared_ptr<tools::wroot::file> > fNtupleFiles;
88  std::vector<tools::wroot::directory*> fMainNtupleDirectories;
89  unsigned int fBasketSize;
90  unsigned int fBasketEntries;
91 };
92 
93 // inline functions
94 
96 { fNofNtupleFiles = nofFiles; }
97 
98 inline void G4RootFileManager::SetBasketSize(unsigned int basketSize)
99 { fBasketSize = basketSize; }
100 
101 inline void G4RootFileManager::SetBasketEntries(unsigned int basketEntries)
102 { fBasketEntries = basketEntries; }
103 
104 inline tools::wroot::directory* G4RootFileManager::GetHistoDirectory() const
105 { return fHistoDirectory; }
106 
107 inline tools::wroot::directory* G4RootFileManager::GetNtupleDirectory() const
108 { return fNtupleDirectory; }
109 
110 inline unsigned int G4RootFileManager::GetBasketSize() const
111 { return fBasketSize; }
112 
113 inline unsigned int G4RootFileManager::GetBasketEntries() const
114 { return fBasketEntries; }
115 
116 #endif
117