How to make RooHistPdf with a RooDataHist and fit

I have three RooDataHists. and make three RooHistPdf,such as pdf1,pdf2,pdf3.

then

TFile *ffd0 = new TFile(“d0.root”);
TH1 hhd0 = (TH1) gDirectory->Get(“h1”);

RooRealVar xd0(“xd0” , “xd0” , 0, 1200);

I expect to extract the fraction of every pdf. but I fail .

anyone can help me?

Hi,

When you do a regular (non-extended) likelihood fit, a sum of three
components has only two fractions f1[0-1], f2[0-1] (f3=1-f1-f2). If you would
omit c3 from your RooAddModel ctor, the fit would work fine and you
will find the two fractions f1 and f2.

Alternatively you can construct an extended likelihood model, which
in addition to the shape also fits for the total number of events. This gives one extra observable and allows for one extra degree of freedom
in your parametrization (f1,f2,Ntot), though one can (and usually does)
rewrite that to N1=f1Ntot, N2=f2Ntot and N3=(1-f1-f2)*Ntot.

This is the type of p.d.f. that is automatically created for you when you give
an equal number of p.d.f.s and coefficients to RooAddModel (as you did).
The only details is that when you fit such a p.d.f. you have to tell fitTo() to included
the extended likelihood term in the fit, i.e. model.fitTo(datad0,“e”)

Hope this helps (I think the RooFit manual has a few more details on this)

Wouter

I used the extended likelihood model and got the result as following

1 c1 1.00000e-00 4.26876e-03
WARNING - - ABOVE PARAMETER IS AT LIMIT.
2 c2 1.00000e-00 1.18197e-02
WARNING - - ABOVE PARAMETER IS AT LIMIT.
3 c3 4.30899e+02 2.43597e+01 -2.39988e+01 2.46702e+01

I expect that c1+c2 equals to 0.5 .but both c1 and c2 reach the limit.
can you help me ?

Hi,

In extended ML mode, the coefficients represent the number of events
in each component, so there are not fractions in the range [0-1] as they
are in non-extended mode.

The warning messages are related to this: the best likelihood is obtained at
the upper limit of the coefficients (value of 1), but the true minimum of the
likelihood will be at much larger coefficient values, depending on the number

Wouter

Hi wouter. I still need your help.

In the attachment , you will see 4 histograms. The first histogram comprises of other three histograms. I expect to get the fraction and
the number of events.

First of all, I make three RooDataPdfs like this:

TFile *ff2 = new TFile("h2.root");
TH1 *hh2  = (TH1*) gDirectory->Get("h1");
RooRealVar x2("x2" , "x2" , 0, 1200);
RooDataHist data2("data2", "dataset with x ", x2 ,hh2);
RooRealVar xx2("xx2" , "xx2" , 0, 1200);
[b]RooHistPdf [/b]h2Pdf("xx2","xx2" ,RooArgList(x2),data2);

secondly, I construct the model like this:

RooRealVar c1(“c1”,“c1”,1000,-1000000,10000000);
RooRealVar c2(“c2”,“c2”,2000,-1000000,10000000);
RooRealVar c3(“c3”,“c3”,5920,-1000000,10000000);

I have used extended likelihood method

RooRealVar xd0(“xd0” , “xd0” , 0, 1200);

finally, I get the result:
============== VARIABLE6 IS AT ITS LOWER ALLOWED LIMIT.
FCN=-15929.8 FROM MINOS STATUS=FAILURE 536 CALLS 2783 TOTAL
EDM=4.29675e+07 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 100.0 per cent
EXT PARAMETER PARABOLIC MINOS ERRORS
NO. NAME VALUE ERROR NEGATIVE POSITIVE
1 c1 -1.44069e+03 2.69927e-04
2 c2 -4.28306e+03 2.69833e-04
3 c3 5.72480e+03 2.70157e-04

I expect c1+c2 = c3. But I failed.