Strange things when fitting a lifetime using RooFit

Dear RooFit experts

I have a TTree *tree with (among other things) a lifetime of a particle from a toy experiment assuming ideal resolution and known lifetime. My code looks like the following snippet (in reduced form, units used are seconds):

[code]RooRealVar t(“t3d”, “t”, 0e-12, 15e-12, “seconds”);

RooDataSet data(“data”, “dataset”, RooArgSet(t), Import(*tree));

RooRealVar tau(“tau”,“tau”, 1e-12, 0e-12, 10e-12);
RooTruthModel idealres(“idealres”,“Ideal resolution model”,t);
RooAddPdf model(“model”, “model”, RooArgSet(decay), RooArgList(nsig));


RooPlot * frame_t = t.frame(Title(“Lifetime plot”));
data.plotOn(frame_t, Binning(nBins));

Running this code gives a nice result

. But playing around with it I observe strange things:

  1. RooRealVar::setRange(…) has no effect on the fit

When I change the limits of my RooRealVar t (either in the constructor or calling setRange(…)) changes the x-axis of my plot but the fit is essentially the same up to the last comma. Example: RooRealVar t(“t3d”, “t”, 1e-12, 15e-12, “seconds”);

I would assume that also the fit range gets adjusted.
My question: Is this a bug or a feature?

  1. Cutting away lifetimes smaller an arbitrary threshold gives fits making no sense

If I exclude entries with a lifetime of say 1e-12 s the fit makes no sense anymore. The output suggests that it worked (so no obvious error there) but does not fit the data on the plot.
Physicswise this should make no change as I can start the clock whenever I want, say 1 ps later. The distribution is still an exponential decay and the slope in a logarithmic plot should be the same.

My question: How to deal with this? How can I fit to a dataset that does not start at 0 s?

I also tested (probably a naïve idea) to go for an extended likelihood fit using

RooRealVar nsig("nsig","signal fraction", 0., curEntries); // curEntries has number of entries in Tree RooAddPdf model("model", "model", RooArgSet(decay), RooArgList(nsig));
but the behavior is the same.

Any suggestions are very welcome. I can provide more code or show some plots as needed.

Kind regards,


Talking to a senior colleague and a bit of thinking helped to get an answer to 2) (still reasonable newbie to RooFit and unbinned fitting - I naïvely did what I did on my previous binned fit). So the behaviour is perfectly fine as it comes from normalisation. If the data doesn’t start at 0 the unbinned likelihood should give an average lifetime and this is what comes out. As my cut at 1e-12 almost halved the dataset I get an average lifetime of roughly double the expected value.

No understanding this I rephrase my question for 2): How to tell RooFit to shift the startpoint to an arbitrary value > 0 and do the correct normalisation?

Kind regards


try to pass the range in the RooAbsPdf::fitTo

model.fitTo(data, Range(t_min, t_max);

Best Regards

Hi Lorenzo

Thanks for the hint. But unfortunately model.fitTo(data, Range(1e-12,15e-12)); gives the same result but just the full data range is visible:

So I guess the problem comes from that particular PDF and its normalization. Of course I could do it using the brute force way by adding a new column to my dataset and calculate t-dt but there must be another way to adjust the normalization integral. But how?