I trying to understand how to shift RooHistPdf’s to get better fits (as you can see in my latest posts). But I think I have now reduced the problem to a quiet simple question. In order to visualize this, I have written the following code:
RooPlot *frame = x.frame();
RooRealVar mean("mean","mean",1200,1000,1400); RooRealVar sigma("sigma","sigma",80,50,90); RooGaussian Gauss("Gauss","Gauss",x,mean,sigma); RooDataSet * Data = Gauss.generate(x,1000000); Data->plotOn(frame); RooRealVar mean2("mean","mean",1210,1200,1220); RooRealVar sigma2("sigma","sigma",80,50,90); RooGaussian Gauss2("Gauss","Gauss",x,mean2,sigma2); RooDataSet * Model = Gauss2.generate(x,1000000); Model->plotOn(frame, LineColor(kGreen), MarkerColor(kGreen)); RooRealVar Shift("Shift","Shift",10,0,20); RooFormulaVar xShifted("xShifted","x + Shift",RooArgSet(x,Shift)); RooDataHist Sim("Sim","Sim",x,*Model); RooHistPdf Func("Func","func",xShifted,x,Sim); Func.plotOn(frame, LineColor(kRed)); Func.fitTo(*Data, Range(1000,1400)); Func.plotOn(frame); Func.paramOn(frame); frame->Draw();
This code should produce to identical, but shifted gaussian curves and use one to generate data while using the second one to create a line shape. Then I add a RooFormulaVar to move this line shape. So in theory with a shift of 10, the shapes should be identical. The result does not agree with this in the sense that I do get identical line shapes but the normalization does not manage to make them look like this (sorry, don’t know how to better express this). I get this result:
unnamed.pdf (33.1 KB)
Why is the normalization not working?