Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RootFileManager.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
27// The manager for Root output file operations.
28
29// Author: Ivana Hrivnacova, 18/06/2013 ([email protected])
30
31#ifndef G4RootFileManager_h
32#define G4RootFileManager_h 1
33
34#include "G4VTFileManager.hh"
35#include "G4RootFileDef.hh"
36#include "globals.hh"
37
38#include <vector>
39#include <memory>
40#include <tuple>
41
42namespace tools {
43namespace wroot{
44class ntuple;
45}
46}
47
48// Types alias
50
51class G4RootFileManager : public G4VTFileManager<G4RootFile>
52{
53 public:
54 explicit G4RootFileManager(const G4AnalysisManagerState& state);
55 virtual ~G4RootFileManager();
56
60
61 // Methods to manipulate file from base classes
62 virtual G4bool OpenFile(const G4String& fileName) final;
63
64 virtual G4String GetFileType() const final { return "root"; }
65
66 // Specific methods for files per objects
67 std::shared_ptr<G4RootFile> CreateNtupleFile(RootNtupleDescription* ntupleDescription,
68 G4int mainNumber = -1);
69 std::shared_ptr<G4RootFile> GetNtupleFile(RootNtupleDescription* ntupleDescription,
70 G4bool perThread = true,
71 G4int mainNumber = -1) const;
73 G4bool CloseNtupleFile(RootNtupleDescription* ntupleDescription);
74
75 // Set methods
76 void SetBasketSize(unsigned int basketSize);
77 void SetBasketEntries(unsigned int basketEntries);
78
79 // Get methods
80 unsigned int GetBasketSize() const;
81 unsigned int GetBasketEntries() const;
82
83 protected:
84 // Methods derived from templated base class
85 virtual std::shared_ptr<G4RootFile> CreateFileImpl(const G4String& fileName) final;
86 virtual G4bool WriteFileImpl(std::shared_ptr<G4RootFile> file) final;
87 virtual G4bool CloseFileImpl(std::shared_ptr<G4RootFile> file) final;
88
89 private:
90 // methods
91 tools::wroot::directory* CreateDirectory(
92 std::shared_ptr<tools::wroot::file> rfile,
93 const G4String& directoryName,
94 const G4String& objectType) const;
95 G4String GetNtupleFileName(
96 RootNtupleDescription* ntupleDescription,
97 G4bool perThread = true,
98 G4int mainNumber = -1) const;
99
100 // data members
101 unsigned int fBasketSize;
102 unsigned int fBasketEntries;
103};
104
105// inline functions
106
107//_____________________________________________________________________________
108inline void G4RootFileManager::SetBasketSize(unsigned int basketSize)
109{ fBasketSize = basketSize; }
110
111//_____________________________________________________________________________
112inline void G4RootFileManager::SetBasketEntries(unsigned int basketEntries)
113{ fBasketEntries = basketEntries; }
114
115//_____________________________________________________________________________
116inline unsigned int G4RootFileManager::GetBasketSize() const
117{ return fBasketSize; }
118
119//_____________________________________________________________________________
120inline unsigned int G4RootFileManager::GetBasketEntries() const
121{ return fBasketEntries; }
122
123#endif
124
std::tuple< std::shared_ptr< tools::wroot::file >, tools::wroot::directory *, tools::wroot::directory * > G4RootFile
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4String GetNtupleFileName(const G4String &ntupleName) const
G4bool CloseNtupleFile(RootNtupleDescription *ntupleDescription)
G4bool WriteNtupleFile(RootNtupleDescription *ntupleDescription)
unsigned int GetBasketSize() const
virtual std::shared_ptr< G4RootFile > CreateFileImpl(const G4String &fileName) final
unsigned int GetBasketEntries() const
virtual ~G4RootFileManager()
void SetBasketSize(unsigned int basketSize)
virtual G4String GetFileType() const final
virtual G4bool CloseFileImpl(std::shared_ptr< G4RootFile > file) final
std::shared_ptr< G4RootFile > GetNtupleFile(RootNtupleDescription *ntupleDescription, G4bool perThread=true, G4int mainNumber=-1) const
void SetBasketEntries(unsigned int basketEntries)
virtual G4bool OpenFile(const G4String &fileName) final
virtual G4bool WriteFileImpl(std::shared_ptr< G4RootFile > file) final
std::shared_ptr< G4RootFile > CreateNtupleFile(RootNtupleDescription *ntupleDescription, G4int mainNumber=-1)
virtual G4bool WriteFile(const G4String &fileName) final
virtual G4bool CloseFile(const G4String &fileName) final