Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion macros/REST_OpenInputFile.C
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
bool gSchemaError = false;

void SchemaErrorHandler(int level, Bool_t abort, const char* location, const char* msg) {
if (level >= kError) {
std::string loc(location);
if (loc.find("TBufferFile") != std::string::npos || loc.find("TStreamerInfo") != std::string::npos) {
gSchemaError = true;
}
}
DefaultErrorHandler(level, abort, location, msg);
}

TRestRun* run = nullptr;
TRestAnalysisTree* ana_tree = nullptr;
TTree* ev_tree = nullptr;
Expand All @@ -6,7 +18,10 @@ TRestDataSet* dSet = nullptr;
void REST_OpenInputFile(const std::string& fileName) {
if (TRestTools::isRunFile(fileName)) {
printf("\n%s\n\n", "REST processed file identified. It contains a valid TRestRun.");
gSchemaError = false;
auto oldHandler = SetErrorHandler(SchemaErrorHandler);
run = new TRestRun(fileName);
SetErrorHandler(oldHandler);
// print number of entries in the run
printf("\nThe run has %lld entries.\n", run->GetEntries());
printf("\nAttaching TRestRun %s as run...\n", fileName.c_str());
Expand All @@ -17,7 +32,16 @@ void REST_OpenInputFile(const std::string& fileName) {
std::string eventType = run->GetInputEvent()->ClassName();
std::string evcmd = Form("%s* ev = (%s*)run->GetInputEvent();", eventType.c_str(), eventType.c_str());
gROOT->ProcessLine(evcmd.c_str());
run->GetEntry(0);
if (gSchemaError) {
printf(
"\nWARNING: Schema errors were detected. This file was produced with an older REST "
"version.\n");
printf(
"Event browsing is disabled to prevent hanging. You can still use ana_tree and "
"metadata.\n\n");
} else {
run->GetEntry(0);
}
printf("Attaching input event %s as ev...\n", eventType.c_str());
for (int n = 0; n < run->GetNumberOfMetadata(); n++) {
if (n == 0) printf("Attaching Metadata classes:\n");
Expand Down
Loading