Dear experts,
I am trying to build a RooAbsPdf in the following way:
TF2 *funcTF2 = new TF2("funcTF2", polXY, xMin, xMax, zMin, zMax, nPar);
hist->Fit("funcTF2","WLVR");
RooAbsPdf* squareDalitz = RooFit::bindPdf(finalTF2, x,z) ;
RooAbsPdf* finalPdf = new sqDalitzToMassesPdf("sqDalitzToMassesPdf","sqDalitzToMassesPdf", x, y, squareDalitz, &z);
where “sqDalitzToMassesPdf” is a class autogenerated by RooClassFactory whose evaluate is:
Double_t sqDalitzToMassesPdf::evaluate() const
{
// ENTER EXPRESSION IN TERMS OF VARIABLE ARGUMENTS HERE
z->setVal( f(x, y) );
return squareDalitz->getVal() ;
}
My code works fine until I ask for the “createHistogram” method on “finalPdf” and it gives the attached stack trace.
The reason for this code structure is that I am only able to fit the (x,z) distribution with a TF2, but I need a RooAbsPdf as a function of the (x,y) variables.
Likely either z or squareDalitz is a null pointer. Maybe simply add printf("z=%p squareDalitz=%p, z, squareDalitz); as the first line of sqDalitzToMassesPdf::evaluate() to see which one? Then you’ll need to find out why it’s null.
I will ask Lorenzo for help, too - maybe it’s something obvious in RooFit’s variable handling that I don’t see.
The we’ll need the debugger’s help. I suppose you run something like “root -l -q myScript.C”. Instead, please make sure you can compile your script, using root -l -b myScript.C+ (note tthe “+”). Once your script crashes as before (i.e. all compilation errors are fixed), please run
gdb --args root.exe -l -b myScript.C+
(yes, that “.exe” is intentional). The type “r” and the script will start and crash. Please send the output of
Okay great! Can you change “Analysis.C+” into “Analysis.C++g” (just for our debug session) and run again with gdb? Then once it crashes, send the output of “bt” from gdb.
Also, could you attach the actual code so O know what we are looking at?
I did not find any run_Analysis.sh file to run your code. It would be nice if you can pack your code in a simple and minimal reproducer that we can ran easly.
One thing I notice in your snippet of code is, when binding a TF1 in a RooAbsPdf or RooAbsReal, you should make sure that the objects used to build the TF1 are still alive.
I suspect the problem is caused from the fact that the TF2 you create cannot be correctly copied or clones.
I think createHistograms calls a clone of the pdf inside and this could cause the problem.
Can you maybe try by replacing createHIstogram with the asTF function ? You can always take the obtained as TF and make an histogram using the TF1::GetHistogram function ?
Hi Lorenzo,
by replacing createHIstogram with the asTF and TF1::GetHistogram methods the code does not crash anymore.
However I noticed that the y variable I was using in the createHIstogram method was not contained in the RooAbsPdf as well. Once I make sure it is a RooAbsPdf variable, the createHIstogram method does not crash either. Perhaps createHIstogram needs some protection against such a request.
I have one last question:
according to the way RooFit returns the RooAbsPdf value, shall i add the Jacobian term in the evaluate method of the “derived” pdf or not? github.com/lecriste/Z4430_AAFit … e317ab8R69