Fitting a sub-range with fitTo(..,Range(),SumCoefRange())

Hello RooFitters,
I noticed that there were some similiar posts about sub-ranges, but I did not find any answers to my specific problem, so I am starting my own “cry for help”. :slight_smile:

I tried to fit a composite model to my data (which is stored in a histogram) within a certain sub-range of my spectrum. If I now restrict the observable to this sub-range, the fit turns out fine, but if I want to plot the whole spectrum and the model solely in the sub-range the plot fails (although the parameters seem to be consistent). How can this be fixed?
I used an old version of ROOT/RooFit to produce the Plots (early 2010 I think), but I had the same problem with a new version (trunk version october 2011).

I think the plots and the code will make everything clear.

[code]void MnFit2(){
gSystem->Load(“libRooFit”) ;
using namespace RooFit;
//observable
RooRealVar t(“t”,“Kanalnummer”,600,1100) ; //producing Mn1.pdf this range was used: 0,2048

// — Model —
//variables
RooRealVar mean("#mu",“Mean”,900,800,1000) ;
RooRealVar sigl("#sigma_{links}","#sigma_{links}",50,10,80) ;
RooRealVar sigr("#sigma_{rechts}","#sigma_{rechts}",60,10,80) ;
RooRealVar a0(“a_{0}”,“a0”,-.48216,-1,1) ;
RooRealVar a1(“a_{1}”,“a1”,.2576,-1,1) ;
RooRealVar a2(“a_{2}”,“a2”,-0.09188,-1,1) ;
//Asymmetric Gaussian
RooBifurGauss asymgaus(“asymgaus”,“asymgaus”,t,mean,sigl,sigr) ;
//Chebychev background
RooChebychev bkg(“bkg”,“Background”,t,RooArgSet(a0,a1,a2)) ;

//Define fit range
//producing Mn1.pdf this was uncommented : t.setRange(“fitRange”,600,1100) ;

//put the model together
RooRealVar nsig(“N_{signal}”,“number of signal events”,98730,70000,150000) ;
RooRealVar nbkg(“N_{background}”,“number of background events”,50000,10000,190000) ;
RooAddPdf model(“model”,“ag+bkg”,RooArgList(asymgaus,bkg),RooArgList(nsig,nbkg)) ;
//I also tried: model.fixCoefRange(“fitRange”);
// — Data —
TFile *MyFile = new TFile(“Mangan2.root”,“OLD”) ;
TH1F h42 = (TH1F) MyFile->Get(“hist”) ;
RooDataHist *data = new RooDataHist(“data”,“dataset with t”,t,h42) ;
// — Fit —
RooFitResult *r = model.fitTo(*data,Save()) ;// producing Mn1.pdf this was put into the paranthesis: ,Range(“fitRange”),SumCoefRange(“fitRange”)

// — Plot —
RooPlot* tframe = t.frame(Title(“Energie Mangan Probe 2”)) ;
data->plotOn(tframe) ;
model.plotOn(tframe,LineColor(2)) ;
model.plotOn(tframe,LineStyle(kDashed),LineColor(2),Components(bkg)) ;
model.paramOn(tframe) ;
tframe->Draw();
}[/code]

Thanks in advance and have a nice weekend!
marian
Mangan2.root (15.9 KB)
Mn2.pdf (61.9 KB)
Mn1.pdf (188 KB)