I’d like to ask for help to better understand how to construct RooHistPdf in a specific case. This question might be similar to , but I was not able to translate the solution from there to my specific problem.
I have a TH1 describing some distribution of a derived quantity (e.g. “pt”). In my implementation, the underlying real free parameters are not pt, but px and py. I would like to be able to define a PDF based on my TH1 and have it depend on pt. Naively, I tried the following implementation using RooDataHist as an intermediate step (in python):
import ROOT ROOT.gSystem.Load('libRooFit') from ROOT import RooFormulaVar, RooRealVar, RooDataHist, RooHistPdf, RooArgList # Dummy histogram th1 = ROOT.TH1D("test","test",10,0,100) th1.Fill(5, 3) th1.Fill(15, 1) th1.Fill(25, 0.1) # Elementary variables px = RooRealVar("px","px",10,0,100) py = RooRealVar("py","py",10,0,100) # Derived variables pt = RooFormulaVar("pt","sqrt(px**2 + py**2)", RooArgList(px,py)) # This does not work. rdh = RooDataHist("test","test", RooArgList(pt), th1) # Ultimately, I want to make a RooHistPdf pdf = RooHistPdf("pdf", "pdf", RooArgList(pt), RooArgList(pt), rdh )
This fails, with the following error message:
[#0] ERROR:InputArguments -- RooAbsDataStore::initialize(test): Data set cannot contain non-fundamental types, ignoring pt
The message is very clear, so I have no doubts what I am doing wrong, but I fail to figure out what I should be doing instead. What better ways are there to achieve what I am trying to do?
The final goal of my implementation is to be able to minimize some negative log-likelihood function by finding optimal values of (px,py). This PDF would be a part of the likelihood. I cannot just switch from (px,py)->pt as the basic variable because other parts of the likelihood depend on (px,py) separately, so I would run into the same problem in reverse.
Any advice would be appreciated!