I modified my script to call TFile::Open()
, instead of taking a pointer to a TFile. It’s a modification from this post. According to Philippe, this is not the most efficient way to do this, see here.
Thus far this is the most robust method I’ve found.
#include <TFile.h>
#include <TH1.h>
#include <iostream>
void viewOnline(const std::string &filename, const int &id) {
const char *name = ("h"+std::to_string(id)).c_str();
TFile *file = TFile::Open(filename.c_str());
TH1D *hist1;
file->GetObject(name, hist1);
hist1->Draw();
}