void PlotEtas(const char* filename = "ETAS.root") { TFile* file = new TFile(filename); TNtuple* etas = (TNtuple*)file->Get("etas"); TH1F* m = new TH1F("m", ";m_{#gamma#gamma} [GeV/c^{2}];Counts/10 MeV", 100, 0, 1); m->SetFillColor(kCyan); etas->Project("m", "m"); TString formula = "gaus(0)+gaus(3)+pol2(6)"; // TString formula; // formula += "[0]*TMath::BreitWigner(x,[1],[2])+"; // formula += "[3]*TMath::BreitWigner(x,[4],[5])+"; // formula += "pol2(6)"; TF1* fit = new TF1("fit", formula, 0.1, 1); fit->SetParameters(21, 0.13, 0.013, 12, 0.49, 0.022, 0.78, 22, -21); m->Fit(fit, "R"); float xmin = 0.45; // fit->GetParameter(4) - 0.05; float xmax = 0.55; // fit->GetParameter(4) + 0.05; TLine* line1 = new TLine(xmin, 0, xmin, m->GetMaximum()); TLine* line2 = new TLine(xmax, 0, xmax, m->GetMaximum()); line1->SetLineColor(kRed); line2->SetLineColor(kRed); line1->Draw(); line2->Draw(); TF1* signal = new TF1("signal", "gaus", xmin, xmax); TF1* background = new TF1("background", "pol2", xmin, xmax); signal->SetParameters(fit->GetParameters() + 3); background->SetParameters(fit->GetParameters() + 6); float signalCounts = signal->Integral(xmin, xmax) / 0.010; float backgroundCounts = background->Integral(xmin, xmax) / 0.010; cout << "Signal = " << signalCounts << endl; cout << "Background = " << backgroundCounts << endl; }