Hello experts,
I am trying to get the integral within a subrange for a RooAddPdf that is the sum of two PDFs. The two PDFs are loaded in from two different files using RooWorkspace’s. The problem is in my choice of which x variable I load in and use for the integral since each workspace has it’s own. For example
TFile * f1 = new TFile("SignalPDF.root");
TFile * f2 = new TFile("BackgroundPDF.root");
RooWorkspace * sigWorkspace = (RooWorkspace *) f1 -> Get("myWorkspace");
RooWorkspace * bkgWorkspace = (RooWorkspace *) f2 -> Get("myWorkspace");
RooAbsPdf * sigPdf = sigWorkspace -> pdf("sigPdf");
RooAbsPdf * bkgPdf = bkgWorkspace -> pdf("bkgPdf");
RooAddPdf * totalPdf = new RooAddPdf("totalPdf", "totalPdf", RooArgList(*sigPdf, *bkgPdf), RooConst(0.5));
// How do I declare the x variable?
// sigWorkspace gives a different result to bkgWorkspace
RooRealVar * xVar = sigWorkspace -> var("xVar");
xVar -> setRange("xRange", 0.25, 1.0); // Full range is 0.25 to 3.5
totalPdf -> createIntegral(RooArgSet(*xVar), NormSet(RooArgSet(*xVar)), Range("xRange"));
Loading the x variable from the signal workspace gives a different value for the integral compared to loading it from the background workspace.
The only way around this I can think of is to construct and save the two PDFs into the same workspace so that they explicitly share the same observable x variable. Is there another way?
Cheers,
Kim