34 #include "tools/wroot/file"
46 fHistoDirectory(nullptr),
47 fNtupleDirectory(nullptr),
50 fMainNtupleDirectories(),
65 auto finalResult =
true;
78 auto rfile = std::make_shared<tools::wroot::file>(
G4cout,
name);
79 rfile->add_ziper(
'Z', tools::compress_buffer);
82 if ( ! rfile->is_open() ) {
84 description <<
" " <<
"Cannot open file " <<
name;
93 tools::wroot::directory* directory = &rfile->dir();
100 G4Exception(
"G4RootFileManager::OpenNtupleFiles()",
102 directory = &
fFile->dir();
129 if ( fState.GetVerboseL4() )
130 fState.GetVerboseL4()->Message(
"write",
"file", fileName);
134 auto result = rfile->write(n);
137 if ( fState.GetVerboseL1() )
138 fState.GetVerboseL1()->Message(
"write",
"file", fileName, result);
153 if ( fState.GetVerboseL4() )
154 fState.GetVerboseL4()->Message(
"close",
"file", fileName);
160 if ( fState.GetVerboseL1() )
161 fState.GetVerboseL1()->Message(
"close",
"file", fileName,
true);
182 fFile->add_ziper(
'Z',tools::compress_buffer);
185 if ( !
fFile->is_open() ) {
187 description <<
" " <<
"Cannot open file " << fileName;
212 auto finalResult =
true;
215 finalResult = finalResult && result;
220 finalResult = finalResult && result;
228 auto finalResult =
true;
231 finalResult = finalResult && result;
236 finalResult = finalResult && result;
265 G4Exception(
"G4RootFileManager::CreateHistoDirectory()",
299 G4Exception(
"G4RootFileManager::CreateNtupleDirectory()",
314 std::shared_ptr<tools::wroot::file>
320 G4String inFunction =
"G4RootFileManager::GetNtupleFile()";
322 description <<
" " <<
"ntuple file " << index <<
" does not exist.";
331 tools::wroot::directory*
337 G4String inFunction =
"G4RootFileManager::GetMainNtupleDirectory()";
339 description <<
" " <<
"main ntuple directory " << index <<
" does not exist.";
std::vector< std::shared_ptr< tools::wroot::file > > fNtupleFiles
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
G4bool CreateNtupleDirectory()
std::shared_ptr< tools::wroot::file > fFile
const G4AnalysisManagerState & fState
G4bool fLockHistoDirectoryName
G4int GetCompressionLevel() const
G4String fNtupleDirectoryName
std::ostringstream G4ExceptionDescription
G4String GetNtupleFileName(const G4String &ntupleName) const
G4bool CreateHistoDirectory()
tools::wroot::directory * fNtupleDirectory
virtual G4bool CloseFile() final
virtual G4bool WriteFile() final
const char * name(G4int ptype)
G4String fHistoDirectoryName
std::vector< tools::wroot::directory * > fMainNtupleDirectories
tools::wroot::directory * fHistoDirectory
const G4AnalysisVerbose * GetVerboseL2() const
std::shared_ptr< tools::wroot::file > GetNtupleFile(G4int index) const
G4RootFileManager(const G4AnalysisManagerState &state)
G4GLOB_DLL std::ostream G4cout
virtual G4bool OpenFile(const G4String &fileName) final
const G4AnalysisVerbose * GetVerboseL4() const
virtual ~G4RootFileManager()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4bool fLockNtupleDirectoryName
tools::wroot::directory * GetMainNtupleDirectory(G4int index) const
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
const G4AnalysisVerbose * GetVerboseL1() const