Hey,
My code is working fine, however I want to get a better background by removing the small bumps in my data which are caused by the trigger. I am not sure how to write my code to only select certain events via the trigger, to then ignore the bumps. So far I have loaded in the trigger branch into my code.
[code]//We have plotted the Higgs Pt and from that selected the JPsi masses from that, and then plotted the background and signal.
using namespace RooFit;
void DemoFits(void)
{
const int binning=100;
RooRealVar Trigger(“Trigger”,“Trigger”, 0.0,1.0);
RooRealVar Higgs_Pt(“Higgs_Pt”, “Higgs Transverse Momentum”, 0.0, 10000.0, “MeV”);
RooRealVar DiLept_M(“DiLept_M”, “J/psi Mass”, 2000.0, 4500.0, “MeV”);
//—
RooRealVar mean(“mean”, “mean”, 3100.0, 2900.0, 3300.0);
RooRealVar sigma(“sigma”,“width of Gaussian”, 100.0, 50.0, 1000.0);
RooRealVar sigmascale(“sigmascale”,“Scale of 2nd Gaussian”, 1.5, 1.0, 5.0);
RooFormulaVar sigma2(“sigma2”, “width of 2nd Gaussian”, “sigmascale * sigma”, RooArgList(sigmascale, sigma));
RooGaussian gauss1(“gauss1”, “Gauss 1 PDF”, DiLept_M, mean, sigma);
RooGaussian gauss2(“gauss2”, “Gauss 2 PDF”, DiLept_M, mean, sigma2);
RooRealVar GaussFrac(“GaussFrac”, “Fraction of both Gaussians”, 0.2, 0.0, 1.0);
RooAddPdf GaussAdd(“GaussAdd”, “Double Gaussian”, RooArgList(gauss1,gauss2), GaussFrac);
//—
RooRealVar c(“c”, “slope”, 0.0 , -10.0, 10.0);
RooRealVar c2(“c2”,“slope”, 0.0 , -10.0, 10.0);
RooPolynomial Pol(“Pol”, “Quadratic distribution”, DiLept_M, RooArgList(c,c2));
//—
RooRealVar bkgfrac(“bkgfrac”, “Fraction of background”, 0.1, 0.0 ,1.0);
RooAddPdf model(“model”, “Gaussian + background”, RooArgList(Pol, GaussAdd), bkgfrac);
//—
TFile *file = new TFile("/home/atlas/amytee/Adam/Data.Merge.root",“Data.Merge.root”, “READ”);
TTree tree = (TTree)file->Get(“newTree”);
RooDataSet data(“data”, “data”, RooArgSet (Higgs_Pt, DiLept_M), Import(*tree));
data.Print();
//—
model.fitTo(data,Binning(binning));
//—
TCanvas *canvas = new TCanvas(“canvas”, “canvas”, 700, 500);
RooPlot *frame = DiLept_M.frame();
data.plotOn(frame);
model.plotOn(frame, Components(“GaussAdd”), LineColor(kGreen));
model.plotOn(frame, Components(“Pol”), LineColor(kRed));
model.plotOn(frame, LineColor(kBlack));
frame->Draw();
canvas->SaveAs(“JPsi_Mass_AllFits.eps”);
};
[/code]JPsi_Mass_AllFits.eps (24.1 KB)