Plot final signal/background distributions, weight problem

Dear Sir,

In my TMVA study, I have ~10 background, all background with different weighting (cross section size).

After TMVA, I wish to plot the signal and background distributions for the input variables, to see the TMVA CUT effect on the variables. I followed this : TMVA: Macro to plot final signal/background distributions?

My question is :
for all the background is added together, it seems the final distribution shown with i.e. " TestTree->Draw(“myvar1”,“LD>0.3”,"");" is plotted with the un-weighted # of events.

Because each contributed BG have different shape of distribution and weight (cross section),
I wish to know, how can I plot with background distribution with correct contribution from each background?

Thanks!

Best,
Jung

Hi,

See section 12.20.1 of the root users guide :slight_smile:

https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#simple-analysis-using-ttreedraw

Basically TestTree->Draw(“myvar1”,“weight*(LD>0.3)”); should work if the event weight is stored in a branch/leaf name weight.

Cheers,
Kim

Hi Kim,

Thanks for the reply. I had tried this. But the weight branch gave by TMVA is strange, i.e. I have totally 9000 events, I want total weight as 20.0, but in the weight branch, it shown as x axis is 22, with y axis 9000.

If I used TestTree->Draw(“myvar1”,“weight*(LD>0.3)”); it gave each event times 9000.

My main problem is, it used # of events for each background, not the weight I input.

I have more than 10 background. Each have different weights, if it used # of events for each background, it will give a wrong BG distribution. And because all BG are added in a BG branch. I cannot re-weight it again.

So I wish to know how to add weight to each BG, which gave a correct total BG distribution.

Thanks,

Jung

Hi,

Ok, thanks for the clarification. If all events have the same weight, then I suspect they are not propagated correctly from your input to TMVA.

Could you explain how you do it?

If you have a branch containing the weights for each event regardless of class using

dataloader->SetWeightExpression("branch_name_in_input_tree");

should do the trick, and the correct weight should end up in the final output file.

Cheers,
Kim

Hi Kim,

Thanks for the reply.

This is part of my BG and its weight :

Double_t bbjaWeight = 367000.0;

Double_t bbaaWeight = 140.0;

Double_t bbjjWeight = 434000000.0;

Double_t bbhWeight = 1.26;

Double_t tthWeight = 1.37;

Double_t ccjaWeight = 1050000.0;

dataloader->AddBackgroundTree( bbja_BG, bbjaWeight*3000.0*5.0/10000.0 *73273.0/3000000.0);

dataloader->AddBackgroundTree( bbaa_BG, bbaaWeight*3000.0*60253.0/3000000.0 );

dataloader->AddBackgroundTree( bbjj_BG, bbjjWeight*3000.0*56126.0/5000000.0*5.0/10000.0*5.0/10000.0);

dataloader->AddBackgroundTree( bbh_BG, bbhWeight*3000.0*666.0/1000000.0);

dataloader->AddBackgroundTree( tth_BG, tthWeight*3000.0*38478.0/1000000.0);

dataloader->AddBackgroundTree( ccja_BG, ccjaWeight *3000.0*10173.0/1000000.0*5.0/10000.0*1/8.0*1/8.0);

I’m thinking is it related to TMVA setting : NormMode, previously I set it as NumEvents. Maybe I should use NormMode=None?

(Actually I had tried with None, seems the output is no difference. I will delete previous output.root file, and try again.)

Thanks!

Best,

Jung

Hi,

That is how you should set the weights for the trees (and I verified that it works in the TMVAClassification example irrespective of the setting of NormMode).

I think some deeper debugging is needed to resolve your issue. Would it be possible for you to reduce your script to a minimal reproducer? (I forsee this will either help you find a bug in your code, or provide us with a concrete test case to debug!)

Cheers,
Kim

Hi Kim,

Thanks for the mail. I just used the default TMVAClassification file provided in ROOT/tutorials/tmva, and add my tree and weighting.

I attached the file. Thanks!

Best,

Jung

TMVAClassification.C (15.7 KB)

Hi,

I can’t run your script since I lack access to the input file but it seems fine from a TMVA perspective. Could you post a plot of the weight branch in the output file?

Cheers,
Kim

Hi Kim,

Thanks for the reply. I had already add two new reply, but it did not shown here.

Sorry I found I made a very stupid mistake. I thought the weight given at " dataloader->AddBackgroundTree( BG, Weight);", the Weight is the total weight. When I read the manual more carefully, I found its the weight of each event.

I modified the weight to each events, now everything is ok.

I have one naive question, if I want to use the weight I set to do the TMVA study, all I need is set NormMode=None?

And if NormMode= NumEvents, it means it will rescale BG and signal to Ns and Nb I set in “nTrain_Signal=0:nTrain_Background=0”, if I set it as 0, then the signal and BG will be weighted as 1/2 of total Ns and Nb.

If I set NormMode= EqualNumEvents, it means the signal and BG will be weighted equally.

Is my understanding of these NormMode setting correct?

And another question is can I have TMVA variables given in different root file?
i.e.
variable A from input1.root
variable B from input2.root

Sorry and Thanks!!

Best,
Jung

Hi,

Glad you figured it out! For you questions:

Cheers,
Kim

Hi Kim,

Thanks a lot for the reply! I got it!

Best,

Jung