I am absolutely sure I’m missing something obvious, but I have a root file with two trees and histograms in their branches. I open the file, get the tree and then start trying to do things with the histograms in those branches.
I get the following errors: test.C:47:5:error:no member named ‘SetDirectory’ in 'std::vector<int, std::allocator >'
h1->SetDirectory(gROOT);
I have also tried using TH1F* h1 = (TH1F*)gDirectory->Get(“m_nominal”); but this does not find m_nominal, which I have checked does indeed exist in the file.
Thanks for any help, sorry if this is a really silly syntax error!
But h1 is ntrack of a jet, which should be a vector of integers, right? Unless I misunderstood what I’m supposed to declare there and it’s not the variable in the branch. The print statement outputs:
Actually that’s weird that pt is showing as a vector int, that’s not right… I screwed up making the tree I think. But when I’ve fixed that I’ll still have the same format and still need a way to access it
Well, if they are vector<int>, then they are not histograms, and you cannot call h1->SetDirectory(gROOT); you have to read the vector and then fill an histogram with their values. Something like this:
Oh dear, I knew it would be something silly… Thanks, that was driving me crazy! I think I’m hugely overcomplicating what I need to do, I’ll have a think about whether I want to store histos or variables. Thanks again!