38 #include <tools/rroot/file>
39 #include <tools/rroot/streamers>
40 #include <tools/rroot/fac>
41 #include <tools/rroot/tree>
42 #include <tools/rroot/ntuple>
55 if ( fgInstance ==
nullptr ) {
66 fNtupleManager(nullptr),
73 <<
"G4RootAnalysisReader already exists."
74 <<
"Cannot create another instance.";
75 G4Exception(
"G4RootAnalysisReader::G4RootAnalysisReader()",
113 G4bool isPerThread =
false;
123 = ( ! rfile ) ?
nullptr : rfile->dir().find_key(objectName);
128 char* charBuffer = 0;
129 if ( key ) charBuffer = key->get_object_buffer(size);
131 if ( ! charBuffer ) {
135 <<
"Cannot get " << objectName <<
" in file " << fileName;
140 auto verbose =
false;
142 key->key_length(), verbose);
150 auto finalResult =
true;
153 finalResult = finalResult && result;
156 finalResult = finalResult && result;
178 auto h1 = tools::rroot::TH1D_stream(*
buffer);
185 <<
"Streaming " << h1Name <<
" in file " << fileName <<
" failed.";
219 auto h2 = tools::rroot::TH2D_stream(*
buffer);
226 <<
"Streaming " << h2Name <<
" in file " << fileName <<
" failed.";
256 auto h3 = tools::rroot::TH3D_stream(*
buffer);
263 <<
"Streaming " << h3Name <<
" in file " << fileName <<
" failed.";
296 auto p1 = tools::rroot::TProfile_stream(*
buffer);
303 <<
"Streaming " << p1Name <<
" in file " << fileName <<
" failed.";
333 auto p2 = tools::rroot::TProfile2D_stream(*
buffer);
340 <<
"Streaming " << p2Name <<
" in file " << fileName <<
" failed.";
368 auto isPerThread =
true;
369 if ( isUserFileName ) isPerThread =
false;
378 auto key = rfile->dir().find_key(ntupleName);
383 <<
"Key " << ntupleName <<
" for Ntuple not found in file " << fileName;
384 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",
390 char* charBuffer = key->get_object_buffer(size);
391 if ( ! charBuffer ) {
395 <<
"Cannot get data buffer for Ntuple " << ntupleName <<
" in file " << fileName;
396 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",
401 auto verbose =
false;
404 key->key_length(), verbose);
407 auto tree =
new tools::rroot::tree(*rfile, *fac);
408 if ( ! tree->stream(*
buffer) ) {
412 <<
"TTree streaming failed for Ntuple " << ntupleName <<
" in file " << fileName;
413 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",
422 =
new tools::rroot::ntuple(*tree);
423 auto rntupleDescription
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
G4RootRFileManager * fFileManager
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, G4bool isUserFileName) final
G4AnalysisManagerState fState
virtual G4int ReadH3Impl(const G4String &h3Name, const G4String &fileName, G4bool isUserFileName) final
const G4AnalysisVerbose * GetVerboseL2() const
G4RootRNtupleManager * fNtupleManager
G4int SetNtuple(G4RootRNtupleDescription *rntupleDescription)
virtual G4bool OpenRFile(const G4String &fileName, G4bool isPerThread)
G4GLOB_DLL std::ostream G4cout
const G4AnalysisVerbose * GetVerboseL4() const
virtual G4int ReadH2Impl(const G4String &h2Name, const G4String &fileName, G4bool isUserFileName) final
static G4ThreadLocal G4RootAnalysisReader * fgInstance
tools::rroot::file * GetRFile(const G4String &fileName, G4bool isPerThread) const
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
virtual ~G4RootAnalysisReader()
virtual G4int ReadH1Impl(const G4String &h1Name, const G4String &fileName, G4bool isUserFileName) final
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4RootAnalysisReader * Instance()
tools::rroot::buffer * GetBuffer(const G4String &fileName, const G4String &name, const G4String &inFunction)
G4bool GetIsMaster() const
virtual G4int ReadP1Impl(const G4String &p1Name, const G4String &fileName, G4bool isUserFileName) final
static const G4double fac
static G4RootAnalysisReader * fgMasterInstance
G4RootAnalysisReader(G4bool isMaster=true)
virtual G4int ReadP2Impl(const G4String &p2Name, const G4String &fileName, G4bool isUserFileName) final
void SetFileManager(G4BaseFileManager *fileManager)