# TMVA - sample reweighting issue

**URL:** <https://root-forum.cern.ch/t/tmva-sample-reweighting-issue/43145>\
**Category:** TMVA\
**Created:** [January 18, 2021, 4:30pm UTC](https://root-forum.cern.ch/t/tmva-sample-reweighting-issue/43145 "2021-01-18T16:30:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![janina.anna.krzysiak](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/85f322/32.png) [@janina.anna.krzysiak](https://root-forum.cern.ch/u/janina.anna.krzysiak)\
**Post date:** [January 18, 2021, 4:30pm UTC](https://root-forum.cern.ch/t/tmva-sample-reweighting-issue/43145/1 "2021-01-18T16:30:07Z")

</div>

Hi TMVA experts,

I’m having some trouble with normalizing signal samples.

I have a number of signal samples with the same resonance production process, but different resonance masses. I want to use all of these samples at the same time to train a mass-parameterized neural net. To do this, I need to normalize the signal samples to get a flat mass distribution. I know the number of weighted events in each sample, and have simply added a “1.0/nWeightedEvents” weight to each signal tree (at the AddSignalTree step). I also have set MC weights via SetSignalWeightExpression. Unfortunately, this does not give me a flat distribution, though it is flatter than when using 1.0 for each signal tree, so the weights are getting applied (see sigMass\_withNormalization.png and sigMass\_withoutNormalization.png). When I use the same numbers in a stand-alone ROOT macro, the samples are normalized correctly (see test.png). No cuts are applied in TMVA or the stand-alone macro. What could be the issue here? I’ve been checking and rechecking this…

Cheers,  
Janina

 ![test](https://root-forum.cern.ch/uploads/default/original/3X/8/e/8ed93a0671c7952aa36f4e27821891e935953dd5.png) ![sigMass_withoutNormalization](https://root-forum.cern.ch/uploads/default/original/3X/a/1/a1a511c4ec8b48ea7bbf4bb77ab7027540b06cc0.png) ![sigMass_withNormalization](https://root-forum.cern.ch/uploads/default/original/3X/2/9/29ea27b2c1b3f95eda21a9bcd6db21b77e393b76.png)

---

<div class="post-metadata">

**Author:** ![janina.anna.krzysiak](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/85f322/32.png) [@janina.anna.krzysiak](https://root-forum.cern.ch/u/janina.anna.krzysiak)\
**Post date:** [January 18, 2021, 7:08pm UTC](https://root-forum.cern.ch/t/tmva-sample-reweighting-issue/43145/2 "2021-01-18T19:08:59Z")

</div>

Just to add - this only happens when MC weights are applied. Removing the MC weights and using 1.0/nUnweightedEvents for the samples works as expected.

---

<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 28, 2021, 3:06pm UTC](https://root-forum.cern.ch/t/tmva-sample-reweighting-issue/43145/3 "2021-01-28T15:06:03Z")

</div>

Hi,  
I think you should normalize to `1./SumOfEventWeights` and not `1/nWeightedEvents`

Lorenzo

---

<div class="post-metadata">

**Author:** ![janina.anna.krzysiak](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/85f322/32.png) [@janina.anna.krzysiak](https://root-forum.cern.ch/u/janina.anna.krzysiak)\
**Post date:** [January 28, 2021, 3:17pm UTC](https://root-forum.cern.ch/t/tmva-sample-reweighting-issue/43145/4 "2021-01-28T15:17:55Z")

</div>

Thanks!
