# Method to change the input variable range in a root file

**URL:** <https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419>\
**Category:** TMVA\
**Created:** [April 15, 2021, 4:17am UTC](https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419 "2021-04-15T04:17:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rithishbarath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rithishbarath/32/23840_2.png) [@rithishbarath](https://root-forum.cern.ch/u/rithishbarath)\
**Post date:** [April 15, 2021, 4:17am UTC](https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419/1 "2021-04-15T04:17:33Z")

</div>

Dear people,  
I wish to change the range of values in x axis of an input variable . For example if you can see the image the range is from -40 to 40 . I wish to zoom in the range and plot from -1 to 1 . Should i modify the root file itself or how to change the range of the particular variable when adding it to the training list.Is there a possibility to modify the following line from the TMVACLASSIFIACTION.C file so that i can see the truncated range when i see the input variable list after training?  
“dataloader-\>AddVariable( “DeltaZ”, “DELTAZ”, “Probability”, ‘F’ );”

![Screenshot from 2021-04-15 15-15-54](https://root-forum.cern.ch/uploads/default/original/3X/5/e/5e68f4011ecbe8c6b336d94d1f4b42250b4034e2.png)

---

<div class="post-metadata">

**Author:** ![rithishbarath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rithishbarath/32/23840_2.png) [@rithishbarath](https://root-forum.cern.ch/u/rithishbarath)\
**Post date:** [April 15, 2021, 4:18am UTC](https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419/2 "2021-04-15T04:18:28Z")

</div>

@moneta @moneta2 kindly help me with this

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [April 15, 2021, 7:24am UTC](https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419/3 "2021-04-15T07:24:00Z")

</div>

Hi @rithishbarath ,  
you can use [TAxis::SetRangeUser](https://root.cern/doc/master/classTAxis.html#ac85f8261dedc23bbe68f90afd196cdb8) method to set the x axis range. You have to call it on the histogram, something like `histogram->GetXaxis()->SetRangeUser(...)`.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [April 15, 2021, 8:23am UTC](https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419/4 "2021-04-15T08:23:25Z")

</div>

Hi,  
I have not understood if your problem is a plotting one or it is in defining the range of the input variable to be used for classification. In the first case you can do what Enrico suggest, or just plot yourself the variables from the input tree in histograms as you wish.  
In the second case you need to apply a variable selection cut. This you can do, for example in TMVAClassification, by modifying line 271 and 272.  
In your case , if the variable is called 'DELTAZ` you do:

```auto
TCut mycuts = "DELTAZ > -40 && DELTAZ < 40";
TCut mycutb = "DELTAZ > -40 && DELTAZ < 40";

```

Lorenzo

---

<div class="post-metadata">

**Author:** ![rithishbarath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rithishbarath/32/23840_2.png) [@rithishbarath](https://root-forum.cern.ch/u/rithishbarath)\
**Post date:** [April 15, 2021, 1:43pm UTC](https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419/5 "2021-04-15T13:43:20Z")

</div>

Where should i enter this piece of code in the TMVACLASSIFICATION.C file so that my histogram changes @eguiraud or send me a example file to execute the same.

---

<div class="post-metadata">

**Author:** ![rithishbarath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rithishbarath/32/23840_2.png) [@rithishbarath](https://root-forum.cern.ch/u/rithishbarath)\
**Post date:** [April 15, 2021, 1:43pm UTC](https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419/6 "2021-04-15T13:43:46Z")

</div>

Thanks @moneta

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [April 15, 2021, 1:47pm UTC](https://root-forum.cern.ch/t/method-to-change-the-input-variable-range-in-a-root-file/44419/7 "2021-04-15T13:47:34Z")

</div>

You can search our tutorials, e.g. [this TMVA tutorial](https://root.cern/doc/master/tmva102__Testing_8py.html) uses `SetRangeUser`.

Cheers,  
Enrico
