# Split TrainTree and TestTree into Signal and Background Train/Test Trees?

**URL:** <https://root-forum.cern.ch/t/split-traintree-and-testtree-into-signal-and-background-train-test-trees/56932>\
**Category:** TMVA\
**Created:** [October 31, 2023, 9:54am UTC](https://root-forum.cern.ch/t/split-traintree-and-testtree-into-signal-and-background-train-test-trees/56932 "2023-10-31T09:54:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abayyari](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abayyari/32/35034_2.png) [@abayyari](https://root-forum.cern.ch/u/abayyari)\
**Post date:** [October 31, 2023, 9:54am UTC](https://root-forum.cern.ch/t/split-traintree-and-testtree-into-signal-and-background-train-test-trees/56932/1 "2023-10-31T09:54:02Z")

</div>

I have successfully trained a classification NN, which uses all my input data as 80:20 for Train:Test that’s been randomly selected from my input TTree. Now I want to apply a selection cut based on the response of my classifier. I see the saved output root file using PrepareTrainingAndTestTree() has saved two TTrees for the events used during training and testing, and there’s a branch in both TTrees for the response of the classifier. However, I don’t know which events are signal and background from the original input as they’ve been mixed together in both TTrees. Is there a way to split the TTrees into signal and background Train/Test, so I can select specific certain signal/background events after my trained NN? Here is what I mean looking at the response plot using the TMVA:GUI. I’d like to select, say, the signal events from 0.7 to 0.9. Thank you!

 ![Response](https://root-forum.cern.ch/uploads/default/original/3X/a/e/aec6bd8d9f431397d78a1ea983ca456f040a6be1.png)

---

<div class="post-metadata">

**Author:** ![abayyari](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abayyari/32/35034_2.png) [@abayyari](https://root-forum.cern.ch/u/abayyari)\
**Post date:** [October 31, 2023, 10:09am UTC](https://root-forum.cern.ch/t/split-traintree-and-testtree-into-signal-and-background-train-test-trees/56932/2 "2023-10-31T10:09:19Z")

</div>

I guess a better question is, how do I apply a selection cut based on the response of my classifier to my input events? Thank you.

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [October 31, 2023, 3:10pm UTC](https://root-forum.cern.ch/t/split-traintree-and-testtree-into-signal-and-background-train-test-trees/56932/3 "2023-10-31T15:10:33Z")

</div>

Dear @abayyari ,

I believe @moneta should be able to help you here.

Cheers,  
Vincenzo

---

<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:** [January 9, 2024, 10:13am UTC](https://root-forum.cern.ch/t/split-traintree-and-testtree-into-signal-and-background-train-test-trees/56932/4 "2024-01-09T10:13:09Z")

</div>

Hello,  
Sorry for the late reply. The output Tree’s that are obtained after training in TMVA contains a “classID” branch which you can use to select signal or background events (classID=0 for signal and =1 for background in case of binary classification).

Best regards

Lorenzo
