34 #include "tools/wroot/file"
40 using namespace G4Analysis;
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 ( ! fIsOpenFile )
return true;
132 if ( fState.GetVerboseL4() )
133 fState.GetVerboseL4()->Message(
"write",
"file", fileName);
137 auto result = rfile->write(n);
140 if ( fState.GetVerboseL1() )
141 fState.GetVerboseL1()->Message(
"write",
"file", fileName,
result);
156 if ( ! fIsOpenFile )
return true;
159 if ( fState.GetVerboseL4() )
160 fState.GetVerboseL4()->Message(
"close",
"file", fileName);
166 if ( fState.GetVerboseL1() )
167 fState.GetVerboseL1()->Message(
"close",
"file", fileName,
true);
188 fFile->add_ziper(
'Z',tools::compress_buffer);
191 if ( !
fFile->is_open() ) {
194 description <<
" " <<
"Cannot open file " << fileName;
219 auto finalResult =
true;
222 finalResult = finalResult &&
result;
227 finalResult = finalResult &&
result;
235 auto finalResult =
true;
238 finalResult = finalResult &&
result;
243 finalResult = finalResult &&
result;
272 G4Exception(
"G4RootFileManager::CreateHistoDirectory()",
306 G4Exception(
"G4RootFileManager::CreateNtupleDirectory()",
321 std::shared_ptr<tools::wroot::file>
327 G4String inFunction =
"G4RootFileManager::GetNtupleFile()";
329 description <<
" " <<
"ntuple file " << index <<
" does not exist.";
338 tools::wroot::directory*
344 G4String inFunction =
"G4RootFileManager::GetMainNtupleDirectory()";
346 description <<
" " <<
"main ntuple directory " << index <<
" does not exist.";
const G4AnalysisVerbose * GetVerboseL2() const
virtual G4bool CloseFile() final
std::vector< std::shared_ptr< tools::wroot::file > > fNtupleFiles
std::ostringstream G4ExceptionDescription
G4bool CreateHistoDirectory()
G4RootFileManager(const G4AnalysisManagerState &state)
G4String GetNtupleFileName(const G4String &ntupleName) const
G4bool CreateNtupleDirectory()
tools::wroot::directory * fNtupleDirectory
G4bool fLockHistoDirectoryName
tools::wroot::directory * GetMainNtupleDirectory(G4int index) const
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
G4bool fLockNtupleDirectoryName
virtual G4bool WriteFile() final
virtual G4bool OpenFile(const G4String &fileName) final
G4String fHistoDirectoryName
const G4AnalysisVerbose * GetVerboseL4() const
std::shared_ptr< tools::wroot::file > GetNtupleFile(G4int index) const
std::vector< tools::wroot::directory * > fMainNtupleDirectories
const G4AnalysisManagerState & fState
virtual ~G4RootFileManager()
G4double G4ParticleHPJENDLHEData::G4double result
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::shared_ptr< tools::wroot::file > fFile
tools::wroot::directory * fHistoDirectory
G4String fNtupleDirectoryName
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
G4GLOB_DLL std::ostream G4cout
G4int GetCompressionLevel() const
const G4AnalysisVerbose * GetVerboseL1() const