34#include "tools/rroot/file"
35#include "tools/rroot/rall"
36#include "tools/rroot/streamers"
37#include "tools/rroot/fac"
38#include "tools/rroot/tree"
61 auto isPerThread =
true;
62 if ( isUserFileName ) isPerThread =
false;
65 auto rfile =
fFileManager->GetRFile(fileName, isPerThread);
72 tools::rroot::key* key =
nullptr;
73 tools::rroot::TDirectory* newDir =
nullptr;
74 if ( ! dirName.empty() ) {
75 newDir = tools::rroot::find_dir(rfile->dir(), dirName);
77 key = newDir->find_key(ntupleName);
81 "Directory " + dirName +
" not found in file " + fileName +
".",
87 key = rfile->dir().find_key(ntupleName);
91 Warn(
"Key " + ntupleName +
" for Ntuple not found in file " + fileName +
92 ", directory " + dirName,
fkClass,
"ReadNtupleImpl");
98 char* charBuffer = key->get_object_buffer(*rfile, size);
100 Warn(
"Cannot get data buffer for Ntuple " + ntupleName +
101 " in file " + fileName,
fkClass,
"ReadNtupleImpl");
106 auto verbose =
false;
109 key->key_length(), verbose);
110 buffer->set_map_objs(
true);
114 auto tree =
new tools::rroot::tree(*rfile, *
fac);
115 if ( ! tree->stream(*
buffer) ) {
116 Warn(
"TTree streaming failed for Ntuple " + ntupleName +
117 " in file " + fileName,
126 auto rntuple =
new tools::rroot::ntuple(*tree);
140 auto ntuple = ntupleDescription->
fNtuple;
146 if ( ! ntuple->initialize(
G4cout, *ntupleBinding) ) {
147 Warn(
"Ntuple initialization failed !!",
fkClass,
"GetTNtupleRow");
154 auto next = ntuple->next();
156 if ( ! ntuple->get_row() ) {
157 Warn(
"Ntuple get_row() failed !!",
fkClass,
"GetTNtupleRow");
static const G4double fac
G4GLOB_DLL std::ostream G4cout
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
std::shared_ptr< G4RootRFileManager > fFileManager
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
G4RootRNtupleManager()=delete
static constexpr std::string_view fkClass
virtual G4bool GetTNtupleRow(G4TRNtupleDescription< tools::rroot::ntuple > *ntupleDescription) final
G4int SetNtuple(G4TRNtupleDescription< tools::rroot::ntuple > *rntupleDescription)
constexpr G4int kInvalidId
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
tools::ntuple_binding * fNtupleBinding