36 #include <tools/rroot/file>
37 #include <tools/rroot/streamers>
38 #include <tools/rroot/fac>
39 #include <tools/rroot/tree>
40 #include <tools/rroot/ntuple>
45 using namespace G4Analysis;
53 if ( fgInstance ==
nullptr ) {
64 fNtupleManager(nullptr),
71 <<
"G4RootAnalysisReader already exists."
72 <<
"Cannot create another instance.";
73 G4Exception(
"G4RootAnalysisReader::G4RootAnalysisReader()",
111 G4bool isPerThread =
false;
121 = ( !
rfile ) ?
nullptr :
rfile->dir().find_key(objectName);
126 char* charBuffer = 0;
127 if ( key ) charBuffer = key->get_object_buffer(*
rfile, size);
129 if ( ! charBuffer ) {
133 <<
"Cannot get " << objectName <<
" in file " << fileName;
138 auto verbose =
false;
140 key->key_length(), verbose);
148 auto finalResult =
true;
151 finalResult = finalResult && result;
154 finalResult = finalResult && result;
177 auto h1 = tools::rroot::TH1D_stream(*
buffer);
184 <<
"Streaming " << h1Name <<
" in file " << fileName <<
" failed.";
219 auto h2 = tools::rroot::TH2D_stream(*
buffer);
226 <<
"Streaming " << h2Name <<
" in file " << fileName <<
" failed.";
257 auto h3 = tools::rroot::TH3D_stream(*
buffer);
264 <<
"Streaming " << h3Name <<
" in file " << fileName <<
" failed.";
298 auto p1 = tools::rroot::TProfile_stream(*
buffer);
305 <<
"Streaming " << p1Name <<
" in file " << fileName <<
" failed.";
336 auto p2 = tools::rroot::TProfile2D_stream(*
buffer);
343 <<
"Streaming " << p2Name <<
" in file " << fileName <<
" failed.";
372 auto isPerThread =
true;
373 if ( isUserFileName ) isPerThread =
false;
382 auto key =
rfile->dir().find_key(ntupleName);
387 <<
"Key " << ntupleName <<
" for Ntuple not found in file " << fileName;
388 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",
394 char* charBuffer = key->get_object_buffer(*
rfile, size);
395 if ( ! charBuffer ) {
399 <<
"Cannot get data buffer for Ntuple " << ntupleName <<
" in file " << fileName;
400 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",
405 auto verbose =
false;
408 key->key_length(), verbose);
409 buffer->set_map_objs(
true);
418 <<
"TTree streaming failed for Ntuple " << ntupleName <<
" in file " << fileName;
419 G4Exception(
"G4RootAnalysisReader::ReadNtupleImpl()",