//______________________________________________________________________________ void Fit(TH1* h, Double_t* outPos, Double_t* outFWHM) { // Perform fit. Char_t tmp[256]; Double_t x1 = 50; Double_t x2 = 230; TF1* func = new TF1("func", "gaus(0)+pol5(3)", x1, x2); func->SetParameters(h->GetMaximum(), 135, 8, 1, 1, 0.1, 0.1); func->SetLineColor(kBlue); func->SetParLimits(1, 130, 140); func->SetParLimits(2, 1, 15); h->Fit(func, "RBQO"); // get position and FWHM fPi0Pos = func->GetParameter(1); *outPos = fPi0Pos; *outFWHM = 2.35*func->GetParameter(2); // indicator line TLine* line = new TLine(); line->SetLineWidth(2); line->SetX1(fPi0Pos); line->SetX2(fPi0Pos); line->SetY1(0); line->SetY2(h->GetMaximum()); TF1* fBG = new TF1("funcBG", "pol5", x1, x2); for (Int_t i = 0; i < 6; i++) fBG->SetParameter(i, func->GetParameter(3+i)); fBG->SetLineColor(kRed); // draw h->GetXaxis()->SetRangeUser(0, 300); h->Draw(); func->Draw("same"); fBG->Draw("same"); line->Draw("same"); }
//______________________________________________________________________________ void Fit(TH1* h, Double_t* outPos, Double_t* outFWHM) { // Perform fit. Char_t tmp[256]; // delete old function TF1* func = new TF1(tmp, "pol1+gaus(2)"); func->SetLineColor(2); // estimate peak position Double_t fPi0Pos = h->GetBinCenter(h->GetMaximumBin()); // configure fitting function func->SetRange(fPi0Pos - 0.8, fPi0Pos + 0.8); func->SetLineColor(2); func->SetParameters( 0.1, 0.1, h->GetMaximum(), 0, 0.1); Int_t fitres = h->Fit(func, "RB0Q"); // get position and FWHM fPi0Pos = func->GetParameter(3); *outPos = fPi0Pos; *outFWHM = 2.35*func->GetParameter(4); // indicator line TLine* line = new TLine(); line->SetX1(fPi0Pos); line->SetX2(fPi0Pos); line->SetY1(0); line->SetY2(h->GetMaximum()); // draw h->GetXaxis()->SetRangeUser(-3, 3); h->Draw(); func->Draw("same"); line->Draw("same"); }
Int_t integrateRatePlots() { gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); // gStyle->SetOptTitle(0); TGaxis::SetMaxDigits(3); const Int_t nFiles = 3; // const Int_t nElectrons = 3; TFile * histoFile = new TFile("integratedRates-eta2p1-26Jan12.root","RECREATE"); TFile * inputFile[nFiles]; inputFile[0] = TFile::Open("RctEmTree-Rates-scaleV1-thr2p0-01Dec11.root"); // v1, 2.0, BOTH ISO AND NON-ISO inputFile[1] = TFile::Open("RctEmTree-Rates-scaleV3-thr1p0-12Jan12.root"); // v3, 1.0, iso inputFile[2] = TFile::Open("RctEmTree-Rates-HighPU-scaleV3-thr1p0-18Jan12.root"); // v3, 1.0, highPU, iso TH1F * h_rank[nFiles], * h_rankIntegrated[nFiles]; TH1F * h_rankBarrel[nFiles], * h_rankBarrelIntegrated[nFiles]; // scale factor here is 1./(total n LS * 23 s/LS) * (total lumi / effective lumi) to get from total event counts to rate (event count per second) Float_t scaleFactor[3]; scaleFactor[0] = 14.2 * 1./(15379.*23.) * (713729./68.794); scaleFactor[1] = 1./(15379.*23.) * (713729./68.794); scaleFactor[2] = 1./(299. * 23.) * (299.556 / 49.926) * (201.78 / 4.3559); // scaled up to 2e33 inst lumi from 4e31 -- those last two numbers are times 10^31 // tree stuff TTree * tree; vector<int> *emRank; vector<int> *emIso; vector<int> *emIeta; TBranch *b_emRank; TBranch *b_emIso; TBranch *b_emIeta; // end tree stuff // Int_t nBins = 64; // Float_t xMin = 0., xMax = 64.; Int_t nBins = 52; Float_t xMin = 12., xMax = 64.; // |eta| < 1.5, barrel-only // Int_t barrelIEtaBoundaryLower = 7; // this is REGION ieta -- goes from 4 to 17, not including HF. // Int_t barrelIEtaBoundaryUpper = 14; // this takes first four regions (last 3 are endcap) // |eta| < 2.1 Int_t barrelIEtaBoundaryLower = 8; // this is REGION ieta -- goes from 4 to 17, not including HF. Int_t barrelIEtaBoundaryUpper = 13; // this takes first three regions (first 24 towers), going to eta 2.1720 TCanvas * rankCanvas = new TCanvas("rankCanvas","EM rank distribution"); TCanvas * rankBarrelCanvas = new TCanvas("rankBarrelCanvas","EM rank distribution (|#eta| < 2.1)"); TCanvas * integratedCanvas = new TCanvas("integratedCanvas","Rate by trigger threshold"); integratedCanvas->cd(); TPad * pad1 = new TPad("pad1","pad1",0.,0.35,1.0,1.0); pad1->SetBottomMargin(0); pad1->Draw(); TPad * pad2 = new TPad("pad2","pad2",0.,0.,1.0,0.35); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.3); pad2->Draw(); TCanvas * integratedBarrelCanvas = new TCanvas("integratedBarrelCanvas","Rate by trigger threshold (|#eta| < 2.1)"); integratedBarrelCanvas->cd(); TPad * pad1B = new TPad("pad1B","pad1B",0.,0.35,1.0,1.0); pad1B->SetBottomMargin(0); pad1B->Draw(); TPad * pad2B = new TPad("pad2B","pad2B",0.,0.,1.0,0.35); pad2B->SetTopMargin(0); pad2B->SetBottomMargin(0.3); pad2B->Draw(); for (Int_t file = 0; file < nFiles; file++) { std::cout << "File " << file << std::endl; inputFile[file]->cd(); TString treeName = TString("rctAnalyzer/emTree;1"); std::cout << "getting tree" << std::endl; gDirectory->GetObject(treeName,tree); // std::cout << "X min = " << h_rank->GetXaxis()->GetXmin() << std::endl; // std::cout << "X max = " << h_rank->GetXaxis()->GetXmax() << std::endl; // Int_t nBins = h_rank->GetNbinsX(); // h_rank = new TH1F("h_rank","EM Rank",nBins,h_rank->GetXaxis()->GetXmin(),h_rank->GetXaxis()->GetXmax()); // h_rankIntegrated = new TH1F("h_rankIntegrated","Rates by trigger threshold",nBins,h_rank->GetXaxis()->GetXmin(),h_rank->GetXaxis()->GetXmax()); std::cout << "making histograms" << std::endl; h_rank[file] = new TH1F(makeName("h_rank",file),"EM Rank",nBins,xMin,xMax); h_rankIntegrated[file] = new TH1F(makeName("h_rankIntegrated",file),"Rates by trigger threshold",nBins,xMin,xMax); h_rankBarrel[file] = new TH1F(makeName("h_rankBarrel",file),"EM Rank (|#eta| < 2.1)",nBins,xMin,xMax); h_rankBarrelIntegrated[file] = new TH1F(makeName("h_rankBarrelIntegrated",file),"Rates by trigger threshold (|#eta| < 2.1)",nBins,xMin,xMax); rankCanvas->cd(); // tree stuff emRank = 0; emIso = 0; emIeta = 0; tree->SetBranchAddress("emRank", &emRank, &b_emRank); tree->SetBranchAddress("emIso", &emIso, &b_emIso); tree->SetBranchAddress("emIeta", &emIeta, &b_emIeta); b_emRank->SetAutoDelete(kTRUE); b_emIso->SetAutoDelete(kTRUE); b_emIeta->SetAutoDelete(kTRUE); tree->SetBranchStatus("*",0); tree->SetBranchStatus("emRank",1); tree->SetBranchStatus("emIso",1); tree->SetBranchStatus("emIeta",1); // loop over tree std::cout << "Looping over tree" << std::endl; Long64_t nentries = tree->GetEntriesFast(); for (Long64_t jentry = 0; jentry < nentries; jentry++) { //std::cout << "entry " << jentry << std::endl; //Long64_t ientry = tree->LoadTree(jentry); //tree->LoadTree(jentry); // Set current entry. tree->GetEntry(jentry); // Read all branches of entry and return total number of bytes read. Int_t elecSize = emRank->size(); for (Int_t elec = 0; elec < elecSize; elec++) { if (file == 0) // isolated and non-isolated { h_rank[file]->Fill(emRank->at(elec)); if (emIeta->at(elec) >= barrelIEtaBoundaryLower && emIeta->at(elec) <= barrelIEtaBoundaryUpper) { h_rankBarrel[file]->Fill(emRank->at(elec)); } break; } else // isolated only { if (emIso->at(elec) == 1) { h_rank[file]->Fill(emRank->at(elec)); if (emIeta->at(elec) >= barrelIEtaBoundaryLower && emIeta->at(elec) <= barrelIEtaBoundaryUpper) { h_rankBarrel[file]->Fill(emRank->at(elec)); } break; } } } } // end tree stuff // making pretty colors for the lines in the rank plots h_rank[file]->SetLineColor(file+1); if (file+1 == 3) { h_rank[file]->SetLineColor(8); } if (file+1 == 5) { h_rank[file]->SetLineColor(41); } h_rank[file]->SetLineWidth(2); h_rankBarrel[file]->SetLineColor(file+40); h_rankBarrel[file]->SetLineWidth(2); if (file == 0) { h_rank[file]->Draw(); } else { h_rank[file]->Draw("same"); h_rankBarrel[file]->Draw("same"); } rankBarrelCanvas->cd(); if (file == 0) { h_rankBarrel[file]->Draw(); } else { h_rankBarrel[file]->Draw("same"); } // doing the integration Int_t eventsAboveThreshold = 0; for (int i = nBins-1; i >= 0; i--) { eventsAboveThreshold = eventsAboveThreshold + h_rank[file]->GetBinContent(i); std::cout << "bin is " << i << ", bin content is " << h_rank[file]->GetBinContent(i) << ", eventsAboveThreshold is " << eventsAboveThreshold << std::endl; h_rankIntegrated[file]->Fill(xMin+i,eventsAboveThreshold); } eventsAboveThreshold = 0; for (int i = nBins-1; i >= 0; i--) { eventsAboveThreshold = eventsAboveThreshold + h_rankBarrel[file]->GetBinContent(i); std::cout << "bin is " << i << ", bin content is " << h_rankBarrel[file]->GetBinContent(i) << ", eventsAboveThreshold is " << eventsAboveThreshold << std::endl; h_rankBarrelIntegrated[file]->Fill(xMin+i,eventsAboveThreshold); } std::cout << "sumw2" << std::endl; h_rankIntegrated[file]->Sumw2(); h_rankIntegrated[file]->Scale(scaleFactor[file]); h_rankBarrelIntegrated[file]->Sumw2(); h_rankBarrelIntegrated[file]->Scale(scaleFactor[file]); // more pretty colors, this time for integrated plots h_rankIntegrated[file]->SetLineColor(file+1); if (file+1 == 3) { h_rankIntegrated[file]->SetLineColor(8); } if (file+1 == 5) { h_rankIntegrated[file]->SetLineColor(41); } h_rankIntegrated[file]->SetLineWidth(2); if (file == 1) { h_rankBarrelIntegrated[file]->SetLineColor(kRed+2); } if (file == 2) { h_rankBarrelIntegrated[file]->SetLineColor(kYellow+2); } h_rankBarrelIntegrated[file]->SetLineWidth(2); integratedCanvas->cd(); pad1->cd(); std::cout << "Draw" << std::endl; if(file == 0) { h_rankIntegrated[file]->Draw(); } else { h_rankIntegrated[file]->Draw("same"); h_rankBarrelIntegrated[file]->Draw("same"); } integratedBarrelCanvas->cd(); pad1B->cd(); std::cout << "Draw" << std::endl; if(file == 0) { h_rankBarrelIntegrated[file]->Draw(); } else { h_rankBarrelIntegrated[file]->Draw("same"); } std::cout << "Done drawing" << std::endl; } std::cout << "Making legend" << std::endl; TLegend legend(0.3,0.6,0.89,0.89); legend.AddEntry(h_rankIntegrated[0],"v1 scales, thr = 2.0, Relaxed"); legend.AddEntry(h_rankIntegrated[1],"v3 scales, thr = 1.0, Isolated"); legend.AddEntry(h_rankBarrelIntegrated[1],"v3 scales, thr = 1.0, Isolated, |#eta| < 2.1"); legend.AddEntry(h_rankIntegrated[2],"High-PU, v3 scales, thr = 1.0, Isolated"); legend.AddEntry(h_rankBarrelIntegrated[2],"High-PU, v3 scales, thr = 1.0, Isolated, |#eta| < 2.1"); legend.SetFillColor(0); integratedCanvas->cd(); pad1->cd(); legend.Draw("same"); integratedBarrelCanvas->cd(); pad1B->cd(); legend.Draw("same"); std::cout << "Making ratio plots" << std::endl; integratedCanvas->cd(); pad2->cd(); TH1F * r_eff1; TH1F * r_eff2; r_eff1 = (TH1F*) h_rankIntegrated[1]->Clone("r_eff1"); r_eff2 = (TH1F*) h_rankIntegrated[2]->Clone("r_eff2"); r_eff1->Divide(h_rankIntegrated[0]); r_eff2->Divide(h_rankIntegrated[0]); r_eff1->SetTitle(""); r_eff2->SetTitle(""); r_eff1->GetXaxis()->SetRangeUser(xMin,xMax); r_eff2->GetXaxis()->SetRangeUser(xMin,xMax); r_eff1->SetMinimum(0.3); r_eff1->SetMaximum(1.0); r_eff2->SetMinimum(0.3); r_eff2->SetMaximum(1.0); r_eff1->GetXaxis()->SetTitle("Trigger threshold (GeV)"); r_eff1->GetXaxis()->SetLabelSize(0.07); r_eff1->GetXaxis()->SetTitleSize(0.07); r_eff1->GetYaxis()->SetLabelSize(0.07); r_eff2->GetXaxis()->SetTitle("Trigger threshold (GeV)"); r_eff2->GetXaxis()->SetLabelSize(0.07); r_eff2->GetXaxis()->SetTitleSize(0.07); r_eff2->GetYaxis()->SetLabelSize(0.07); r_eff1->Draw(); r_eff2->Draw("same"); integratedBarrelCanvas->cd(); pad2B->cd(); TH1F * r_eff1B; TH1F * r_eff2B; r_eff1B = (TH1F*) h_rankBarrelIntegrated[1]->Clone("r_eff1B"); r_eff2B = (TH1F*) h_rankBarrelIntegrated[2]->Clone("r_eff2B"); r_eff1B->Divide(h_rankIntegrated[0]); r_eff2B->Divide(h_rankIntegrated[0]); r_eff1B->SetTitle(""); r_eff2B->SetTitle(""); r_eff1B->GetXaxis()->SetRangeUser(xMin,xMax); r_eff2B->GetXaxis()->SetRangeUser(xMin,xMax); r_eff1B->SetMinimum(0.3); r_eff1B->SetMaximum(1.0); r_eff2B->SetMinimum(0.3); r_eff2B->SetMaximum(1.0); r_eff1B->GetXaxis()->SetTitle("Trigger threshold (GeV)"); r_eff1B->GetXaxis()->SetLabelSize(0.07); r_eff1B->GetXaxis()->SetTitleSize(0.07); r_eff1B->GetYaxis()->SetLabelSize(0.07); r_eff2B->GetXaxis()->SetTitle("Trigger threshold (GeV)"); r_eff2B->GetXaxis()->SetLabelSize(0.07); r_eff2B->GetXaxis()->SetTitleSize(0.07); r_eff2B->GetYaxis()->SetLabelSize(0.07); r_eff1B->Draw(); r_eff2B->Draw("same"); integratedCanvas->cd(); r_eff1B->Draw("same"); r_eff2B->Draw("same"); TLine * unity; unity = new TLine(0.,1.0,64.,1.0); unity->SetX1(gPad->PadtoX(xMin)); unity->SetX2(gPad->PadtoX(xMax)); unity->SetLineColor(kBlue); integratedCanvas->cd(); pad2->cd(); r_eff1B->Draw("same"); r_eff2B->Draw("same"); unity->Draw("same"); integratedBarrelCanvas->cd(); pad2B->cd(); unity->Draw("same"); std::cout << "Writing canvases to file" << std::endl; histoFile->WriteTObject(rankCanvas); histoFile->WriteTObject(rankBarrelCanvas); histoFile->WriteTObject(integratedCanvas); histoFile->WriteTObject(integratedBarrelCanvas); std::cout << "Closing input files" << std::endl; for (Int_t i = 0; i < nFiles; i++) { inputFile[i]->Close(); } std::cout << "Deleting canvases" << std::endl; delete rankCanvas; delete rankBarrelCanvas; delete pad1; delete pad2; delete integratedCanvas; delete pad1B; delete pad2B; delete integratedBarrelCanvas; return 0; }
void plot (const string &file, const string &metTrigger, const string &metTriggerLabel = "", const bool effOnL1 = false, const bool effOnMu = true, const bool useCaloMET = true, const bool doFit = true) { gStyle->SetOptStat (0); TFile *fin; map<string, TH1D *> triggerEfficiencyNumerator, triggerEfficiencyDenominator; string histName = (useCaloMET ? "pfMETNoMuPt" : "metPt"); string metNumeratorDir = (effOnL1 ? "MuMETNoMETL1SeedPlotter" : (effOnMu ? "MuMETNoMETMuSeedPlotter" : "MuMETNoMETPlotter")); string metDenominatorDir = (effOnL1 ? "MuMETNoMETPlotter/hltL1sL1ETM60ORETM70" : (effOnMu ? "MuMETNoMETPlotter/HLT_IsoMu20_v" : "MuMETNoMETNoTriggerPlotter")); string muonNumeratorDir = (effOnL1 ? "MuMETNoMuonPtL1SeedPlotter" : (effOnMu ? "MuMETNoMuonPtMuSeedPlotter" : "MuMETNoMuonPtPlotter")); string muonDenominatorDir = (effOnL1 ? "MuMETNoMuonPtPlotter/hltL1sL1ETM60ORETM70" : (effOnMu ? "MuMETNoMuonPtPlotter/HLT_IsoMu20_v" : "MuMETNoMuonPtNoTriggerPlotter")); fin = TFile::Open ((file + ".root").c_str ()); triggerEfficiencyNumerator["WJets_MET"] = (TH1D *) fin->Get (("TriggerEfficiency/" + metNumeratorDir + "/" + metTrigger + "/Met Plots/" + histName).c_str ()); triggerEfficiencyNumerator.at ("WJets_MET")->SetDirectory (0); triggerEfficiencyDenominator["WJets_MET"] = (TH1D *) fin->Get (("TriggerEfficiency/" + metDenominatorDir + "/Met Plots/" + histName).c_str ()); triggerEfficiencyDenominator.at ("WJets_MET")->SetDirectory (0); triggerEfficiencyNumerator["WJets_MuonPt"] = (TH1D *) fin->Get (("TriggerEfficiency/" + muonNumeratorDir + "/" + metTrigger + "/Muon Plots/muonPt").c_str ()); triggerEfficiencyNumerator.at ("WJets_MuonPt")->SetDirectory (0); triggerEfficiencyDenominator["WJets_MuonPt"] = (TH1D *) fin->Get (("TriggerEfficiency/" + muonDenominatorDir + "/Muon Plots/muonPt").c_str ()); triggerEfficiencyDenominator.at ("WJets_MuonPt")->SetDirectory (0); fin->Close (); map<string, TGraphAsymmErrors *> triggerEfficiency; for (map<string, TH1D *>::const_iterator design = triggerEfficiencyNumerator.begin (); design != triggerEfficiencyNumerator.end (); design++) { TH1D *numerator = NULL, *denominator = NULL; vector<double> bins; logSpace (NBINS, 1.0, 3.0, bins); numerator = (TH1D *) triggerEfficiencyNumerator.at (design->first)->Rebin (bins.size () - 1, "triggerEfficiencyNumerator", bins.data ()); denominator = (TH1D *) triggerEfficiencyDenominator.at (design->first)->Rebin (bins.size () - 1, "triggerEfficiencyDenominator", bins.data ()); triggerEfficiency[design->first] = new TGraphAsymmErrors (numerator, denominator, "cp"); triggerEfficiency.at (design->first)->SetName ("triggerEfficiency"); triggerEfficiency.at (design->first)->GetYaxis ()->SetTitle ((effOnL1 ? "trigger efficiency on L1 seed" : (metTrigger == "hltL1sL1ETM60ORETM70" ? "L1 seed efficiency" : "trigger efficiency"))); if (design->first == "WJets_MET") { setStyle (triggerEfficiency.at (design->first), kBlack, 20); triggerEfficiency.at (design->first)->GetXaxis ()->SetTitle (useCaloMET ? "PF E_{T}^{miss} (no muons) [GeV]" : "PF E_{T}^{miss} [GeV]"); } else if (design->first == "WJets_MuonPt") { setStyle (triggerEfficiency.at (design->first), kBlack, 20); triggerEfficiency.at (design->first)->GetXaxis ()->SetTitle ("muon p_{T} [GeV]"); } } TPaveText *pt1 = NULL; if (file.find ("SingleMuon") == 0) pt1 = new TPaveText(0.132832,0.859453,0.486216,0.906716,"brNDC"); else pt1 = new TPaveText(0.229323,0.859453,0.581454,0.906716,"brNDC"); pt1->SetBorderSize(0); pt1->SetFillStyle(0); pt1->SetTextFont(62); pt1->SetTextSize(0.0374065); pt1->AddText(file.find ("SingleMuon") == 0 ? "CMS Preliminary" : "CMS Simulation Preliminary"); TPaveText *pt2 = NULL; if (file.find ("SingleMuon") == 0) pt2 = new TPaveText(0.744361,0.92928,0.860902,0.977667,"brNDC"); else pt2 = new TPaveText(0.827068,0.92928,0.942356,0.977667,"brNDC"); pt2->SetBorderSize(0); pt2->SetFillStyle(0); pt2->SetTextFont(42); pt2->SetTextSize(0.0374065); pt2->AddText((file.find ("SingleMuon") == 0 ? (file == "SingleMuon_2015C" ? string ("16.34") : (file == "SingleMuon_2015D" ? string ("209.2") : string ("225.6"))) + " pb^{-1}, 13 TeV" : "13 TeV").c_str ()); TPaveText *pt3 = new TPaveText(0.160401,0.768657,0.342105,0.863184,"brNDC"); pt3->SetBorderSize(0); pt3->SetFillStyle(0); pt3->SetTextFont(42); pt3->SetTextSize(0.0349127); pt3->SetTextAlign(12); pt3->AddText((metTriggerLabel == "" ? metTrigger : metTriggerLabel).c_str ()); pt3->AddText((file.find ("SingleMuon") == 0 ? string ("SingleMuon ") + (file == "SingleMuon_2015C" ? "2015C" : (file == "SingleMuon_2015D" ? "2015D" : "2015C+D")) + " data (25 ns)" : "W+jets MC").c_str ()); TPaveText *pt4 = new TPaveText(0.159548,0.742537,0.341709,0.863184,"brNDC"); pt4->SetBorderSize(0); pt4->SetFillStyle(0); pt4->SetTextFont(42); pt4->SetTextSize(0.0349127); pt4->SetTextAlign(12); if (file.find ("SingleMuon") == 0) { pt4->AddText(metTrigger == "hltMETClean75" ? "HLT_MET75_IsoTrk50_v2" : ("HLT_MET75_IsoTrk50_v2 OR " + (metTriggerLabel == "" ? metTrigger : metTriggerLabel)).c_str ()); pt4->AddText((string ("SingleMuon ") + (file == "SingleMuon_2015C" ? "2015C" : (file == "SingleMuon_2015D" ? "2015D" : "2015C+D")) + " data (25 ns)").c_str ()); pt4->AddText("hltMET75 applied"); } else { pt4->AddText(metTrigger == "hltMET75" ? "HLT_MET75_IsoTrk50_v1" : ("HLT_MET75_IsoTrk50_v1 OR " + (metTriggerLabel == "" ? metTrigger : metTriggerLabel)).c_str ()); pt4->AddText("W+jets MC"); pt4->AddText("hltMETClean75 applied"); } TCanvas *c1 = new TCanvas("c1", "c1",561,482,800,830); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c1->Range(0.644391,-0.1480839,3.167468,1.19299); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetLogx(); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.122807); c1->SetRightMargin(0.05012531); c1->SetTopMargin(0.06947891); c1->SetBottomMargin(0.1104218); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); TCanvas *c2 = new TCanvas("c2", "c2",561,482,800,830); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c2->Range(0.644391,-0.1480839,3.167468,1.19299); c2->SetFillColor(0); c2->SetBorderMode(0); c2->SetBorderSize(2); c2->SetLogx(); c2->SetTickx(1); c2->SetTicky(1); c2->SetLeftMargin(0.122807); c2->SetRightMargin(0.05012531); c2->SetTopMargin(0.06947891); c2->SetBottomMargin(0.1104218); c2->SetFrameFillStyle(0); c2->SetFrameBorderMode(0); c2->SetFrameFillStyle(0); c2->SetFrameBorderMode(0); TGraphAsymmErrors *WJets_MET = NULL, *WJets_MuonPt = NULL; c1->cd (); (WJets_MET = (TGraphAsymmErrors *) triggerEfficiency.at ("WJets_MET")->Clone ())->Draw ("ap"); pt1->Clone ()->Draw ("same"); pt2->Clone ()->Draw ("same"); pt3->Clone ()->Draw ("same"); WJets_MET->GetYaxis ()->SetRangeUser (0.0, YMAX); c2->cd (); (WJets_MuonPt = (TGraphAsymmErrors *) triggerEfficiency.at ("WJets_MuonPt")->Clone ())->Draw ("ap"); pt1->Clone ()->Draw ("same"); pt2->Clone ()->Draw ("same"); pt4->Clone ()->Draw ("same"); WJets_MuonPt->GetYaxis ()->SetRangeUser (0.0, YMAX); TLine *l = new TLine (1.0e1, 1.0, 1.1e3, 1.0); l->SetLineWidth (3); l->SetLineStyle (2); c1->cd (); l->SetX1 (WJets_MET->GetXaxis ()->GetXmin ()); l->SetX2 (WJets_MET->GetXaxis ()->GetXmax ()); l->Clone ()->Draw ("same"); c2->cd (); l->SetX1 (WJets_MuonPt->GetXaxis ()->GetXmin ()); l->SetX2 (WJets_MuonPt->GetXaxis ()->GetXmax ()); l->Clone ()->Draw ("same"); if (!doFit) return; TF1 *f0 = new TF1 ("f0", normCDF, 1.0e1, 1.0e3, 4), *f1 = new TF1 ("f1", normCDF, 1.0e1, 1.0e3, 4); f0->SetParameter (0, 75.0); f0->SetParameter (1, 5.0); f0->FixParameter (2, 0.99); f0->FixParameter (3, 0.01); f1->SetParameter (0, 50.0); f1->SetParameter (1, 1.0); f1->FixParameter (2, 0.85); f1->FixParameter (3, 0.0); for (unsigned i = 0; i < 100; i++) triggerEfficiency.at ("WJets_MET")->Fit (f0, "emrq0"); for (unsigned i = 0; i < 100; i++) triggerEfficiency.at ("WJets_MuonPt")->Fit (f1, "emrq0"); f0->ReleaseParameter (2); f0->ReleaseParameter (3); f1->ReleaseParameter (2); f1->ReleaseParameter (3); for (unsigned i = 0; i < 100; i++) triggerEfficiency.at ("WJets_MET")->Fit (f0, "emrq0"); triggerEfficiency.at ("WJets_MET")->Fit (f0, "emr0"); for (unsigned i = 0; i < 100; i++) triggerEfficiency.at ("WJets_MuonPt")->Fit (f1, "emrq0"); triggerEfficiency.at ("WJets_MuonPt")->Fit (f1, "emr0"); stringstream ss0, ss1; TPaveText *pt5 = new TPaveText(0.159148,0.689055,0.342105,0.774876,"brNDC"); pt5->SetBorderSize(0); pt5->SetFillStyle(0); pt5->SetTextFont(42); pt5->SetTextSize(0.0349127); pt5->SetTextAlign(12); ss0.str (""); ss0 << "#mu: (" << setprecision (3) << f0->GetParameter (0) << " #pm " << setprecision (2) << f0->GetParError (0) << ") GeV"; pt5->AddText(ss0.str ().c_str ()); ss0.str (""); ss0 << "#sigma: (" << setprecision (3) << f0->GetParameter (1) << " #pm " << setprecision (2) << f0->GetParError (1) << ") GeV"; pt5->AddText(ss0.str ().c_str ()); TPaveText *pt6 = new TPaveText(0.160804,0.665423,0.322864,0.746269,"brNDC"); pt6->SetBorderSize(0); pt6->SetFillStyle(0); pt6->SetTextFont(42); pt6->SetTextSize(0.0349127); pt6->SetTextAlign(12); ss1.str (""); ss1 << "#mu: (" << setprecision (3) << f1->GetParameter (0) << " #pm " << setprecision (2) << f1->GetParError (0) << ") GeV"; pt6->AddText(ss1.str ().c_str ()); ss1.str (""); ss1 << "#sigma: (" << setprecision (3) << f1->GetParameter (1) << " #pm " << setprecision (2) << f1->GetParError (1) << ") GeV"; pt6->AddText(ss1.str ().c_str ()); f0->SetLineWidth (3); f1->SetLineWidth (3); c1->cd (); f0->Clone ()->Draw ("same"); pt5->Clone ()->Draw ("same"); c2->cd (); f1->Clone ()->Draw ("same"); pt6->Clone ()->Draw ("same"); }