I would like to get the minimum and maximum value of a Graph. I see that there is a function Getmaximum and minimum in TGraph but it always gives -1111. I have modified a tutorial example to illustrate this.
I’m doing something wrong?
exclusiongraph.C (2.51 KB)
Double_t fMaximum Maximum value for plotting along y
Double_t fMinimum Minimum value for plotting along y
Maybe I will shed some light:
You see, those minimum and maximum values in histograms are more of user set limits, that are SUPPOSED to be used for drawing only, and also for computing integrals, finding local minimums and such on that part of histogram that is drawn right now. They stopped being “real” minimums a while ago, when people wanted to be able to put left and right limits on a histogram, draw it, and compute integral within the limits that are visible only. Graphs use histogram for drawing, and they themselves have fMinimum and fMaximum for plotting only, double trouble now . TGraph::GetMinimum() returning -1111 means that no user set limit exists in TGraph. Interesting, huh ? Underlying histogram computes limits for itself within its binning precision because it has to accommodate the whole graph in absence of user limits.
I don’t know how to best remedy this confusion, maybe add methods GetAbsoluteMinimumX-Y-or-Z-() which always returns what people think minimum means irrespectively of user set drawing limits. Or, add a whole spectra of methods interfacing user to all possible operations on arrays.
Anyhow, without changing anything - here is a simple recipe: if you want to do something with an array, you do something with the array, instead of jamming it into TGraph and then asking TGraph to interface you with all kinds of mathematical operations on the array, that you might come up with. Savvy ?
This method is just an inline function returning the value of the data member
fMaximum that’s why there is not real doc.
not a user friendly approach
I am not saying it is good. I just explain why it is like that. We can surely improve that. I’ll have a look
There’s nothing to add to document here. This is one of those things that exists as hazing for new users (and for those who have forgotten after a while) to remind that root is made by physicists for physicists who are supposed to toil and suffer till you become an expert…
Then ofcourse you get to be like, ‘aha, this is how ROOT actually works…’ to the next newb!
Alternatively (to just shrugging it away with a nonchalant shoulders motion), you could decide to help fixing these inconsistencies or doc mishaps in ROOT-7 (where we’re allowed to break things).
(Or, you say, “screw c++, I’ll go with Go” and you come to enjoy fast compilation and concurrency )