# getRange for RooRealVar

**URL:** <https://root-forum.cern.ch/t/getrange-for-roorealvar/33982>\
**Category:** Roofit and RooStats\
**Tags:** feature\
**Created:** [May 9, 2019, 8:18pm UTC](https://root-forum.cern.ch/t/getrange-for-roorealvar/33982 "2019-05-09T20:18:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [May 9, 2019, 8:18pm UTC](https://root-forum.cern.ch/t/getrange-for-roorealvar/33982/1 "2019-05-09T20:18:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![StephanH](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@StephanH](https://root-forum.cern.ch/u/StephanH)\
**Post date:** [May 10, 2019, 1:45pm UTC](https://root-forum.cern.ch/t/getrange-for-roorealvar/33982/2 "2019-05-10T13:45:37Z")

</div>

Hi @mwilkins,

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

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

```

With the binning [(RooAbsBinning documentation)](https://root.cern.ch/doc/master/classRooAbsBinning.html) you can do all kinds of operations. Convenience functions for retrieving the bounds from the binning are also defined in RooAbsReal:

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [May 10, 2019, 5:28pm UTC](https://root-forum.cern.ch/t/getrange-for-roorealvar/33982/3 "2019-05-10T17:28:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 24, 2019, 5:28pm UTC](https://root-forum.cern.ch/t/getrange-for-roorealvar/33982/4 "2019-05-24T17:28:40Z")

</div>

Closed on May 24, 2019, 5:28pm UTC

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