I have already posted this question in a fairly old thread but since the one did not even belong to me and was from 2013, I thought it might be a good idea to start a new topic in order to not mix to many topics in one thread.
I have a RooHistPdf made from a histogram and want to shift this along the x-axis. Thus (with the help of you) I used RooFormulaVar in order to shift the pdf, which works in the sense that the pdf is shifted. But sadly the result is much distorted and does not really look like the original pdf. The following pictures show my problem:
This is my code to produce the images:
RooRealVar mass("Mass","Missing Mass",0,2000); RooPlot * Massframe = mass.frame(Title(TString("Missing Mass"))); TFile * g=TFile::Open("../Data/KPlusSigmaStar.root"); TString * HistPost = new TString("FittedTrack_BeamEnergyVsMissingMassKaonPlusBE"); TH2 * HistSigStar2 = (TH2*) g->FindObjectAny(*HistPost); TH1 * HistSigStar = (TH1*) HistSigStar2->ProjectionX(TString("SigStar_"),1,119)->Rebin(5,0); RooRealVar shiftSigStar("shiftSigStar","Shift of SigStar",100.0,-1000,1000.0); RooFormulaVar MassShifted("MassShift","Mass + shiftSigStar",RooArgList(mass,shiftSigStar)); RooDataHist SimSigStar("SimSigStar","Simulation of SigStar",mass,Import(*(HistSigStar))); RooHistPdf * CurveSigStar = new RooHistPdf("CurveSigStar","Kurve SigStar",MassShifted,mass,SimSigStar); RooHistPdf * CurveSigStarNorm = new RooHistPdf("CurveSigStar","Kurve SigStar",mass,SimSigStar); CurveSigStar->plotOn(Massframe); CurveSigStar->paramOn(Massframe); CurveSigStarNorm->plotOn(Massframe, LineColor(kRed)); CurveSigStarNorm->paramOn(Massframe); Massframe->Draw();
If anyone has experience with RooFormulaVar it would be nice if he could help.