…a cryptically difficult task, apparently.
So I’ve managed to find quite a few threads that more or less cover the issue I’m having… but nothing I have tried seems to be working at all.
The short of it is, I have two files, each with one histogram inside. Not a tree, just a histogram. I’d like to open them one at a time, and make a copy of each of these histograms in a way that I can perform simple functions such as GetXmin() and GetBinContent(bin). Later of course, there are more complicated things to be done with the content, but it’s the first part that doesn’t seem to be working for me.
Let’s start with something a bit more simple, and I’ll work my way towards something I actually want to do, though:
TFile *file1 = new TFile("first_file.root"); // open the file, easy.
c1->Draw(); // the histogram I want is definitely there.
TH1D *hist1 = (TH1D*)file1->Get("c1"); // get the histogram, no complaints here.
hist1->Draw(); // I can draw the new histogram, great! Let's start doing useful things with it.
hist1->GetXaxis()->GetXmax(); // ...Oh. It doesn't work. I get the message: Error: Symbol hist1 is not defined in current scope. Productivity grinds to a screeching halt.
// in fact, at this point I can't even draw the histogram again. I can draw it once, and then it's gone; no longer defined in the current scope.
I’m lost. I can draw it once, but I can’t do anything else with it. Every thread I can find points towards this approach. If I were drawing data from a tree I’d be golden, but the syntax here seems to have taken a leap into the unknown: This is baffling.