# Adding weights to multiple backgrounds and significance value

**URL:** <https://root-forum.cern.ch/t/adding-weights-to-multiple-backgrounds-and-significance-value/49356>\
**Category:** TMVA\
**Created:** [March 25, 2022, 9:33am UTC](https://root-forum.cern.ch/t/adding-weights-to-multiple-backgrounds-and-significance-value/49356 "2022-03-25T09:33:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antara\_Mehta](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/9f8e36/32.png) [@Antara\_Mehta](https://root-forum.cern.ch/u/Antara_Mehta)\
**Post date:** [March 25, 2022, 9:33am UTC](https://root-forum.cern.ch/t/adding-weights-to-multiple-backgrounds-and-significance-value/49356/1 "2022-03-25T09:33:32Z")

</div>

Hi,

I’m trying to setup a training with signal and multiple backgrounds, but I’m really confused with how to set weight the multiple backgrounds so that they are normalised to the same luminosity and how the PrepareTrainingAndTestTree method should be called. There are 4 backgrounds and 1 signal tree. I am scaling them to the same luminosity as follows

```auto

	int nSigTrain = sigTrain->GetEntries();
	int nBkg0Train = bkg0Train->GetEntries();
	int nBkg1Train = bkg1Train->GetEntries();
	int nBkg2Train = bkg2Train->GetEntries();
	int nBkg3Train = bkg3Train->GetEntries();

	int nSigTest = sigTest->GetEntries();
	int nBkg0Test = bkg0Test->GetEntries();
	int nBkg1Test = bkg1Test->GetEntries();
	int nBkg2Test = bkg2Test->GetEntries();
	int nBkg3Test = bkg3Test->GetEntries();

  double sigWeight = 0.3*0.3*1.212*3000/(nSigTrain+nSigTest);
  double bkg0Weight = 41.05*1.2*1000*3000/(nBkg0Train+nBkg0Test);
  double bkg1Weight = 108.6*1.46*3000/(nBkg1Train+nBkg1Test);
  double bkg2Weight = 5.34*1.54*3000/(nBkg2Train+nBkg2Test);
  double bkg3Weight = 0.00176*3000/(nBkg3Train+nBkg3Test);

  dataloader->AddSignalTree(sigTrain, sigWeight, TMVA::Types::kTraining);
  dataloader->AddBackgroundTree(bkg0Train, bkg0Weight, TMVA::Types::kTraining);
  dataloader->AddBackgroundTree(bkg1Train, bkg1Weight, TMVA::Types::kTraining);
  dataloader->AddBackgroundTree(bkg2Train, bkg2Weight, TMVA::Types::kTraining);
  dataloader->AddBackgroundTree(bkg3Train, bkg3Weight, TMVA::Types::kTraining);

  dataloader->AddSignalTree(sigTest, sigWeight, TMVA::Types::kTesting);
  dataloader->AddBackgroundTree(bkg0Test, bkg0Weight, TMVA::Types::kTesting);
  dataloader->AddBackgroundTree(bkg1Test, bkg1Weight, TMVA::Types::kTesting);
  dataloader->AddBackgroundTree(bkg2Test, bkg2Weight, TMVA::Types::kTesting);
  dataloader->AddBackgroundTree(bkg3Test, bkg3Weight, TMVA::Types::kTesting); 

```

and dividing them for training and testing as follows:

```auto
   dataloader->PrepareTrainingAndTestTree( mycuts, mycutb,
                                      "nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V" ); 

```

Could you please tell if it is the correct way?

I see in the BDT cut efficiencies plot, in the lower corner, it is written that there are 1000 signal and 1000 background events. It seems to me that I am not doing the scaling correctly so that the numbers at 3000 fb^{-1} luminosity get reflected here. Please advice on this matter how to proceed?

Thanks and regards,  
Antara

---

<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:** [March 25, 2022, 6:10pm UTC](https://root-forum.cern.ch/t/adding-weights-to-multiple-backgrounds-and-significance-value/49356/3 "2022-03-25T18:10:15Z")

</div>

Hi,  
Looking at the code, what you are doing seems fine. I think in the efficiency plot you see just the actual number of events used and not the sum of their weights and this number it is selected with its corresponding GUI.

Lorenzo

---

<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:** [March 28, 2022, 10:13am UTC](https://root-forum.cern.ch/t/adding-weights-to-multiple-backgrounds-and-significance-value/49356/6 "2022-03-28T10:13:46Z")

</div>

Hi,  
I think you should compute the total number of signal events and background events that you expected given a luminosity and then use them in the TMVA GUI to estimate the significance and optimal cut value.

Lorenzo

---

<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:** [March 28, 2022, 12:47pm UTC](https://root-forum.cern.ch/t/adding-weights-to-multiple-backgrounds-and-significance-value/49356/9 "2022-03-28T12:47:34Z")

</div>

Hi,  
Yes this above are the number of events used. The total number of signal legends you expected will be what you have written before:

```auto
nsig = 0.3*0.3*1.212*3000 = 327.24
nbkg = 41.05*1.2*1000*3000 + 108.6*1.46*3000 + 5.34*1.54*3000 + 0.00176*3000 = 148280340

```

You should then use this number to put in the TMVA GUI when plotting the efficiency.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/b/5/b549ee9be3f0bfb4738f44e83f74b007009dae4e.png)

Lorenzo
