37 #include <tools/rroot/file>
38 #include <tools/rroot/streamers>
39 #include <tools/rroot/fac>
40 #include <tools/rroot/tree>
41 #include <tools/rroot/ntuple>
46 using namespace G4Analysis;
54 if ( fgInstance ==
nullptr ) {
65 fNtupleManager(nullptr),
72 <<
"G4RootAnalysisReader already exists."
73 <<
"Cannot create another instance.";
74 G4Exception(
"G4RootAnalysisReader::G4RootAnalysisReader()",
112 G4bool isPerThread =
false;
122 = ( ! rfile ) ?
nullptr : rfile->dir().find_key(objectName);
127 char* charBuffer = 0;
128 if ( key ) charBuffer = key->get_object_buffer(*rfile, size);
130 if ( ! charBuffer ) {
134 <<
"Cannot get " << objectName <<
" in file " << fileName;
139 auto verbose =
false;
141 key->key_length(), verbose);
149 auto finalResult =
true;
152 finalResult = finalResult &&
result;
155 finalResult = finalResult &&
result;
178 auto h1 = tools::rroot::TH1D_stream(*
buffer);
185 <<
"Streaming " << h1Name <<
" in file " << fileName <<
" failed.";
220 auto h2 = tools::rroot::TH2D_stream(*
buffer);
227 <<
"Streaming " << h2Name <<
" in file " << fileName <<
" failed.";
258 auto h3 = tools::rroot::TH3D_stream(*
buffer);
265 <<
"Streaming " << h3Name <<
" in file " << fileName <<
" failed.";
299 auto p1 = tools::rroot::TProfile_stream(*
buffer);
306 <<
"Streaming " << p1Name <<
" in file " << fileName <<
" failed.";
337 auto p2 = tools::rroot::TProfile2D_stream(*
buffer);
344 <<
"Streaming " << p2Name <<
" in file " << fileName <<
" failed.";
373 auto isPerThread =
true;
374 if ( isUserFileName ) isPerThread =
false;
383 auto key = rfile->dir().find_key(ntupleName);
388 <<
"Key " << ntupleName <<
" for Ntuple not found in file " << fileName;
389 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",
395 char* charBuffer = key->get_object_buffer(*rfile, size);
396 if ( ! charBuffer ) {
400 <<
"Cannot get data buffer for Ntuple " << ntupleName <<
" in file " << fileName;
401 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",
406 auto verbose =
false;
409 key->key_length(), verbose);
410 buffer->set_map_objs(
true);
414 auto tree =
new tools::rroot::tree(*rfile, *
fac);
415 if ( ! tree->stream(*
buffer) ) {
419 <<
"TTree streaming failed for Ntuple " << ntupleName <<
" in file " << fileName;
420 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",
const G4AnalysisVerbose * GetVerboseL2() const
std::ostringstream G4ExceptionDescription
G4AnalysisManagerState fState
tools::rroot::file * GetRFile(const G4String &fileName, G4bool isPerThread) const
virtual G4int ReadP1Impl(const G4String &p1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
void SetFileManager(G4BaseFileManager *fileManager)
static G4RootAnalysisReader * fgMasterInstance
G4RootRNtupleManager * fNtupleManager
virtual G4int ReadH3Impl(const G4String &h3Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
G4RootRFileManager * fFileManager
static G4RootAnalysisReader * Instance()
virtual ~G4RootAnalysisReader()
const G4AnalysisVerbose * GetVerboseL4() const
virtual G4int ReadP2Impl(const G4String &p2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
virtual G4int ReadH2Impl(const G4String &h2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
G4double G4ParticleHPJENDLHEData::G4double result
static G4ThreadLocal G4RootAnalysisReader * fgInstance
virtual G4bool OpenRFile(const G4String &fileName, G4bool isPerThread)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4int SetNtuple(G4TRNtupleDescription< TNTUPLE > *rntupleDescription)
tools::rroot::buffer * GetBuffer(const G4String &fileName, const G4String &name, const G4String &inFunction)
virtual G4int ReadH1Impl(const G4String &h1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
static const G4double fac
G4RootAnalysisReader(G4bool isMaster=true)
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
G4GLOB_DLL std::ostream G4cout
G4bool GetIsMaster() const
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final