// An example application of this fit is given below. For a TH1* histogram //("data") fitted as the sum of three Monte Carlo sources ("mc"): { TFile d1("DataNonQcd.root");//data file TFile f1("MetcontrolFit.root");// QCD file TFile f2("T1_Mc_NonQCD.root");//ttbar signal file TFile f3("bkgBaseline.root");//bkg file TH1F *dmb = (TH1F*)d1.Get("final_met")->Clone("data2");//data //TH1F *data = (TH1F*)d1.Get("final_met"); TH1F *mc0 = (TH1F*)f1.Get("data_minus_sigmc_and_bkg_metControl");//qcd template TH1F *mc1 = (TH1F*)f2.Get("final_met");//ttbar mc1->Scale(1/0.036); cout << "Integral for ttbar unscaled " << mc1->Integral() << endl; TH1F *mc2 = (TH1F*)f3.Get("final_met");//bkg dmb->Add(mc2, -1); //TH1F *data; //data histogram //TH1F *mc0; // first MC histogram // TH1F *mc1; // second MC histogram // TH1F *mc2; // third MC histogram // retrieve histograms TObjArray *mc = new TObjArray(2); // MC histograms are put in this array mc->Add(mc0); mc->Add(mc1); //mc->Add(mc2); //TFractionFitter* fit = new TFractionFitter(data, mc); TFractionFitter* fit = new TFractionFitter(dmb, mc); // initialise fit->Constrain(1,0.0,1.0); // constrain fraction 1 to be between 0 and 1 fit->SetRangeX(1,15); // use only the first 15 bins in the fit Int_t status = fit->Fit(); // perform the fit std::cout << "fit status: " << status << std::endl; if (status == 0) { // check on fit status TH1F* result = (TH1F*) fit->GetPlot(); //result->SetDirectory(0); dmb->Draw("Ep"); result->Draw("same"); ; } }