void trackingStudyAroundJet(char *infname = "skim_jet_ptha120.root") { HiForest *c = new HiForest(infname); c->tree->AddFriend("nt"); TCut trackSelection = "(mtrkQual||mtrkAlgo<4)&&pNRec>0"; TCut dijetSelection = "leadingJetPt>120&&subleadingJetPt>50&&acos(cos(leadingJetPhi-subleadingJetPhi))>7./8.*3.141593"; TCut genParticleCut = "abs(pEta)<2.4"; TCanvas *cleadingJetPt = new TCanvas ("cleadingJetPt","",600,600); TH1F *hEffleadingJetPt = new TH1F("hEffleadingJetPt","",10,0,0.3); makeHistTitle(hEffleadingJetPt,"","Leading Jet p_{T} (GeV/c)","Tracking Efficiency"); TGraphAsymmErrors *g = getEfficiency(c->tree,"acos(cos(pPhi-leadingJetPhi))",10,0,0.3,trackSelection,TCut("pPt>20")&&dijetSelection&&genParticleCut); TGraphAsymmErrors *g2 = getEfficiency(c->tree,"acos(cos(pPhi-leadingJetPhi))",10,0,0.3,trackSelection,TCut("pPt>8")&&dijetSelection&&genParticleCut); TGraphAsymmErrors *g3 = getEfficiency(c->tree,"acos(cos(pPhi-leadingJetPhi))",10,0,0.3,trackSelection,TCut("pPt>0")&&dijetSelection&&genParticleCut); hEffleadingJetPt->SetAxisRange(0.6,0.9,"Y"); hEffleadingJetPt->Draw(); g->Draw("p same"); g2->SetLineColor(2); g2->SetMarkerColor(2); g2->Draw("p same"); g3->SetLineColor(4); g3->SetMarkerColor(4); g3->Draw("p same"); TLegend *legleadingJetPt = myLegend(0.5,0.7,0.9,0.9); legleadingJetPt->AddEntry(g,"#hat{p}_{T} 170 GeV/c, Dijet selection",""); legleadingJetPt->AddEntry(g,"simTrack p_{T} > 20 GeV/c","pl"); legleadingJetPt->AddEntry(g2,"simTrack p_{T} > 8 GeV/c","pl"); legleadingJetPt->AddEntry(g3,"simTrack p_{T} > 0 GeV/c","pl"); legleadingJetPt->Draw(); cleadingJetPt->SaveAs("effFig/EffVsleadingJetDphi-DijetSelection.gif"); cleadingJetPt->SaveAs("effFig/EffVsleadingJetDphi-DijetSelection.C"); }
//Power models double PlantBChiller::computePower(CoolingParams *params) { params->freeCooling=false; double heat = params->waterFlow*GPM_CONVERSION*RHO_WATER*CP_WATER*1000 *(params->waterTemp-m_params.coldWaterTemp); double tons = heat*KW_TON_CONVERSION; double eff = getEfficiency(m_params.coldWaterTemp); if (eff < 0){ LOG_ERROR << "Invalid value for chiller efficiency"; } m_electricPower = tons*1000*eff; VLOG_2 << " -- Chiller: heat= " << heat << " eff= " << eff; VLOG_2 << "Chiller electrical power consumption is " << m_electricPower; m_chillerPower = m_electricPower; return m_electricPower; }
void makePlot_wrapper(const TString& title, const TH1* histogram_numerator_Data_passed, const TH1* histogram_denominator_Data_passed, const TH1* histogram_numerator_mcSum_passed, const TH1* histogram_denominator_mcSum_passed, const TH1* histogram_numerator_Data_failed, const TH1* histogram_denominator_Data_failed, const TH1* histogram_numerator_mcSum_failed, const TH1* histogram_denominator_mcSum_failed, const TString& legendEntry_Data, const TString& legendEntry_mcSum, const TString& region_passed, const TString& region_failed, const TString& outputFileName) { TAxis* xAxis = histogram_numerator_Data_passed->GetXaxis(); Double_t xMin = xAxis->GetXmin(); Double_t xMax = xAxis->GetXmax(); std::cout << "processing Data, region " << region_passed.Data() << "..." << std::endl; TGraphAsymmErrors* graph_efficiency_Data_passed = getEfficiency(histogram_numerator_Data_passed, histogram_denominator_Data_passed); TF1* fit_efficiency_Data_passed = new TF1("fit_efficiency_Data_passed", &integralCrystalBall_f, xMin, xMax, 5); initializeCrystalBall(fit_efficiency_Data_passed); graph_efficiency_Data_passed->Fit(fit_efficiency_Data_passed, "0"); TString legendEntry_Data_passed = Form("%s, %s", legendEntry_Data.Data(), region_passed.Data()); std::cout << "processing mcSum, region " << region_passed.Data() << "..." << std::endl; TGraphAsymmErrors* graph_efficiency_mcSum_passed = getEfficiency(histogram_numerator_mcSum_passed, histogram_denominator_mcSum_passed); TF1* fit_efficiency_mcSum_passed = new TF1("fit_efficiency_mcSum_passed", &integralCrystalBall_f, xMin, xMax, 5); initializeCrystalBall(fit_efficiency_mcSum_passed); graph_efficiency_mcSum_passed->Fit(fit_efficiency_mcSum_passed, "0"); TString legendEntry_mcSum_passed = Form("%s, %s", legendEntry_mcSum.Data(), region_passed.Data()); std::cout << "processing Data, region " << region_failed.Data() << "..." << std::endl; TGraphAsymmErrors* graph_efficiency_Data_failed = getEfficiency(histogram_numerator_Data_failed, histogram_denominator_Data_failed); TF1* fit_efficiency_Data_failed = new TF1("fit_efficiency_Data_failed", &integralCrystalBall_f, xMin, xMax, 5); initializeCrystalBall(fit_efficiency_Data_failed); graph_efficiency_Data_failed->Fit(fit_efficiency_Data_failed, "0"); TString legendEntry_Data_failed = Form("%s, %s", legendEntry_Data.Data(), region_failed.Data()); std::cout << "processing mcSum, region " << region_failed.Data() << "..." << std::endl; TGraphAsymmErrors* graph_efficiency_mcSum_failed = getEfficiency(histogram_numerator_mcSum_failed, histogram_denominator_mcSum_failed); TF1* fit_efficiency_mcSum_failed = new TF1("fit_efficiency_mcSum_failed", &integralCrystalBall_f, xMin, xMax, 5); initializeCrystalBall(fit_efficiency_mcSum_failed); graph_efficiency_mcSum_failed->Fit(fit_efficiency_mcSum_failed, "0"); TString legendEntry_mcSum_failed = Form("%s, %s", legendEntry_mcSum.Data(), region_failed.Data()); makePlot(title, graph_efficiency_Data_passed, fit_efficiency_Data_passed, legendEntry_Data_passed, graph_efficiency_mcSum_passed, fit_efficiency_mcSum_passed, legendEntry_mcSum_passed, graph_efficiency_Data_failed, fit_efficiency_Data_failed, legendEntry_Data_failed, graph_efficiency_mcSum_failed, fit_efficiency_mcSum_failed, legendEntry_mcSum_failed, outputFileName); delete graph_efficiency_Data_passed; delete fit_efficiency_Data_passed; delete graph_efficiency_mcSum_passed; delete fit_efficiency_mcSum_passed; delete graph_efficiency_Data_failed; delete fit_efficiency_Data_failed; delete graph_efficiency_mcSum_failed; delete fit_efficiency_mcSum_failed; }
double BTagWeight::weight(const JetCollection jets, const int systematic) const { float bTaggedMCJet = 1.0; float nonBTaggedMCJet = 1.0; float bTaggedDataJet = 1.0; float nonBTaggedDataJet = 1.0; for (unsigned int index = 0; index < jets.size(); ++index) { // Info on this jet const JetPointer jet(jets.at(index)); double jetPt = jet->pt(); if ( jetPt < 25 ) continue; // If the pt of the jet is outside the pt range of the SFs, // use the pt at the upper/lower edge and double the uncertainty. bool ptOutOfRange = false; if ( jetPt <= 30 || jet->pt() >= 670 ) { ptOutOfRange = true; } const unsigned int partonFlavour = abs( jet->partonFlavour() ); const bool isBTagged = jet->isBJet(); // Get scale factor for this jet const double sf = jet->getBTagSF( 0 ); double sf_up = jet->getBTagSF( 1 ); double sf_down = jet->getBTagSF( -1 ); if ( ptOutOfRange ) { sf_up = sf + 2 * ( sf_up - sf ); sf_down = sf - 2 * ( sf - sf_down ); if ( sf_up < 0 ) sf_up = 0; if ( sf_down < 0 ) sf_down = 0; } // Get efficiency for this jet const double eff = getEfficiency( partonFlavour, jet ); double sfToUse = sf; if ( systematic == 1 ) { sfToUse = sf_up; } else if ( systematic == -1 ) { sfToUse = sf_down; } if ( isBTagged ) { bTaggedMCJet *= eff; if ( eff*sfToUse > 1 ) { bTaggedDataJet *= 1; } else if ( eff*sfToUse < 0 ) { bTaggedDataJet *= 0; } else { bTaggedDataJet *= eff*sfToUse; } } else { nonBTaggedMCJet *= ( 1 - eff ); if ( eff*sfToUse > 1 ) { nonBTaggedDataJet *= 0; } else if ( eff*sfToUse < 0 ) { nonBTaggedDataJet *= 1; } else { bTaggedDataJet *= ( 1 - eff*sfToUse ); } } // if ( nonBTaggedMCJet < 0 || nonBTaggedDataJet < 0 ) { // cout << nonBTaggedMCJet << " " << nonBTaggedDataJet << endl; // cout << eff << " " << sfToUse << endl; // } } double bTagWeight = (nonBTaggedDataJet * bTaggedDataJet) / (nonBTaggedMCJet * bTaggedMCJet); return bTagWeight; }
openstudio::Quantity ZoneHVACBaseboardConvectiveElectric_Impl::efficiency_IP() const { return getEfficiency(true); }
void showEfficiency(const TString& title, double canvasSizeX, double canvasSizeY, const TH1* histogram1_numerator, const TH1* histogram1_denominator, const std::string& legendEntry1, const TH1* histogram2_numerator, const TH1* histogram2_denominator, const std::string& legendEntry2, const TH1* histogram3_numerator, const TH1* histogram3_denominator, const std::string& legendEntry3, const TH1* histogram4_numerator, const TH1* histogram4_denominator, const std::string& legendEntry4, const TH1* histogram5_numerator, const TH1* histogram5_denominator, const std::string& legendEntry5, const TH1* histogram6_numerator, const TH1* histogram6_denominator, const std::string& legendEntry6, const std::string& xAxisTitle, double xAxisOffset, bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, double legendX0, double legendY0, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); canvas->SetLogy(useLogScale); canvas->SetGridx(); canvas->SetGridy(); TH1* dummyHistogram = new TH1D("dummyHistogram_top", "dummyHistogram_top", 10, histogram1_numerator->GetXaxis()->GetXmin(), histogram1_numerator->GetXaxis()->GetXmax()); dummyHistogram->SetTitle(""); dummyHistogram->SetStats(false); dummyHistogram->SetMaximum(yMax); dummyHistogram->SetMinimum(yMin); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleOffset(xAxisOffset); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleOffset(yAxisOffset); dummyHistogram->Draw(); int colors[6] = { 1, 2, 3, 4, 6, 7 }; int markerStyles[6] = { 22, 32, 20, 24, 21, 25 }; int numGraphs = 1; if ( histogram2_numerator && histogram2_denominator ) ++numGraphs; if ( histogram3_numerator && histogram3_denominator ) ++numGraphs; if ( histogram4_numerator && histogram4_denominator ) ++numGraphs; if ( histogram5_numerator && histogram5_denominator ) ++numGraphs; if ( histogram6_numerator && histogram6_denominator ) ++numGraphs; TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.18, legendY0 + 0.05*numGraphs, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); TGraphAsymmErrors* graph1 = getEfficiency(histogram1_numerator, histogram1_denominator); graph1->SetLineColor(colors[0]); graph1->SetMarkerColor(colors[0]); graph1->SetMarkerStyle(markerStyles[0]); graph1->Draw("p"); legend->AddEntry(graph1, legendEntry1.data(), "p"); TGraphAsymmErrors* graph2 = 0; if ( histogram2_numerator && histogram2_denominator ) { graph2 = getEfficiency(histogram2_numerator, histogram2_denominator); graph2->SetLineColor(colors[1]); graph2->SetMarkerColor(colors[1]); graph2->SetMarkerStyle(markerStyles[1]); graph2->Draw("p"); legend->AddEntry(graph2, legendEntry2.data(), "p"); } TGraphAsymmErrors* graph3 = 0; if ( histogram3_numerator && histogram3_denominator ) { graph3 = getEfficiency(histogram3_numerator, histogram3_denominator); graph3->SetLineColor(colors[2]); graph3->SetMarkerColor(colors[2]); graph3->SetMarkerStyle(markerStyles[2]); graph3->Draw("p"); legend->AddEntry(graph3, legendEntry3.data(), "p"); } TGraphAsymmErrors* graph4 = 0; if ( histogram4_numerator && histogram4_denominator ) { graph4 = getEfficiency(histogram4_numerator, histogram4_denominator); graph4->SetLineColor(colors[3]); graph4->SetMarkerColor(colors[3]); graph4->SetMarkerStyle(markerStyles[3]); graph4->Draw("p"); legend->AddEntry(graph4, legendEntry4.data(), "p"); } TGraphAsymmErrors* graph5 = 0; if ( histogram5_numerator && histogram5_denominator ) { graph5 = getEfficiency(histogram5_numerator, histogram5_denominator); graph5->SetLineColor(colors[4]); graph5->SetMarkerColor(colors[4]); graph5->SetMarkerStyle(markerStyles[4]); graph5->Draw("p"); legend->AddEntry(graph5, legendEntry5.data(), "p"); } TGraphAsymmErrors* graph6 = 0; if ( histogram6_numerator && histogram6_denominator ) { graph6 = getEfficiency(histogram6_numerator, histogram6_denominator); graph6->SetLineColor(colors[5]); graph6->SetMarkerColor(colors[5]); graph6->SetMarkerStyle(markerStyles[5]); graph6->Draw("p"); legend->AddEntry(graph6, legendEntry6.data(), "p"); } legend->Draw(); TPaveText* label = 0; if ( title.Length() > 0 ) { label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC"); label->AddText(title.Data()); label->SetTextAlign(13); label->SetTextSize(0.045); label->SetFillStyle(0); label->SetBorderSize(0); label->Draw(); } canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data()); canvas->Print(std::string(outputFileName_plot).append(".png").data()); canvas->Print(std::string(outputFileName_plot).append(".pdf").data()); delete legend; delete label; delete dummyHistogram; delete canvas; }
void trackingStudyTrkEta(char *infname = "skim_jet_pthat80Sim05.root") { HiForest *c = new HiForest(infname); c->tree->AddFriend("nt"); TCut trackSelection = "(mtrkQual||mtrkAlgo<4)&&pNRec>0"; TCut genParticleCut = "abs(pEta)<2.8&&pPt>0"; TCut weightCent = "1";//"(0.64661/(0.64661+0.00279303*hiBin+(-3.89902e-5)*hiBin*hiBin)*(hiBin<34)+(hiBin>=34)*0.64661/(-1.38822+0.123182*hiBin-0.0018135*hiBin*hiBin))"; TCut weight = "1";//"1./(0.757356-0.030163*pEta-0.0769554*pEta**2+0.0176546*pEta**3+0.0200791*pEta**4-0.00256533*pEta**5-0.00304287*pEta**6)"; TCanvas *cpPt = new TCanvas ("cpPt","",600,600); TH1F *hEffpPt = new TH1F("hEffpPt","",28,-2.8,2.8); makeHistTitle(hEffpPt,"","SimTrack #eta","Tracking Efficiency"); TGraphAsymmErrors *g = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>0.5")&&genParticleCut,weight*weightCent); TGraphAsymmErrors *g1 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>0.5&&pPt<1")&&genParticleCut,weight*weightCent); TGraphAsymmErrors *g2 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>1&&pPt<2")&&genParticleCut,weight*weightCent); TGraphAsymmErrors *g3 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>2&&pPt<4")&&genParticleCut,weight*weightCent); TGraphAsymmErrors *g4 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>4&&pPt<8")&&genParticleCut,weight*weightCent); TGraphAsymmErrors *g5 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>8")&&genParticleCut,weight*weightCent); hEffpPt->SetAxisRange(0.,1,"Y"); hEffpPt->Draw(); g->Draw("p same"); g1->SetLineColor(2); g1->SetMarkerColor(2); g1->Draw("p same"); g2->SetLineColor(3); g2->SetMarkerColor(3); g2->Draw("p same"); g3->SetLineColor(4); g3->SetMarkerColor(4); g3->Draw("p same"); g4->SetLineColor(46); g4->SetMarkerColor(46); g4->Draw("p same"); g5->SetLineColor(kOrange); g5->SetMarkerColor(kOrange); g5->Draw("p same"); TLegend *legpPt = myLegend(0.2,0.7,0.6,0.9); legpPt->AddEntry(g,"#hat{p}_{T} 80 GeV/c, No selection",""); legpPt->AddEntry(g,"Simtrack p_{T} > 0.5 GeV/c","pl"); legpPt->AddEntry(g1,"Simtrack 0.5 > p_{T} > 1 GeV/c","pl"); legpPt->AddEntry(g2,"Simtrack 1 > p_{T} > 2 GeV/c","pl"); legpPt->AddEntry(g3,"Simtrack 2 > p_{T} > 4 GeV/c","pl"); legpPt->AddEntry(g4,"Simtrack 4 > p_{T} > 8 GeV/c","pl"); legpPt->AddEntry(g5,"Simtrack p_{T} > 8 GeV/c","pl"); legpPt->Draw(); cpPt->SaveAs("effFig/EffVsTrackPt.gif"); cpPt->SaveAs("effFig/EffVsTrackPt.C"); g->Fit("pol6") ; }
void plotTrigger_PbPb(char *infname="/data/jisun/PbPb2015/skim_Dntuple_crab_PbPb_HIMinimumBias2_ForestAOD_Track_AK4CaloJet_D0_tkpt0p9eta1p5_01142016_tkpt8p0fortrigstudy.root") { // ============== Open file and basic settings =============== // Open Dntuple file TFile *inf = new TFile(infname); TTree *ntDkpi = (TTree*)inf->Get("ntDkpi"); TTree *ntHlt = (TTree*)inf->Get("ntHlt"); TTree *ntSkim = (TTree*)inf->Get("ntSkim"); ntDkpi->AddFriend(ntHlt); ntDkpi->AddFriend(ntSkim); // Define bin size and bin width for trigger turnon curve histograms const int nBin = 15; Float_t bins[nBin+1]={0,5,10,15,18,20,25,30,35,40,45,55,60,65,70,80}; // Templates for plotting TH1D *hTmp = new TH1D ("hTmp","",nBin,bins); TH1D *hTmp2 = new TH1D ("hTmp2","",nBin,bins); // ============== Selection Criteria =============== //TCut mbCut = "(HLT_HIL1MinimumBiasHF1AND_v1|| \ HLT_HIL1MinimumBiasHF2AND_v1|| \ HLT_HIL1MinimumBiasHF2AND_part1_v1)"; TCut mbCut = "(HLT_HIL1MinimumBiasHF1AND_v1)"; // L1 trigger thresholds TCut l1CutMBHF1And = "L1_MinimumBiasHF1_AND==1"; TCut l1Cut28 = "L1_SingleS1Jet28_BptxAND==1"; TCut l1Cut44 = "L1_SingleJet44_BptxAND==1"; // D meson selection TCut DmassCut = "(abs(Dmass-1.8696)<0.03)"; TCut DmesonCut = "(DsvpvDistance/DsvpvDisErr)>3.5&&Dchi2cl>0.05&&Dalpha<0.12"; //TCut DmesonDaughterTrkCut = "Dtrk1Pt>8.5&&abs(Dtrk1Eta)<2.0&&Dtrk1Algo<8&&(Dtrk1PixelHit+Dtrk1StripHit)>=10.5&&Dtrk1PtErr/Dtrk1Pt<0.1&& \ Dtrk2Pt>8.5&&abs(Dtrk2Eta)<2.0&&Dtrk2Algo<8&&(Dtrk2PixelHit+Dtrk2StripHit)>=10.5&&Dtrk2PtErr/Dtrk2Pt<0.1"; //TCut DmesonDaughterTrkCut = "Dtrk1Pt>8.5&&abs(Dtrk1Eta)<2.0&&(Dtrk1Algo<8||Dtrk1Algo==11)&&(Dtrk1PixelHit+Dtrk1StripHit)>=10.5&&Dtrk1PtErr/Dtrk1Pt<0.1&& \ Dtrk2Pt>8.5&&abs(Dtrk2Eta)<2.0&&(Dtrk2Algo<8||Dtrk2Algo==11)&&(Dtrk2PixelHit+Dtrk2StripHit)>=10.5&&Dtrk2PtErr/Dtrk2Pt<0.1"; TCut DmesonDaughterTrkCut = "Dtrk1Pt>8.5&&abs(Dtrk1Eta)<2.0&&(Dtrk1PixelHit+Dtrk1StripHit)>=10.5&&Dtrk1PtErr/Dtrk1Pt<0.1&& \ Dtrk2Pt>8.5&&abs(Dtrk2Eta)<2.0&&(Dtrk2PixelHit+Dtrk2StripHit)>=10.5&&Dtrk2PtErr/Dtrk2Pt<0.1"; // Final selection for D candidates for trigger turnon studies TCut DAnaCut = DmassCut && DmesonCut && DmesonDaughterTrkCut; // HLT trigger thresholds TCut HLTCut20 = "HLT_HIDmesonHITrackingGlobal_Dpt20_v1"; TCut HLTCut40 = "HLT_HIDmesonHITrackingGlobal_Dpt40_v1"; TCut HLTCut60 = "HLT_HIDmesonHITrackingGlobal_Dpt60_v1"; // ============== L1 trigger efficiency study =============== TCanvas *c = new TCanvas("c","",600,600); TGraphAsymmErrors* g20 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1CutMBHF1And), HLTCut20, nBin, bins); TGraphAsymmErrors* g40 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut28), HLTCut40, nBin, bins); TGraphAsymmErrors* g60 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut44), HLTCut60, nBin, bins); hTmp->Draw(); hTmp->SetXTitle("D Meson p_{T} (GeV/c)"); hTmp->SetYTitle("D Meson HLT Efficiency"); g20->SetLineColor(1); g20->SetMarkerColor(1); g20->Draw("pl same"); g40->SetLineColor(2); g40->SetMarkerColor(2); g40->Draw("pl same"); g60->SetLineColor(kGreen+2); g60->SetMarkerColor(kGreen+2); g60->Draw("pl same"); TLegend *leg = new TLegend(0.53,0.2,0.93,0.6); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->AddEntry(g20,"PbPb #sqrt{s} = 5.02 TeV",""); leg->AddEntry(g20,"HLT D meson 20","pl"); leg->AddEntry(g40,"HLT D meson 40","pl"); leg->AddEntry(g60,"HLT D meson 60","pl"); leg->Draw(); c->SaveAs("result/Dmeson-HIHLTriggerEfficiency.pdf"); c->SaveAs("result/Dmeson-HIHLTriggerEfficiency.png"); c->SaveAs("result/Dmeson-HIHLTriggerEfficiency.C"); // ============== L1 trigger efficiency study =============== TCanvas *c2 = new TCanvas("c2","",600,600); TGraphAsymmErrors* gLMBHF1And = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_MinimumBiasHF1_AND_Prescl==1"), l1CutMBHF1And, nBin, bins); TGraphAsymmErrors* gL28 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleS1Jet28_BptxAND_Prescl==1"), l1Cut28, nBin, bins); TGraphAsymmErrors* gL44 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet44_BptxAND_Prescl==1"), l1Cut44, nBin, bins); hTmp2->Draw(); hTmp2->SetXTitle("D meson p_{T} (GeV/c)"); hTmp2->SetYTitle("L1 Trigger Efficiency"); gLMBHF1And->SetMarkerColor(1); gLMBHF1And->SetLineColor(1); gLMBHF1And->Draw("pl same"); gL28->SetMarkerColor(4); gL28->SetLineColor(4); gL28->Draw("pl same"); gL44->SetMarkerColor(kGreen+2); gL44->SetLineColor(kGreen+2); gL44->Draw("pl same"); TLegend *leg2 = new TLegend(0.53,0.2,0.93,0.6); leg2->SetBorderSize(0); leg2->SetFillStyle(0); leg2->AddEntry(gLMBHF1And,"PbPb #sqrt{s} = 5.02 TeV",""); leg2->AddEntry(gLMBHF1And,"Level 1 Jet 16","pl"); leg2->AddEntry(gL28,"Level 1 Jet 28","pl"); leg2->AddEntry(gL44,"Level 1 Jet 44","pl"); leg2->Draw(); c2->SaveAs("result/Dmeson-HIL1TriggerEfficiency.pdf"); c2->SaveAs("result/Dmeson-HIL1TriggerEfficiency.png"); c2->SaveAs("result/Dmeson-HIL1TriggerEfficiency.C"); // ============== Plot an example D mass distribution =============== TCanvas *c3 = new TCanvas("c3","",600,600); ntDkpi->Draw("Dmass>>h(100,1.7696,1.9696)",DmesonCut&&DmesonDaughterTrkCut&&mbCut&&l1CutMBHF1And); // ..done }
//void plotTriggerForTDR(char *infname="/data/yjlee/dmeson/2015/trigger/mb.root") void plotTrigger(string infname="/data/jisun/ppMB2015fullstats/skim_ncand_D0Dntuple_crab_pp_ALLMinimumBias_AOD_D0_tkpt0p5_Ds_01212016.root") { bool sideband = false; infname="/data/jisun/ppMB2015fullstats/skim_ncand_D0Dntuple_crab_pp_ALLMinimumBias_AOD_D0_tkpt0p5_Ds_01212016.root"; TString outf = "result"; //infname="/data/wangj/Data2015/Dntuple/pp/ntD_EvtBase_20160425_HighPtJet80_DfinderData_pp_20160329_dPt0tkPt0p5_D0Dstar_skim.root"; //TString outf = "result_ppJet80"; //infname="/data/wangj/Data2015/Dntuple/pp/ntD_EvtBase_20160425_HighPtLowerJets_DfinderData_pp_20160329_dPt0tkPt0p5_D0Dstar_skim.root"; //TString outf = "result_ppLowerJets"; //infname="/data/jisun/ppMB2015fullstats/skim_ncand_D0Dntuple_crab_pp_ALLMinimumBias_AOD_D0_tkpt0p5_Ds_01212016.root"; //sideband = true; TString outf = "result_sideband"; // ============== Open file and basic settings =============== // Open Dntuple file TFile *inf = new TFile(infname.c_str()); TTree *ntDkpi = (TTree*)inf->Get("ntDkpi"); TTree *ntHlt = (TTree*)inf->Get("ntHlt"); TTree *ntSkim = (TTree*)inf->Get("ntSkim"); ntDkpi->AddFriend(ntHlt); ntDkpi->AddFriend(ntSkim); // Define bin size and bin width for trigger turnon curve histograms const int nBin = 8; Float_t bins[nBin+1]={0,6,8,10,15,20,30,50,80}; //const int nBin = 12; //Float_t bins[nBin+1]={0,5,6,8,10,12,15,20,25,30,35,40,70}; // Templates for plotting TH1D *hTmp2 = new TH1D ("hTmp2","",nBin,bins); // ============== Selection Criteria =============== // This MB sample has all pp MB TCut mbCut = "(HLT_L1MinimumBiasHF1OR_part0_v1|| \ HLT_L1MinimumBiasHF1OR_part1_v1|| \ HLT_L1MinimumBiasHF1OR_part2_v1|| \ HLT_L1MinimumBiasHF1OR_part3_v1|| \ HLT_L1MinimumBiasHF1OR_part4_v1|| \ HLT_L1MinimumBiasHF1OR_part5_v1|| \ HLT_L1MinimumBiasHF1OR_part6_v1|| \ HLT_L1MinimumBiasHF1OR_part7_v1|| \ HLT_L1MinimumBiasHF1OR_part8_v1|| \ HLT_L1MinimumBiasHF1OR_part9_v1|| \ HLT_L1MinimumBiasHF1OR_part10_v1|| \ HLT_L1MinimumBiasHF1OR_part11_v1|| \ HLT_L1MinimumBiasHF1OR_part12_v1|| \ HLT_L1MinimumBiasHF1OR_part13_v1|| \ HLT_L1MinimumBiasHF1OR_part14_v1|| \ HLT_L1MinimumBiasHF1OR_part15_v1|| \ HLT_L1MinimumBiasHF1OR_part16_v1|| \ HLT_L1MinimumBiasHF1OR_part17_v1|| \ HLT_L1MinimumBiasHF1OR_part18_v1|| \ HLT_L1MinimumBiasHF1OR_part19_v1)"; // L1 trigger thresholds TCut l1Cut16 = "L1_SingleJet16_BptxAND==1"; TCut l1Cut24 = "L1_SingleJet24_BptxAND==1"; TCut l1Cut28 = "L1_SingleJet28_BptxAND==1"; TCut l1Cut40 = "L1_SingleJet40_BptxAND==1"; TCut l1Cut48 = "L1_SingleJet48_BptxAND==1"; // D meson selection TCut DmassCut = "(abs(Dmass-1.8696)<0.03)"; TCut DmesonCut = "Dy>-1.&&Dy<1&&(DsvpvDistance/DsvpvDisErr)>3.5&&(DlxyBS/DlxyBSErr)>2.0&&Dchi2cl>0.05&&Dalpha<0.12"; TCut DmesonDaughterTrkCut = "Dtrk1highPurity&&Dtrk2highPurity&&Dtrk1Pt>2.0&&Dtrk2Pt>2.0&&Dtrk1PtErr/Dtrk1Pt<0.1&&Dtrk2PtErr/Dtrk2Pt<0.1&&abs(Dtrk1Eta)<2.0&&abs(Dtrk2Eta)<2.0&&Dtrk1Algo>3&&Dtrk1Algo<8&&Dtrk2Algo>3&&Dtrk2Algo<8&&(Dtrk1PixelHit+Dtrk1StripHit)>=11&&(Dtrk1Chi2ndf/(Dtrk1nStripLayer+Dtrk1nPixelLayer)<0.15)&&(Dtrk2Chi2ndf/(Dtrk2nStripLayer+Dtrk2nPixelLayer)<0.15)"; if (sideband) DmassCut = "(abs(Dmass-1.8696)>0.06 && abs(Dmass-1.8696)>0.12)"; // Final selection for D candidates for trigger turnon studies TCut DAnaCut = DmassCut && DmesonCut && DmesonDaughterTrkCut; // HLT trigger thresholds TCut HLTCut8 = "HLT_DmesonPPTrackingGlobal_Dpt8_v1"; TCut HLTCut15 = "HLT_DmesonPPTrackingGlobal_Dpt15_v1"; TCut HLTCut20 = "HLT_DmesonPPTrackingGlobal_Dpt20_v1"; TCut HLTCut30 = "HLT_DmesonPPTrackingGlobal_Dpt30_v1"; TCut HLTCut50 = "HLT_DmesonPPTrackingGlobal_Dpt50_v1"; // ============== L1 trigger efficiency study =============== int W = 600; int H = 600; int H_ref = 600; int W_ref = 600; // references for T, B, L, R float T = 0.08*H_ref; float B = 0.14*H_ref; float L = 0.14*W_ref; float R = 0.08*W_ref; TString canvName = "TRDFigure_Centrality"; TCanvas* c = new TCanvas(canvName,canvName,50,50,W,H); c->cd(); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillStyle(0); c->SetFrameBorderMode(0); c->SetLeftMargin( L/W ); c->SetRightMargin( R/W ); c->SetTopMargin( T/H ); c->SetBottomMargin( B/H ); TH2D *hTmp = new TH2D ("hTmp","",100,0,60,100,0,1.4); hTmp->GetXaxis()->SetTitle("p_{T} (D^{0}) (GeV)"); hTmp->GetYaxis()->SetTitleOffset(1.15); hTmp->GetXaxis()->SetTitleOffset(0.95); hTmp->GetYaxis()->SetTitle("HLT Efficiency"); hTmp->GetYaxis()->CenterTitle(); hTmp->GetXaxis()->CenterTitle(); hTmp->SetMaximum(1.4); hTmp->GetXaxis()->SetTitleFont(42); hTmp->GetXaxis()->SetLabelFont(42); hTmp->GetXaxis()->SetTitleSize(0.06); hTmp->GetXaxis()->SetLabelSize(0.05); hTmp->GetYaxis()->SetTitleFont(42); hTmp->GetYaxis()->SetLabelFont(42); hTmp->GetYaxis()->SetTitleSize(0.06); hTmp->GetYaxis()->SetLabelSize(0.05); // TGraphAsymmErrors* g8 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut16), HLTCut8, nBin, bins); // TGraphAsymmErrors* g15 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut24), HLTCut15, nBin, bins); TGraphAsymmErrors* g20 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut28), HLTCut20, nBin, bins); TGraphAsymmErrors* g30 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut40), HLTCut30, nBin, bins); TGraphAsymmErrors* g50 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut48), HLTCut50, nBin, bins); /* TGraphAsymmErrors* g8 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&l1Cut16), HLTCut8, nBin, bins); TGraphAsymmErrors* g15 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&l1Cut24), HLTCut15, nBin, bins); TGraphAsymmErrors* g20 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&l1Cut28), HLTCut20, nBin, bins); TGraphAsymmErrors* g30 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&l1Cut40), HLTCut30, nBin, bins); */ hTmp->Draw(); // g8->SetLineColor(1); // g8->SetMarkerColor(1); // g8->Draw("p same"); // g15->SetLineColor(2); // g15->SetMarkerColor(2); // g15->Draw("pl same"); g20->SetLineColor(4); g20->SetMarkerColor(4); g20->Draw("pl same"); g30->SetLineColor(kGreen+2); g30->SetMarkerColor(kGreen+2); g30->Draw("pl same"); g50->SetLineColor(kOrange); g50->SetMarkerColor(kOrange); g50->Draw("pl same"); TLegend *legend=new TLegend(0.4579866,0.2472028,0.8389262,0.4342657,""); legend->SetBorderSize(0); legend->SetLineColor(0); legend->SetFillColor(0); legend->SetFillStyle(1001); legend->SetTextFont(42); legend->SetTextSize(0.04); // TLegendEntry *ent_g8=legend->AddEntry(g8,"HLT D meson p_{T} #geq 8","pl"); // ent_g8->SetTextFont(42); // ent_g8->SetLineColor(1); // ent_g8->SetMarkerColor(1); // TLegendEntry *ent_g15=legend->AddEntry(g15,"HLT D meson p_{T} #geq15","pl"); // ent_g15->SetTextFont(42); // ent_g15->SetLineColor(1); // ent_g15->SetMarkerColor(1); TLegendEntry *ent_g20=legend->AddEntry(g20,"HLT D meson p_{T} #geq 20","pl"); ent_g20->SetTextFont(42); ent_g20->SetLineColor(1); ent_g20->SetMarkerColor(1); TLegendEntry *ent_g30=legend->AddEntry(g30,"HLT D meson p_{T} #geq 30","pl"); ent_g30->SetTextFont(42); ent_g30->SetLineColor(1); ent_g30->SetMarkerColor(1); TLegendEntry *ent_g50=legend->AddEntry(g50,"HLT D meson p_{T} #geq 50","pl"); ent_g50->SetTextFont(42); ent_g50->SetLineColor(1); ent_g50->SetMarkerColor(1); legend->Draw("same"); CMS_lumi( c, 1, 11 ); TLatex * tlatexeff=new TLatex(0.2079866,0.70,"HLT efficiency with respect to L1 seed"); tlatexeff->SetNDC(); tlatexeff->SetTextColor(1); tlatexeff->SetTextFont(42); tlatexeff->SetTextSize(0.040); // tlatexeff->Draw("same"); c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.pdf"); c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.png"); // c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.jpeg"); // c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.eps"); c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.C"); /* // ============== HLT trigger efficiency study =============== TCanvas *c2 = new TCanvas("c2","",600,600); TGraphAsymmErrors* gL16 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet16_BptxAND_Prescl==1"), l1Cut16, nBin, bins); TGraphAsymmErrors* gL24 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet24_BptxAND_Prescl==1"), l1Cut24, nBin, bins); TGraphAsymmErrors* gL28 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet28_BptxAND_Prescl==1"), l1Cut28, nBin, bins); TGraphAsymmErrors* gL40 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet40_BptxAND_Prescl==1"), l1Cut40, nBin, bins); hTmp2->Draw(); hTmp2->SetXTitle("p_{T} (D^{0})(GeV/c)"); hTmp2->SetYTitle("L1 Trigger Efficiency"); gL16->SetMarkerColor(1); gL16->SetLineColor(1); gL16->Draw("p same"); gL24->SetMarkerColor(2); gL24->SetLineColor(2); gL24->Draw("p same"); gL28->SetMarkerColor(4); gL28->SetLineColor(4); gL28->Draw("p same"); gL40->SetMarkerColor(kGreen+2); gL40->SetLineColor(kGreen+2); gL40->Draw("p same"); TLegend *leg2 = new TLegend(0.4916107,0.3059441,0.8322148,0.4912587); leg2->SetBorderSize(0); leg2->SetFillStyle(0); leg2->AddEntry(gL16,"pp #sqrt{s} = 5.02 TeV",""); leg2->AddEntry(gL16,"Level 1 Jet 16","pl"); leg2->AddEntry(gL24,"Level 1 Jet 24","pl"); leg2->AddEntry(gL28,"Level 1 Jet 28","pl"); leg2->AddEntry(gL40,"Level 1 Jet 40","pl"); leg2->Draw(); c2->SaveAs(outf+"/Dmeson-L1TriggerEfficiency.pdf"); c2->SaveAs(outf+"/Dmeson-L1TriggerEfficiency.png"); // c2->SaveAs(outf+"/Dmeson-L1TriggerEfficiency.jpeg"); c2->SaveAs(outf+"/Dmeson-L1TriggerEfficiency.C"); // ============== Plot an example D mass distribution =============== TCanvas *c3 = new TCanvas("c3","",600,600); ntDkpi->Draw("Dmass>>h(100,1.7696,1.9696)",DmesonCut&&DmesonDaughterTrkCut&&mbCut&&l1Cut16); // ..done */ }