Binned fit stuck

Hello!

I am facing a problem when running a fit on a binned dataset in RooFit.
I write down the piece of code I am using to set up all my observables. Basically I am taking data from some Trees and I want to fit them using the sum of two landaus.

TFile* finput_iso = new TFile("2017/fit_iso.root");
TTree* tData_iso = (TTree*) finput_iso->Get("T");

RooRealVar *sip = new RooRealVar("sip","sip",0,400);
RooRealVar *iso = new RooRealVar("iso","iso",0,100);
RooRealVar *lepid = new RooRealVar("lepid", "lepid",-20,20);
RooRealVar *id1 = new RooRealVar("id","id",0,3);
RooRealVar *z1flav = new RooRealVar("z1flav","z1flav",120,170);

RooDataSet *tdata_iso = new RooDataSet("tdata_iso","tdata_iso",tData_iso, RooArgSet(*id1,*sip,*iso,*lepid,*z1flav));
RooDataSet *tdata_mu_iso    = (RooDataSet *)tdata_iso->reduce("abs(lepid)==13 && id==1 && iso < 0.35 && abs(z1flav)==169");
RooDataSet *tdata_ele_iso    = (RooDataSet *)tdata_iso->reduce("abs(lepid)==11 && id==1 && abs(z1flav)==121");

sip->setRange("range_ext", 0, 40);

RooRealVar *ml3 = new RooRealVar("mean3","mean3",0.7,0.,5.);
RooRealVar *sl3 = new RooRealVar("sigma3","sigma3", 0.3,0.1,10.);
RooRealVar *ml4 = new RooRealVar("mean4","mean4",4.,2.5,20.);
RooRealVar *sl4 = new RooRealVar("sigma4","sigma4", 4.5,0.1,10.);

RooLandau* landau3 = new RooLandau("landau3","landau3 ",*sip,*ml3,*sl3);
RooLandau* landau4 = new RooLandau("landau4","landau4 ",*sip,*ml4,*sl4);

RooRealVar *frac3 = new RooRealVar("frac3","fraction of component 1",0.9,0.,1.);

RooAddPdf *model_ee_isoCut = new RooAddPdf("model_ee_isoCut","landau2+landau1", RooArgList(*landau4,*landau3),RooArgList(*frac3));

I have always run the fit using unbinned data, now I have to rerun the fit using binned data for some crosschecks. To run the binned fit I use the following commands:

TH1 *hh_ele = (TH1 *)tdata_ele_iso->createHistogram("sip", 20);
RooDataHist *tdata_ele_iso_binned = new RooDataHist("tdata_ele_iso_binned", "tdata_ele_iso_binned", *sip, hh_ele);
RooFitResult *result_Fit_ele_isoCut = model_ee_isoCut->fitTo(*tdata_ele_iso_binned,RooFit::Range("range_ext"), RooFit::Save(), RooFit::NumCPU(16));

After the last command the code hangs. No warning, no errors, no outputs at all.
I have tried to fit using only one landau, instead of the sum, and the fit works. Using unbinned data it works perfectly, too. It seems the problem is when I move to binned data.
If you have any insight of this problem, it will be extremely useful.

Thanks,
Alessandro

Hi @Ale_olomorfo, I hope things are well at LLR-CMS :smiley:

That’s not good that the code hangs without any explanation. If you can give me the files necessary to reproduce this, I’ll see if RooFit can be patched to handle the problem more gracefully, whatever the problem is.

I suspect that it has something to to with the range. You fit to the range range_ext, but the histogram was created with the default range. I suspect that the default binning and the binning of range_ext are not compatible, causing a problem somewhere. Have you tried to pass the correct range name to createHistogram()?

By the way, the usual way to go from an unbinned dataset to a binned one with via RooDataSet::binnedClone(), but probably that will also not work out of the box because of you alternative binning/range.

Maybe it’s even possible for you to define the default range of sip as [0,40], and then you don’t need to set range_ext? Or do you need the default range for something else?

Anyway, I would be happy to get my hands on a reproducer for this problem, also via PM on Mattermost if you prefer.

Cheers,
Jonas

Thanks @Jonas!

The problem was in the definition of the range. If I set range_ext to [0,400], which is the histogram range, the fit work perfectly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.