Details
-
Bug
-
Status: Resolved (View Workflow)
-
Medium
-
Resolution: Fixed
-
5.34/00
-
None
-
All
-
bugs100964
-
Description
The following code is not working as expected:
using namespace RooFit;
|
|
// PDF for arbitrary "time error" distribution
|
RooRealVar timeerror("timeerror","timeerror", 0.0, 1.0);
|
RooRealVar timeexp("timeexp","timeexp", \-0.3, 0.0, 1.0);
|
RooExponential exp("exp", "exp", timeerror, timeexp);
|
|
// proto data for time error
|
RooDataSet* proto = exp.generate(timeerror, 1000);
|
|
// PDF for abitrary "time" distribution depending on time errors
|
RooRealVar time("time","time", \-10.0, 10.0);
|
RooRealVar timemean("timemean","timemean", 0.0, \-10.0, 10.0);
|
RooGaussian gauss("gauss", "gauss", time, timemean, timeerror);
|
|
// dataset for time with correct time errors as proto data
|
RooDataSet* toydata = gauss.generate(time, 1000, ProtoData(*proto));
|
|
// fitting time distribution with time error as conditional observable
|
gauss.fitTo(*toydata, ConditionalObservables(timeerror));
|
|
// RooCmdArg for correct plotting (could be on stack, would not change anything)
|
RooCmdArg * arg = new RooCmdArg(ProjWData(timeerror, *toydata));
|
|
// Plot the distribution and PDF with above RooCmdArg fails (giving ProjWData directly works)
|
TCanvas c("c","c",800,600);
|
RooPlot* frame = time.frame();
|
toydata->plotOn(frame);
|
gauss.plotOn(frame, *arg/*,ProjWData(timeerror, *toydata)*/);
|
frame->Draw();
|
c.SaveAs("test.pdf");
|
It simply generates an arbitrary distribution for "time" which is depending on the "timeerror" variable. The PDF is fitted afterwards. Everything works fine until here, the problematic part is the plotting.
The RooCmdArg arg should take care of correct plotting of the PDF. However, in the above code it is simply ignored and the plot looks like no RooCmdArg was supplied at all. Only if not passing arg directly, but using "ProjWData(timeerror, *toydata)" in the plotOn function call, it produces the correct desired result.
I do not understand how this is even possible, but it makes a difference if the supplied RooCmdArg is instantiated temporarily for plotOn or if it is passed as an actual object.
Attachments
Issue Links
- is duplicated by
-
ROOT-9861 [RF] RooCmdArgs copy pointers to temporaries
-
- Resolved
-