{ //*************************************** // macro for Bs2PhiMuMu @ 13TeV //*************************************** #include #include #include #include #include #include #include #include Double_t myfitfunction(Double_t *x, Double_t *par){ Double_t signal = par[0]+ par[1]*x[0] + par[2]*x[0]*x[0]; return (signal); } void macro_fit(){ gStyle->SetOptFit(1); gStyle->SetOptStat(1); gStyle->SetPadBorderMode(0); gStyle->SetStatX(0.997); gStyle->SetStatY(0.997); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetFrameFillColor(10); gStyle->SetFrameFillColor(10); gStyle->SetTitleFillColor(33); gStyle->SetTitleW(.77); gStyle->SetTitleH(.07); gStyle->SetTitleFillColor(33); gStyle->SetHistMinimumZero(false); TChain *ch = new TChain("Task1"); ch->Add("/home/deepak/Desktop/Jazz/18-03-08-full.root"); // ch->Add("/home/deepak/Desktop/Jazz/18-03-09-10-34.root"); // ch->Add("/home/deepak/Desktop/Jazz/18-03-10-11-17.root"); // ch->Add("/home/deepak/Desktop/Jazz/18-03-11-09-23.root"); TTree *tr = ch; TH1D *h_mm = new TH1D("h_mm" ,"Muon Lifetime ; #mu life time (#mus) ; Freequency", 50,200, 10000 ); TCut jpR = "x < 40000"; TCut selbm = jpR; TF1 *fSpectrum = new TF1("fSpectrum", myfitfunction, 200, 10000,3); fSpectrum->SetParameters(0, 2, 2); Double_t fitParameters[3]; fSpectrum->GetParameters(fitParameters); TCanvas *cv1 = new TCanvas("cv1","",600,600); tr->Draw("x >> h_mm", selbm); h_mm->Fit("fSpectrum"); h_mm->GetYaxis()->SetTitleOffset(1.5); h_mm->Draw(); cv1->SaveAs("18-03-11_fit.pdf"); }