Forcing value to zero

Hello. I want to use roofit. But my code doesn’t work as I expected.

The histogram is consisted of gaussian and Compton cross section.
Here are code and result.

RooRealVar x("x", "x", 0., 0.8);

// read histogram
TFile* file = new TFile("test.root");
TH1F* roothist1 = (TH1F*)file->Get("h1");
// Reading histogram from existing TH1
RooDataHist* hist = new RooDataHist("Rfit:x", "convo", x, (TH1F*)roothist1);
RooPlot* frame = x.frame(Name("xframe"), Title("convotest"));

// gauss
RooRealVar mean("mean", "mean", 0.25, 0.30);
RooRealVar sigma("sigma", "sigma", 0.15,0.20);
RooGaussian gauss("gauss", "gauss", x, mean, sigma);

//compton
RooRealVar hn("hn", "hn", 0.662);//ev
RooRealVar re("re", "re", 0.00000000000000281794);
RooRealVar me("me", "me", 0.511);//ev 
RooFormulaVar s("s", "@0/0.662", RooArgList(x));
RooFormulaVar ga("ga", "@0/@1", RooArgList(hn, me));
RooGenericPdf pdf("function", "function", "1/@2/@2*(@0 *( (@1*@1)/((@2*@2)*(1-@1)*(1-@1)) + @1/(1-@1)*(@1-2/@2) + 2))", RooArgList(me, s, ga));
RooNumConvPdf fff("model", "model", x, pdf,gauss);
x.setBins(100);

gauss.fitTo(*hist);
pdf.fitTo(*hist);
fff.fitTo(*hist);

hist->plotOn(frame, DrawOption("B"), DataError(RooAbsData::None), XErrorSize(0), FillColor(kBlue));

gauss.plotOn(frame, Range(0.05, 0.8), LineColor(kMagenta));
pdf.plotOn(frame, Range(0.05, 0.8), LineColor(kBlack));
fff.plotOn(frame, Range(0.05, 0.8), LineColor(kYellow));


frame->GetYaxis()->SetTitleOffset(1.6);
frame->Draw();

Should I use RooAbsReal?
I think that convolution doesn’t work well.

Thank you for your help.

Regards.

Nea

I guess @moneta can help you

Thank you. I upload test.root.
test.root (3.8 KB)

I tried using RooAbsReal with bindFunction. In this case, my code don’t also work. The error is “no matching function for call to ‘bindFunction’.” I know I have mistake but I have no idea to solve my problem…

Hi,
I think you have continued in another post, No matching function for call to 'bindFunction'.
You should probably keep the same one.
Trying your code, the main problem is that your pdf function you want to convolute with a Gaussian is too sharp, it is almost as a delta function and you cannot perform a numerical convolution with such a peak. I think in this case you can probably assume it is a delta function and then your final pdf will be a Gaussian centred at the peak location.

Lorenzo

Thank you very much!!!

Regards,

Nea

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