# TMVA extract optimal cut with various numbers of signal and background events like in the classifier cut efficiencies 5a in TMVAGui

**URL:** <https://root-forum.cern.ch/t/tmva-extract-optimal-cut-with-various-numbers-of-signal-and-background-events-like-in-the-classifier-cut-efficiencies-5a-in-tmvagui/45467>\
**Category:** TMVA\
**Created:** [June 18, 2021, 8:27pm UTC](https://root-forum.cern.ch/t/tmva-extract-optimal-cut-with-various-numbers-of-signal-and-background-events-like-in-the-classifier-cut-efficiencies-5a-in-tmvagui/45467 "2021-06-18T20:27:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yao\_Yao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/yao_yao/32/23839_2.png) [@Yao\_Yao](https://root-forum.cern.ch/u/Yao_Yao)\
**Post date:** [June 18, 2021, 8:27pm UTC](https://root-forum.cern.ch/t/tmva-extract-optimal-cut-with-various-numbers-of-signal-and-background-events-like-in-the-classifier-cut-efficiencies-5a-in-tmvagui/45467/1 "2021-06-18T20:27:27Z")

</div>

Dear experts,

I would like to ask how to write a piece of code instead of opening the TMVAGui and modifying the number of signal and background events manually in the Classifier cut efficiency (5a). I’ve been looking into some topics about TMVA MethodCuts class but not sure which function that I should use.

I’ve trained a BDTG with signal and background Monte Carlo events and it generated a dataset folder, the TMVA.root. Now I need to find an optimal BDT score that maximize the S/sqrt(S+B) with about, for example, 10 Signal events and 10000 backgrounds. Could you give me any hint about where I should start it with?

Thank you, and please let me know if there is anything unclear.  
Yao

---

<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:** [June 21, 2021, 7:11am UTC](https://root-forum.cern.ch/t/tmva-extract-optimal-cut-with-various-numbers-of-signal-and-background-events-like-in-the-classifier-cut-efficiencies-5a-in-tmvagui/45467/2 "2021-06-21T07:11:33Z")

</div>

Hi @Yao_Yao ,  
@moneta can surely help.

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:** [June 21, 2021, 7:52am UTC](https://root-forum.cern.ch/t/tmva-extract-optimal-cut-with-various-numbers-of-signal-and-background-events-like-in-the-classifier-cut-efficiencies-5a-in-tmvagui/45467/3 "2021-06-21T07:52:01Z")

</div>

Hi,

You can look at the code used in the TVAGUI that you can call it directly.

> <https://github.com/root-project/root/blob/master/tmva/tmvagui/src/mvaeffs.cxx>

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![Yao\_Yao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/yao_yao/32/23839_2.png) [@Yao\_Yao](https://root-forum.cern.ch/u/Yao_Yao)\
**Post date:** [June 23, 2021, 5:32pm UTC](https://root-forum.cern.ch/t/tmva-extract-optimal-cut-with-various-numbers-of-signal-and-background-events-like-in-the-classifier-cut-efficiencies-5a-in-tmvagui/45467/4 "2021-06-23T17:32:45Z")

</div>

Yes it works, though it took me a while to realize that the StatDialogMVAEffs can take nullptr for the TGClient since root version 6.24. Many thanks.

Best,  
Yao
