Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RootRFileManager Class Reference

#include <G4RootRFileManager.hh>

+ Inheritance diagram for G4RootRFileManager:

Public Member Functions

 G4RootRFileManager (const G4AnalysisManagerState &state)
 
 G4RootRFileManager ()=delete
 
 ~G4RootRFileManager () override
 
G4String GetFileType () const final
 
void CloseFiles () final
 
virtual G4bool OpenRFile (const G4String &fileName, G4bool isPerThread)
 
G4RootRFileGetRFile (const G4String &fileName, G4bool isPerThread) const
 
- Public Member Functions inherited from G4VRFileManager
 G4VRFileManager (const G4AnalysisManagerState &state)
 
 G4VRFileManager ()=delete
 
 ~G4VRFileManager () override=default
 
template<typename HT >
std::shared_ptr< G4VTHnRFileManager< HT > > GetHnRFileManager () const
 
- Public Member Functions inherited from G4BaseFileManager
 G4BaseFileManager (const G4AnalysisManagerState &state)
 
 G4BaseFileManager ()=delete
 
virtual ~G4BaseFileManager ()=default
 
void SetCompressionLevel (G4int level)
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4bool HasCycles () const
 
void AddFileName (const G4String &fileName)
 
G4int GetCompressionLevel () const
 
G4String GetFileName () const
 
G4String GetFullFileName (const G4String &baseFileName="", G4bool isPerThread=true) const
 
const std::vector< G4String > & GetFileNames () const
 
G4String GetHnFileName (const G4String &hnType, const G4String &hnName) const
 
G4String GetHnFileName (const G4String &fileName, G4int cycle=0) const
 
G4String GetNtupleFileName (const G4String &ntupleName, G4int cycle=0) const
 
G4String GetNtupleFileName (G4int ntupleFileNumber, G4int cycle=0) const
 
G4String GetPlotFileName () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4BaseFileManager
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 
void ClearData ()
 
- Protected Attributes inherited from G4VRFileManager
std::shared_ptr< G4VTHnRFileManager< tools::histo::h1d > > fH1RFileManager { nullptr }
 
std::shared_ptr< G4VTHnRFileManager< tools::histo::h2d > > fH2RFileManager { nullptr }
 
std::shared_ptr< G4VTHnRFileManager< tools::histo::h3d > > fH3RFileManager { nullptr }
 
std::shared_ptr< G4VTHnRFileManager< tools::histo::p1d > > fP1RFileManager { nullptr }
 
std::shared_ptr< G4VTHnRFileManager< tools::histo::p2d > > fP2RFileManager { nullptr }
 
- Protected Attributes inherited from G4BaseFileManager
const G4AnalysisManagerStatefState
 
G4int fCompressionLevel { 1 }
 
G4String fFileName
 
std::vector< G4StringfFileNames
 
- Static Protected Attributes inherited from G4VRFileManager
static constexpr std::string_view fkClass { "G4VRFileManager" }
 

Detailed Description

Definition at line 41 of file G4RootRFileManager.hh.

Constructor & Destructor Documentation

◆ G4RootRFileManager() [1/2]

G4RootRFileManager::G4RootRFileManager ( const G4AnalysisManagerState & state)
explicit

Definition at line 42 of file G4RootRFileManager.cc.

43 : G4VRFileManager(state)
44{
45 // Create helpers defined in the base class
46 fH1RFileManager = std::make_shared<G4RootHnRFileManager<histo::h1d>>(this);
47 fH2RFileManager = std::make_shared<G4RootHnRFileManager<histo::h2d>>(this);
48 fH3RFileManager = std::make_shared<G4RootHnRFileManager<histo::h3d>>(this);
49 fP1RFileManager = std::make_shared<G4RootHnRFileManager<histo::p1d>>(this);
50 fP2RFileManager = std::make_shared<G4RootHnRFileManager<histo::p2d>>(this);
51}
std::shared_ptr< G4VTHnRFileManager< tools::histo::h2d > > fH2RFileManager
std::shared_ptr< G4VTHnRFileManager< tools::histo::p2d > > fP2RFileManager
std::shared_ptr< G4VTHnRFileManager< tools::histo::h3d > > fH3RFileManager
G4VRFileManager()=delete
std::shared_ptr< G4VTHnRFileManager< tools::histo::p1d > > fP1RFileManager
std::shared_ptr< G4VTHnRFileManager< tools::histo::h1d > > fH1RFileManager

◆ G4RootRFileManager() [2/2]

G4RootRFileManager::G4RootRFileManager ( )
delete

◆ ~G4RootRFileManager()

G4RootRFileManager::~G4RootRFileManager ( )
override

Definition at line 54 of file G4RootRFileManager.cc.

55{
56 // Delete all open file and their directories
57 for ( auto& mapElement : fRFiles ) {
58 auto rfileTuple = mapElement.second;
59 delete std::get<1>(*rfileTuple); // histo directory
60 delete std::get<2>(*rfileTuple);; // ntuple directory
61 delete std::get<0>(*rfileTuple); // rfile
62 delete rfileTuple;
63 }
64}

Member Function Documentation

◆ CloseFiles()

void G4RootRFileManager::CloseFiles ( )
inlinefinalvirtual

Implements G4VRFileManager.

Definition at line 51 of file G4RootRFileManager.hh.

51{}

◆ GetFileType()

G4String G4RootRFileManager::GetFileType ( ) const
inlinefinalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 48 of file G4RootRFileManager.hh.

48{ return "Root"; }

◆ GetRFile()

G4RootRFile * G4RootRFileManager::GetRFile ( const G4String & fileName,
G4bool isPerThread ) const

Definition at line 107 of file G4RootRFileManager.cc.

109{
110 // Get full file name
111 G4String name = GetFullFileName(fileName, isPerThread);
112
113 auto it = fRFiles.find(name);
114 if (it != fRFiles.end()) {
115 return it->second;
116 }
117 return nullptr;
118}
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
const char * name(G4int ptype)

◆ OpenRFile()

G4bool G4RootRFileManager::OpenRFile ( const G4String & fileName,
G4bool isPerThread )
virtual

Definition at line 71 of file G4RootRFileManager.cc.

73{
74 // Get full file name
75 G4String name = GetFullFileName(fileName, isPerThread);
76
77 Message(kVL4, "open", "read analysis file", name);
78
79 // create new file
80 auto newFile = new tools::rroot::file(G4cout, name);
81 newFile->add_unziper('Z',toolx::decompress_buffer);
82
83 if ( ! newFile->is_open() ) {
84 Warn("Cannot open file " + name, fkClass, "OpenRFile");
85 delete newFile;
86 return false;
87 }
88
89 auto newFileTuple = new G4RootRFile(newFile, nullptr, nullptr);
90
91 // add file in a map and delete the previous file if it exists
92 auto it = fRFiles.find(name);
93 if ( it != fRFiles.end() ) {
94 delete it->second;
95 it->second = newFileTuple;
96 }
97 else {
98 fRFiles[name] = newFileTuple;
99 }
100
101 Message(kVL1, "open", "read analysis file", name);
102
103 return true;
104}
std::tuple< tools::rroot::file *, tools::rroot::directory *, tools::rroot::directory * > G4RootRFile
G4GLOB_DLL std::ostream G4cout
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
constexpr G4int kVL1
constexpr G4int kVL4
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

The documentation for this class was generated from the following files: