I would like to apply some weight to a
RooDataSet using a 2D histogram as a weight map. The 2 variables of the histograms (x,y) are some of the variables of the
RooDataSet, while the value (z) of the histogram is the weight.
The only way I can think to do so is to build a very complex
RooFormulaVar with the structure:
Bin00*(var0>bin0EdgeDown0 && var0<bin0EdgeUp0 && var1>bin1EdgeDown0 && var1<bin1EdgeUp0)+ Bin01*(var0>bin0EdgeDown0 && var0<bin0EdgeUp0 && var1>bin1EdgeDown1 && var1<bin1EdgeUp1)+
BinXY is the value of the bin
XY. But since is 20x20 histogram this is not very practical.
Is there a way to apply a weight map in a more convenient way?
Thank you in advance,
I’m sure @jonas can give some hints
Like you describe it, this is out of the scope of RooFit. When building likelihoods with RooFit, the data always needs to be completely constant, also the weights. You can’t apply a weight on a
RooDataSet as part of your RooFit model.
What I suggest you to do depends on if these weights in each bin are just constants, or if they are free parameters in the model. If they are just constants, then you can directly create the RooDataSet with these weights that you get from the histogram still outside RooFit.
If these weights correspond to floating nuisance parameters of the model, which is also quite common, then you can use the ParamHistFunc to create a mapping between parameters and histogram bins, and then multiply your model with this ParamHistFunc. Let me know if you need help with this, if you think this is the solution! I think the ParamHistFunc is so far not used outside HistFactory, so the documentation might be poor.
Thank you for your reply. These weights are not nuisances, they are fixed values at fitting time.
Let me simplify the example to better explain: I have a RooDataSet with several variables, one of this is pT. I have a binned function w(pT) hardcoded in a histogram. I would like to weight each event of the dataset according to its w(pT).
When you say “then you can directly create the RooDataSet with these weights that you get from the histogram still outside RooFit”, sounds good to me. How? I know how to weight a TTree, but is this weight preserved in the coversion to a rooDataSet?
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.