Adam Roe
2006-09-21 14:01:52 UTC
Hi all (again),
I asked a question this morning, but i believe i phrased it wrong. I am trying to access the highest y-value in a data set which is in a histogram. Here is an explicit (trivial) example of what I am trying to do:
root [1] TH2F* h2Test = new TH2F("h2Test", "test of yMax", 10, 0, 10, -5, 20);
root [2] h2Test->SetBinContent(1,1,1);
root [3] h2Test->SetBinContent(3,5,2);
root [4] h2Test->SetBinContent(4,41,3);
And now i would like to call somethineg which returns 41, the maximum y value in h2Test. I would then use this to reset the yaxis range, so that this point is included.
I cannot find a way to get this value. The looping is rather large and complicated, so i am trying to avoid filling a vector with x-y coordinates and then fidning the maximum value in it.
This functionality is very simple for a TH1F. calling h1->GetMaximum() returns the highest y-value that is reached in h1. But i cannot get it to function for TH2F.
Thanks,
Adam
I asked a question this morning, but i believe i phrased it wrong. I am trying to access the highest y-value in a data set which is in a histogram. Here is an explicit (trivial) example of what I am trying to do:
root [1] TH2F* h2Test = new TH2F("h2Test", "test of yMax", 10, 0, 10, -5, 20);
root [2] h2Test->SetBinContent(1,1,1);
root [3] h2Test->SetBinContent(3,5,2);
root [4] h2Test->SetBinContent(4,41,3);
And now i would like to call somethineg which returns 41, the maximum y value in h2Test. I would then use this to reset the yaxis range, so that this point is included.
I cannot find a way to get this value. The looping is rather large and complicated, so i am trying to avoid filling a vector with x-y coordinates and then fidning the maximum value in it.
This functionality is very simple for a TH1F. calling h1->GetMaximum() returns the highest y-value that is reached in h1. But i cannot get it to function for TH2F.
Thanks,
Adam