getRange for RooRealVar

I would like to be able to call getRange or getMin or getMax on a RooRealVar just as I can call setRange, setMin, and setMax. As far as I can tell, RooRealVar has no such member.

Hi @mwilkins,

what you look for is this part of RooAbsReal’s interface:

virtual const RooAbsBinning& getBinning(const char* name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const;

With the binning (RooAbsBinning documentation) you can do all kinds of operations. Convenience functions for retrieving the bounds from the binning are also defined in RooAbsReal:

virtual Double_t getMin(const char* name=0) const { return getBinning(name).lowBound(); }
virtual Double_t getMax(const char* name=0) const { return getBinning(name).highBound(); }

The names don’t hint at a range, but this will do the trick.

I could add the following if you see the need:

  std::pair<double, double> getRange(const char* name = 0) const {
    return {getMin(name), getMax(name)};
  }
1 Like

Hello,

Thanks for your response. Indeed, getMin and getMax are already just what I was looking for–I missed them for lack of a “range” keyword in the documentation.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.