# TMVA: Macro to plot final signal/background distributions?

**URL:** <https://root-forum.cern.ch/t/tmva-macro-to-plot-final-signal-background-distributions/9970>\
**Category:** TMVA\
**Created:** [April 15, 2010, 12:40pm UTC](https://root-forum.cern.ch/t/tmva-macro-to-plot-final-signal-background-distributions/9970 "2010-04-15T12:40:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![delaossa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/delaossa/32/12319_2.png) [@delaossa](https://root-forum.cern.ch/u/delaossa)\
**Post date:** [April 15, 2010, 12:40pm UTC](https://root-forum.cern.ch/t/tmva-macro-to-plot-final-signal-background-distributions/9970/1 "2010-04-15T12:40:44Z")

</div>

Hello,  
I wonder is there is any macro available in TMVA package which  
plot the input variables after a cut is chosen on the output variable of a particular (already trained) classifier.

TMVAGui.C is actually fantastic tool to easily access to a bunch of macros, but I really miss a button which shows these final distributions for signal and background events on the EVALUATION sample after the desired cut is applied on the classifier.

I would appreciate any advices or comment in this respect.  
Thanks!

---

<div class="post-metadata">

**Author:** ![hvoss](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/cc9497/32.png) [@hvoss](https://root-forum.cern.ch/u/hvoss)\
**Post date:** [May 19, 2010, 1:04pm UTC](https://root-forum.cern.ch/t/tmva-macro-to-plot-final-signal-background-distributions/9970/2 "2010-05-19T13:04:31Z")

</div>

Hi,

no I’m sorry, this option does not exist as such. BUT, the test tree that is written out by default has the  
MVA-values of the different methods added for each event. Hence…

a simple loop over this ntuple with the “desired” cut on the MVA value gives exactly what you want… maybe we could think of providing a macro for that… I’ll keep it in mind…

```
                    cheers,

                         Helge
```

---

<div class="post-metadata">

**Author:** ![pspe](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pspe](https://root-forum.cern.ch/u/pspe)\
**Post date:** [May 19, 2010, 1:10pm UTC](https://root-forum.cern.ch/t/tmva-macro-to-plot-final-signal-background-distributions/9970/3 "2010-05-19T13:10:20Z")

</div>

Hi,

There is no dedicated macro, but in the output-file (default name: TMVA.root) you find a “TestTree” with the input-variables and the classifier output (and the true class) for all events.

You can do something like:

```auto
root -l TMVA.root
```

```auto
TestTree->SetLineColor(kRed);
TestTree->Draw("myvar1","LD>0.3","");
TestTree->SetLineColor(kBlue);
TestTree->Draw("myvar1","LD<=0.3","same");
```

… where myvar1 would be the variable you want to look at and 0.3 would be the cut on the classifier output you choose.

cheers,  
Peter

---

<div class="post-metadata">

**Author:** ![delaossa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/delaossa/32/12319_2.png) [@delaossa](https://root-forum.cern.ch/u/delaossa)\
**Post date:** [May 27, 2010, 4:24pm UTC](https://root-forum.cern.ch/t/tmva-macro-to-plot-final-signal-background-distributions/9970/4 "2010-05-27T16:24:41Z")

</div>

Hello,  
Thanks for your responses.  
I know is always possible to make these plots by your own.  
However, providing that we have this fantastic macro to easy inspect a bunch of features of our particular pattern recognition problem, I think that this functionality of watching final distributions after the cut is missing.  
It is really easy to implement, by the way, and I think the users would appreciate that.  
Take into account that is always very important to see what the cut does to the original distributions.

Let me, please, correct Peter’s piece of code. What I was looking for is actually the following:

`TestTree->SetLineColor(kRed);
TestTree->Draw("myvar1","LD>0.3 && class==0","");
TestTree->SetLineColor(kBlue);
TestTree->Draw("myvar1","LD>0.3 && class==1","same");`  
which draws signal (class==0) and background (class==1) distributions for a certain cut (specified by LD\>0.3).

Cheers,  
Alberto
