# Signal and background from the output MVA

**URL:** <https://root-forum.cern.ch/t/signal-and-background-from-the-output-mva/42652>\
**Category:** TMVA\
**Created:** [December 8, 2020, 10:21pm UTC](https://root-forum.cern.ch/t/signal-and-background-from-the-output-mva/42652 "2020-12-08T22:21:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel\_Torres](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/manuel_torres/32/20053_2.png) [@Manuel\_Torres](https://root-forum.cern.ch/u/Manuel_Torres)\
**Post date:** [December 8, 2020, 10:21pm UTC](https://root-forum.cern.ch/t/signal-and-background-from-the-output-mva/42652/1 "2020-12-08T22:21:45Z")

</div>

Hello root family,

I’m working with the tmva, I already did a Tmvaclassification and a tmvaclassificationApplication, and I saved the output of the TMVAClassificationApplication in a Branch, now I want to access to the number of background and signal in this MVA outputs, with the objective to do a figure of merit.

This is my output of the TMVAClassificationApplication with the method BDT

 ![imagen](https://root-forum.cern.ch/uploads/default/original/3X/6/9/69cda3ee066be5bf01c6ab1ad7539b0983e37f12.png)

So my question is how to access to this number of signal and background to make this figure of merit (# events signal/ # events background) ?

---

<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:** [December 9, 2020, 8:33am UTC](https://root-forum.cern.ch/t/signal-and-background-from-the-output-mva/42652/2 "2020-12-09T08:33:11Z")

</div>

TMVAClassificationApplication does not have the information on signal and background type. You pass an input event and it just performs the evaluation of your machine learning model.  
If you know the true nature of the event you need to store that information (e.g. the classID) and add in your TTree.

On the other hand, TMVAClassification knows about signal and background events and its outputs (Testing and Training trees) contain the classID of the event.

Lorenzo

---

<div class="post-metadata">

**Author:** ![Manuel\_Torres](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/manuel_torres/32/20053_2.png) [@Manuel\_Torres](https://root-forum.cern.ch/u/Manuel_Torres)\
**Post date:** [December 9, 2020, 3:24pm UTC](https://root-forum.cern.ch/t/signal-and-background-from-the-output-mva/42652/3 "2020-12-09T15:24:56Z")

</div>

My idea was made a figure of merit with that output, but now I do not know If that is possible.

Now If I can’t do the first idea, I want to ask how to do manually the figure of merit, like they said in the part of changing the metric

> [@How can I change the default figure of merit?](https://root-forum.cern.ch/t/how-can-i-change-the-default-figure-of-merit/34589):
>
> Hi, ROOT experts! When I have done the training work and got the figure of ‘Cut efficiencies and Optimized Cut Value’, I just wander how I can change the default figure of merit S/sqrt(S+B) to Punzi figure of merit signal\_efficiency/(3/2 + sqrt(B)). The figure has been attached. Mantou.

“(by using the Application interface to get the raw output values and calculating your metric from there).”  
I’m confused with this part

---

<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:** [December 9, 2020, 3:47pm UTC](https://root-forum.cern.ch/t/signal-and-background-from-the-output-mva/42652/4 "2020-12-09T15:47:38Z")

</div>

Hi,  
You can do this on a data set where you have the label information (e.g. what is signal and what is background).  
What is missing in the post above, is that you don\t need to run the application interface to change the metrics. You can run this and remake the efficiency plot with a different formula directly using the output file form the classification.  
You need to run the GUI function [mvaeffs()](https://root.cern.ch/doc/master/namespaceTMVA.html#a8a363b3cfcfde6ed3e7416df05f9dc48) on the TMVA output file.

Lorenzo

---

<div class="post-metadata">

**Author:** ![Manuel\_Torres](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/manuel_torres/32/20053_2.png) [@Manuel\_Torres](https://root-forum.cern.ch/u/Manuel_Torres)\
**Post date:** [December 10, 2020, 7:33pm UTC](https://root-forum.cern.ch/t/signal-and-background-from-the-output-mva/42652/5 "2020-12-10T19:33:07Z")

</div>

One last question, I realized that I’m a little confused with the output of the Classification, so my question is what is the real meaning of that output

and thanks for answering all my questions

---

<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:** [December 11, 2020, 8:32am UTC](https://root-forum.cern.ch/t/signal-and-background-from-the-output-mva/42652/6 "2020-12-11T08:32:14Z")

</div>

Hi,  
The output of the classification is a ROOT file, which is provided as input when creating the Factory object, see the [`TMCAClassification.C`](https://root.cern.ch/doc/master/TMVAClassification_8C.html) tutorial. There the output file is called TMVA.root.  
The output file contains a TTree for the training events and a TTree for the test events, which are used to validate and test the trained classifier. From that TTree you have all the information to compute the metrics. For example you can call from the ROOT prompt to make the plot for the Punzi metric with a= 3-sigma:

```auto
TMVA::mvaeffs("dataset","TMVA.root",1000,1000,true,"(S/1000)/(3./2+sqrt(B))")

```

Lorenzo
