//Breit-Wigner function Double_t fitFunc(Double_t* x, Double_t* par) { Double_t arg1 = 14.0/22.0; // 2 over pi Double_t arg2 = par[1]*par[1]*par[2]*par[2]; //Gamma=par[1] M=par[2] Double_t arg3 = ((x[0]*x[0]) - (par[2]*par[2]))*((x[0]*x[0]) - (par[2]*par[2])); Double_t arg4 = x[0]*x[0]*x[0]*x[0]*((par[1]*par[1])/(par[2]*par[2])); return par[0]*arg1*arg2/(arg3 + arg4); } void RootTutorial2_2022_answer(){ //load file TFile *f = new TFile("zjet_rec.root", "read"); //load tree TTree *t = (TTree*)f->Get("Tdata"); //plot Z boson mass TH1F *h = new TH1F("h","h",100,60,140); TCanvas *c1 = new TCanvas("c1","c1",1000,1000); Double_t m; //assign to where the mass should be saved t->SetBranchAddress("m",&m); for(int i = 0; iGetEntries();i++){ t->GetEntry(i); h->Fill(m,1); } h->Draw(); //h->Fit("gaus"); TF1 *func = new TF1("fitFunc",fitFunc,60,140,3); func->SetParameter(0,1.0); func->SetParameter(2,5.0); func->SetParameter(1,95.0); h->Fit("fitFunc"); }