Geant4 10.7.0
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)
 
virtual ~G4RootRFileManager ()
 
virtual G4String GetFileType () const final
 
virtual G4bool OpenRFile (const G4String &fileName, G4bool isPerThread)
 
tools::rroot::file * GetRFile (const G4String &fileName, G4bool isPerThread) const
 
- Public Member Functions inherited from G4BaseFileManager
 G4BaseFileManager (const G4AnalysisManagerState &state)
 
virtual ~G4BaseFileManager ()
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4String GetFileType () const
 
void AddFileName (const G4String &fileName)
 
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 GetNtupleFileName (const G4String &ntupleName) const
 
G4String GetNtupleFileName (G4int ntupleFileNumber) const
 
G4String GetPlotFileName () const
 

Additional Inherited Members

- Protected Attributes inherited from G4BaseFileManager
const G4AnalysisManagerStatefState
 
G4String fFileName
 
std::vector< G4StringfFileNames
 

Detailed Description

Definition at line 46 of file G4RootRFileManager.hh.

Constructor & Destructor Documentation

◆ G4RootRFileManager()

G4RootRFileManager::G4RootRFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 40 of file G4RootRFileManager.cc.

41 : G4BaseFileManager(state),
42 fRFiles()
43{
44}

◆ ~G4RootRFileManager()

G4RootRFileManager::~G4RootRFileManager ( )
virtual

Definition at line 47 of file G4RootRFileManager.cc.

48{
49 for (G4int i=0; i<G4int(fRFiles.size()); ++i) {
50 delete fRFiles[i];
51 }
52}
int G4int
Definition: G4Types.hh:85

Member Function Documentation

◆ GetFileType()

virtual G4String G4RootRFileManager::GetFileType ( ) const
inlinefinalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 52 of file G4RootRFileManager.hh.

52{ return "Root"; }

◆ GetRFile()

tools::rroot::file * G4RootRFileManager::GetRFile ( const G4String fileName,
G4bool  isPerThread 
) const

Definition at line 104 of file G4RootRFileManager.cc.

106{
107 // Get full file name
108 G4String name = GetFullFileName(fileName, isPerThread);
109
110 std::map<G4String, tools::rroot::file*>::const_iterator it
111 = fRFiles.find(name);
112 if ( it != fRFiles.end() )
113 return it->second;
114 else {
115 return nullptr;
116 }
117}
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
const char * name(G4int ptype)

Referenced by G4RootAnalysisReader::ReadNtupleImpl().

◆ OpenRFile()

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

Definition at line 59 of file G4RootRFileManager.cc.

61{
62 // Get full file name
63 G4String name = GetFullFileName(fileName, isPerThread);
64
65#ifdef G4VERBOSE
66 if ( fState.GetVerboseL4() )
67 fState.GetVerboseL4()->Message("open", "read analysis file", name);
68#endif
69
70 // create new file
71 tools::rroot::file* newFile = new tools::rroot::file(G4cout, name);
72 newFile->add_unziper('Z',tools::decompress_buffer);
73
74 if ( ! newFile->is_open() ) {
75 G4ExceptionDescription description;
76 description << " " << "Cannot open file " << name;
77 G4Exception("G4RootRFileManager::OpenFile()",
78 "Analysis_WR001", JustWarning, description);
79 delete newFile;
80 return false;
81 }
82
83 // add file in a map and delete the previous file if it exists
84 std::map<G4String, tools::rroot::file*>::iterator it
85 = fRFiles.find(name);
86 if ( it != fRFiles.end() ) {
87 delete it->second;
88 it->second = newFile;
89 }
90 else {
91 fRFiles[name] = newFile;
92 }
93
94#ifdef G4VERBOSE
95 if ( fState.GetVerboseL1() )
97 ->Message("open", "read analysis file", name);
98#endif
99
100 return true;
101}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
G4GLOB_DLL std::ostream G4cout
const G4AnalysisVerbose * GetVerboseL1() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState

Referenced by G4RootAnalysisReader::ReadNtupleImpl().


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