to access the stats box works fine for simple histograms. However, I try the following (h1 is a standard list: std::list<TH1D*> h1;):
std::list<TH1D*>::iterator it1 = h1.begin();
TPaveStats *st = (TPaveStats*)(*it1)->FindObject("stats");
cout << st << endl;
and get the output “0” - st is a null pointer, apparently the objects “stats” does not exist. Accessing st then obviously leads to segmentation faults…
Any solutions? Or maybe a simpler way to access the stats, e.g. something of the kind
(What I want is to change position, and to change color of line and text).
I am using code compiled against root 5.12.
Thanks a lot!
TCanvas * c1 = new TCanvas("Canv1","Canv1");
TH1F *h1 = new TH1F("h1","h1",100,-4,4);
TH1F *h2 = new TH1F("h2","h2",100,-4,4);
TPaveStats *statsBox = (TPaveStats*)h2->GetListOfFunctions()->FindObject("stats");
Thanks for your reply - however, it does not solve my problem. As mentioned it works perfectly well for pointers at histograms, but for some reason it does not with the iterators over a TH1D std::list , as given in the example in my previous post.
Unfortunately I can’t provide a simple macro to reproduce the problem, somehow root crashes whenever I just declare a std::list<TH1*> object (works fine for compiled code, though).
Thankful for any suggestions!
Ok, but a simple macro showing the problem would be great help !!!