hi all
i’m using root version 5.32 and i don’t understand why this program shouldn’t work:
//////////////////////// BEGIN
#include
#include “TFile.h”
#include “TTree.h”
#include “TH1D.h”
int main() {
TFile* file = TFile::Open(“testfile.root”);
TTree* tree = (TTree*)file->Get(“tree_passedEvents”);
TH1D* h1 = new TH1D(“h1”, “”, 100, 0., 300.);
tree->Project(“h1”, “mt_top”, “”);
file->Close();
std::cout << h1->GetEntries() << std::endl;
std::cout << h1->GetMean() << std::endl;
return 0;
}
//////////////////////// END
it does work if i comment the line that closes the file, but in the usecase i need it for i’d like to have that TFile closed. in principle though, once the tree has been projected into the histogram, shouldnt the histogram be just a normal histogram, not linked anymore to the tree nor the file?
if needed you can find the code and the necessary rootfile in here: dl.dropboxusercontent.com/u/795 … xample.tar
thanks
f