Weighting a branch variable

Hi Root experts,

I’m needing to create a branch with a variable that is weighted by a factor != 1. Currently I can successfully create and fill a branch with a vector filled with the unweighted variable, but can’t think of how to apply the weight to each entry. Do you have any suggestions? My apologies if this has been addressed before.

Thanks for the help,
Peter

Hi Peter,

You have 2 solutions. One is simply to scale each of the value in the vector before calling tree->Fill, the other is to add another branch containing the value of the weight/factor.

Cheers,
Philippe.

sorry, I don’t get this point.
I don’t see how scaling the values in the vector may help with the weight of the event.
Am I missing something?

cheers,
Francesco

Hi Francesco,

[quote]but can’t think of how to apply the weight to each entry[/quote]In which context (using which tools) do you have this problem? What did you try?

[quote]I don’t see how scaling the values in the vector may help with the weight of the event. [/quote]Well that depends whether the weight is a single fixed quantity that is known at the time the event is produced or not. If it is a single fixed value, then by ‘scaling’ the values in the vector for each event with the correct weight for that event, you will end storing the weighted values and thus simply using the value as is would have the weight “applied”. If the weight is not known in advanced or if it changed from analysis to analysis, then how to apply the weight is completely depend on how you use the values …

Cheers,
Philippe.

Starting from an ntuple I would like to produce an ntuple in which each event is weighted (for example pileup reweight). The weight is calculated in the loop.
It should be nice to set a different weight for each event in a Tree.
(As it is in TH1::Fill(Double_t x, Double_t w) )

Anyway I think I solved my problem. The final pourpose was to have ntuple to use as TMVA input, but I realized that in TMVA is possible to set the event weight using a branch.

cheers,
Francesco