Dear all,
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:
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.
Hi @jonas
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?