#include "TF1.h" #include "TH1.h" #include "TFile.h" #include "TTree.h" #include "TMath.h" #include #include "TH1.h" #include "TLegend.h" #include "TCut.h" #include "TCanvas.h" //#include "../SetStyle.C" #include "TFitResultPtr.h" #include "Fit/FitResult.h" #include "RooFormulaVar.h" #include "TEfficiency.h" #include "RooRealVar.h" #include "RooGenericPdf.h" #include "RooPlot.h" #include "RooWorkspace.h" #include "RooDataSet.h" #include "RooExponential.h" #include "RooTreeDataStore.h" #include "RooBinning.h" #include "RooRealSumPdf.h" #include "RooDataHist.h" #include "TEfficiency.h" #include "TGaxis.h" #include "TAxis.h" #include "TLatex.h" #include "TGraphAsymmErrors.h" using namespace RooFit; Double_t fitFunction(Double_t *x, Double_t *p0) { return p0 + p1 * x * x + p2 / (1 + exp(-x * p3)); // return p0[0]*x[0]; } void eff_band() { TFile *outfile = new TFile("parametr_eff_syst_2sigma_ch1.root"); TTree *tree = (TTree *)outfile->Get("parametersTree"); TFile *File_reco = TFile::Open("eff_var.root"); TH1F *h1 = (TH1F *)File_reco->Get("h1treco_temp"); // TFile *File_reco1 = TFile::Open("sel_17Bd_osc_mc_cut_bdt_s0.root"); // TTree *t1 = (TTree *)File_reco1->Get("tree"); double p0, p1, p2, p3; float treco; tree->SetBranchAddress("p0", &p0); tree->SetBranchAddress("p1", &p1); tree->SetBranchAddress("p2", &p2); tree->SetBranchAddress("p3", &p3); t1->SetBranchAddress("Btrecoxy_PDG", &treco); TCanvas *c = new TCanvas("hist", " ", 600, 600); // TF1 *f = new TF1("function", "[0]+[1]*x*x+[2]/(1+exp(-x*[3]))", 0.2, 10.0); // TF1 *f1 = new TF1("function1", "[0]+[1]*x+[2]/(1+exp(-x*[3]))", 0.2, 10.0); // TF1 *f = new TF1("function", p0+p1*treco*treco+p2/(1+exp(-treco*p3)), 0.2, 10.0); // h1->Draw(); f->Draw(); // f->SetLineColor(kMagenta); f->SetLineWidth(3); f1->SetLineColor(kRed); f1->SetLineWidth(3); // h1->Fit(f,"R"); h1->Fit(f1, "R+"); // h1->Draw(); // f->Draw(); // f1->Draw(); // TF1 *func[2200]; for (int i = 0; i < 1; i++) { tree->GetEntry(i); // TF1 *f = new TF1("function", "[0]+[1]*x*x+[2]/(1+exp(-x*[3]))", 0.2, 10.0); // TF1 *f = new TF1("function", p0+p1*treco*treco+p2/(1+exp(-treco*p3)), 0.2, 10.0); // func[i] = [0]+[1]*x*x+[2]/(1+exp(-x*[3])) TF1 *f = new TF1("function", fitFunction, 0.2, 10); h1->Fit(f, "R"); // f->Draw("same"); // f->SetLineColor(kBlue); // h1->Fit(f,"R+"); } }