36 #include "TGraphAsymmErrors.h"
41 static const bool fdbg =
true;
44 bool HI_pp_key =
false;
46 if (fdbg) std::cout <<
" Start to Divide HLTMuon Histograms for Efficiency and Rate Ratio" << std::endl;
49 std::cerr <<
"HLTMuonPostProcess(): "
50 <<
"Input file not opened \n";
53 if (
mf.GetSize() < 1000.) {
54 std::cerr <<
"HLTMuonPostProcess(): "
55 <<
"Input file empty \n";
61 TKey* key0 = (TKey*) nextcd0();
62 if (key0 == 0)
return;
64 TDirectory* dir0 =
dynamic_cast<TDirectory*
> (key0->ReadObj());
65 if (dir0 == 0)
return;
73 std::cerr <<
"HLTMuon PostProcessing: no such histogram!! " <<
hname << std::endl;
77 auto getHistogramPair = [&getHPointer] (
const TString &numeratorName,
const TString &denominatorName)->std::pair<TH1F *, TH1F *> {
79 TH1F* pH1 = getHPointer(numeratorName);
81 pH2 = getHPointer(denominatorName);
83 return std::pair{pH1, pH2};
90 std::cerr <<
"HLTMuon PostProcessing: no such histogram!! " <<
hname << std::endl;
100 TIter next_run(
mf.GetListOfKeys());
102 while ((key_run =
dynamic_cast<TKey*
> (next_run())) != 0) {
103 if (!key_run->IsFolder())
continue;
104 run_dir = key_run->GetName();
105 if (!run_dir.Contains(
"run")) {
110 if (!run_dir.Contains(
"run")) {
111 std::cerr <<
"HLTMuon: unable to find run directory ..." << std::endl;
116 std::cout <<
"HLTMuon: run directory is " << run_dir << std::endl;
118 std::string run_dir2 = run_dir.Data();
122 TH1F* hHI_PP_Flag(0);
123 TString hi_pp_flag = run_dir +
"/HLT/MuonMon/Common/HI_PP_Flag";
124 hHI_PP_Flag = getHPointer(hi_pp_flag);
126 HI_pp_key = hHI_PP_Flag->GetBinContent(1) > 0;
129 TString muon_dir = run_dir +
"/HLT/MuonMon/";
131 TString cm_dir = muon_dir +
"Common/";
132 TString mf_dir = muon_dir +
"L2MuonSA/";
133 TString mc_dir = muon_dir +
"muComb/";
134 TString mi_dir = muon_dir +
"muIso/";
135 TString tm_dir = muon_dir +
"TileMu/";
136 TString ef_dir = muon_dir +
"MuonEF/";
138 TString ztp_dir = muon_dir +
"MuZTP/";
140 TString eff_dir = muon_dir +
"Efficiency/";
141 TString nd_dir = muon_dir +
"Efficiency/NumDenom/";
142 TString rate_dir = muon_dir +
"Rate/";
143 TString rr_dir = muon_dir +
"Rate/Ratio/";
155 TH1F* h1effsum(
nullptr);
156 TGraphAsymmErrors* h1tmpg;
160 TDirectory*
dir =
mf.GetDirectory(eff_dir);
162 std::cerr <<
"HLTMuonHistogramDivision: directory " << eff_dir <<
" not found" << std::endl;
166 std::vector<TString> effnames;
167 effnames.push_back(
"L2MuonSA_effi_toRecMuonCB_pt");
168 effnames.push_back(
"L2MuonSA_effi_toRecMuonCB_pt_barrel");
169 effnames.push_back(
"L2MuonSA_effi_toRecMuonCB_pt_endcap");
170 effnames.push_back(
"L2MuonSA_effi_toRecMuonCB_eta");
171 effnames.push_back(
"L2MuonSA_effi_toRecMuonCB_phi");
174 seff = eff_dir + (*it);
175 snum = mf_dir + (*it) +
"_numer";
176 sden = mf_dir + (*it) +
"_denom";
178 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
179 if (not h1num)
continue;
181 h1tmp = (
TH1F*) h1den->Clone();
182 h1tmp->SetName(stmp);
183 std::string stcar = h1tmp->GetTitle();
184 stcar.replace(stcar.end() - 5, stcar.end(),
"");
185 h1tmp->SetTitle(stcar.c_str());
186 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
188 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
196 effnames.push_back(
"muComb_effi_toOffl_pt");
197 effnames.push_back(
"muComb_effi_toOffl_pt_barrel");
198 effnames.push_back(
"muComb_effi_toOffl_pt_endcap");
199 effnames.push_back(
"muComb_effi_toOffl_eta");
200 effnames.push_back(
"muComb_effi_toOffl_phi");
203 seff = eff_dir + (*it);
204 snum = mc_dir + (*it) +
"_numer";
205 sden = mc_dir + (*it) +
"_denom";
207 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
208 if (!h1num)
continue;
210 h1tmp = (
TH1F*) h1den->Clone();
211 h1tmp->SetName(stmp);
212 std::string stcar = h1tmp->GetTitle();
213 stcar.replace(stcar.end() - 5, stcar.end(),
"");
214 h1tmp->SetTitle(stcar.c_str());
215 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
217 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
225 effnames.push_back(
"muIso_effi_toOffl_pt");
228 seff = eff_dir + (*it);
229 snum = mi_dir + (*it) +
"_numer";
230 sden = mi_dir + (*it) +
"_denom";
232 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
233 if (!h1num)
continue;
235 h1tmp = (
TH1F*) h1den->Clone();
236 h1tmp->SetName(stmp);
237 std::string stcar = h1tmp->GetTitle();
238 stcar.replace(stcar.end() - 5, stcar.end(),
"");
239 h1tmp->SetTitle(stcar.c_str());
240 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
242 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
250 std::vector<TString> numnames;
251 std::vector<TString> dennames;
252 effnames.push_back(
"TileMu_RecCBMuon_EffEta");
253 numnames.push_back(
"Rec_Eta_Num");
254 dennames.push_back(
"Rec_Eta");
255 effnames.push_back(
"TileMu_RecCBMuon_EffPhi");
256 numnames.push_back(
"Rec_Phi_Num");
257 dennames.push_back(
"Rec_Phi");
258 effnames.push_back(
"TileTrackMu_RecCBMuon_EffEta");
259 numnames.push_back(
"TileTrackMu_Eta");
260 dennames.push_back(
"Rec_Eta");
261 effnames.push_back(
"TileTrackMu_RecCBMuon_EffPhi");
262 numnames.push_back(
"TileTrackMu_Phi");
263 dennames.push_back(
"Rec_Phi");
264 effnames.push_back(
"TileTrackMu_RecCBMuon_EffPt");
265 numnames.push_back(
"TileTrackMu_Pt");
266 dennames.push_back(
"Rec_Pt");
268 for (
unsigned int i = 0;
i < effnames.size();
i++) {
269 seff = eff_dir + effnames.at(
i);
270 snum = tm_dir + numnames.at(
i);
271 sden = tm_dir + dennames.at(
i);
272 stmp = effnames.at(
i);
273 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
274 if (!h1num)
continue;
276 h1tmp = (
TH1F*) h1den->Clone();
277 h1tmp->SetName(stmp);
278 std::istringstream iss(stmp.Data());
281 while (std::getline(iss, token,
'_')) {
282 stmp = token +
"Feature wrt Offline)";
287 std::string stcar = h1tmp->GetTitle();
288 if (stcar.find(
"Pt") != std::string::npos) {
289 stmp =
"Efficiency on p_{T} (" + stmp;
290 h1tmp->GetXaxis()->SetTitle(
"p_{T}");
292 if (stcar.find(
"Eta") != std::string::npos) stmp =
"Efficiency on #eta (" + stmp;
293 if (stcar.find(
"Phi") != std::string::npos) stmp =
"Efficiency on #phi (" + stmp;
294 h1tmp->SetTitle(stmp);
295 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
297 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
307 effnames.push_back(
"EFMS_effi_toOffl_pt");
308 effnames.push_back(
"EFMS_effi_toOffl_eta");
309 effnames.push_back(
"EFMS_effi_toOffl_phi");
310 effnames.push_back(
"EFSA_effi_toOffl_pt");
311 effnames.push_back(
"EFCB_effi_toOffl_pt");
314 seff = eff_dir + (*it);
315 snum = ef_dir + (*it) +
"_numer";
316 sden = ef_dir + (*it) +
"_denom";
318 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
319 if (!h1num)
continue;
321 h1tmp = (
TH1F*) h1den->Clone();
322 h1tmp->SetName(stmp);
323 std::string stcar = h1tmp->GetTitle();
324 stcar.replace(stcar.end() - 5, stcar.end(),
"");
325 h1tmp->SetTitle(stcar.c_str());
326 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
328 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
335 std::vector<TString> chainsMSonly;
336 std::vector<TString> chainsStandard;
337 std::vector<TString> chainsMG;
338 std::vector<TString> chainsMI;
339 std::vector<TString> chainsGeneric;
340 std::vector<TString> chainsEFiso;
341 std::vector<TString> chainsEFFS;
345 chainsGeneric.push_back(
"muChain1");
346 chainsGeneric.push_back(
"muChain2");
349 chainsEFiso.push_back(
"muChainEFiso1");
350 chainsEFiso.push_back(
"muChainEFiso2");
354 chainsMSonly.push_back(
"muChainMSonly1");
355 chainsMSonly.push_back(
"muChainMSonly2");
358 chainsEFFS.push_back(
"muChainEFFS");
361 INDORTH, INDEGAMMA, INDMET, INDJET, INDTAU, INDMBIAS
363 TString trigger[INDMBIAS + 1];
365 trigger[INDORTH] =
"Orthog";
366 trigger[INDEGAMMA] =
"EGamma";
367 trigger[INDMET] =
"MET";
368 trigger[INDJET] =
"Jet";
373 TString ESchainName =
"_ES";
380 std::string triggerES[7] = {
381 "_ESstd",
"_EStag",
"_ESid",
"_ESindep",
"_ESHIL1",
"_ESHIid",
"_ESHIindep"
384 ESSTD, ESTAG, ESID, ESINDEP, ESHIL1, ESHIID, ESHIINDEP
387 int maxESbr = ESINDEP;
389 bool CB_mon_ESbr[ESHIINDEP + 1];
390 bool MS_mon_ESbr[ESHIINDEP + 1];
392 CB_mon_ESbr[ESSTD] = 0;
393 CB_mon_ESbr[ESTAG] = 0;
394 CB_mon_ESbr[ESID] = 1;
395 CB_mon_ESbr[ESINDEP] = 0;
396 CB_mon_ESbr[ESHIL1] = 0;
397 CB_mon_ESbr[ESHIID] = 0;
398 CB_mon_ESbr[ESHIINDEP] = 0;
400 MS_mon_ESbr[ESSTD] = 0;
401 MS_mon_ESbr[ESTAG] = 1;
402 MS_mon_ESbr[ESID] = 0;
403 MS_mon_ESbr[ESINDEP] = 0;
404 MS_mon_ESbr[ESHIL1] = 0;
405 MS_mon_ESbr[ESHIID] = 0;
406 MS_mon_ESbr[ESHIINDEP] = 0;
408 std::vector<std::string> vectkwd;
410 vectkwd.push_back(triggerES[ESTAG]);
411 vectkwd.push_back(triggerES[ESID]);
412 vectkwd.push_back(
"_Jet");
413 vectkwd.push_back(
"_all");
415 TString hptName =
"_hpt";
416 TString MSchainName =
"_MSb";
455 TString FS_pre_trigger =
"EFFSpre";
456 for (
unsigned int i = 0;
i < chainsEFFS.size();
i++) {
459 TString hists_str[9] = {
460 chainName +
"_tagEFFSpre" +
"_Turn_On_Curve_wrt_probe_MuidCB",
461 chainName +
"_tagEFFSpre" +
"_Turn_On_Curve_wrt_probe_MuidCB_Barrel",
462 chainName +
"_tagEFFSpre" +
"_Turn_On_Curve_wrt_probe_MuidCB_Endcap",
463 chainName +
"_tagEFFSpre_mu0_15" +
"_Turn_On_Curve_wrt_probe_MuidCB",
464 chainName +
"_tagEFFSpre_mu15_20" +
"_Turn_On_Curve_wrt_probe_MuidCB",
465 chainName +
"_tagEFFSpre_mu20" +
"_Turn_On_Curve_wrt_probe_MuidCB",
466 chainName +
"_Turn_On_Curve_wrt_subleading_MuidCB",
467 FS_pre_trigger +
"_dimuonTP" +
"_Turn_On_Curve_wrt_probe_MuidCB",
468 FS_pre_trigger +
"_dimuonTP" +
"_Turn_On_Curve_wrt_L1_probe_MuidCB",
471 bool for_mydebug =
false;
476 if (!pH and for_mydebug) {
477 std::cerr <<
"HLTMuon PostProcessing: no such histogram!! " <<
hname << std::endl;
481 auto getHistogramPairQuietly = [&getHPointerQuietly] (
const TString &numeratorName,
const TString &denominatorName)->std::pair<TH1F *, TH1F *> {
483 TH1F* pH1 = getHPointerQuietly(numeratorName);
485 pH2 = getHPointerQuietly(denominatorName);
487 return std::pair{pH1, pH2};
491 for (
int iROI = 0; iROI < 9; iROI++) {
492 sden = nd_dir + hists_str[iROI] +
"_Denominator";
493 snum = nd_dir + hists_str[iROI] +
"_Numerator";
494 seff = eff_dir + hists_str[iROI];
495 seffg = seff +
"_Fit";
497 stmp = hists_str[iROI];
498 stmpg = hists_str[iROI] +
"_Fit";
499 const auto & [h1num, h1den] = getHistogramPairQuietly(snum, sden);
500 if (!h1num)
continue;
502 h1tmp = (
TH1F*) h1den->Clone();
503 h1tmp->SetName(stmp);
504 h1tmp->SetTitle(stmp);
505 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
507 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
510 h1tmpg =
new TGraphAsymmErrors();
511 h1tmpg->SetMarkerStyle(20);
512 h1tmpg->SetMinimum(0.0);
513 h1tmpg->SetMaximum(1.05);
514 h1tmpg->BayesDivide(h1num, h1den);
515 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
516 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
517 h1tmpg->SetName(stmpg);
522 TString L1_TP_str = FS_pre_trigger +
"_dimuonTP_L1" +
"_Turn_On_Curve_wrt_probe_MuidCB";
523 sden = nd_dir + FS_pre_trigger +
"_dimuonTP" +
"_Turn_On_Curve_wrt_probe_MuidCB" +
"_Denominator";
524 snum = nd_dir + FS_pre_trigger +
"_dimuonTP" +
"_Turn_On_Curve_wrt_L1_probe_MuidCB" +
"_Denominator";
525 seff = eff_dir + L1_TP_str;
526 seffg = seff +
"_Fit";
528 stmpg = L1_TP_str +
"_Fit";
529 const auto & [h1num, h1den] = getHistogramPairQuietly(snum, sden);
530 if (!h1num)
continue;
532 h1tmp = (
TH1F*) h1den->Clone();
533 h1tmp->SetName(stmp);
534 h1tmp->SetTitle(stmp);
535 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
537 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
540 h1tmpg =
new TGraphAsymmErrors();
541 h1tmpg->SetMarkerStyle(20);
542 h1tmpg->SetMinimum(0.0);
543 h1tmpg->SetMaximum(1.05);
544 h1tmpg->BayesDivide(h1num, h1den);
545 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
546 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
548 h1tmpg->SetName(stmpg);
554 TString histNumB = nd_dir +
chainName +
"_tagEFFSpre_Turn_On_Curve_wrt_probe_MuidCB_Barrel_Numerator";
555 TString histDenB = nd_dir +
chainName +
"_tagEFFSpre_Turn_On_Curve_wrt_probe_MuidCB_Barrel_Denominator";
556 TString histNumE = nd_dir +
chainName +
"_tagEFFSpre_Turn_On_Curve_wrt_probe_MuidCB_Endcap_Numerator";
557 TString histDenE = nd_dir +
chainName +
"_tagEFFSpre_Turn_On_Curve_wrt_probe_MuidCB_Endcap_Denominator";
558 TString histL1sum = eff_dir +
chainName +
"_EFplateau_wrtOffline";
559 const auto & [h1numb, h1denb] = getHistogramPairQuietly(histNumB, histDenB);
560 if (!h1numb)
continue;
562 const auto & [h1nume, h1dene] = getHistogramPairQuietly(histNumE, histDenE);
563 if (!h1nume)
continue;
565 TH1F* h1sumL = getHPointerQuietly(histL1sum);
566 if (!h1sumL)
continue;
574 double sumeff {}, sumerr {};
575 double sumn = h1numb->Integral(iSTDL, iSTDH);
576 double sumd = h1denb->Integral(iSTDL, iSTDH);
578 sumeff = (
double) sumn / (
double) sumd;
579 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
582 h1sumL->SetBinContent(1, sumeff);
583 h1sumL->SetBinError(1, sumerr);
585 sumn = h1nume->Integral(iSTDL, iSTDH);
586 sumd = h1dene->Integral(iSTDL, iSTDH);
591 sumeff = (
double) sumn / (
double) sumd;
592 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
594 h1sumL->GetYaxis()->SetTitle(
"Efficiency");
595 h1sumL->SetBinContent(2, sumeff);
596 h1sumL->SetBinError(2, sumerr);
597 h1sumL->SetMinimum(0.0);
598 h1sumL->SetMaximum(1.05);
601 h1sumL->Write(
"", TObject::kOverwrite);
603 TString histNum_mu0_15 = nd_dir +
chainName +
"_tagEFFSpre_mu0_15_Turn_On_Curve_wrt_probe_MuidCB_Numerator";
604 TString histDen_mu0_15 = nd_dir +
chainName +
"_tagEFFSpre_mu0_15_Turn_On_Curve_wrt_probe_MuidCB_Denominator";
605 TString histNum_mu15_20 = nd_dir +
chainName +
"_tagEFFSpre_mu15_20_Turn_On_Curve_wrt_probe_MuidCB_Numerator";
606 TString histDen_mu15_20 = nd_dir +
chainName +
"_tagEFFSpre_mu15_20_Turn_On_Curve_wrt_probe_MuidCB_Denominator";
607 TString histNum_mu20 = nd_dir +
chainName +
"_tagEFFSpre_mu20_Turn_On_Curve_wrt_probe_MuidCB_Numerator";
608 TString histDen_mu20 = nd_dir +
chainName +
"_tagEFFSpre_mu20_Turn_On_Curve_wrt_probe_MuidCB_Denominator";
609 TString histEFsum_mu = eff_dir +
chainName +
"_EFplateau_wrtOffline_mu_dependence";
611 TH1F* h1num_mu0_15 = getHPointerQuietly(histNum_mu0_15);
612 if (!h1num_mu0_15)
continue;
614 TH1F* h1num_mu15_20 = getHPointerQuietly(histNum_mu15_20);
615 if (!h1num_mu15_20)
continue;
617 TH1F* h1num_mu20 = getHPointerQuietly(histNum_mu20);
618 if (!h1num_mu20)
continue;
620 TH1F* h1den_mu0_15 = getHPointerQuietly(histDen_mu0_15);
621 if (!h1den_mu0_15)
continue;
623 TH1F* h1den_mu15_20 = getHPointerQuietly(histDen_mu15_20);
624 if (!h1den_mu15_20)
continue;
626 TH1F* h1den_mu20 = getHPointerQuietly(histDen_mu20);
627 if (!h1den_mu20)
continue;
629 TH1F* h1sum_mu = getHPointerQuietly(histEFsum_mu);
630 if (!h1sum_mu)
continue;
632 sumn = h1num_mu0_15->Integral(iSTDL, iSTDH);
633 sumd = h1den_mu0_15->Integral(iSTDL, iSTDH);
638 sumeff = (
double) sumn / (
double) sumd;
639 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
642 h1sum_mu->SetBinContent(1, sumeff);
643 h1sum_mu->SetBinError(1, sumerr);
645 sumn = h1num_mu15_20->Integral(iSTDL, iSTDH);
646 sumd = h1den_mu15_20->Integral(iSTDL, iSTDH);
651 sumeff = (
double) sumn / (
double) sumd;
652 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
654 h1sum_mu->SetBinContent(2, sumeff);
655 h1sum_mu->SetBinError(2, sumerr);
657 sumn = h1num_mu20->Integral(iSTDL, iSTDH);
658 sumd = h1den_mu20->Integral(iSTDL, iSTDH);
663 sumeff = (
double) sumn / (
double) sumd;
664 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
666 h1sum_mu->GetYaxis()->SetTitle(
"Efficiency");
667 h1sum_mu->SetBinContent(3, sumeff);
668 h1sum_mu->SetBinError(3, sumerr);
669 h1sum_mu->SetMaximum(1.05);
670 h1sum_mu->SetMinimum(0.0);
672 h1sum_mu->Write(
"", TObject::kOverwrite);
678 "_L2MuonSA",
"_MuonEFMS",
"_MuonEFSA"
680 TString wrtalg2[3] = {
681 "_L1",
"_L2MuonSA",
"_L2MuonSA"
687 for (
unsigned int i = 0;
i < chainsMSonly.size();
i++) {
690 for (
int trg = 0; trg < maxindep; trg++) {
691 sden = nd_dir +
chainName +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered_Denominator";
694 snum = nd_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered_Numerator";
695 seff = eff_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered";
696 seffg = seff +
"_Fit";
697 stmp =
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered";
698 stmpg =
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered" +
"_Fit";
699 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
700 if (!h1num)
continue;
702 h1tmp = (
TH1F*) h1den->Clone();
703 h1tmp->SetName(stmp);
704 h1tmp->SetTitle(stmp);
705 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
707 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
710 h1tmpg =
new TGraphAsymmErrors();
711 h1tmpg->SetName(stmpg);
712 h1tmpg->SetMarkerStyle(20);
713 h1tmpg->SetMinimum(0.0);
714 h1tmpg->SetMaximum(1.05);
715 h1tmpg->BayesDivide(h1num, h1den);
716 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
717 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
723 if (0 ==
alg || 2 ==
alg) {
725 double sumeff {}, sumerr {};
726 double sumn = h1num->Integral(iMSL, iMSH);
727 double sumd = h1den->Integral(iMSL, iMSH);
729 sumeff = (
double) sumn / (
double) sumd;
730 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
734 iholx =
static_cast<int>(iL2MuonSA);
735 }
else if (2 ==
alg) {
736 iholx =
static_cast<int>(iEFSA);
740 TString
s = eff_dir +
chainName +
"_highpt_effsummary_by" + vectkwd.at(2);
741 h1sumeff = getHPointer(
s);
742 if (!h1sumeff)
continue;
744 h1sumeff->SetBinContent(iholx + 1, sumeff);
745 h1sumeff->SetBinError(iholx + 1, sumerr);
746 h1sumeff->GetYaxis()->SetTitleOffset(1.3);
747 h1sumeff->SetMinimum(0.0);
748 h1sumeff->SetMaximum(1.05);
751 h1sumeff->Write(
"", TObject::kOverwrite);
761 sden = nd_dir +
chainName +
"_Turn_On_Curve_wrt_MuidSA_Denominator";
762 snum = nd_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_Numerator";
763 seff = eff_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA";
764 seffg = seff +
"_Fit";
765 stmp =
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA";
766 stmpg =
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
767 const auto & [pNum, pDen] = getHistogramPair(snum, sden);
770 h1tmp = (
TH1F*) pDen->Clone();
771 h1tmp->SetName(stmp);
772 h1tmp->SetTitle(stmp);
773 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
775 h1tmp->Divide(pNum, pDen, 1., 1.,
"B");
778 h1tmpg =
new TGraphAsymmErrors();
779 h1tmpg->SetName(stmpg);
780 h1tmpg->SetMarkerStyle(20);
781 h1tmpg->SetMinimum(0.0);
782 h1tmpg->SetMaximum(1.05);
783 h1tmpg->BayesDivide(pNum, pDen);
784 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
785 h1tmpg->GetXaxis()->SetTitle(pDen->GetXaxis()->GetTitle());
790 if (0 ==
alg || 2 ==
alg) {
791 double sumeff {}, sumerr {};
792 double sumn = pNum->Integral(iMSL, iMSH);
793 double sumd = pDen->Integral(iMSL, iMSH);
795 sumeff = (
double) sumn / (
double) sumd;
796 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
800 iholx =
static_cast<int>(iL2MuonSA);
801 }
else if (2 ==
alg) {
802 iholx =
static_cast<int>(iEFSA);
806 TString
s = eff_dir +
chainName +
"_highpt_effsummary_by" + vectkwd.at(3);
807 h1sumeff = getHPointer(
s);
808 if (!h1sumeff)
continue;
809 h1sumeff->GetYaxis()->SetTitleOffset(1.3);
810 h1sumeff->SetBinContent(iholx + 1, sumeff);
811 h1sumeff->SetBinError(iholx + 1, sumerr);
812 h1sumeff->SetMinimum(0.0);
813 h1sumeff->SetMaximum(1.05);
816 h1sumeff->Write(
"", TObject::kOverwrite);
822 for (
int ies = 0; ies <= maxESbr; ies++) {
823 if (!MS_mon_ESbr[ies])
continue;
826 sden = nd_dir +
chainName + triggerES[ies] +
"_Turn_On_Curve_wrt_MuidSA_Denominator";
827 snum = nd_dir +
chainName + triggerES[ies] +
"_L2MuonSA" +
"_Turn_On_Curve_wrt" +
"_L1" +
"_Denominator";
828 seff = eff_dir +
chainName + triggerES[ies] +
"_L1" +
"_Turn_On_Curve_wrt_MuidSA";
829 seffg = seff +
"_Fit";
830 stmp =
chainName + triggerES[
alg] +
"_L1" +
"_Turn_On_Curve_wrt_MuidSA";
831 stmpg =
chainName + triggerES[
alg] +
"_L1" +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
832 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
833 if (!h1num)
continue;
835 h1tmp = (
TH1F*) h1den->Clone();
836 h1tmp->SetName(stmp);
837 h1tmp->SetTitle(stmp);
838 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
840 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
843 h1tmpg =
new TGraphAsymmErrors();
844 h1tmpg->SetName(stmpg);
845 h1tmpg->SetMarkerStyle(20);
846 h1tmpg->SetMinimum(0.0);
847 h1tmpg->SetMaximum(1.05);
848 h1tmpg->BayesDivide(h1num, h1den);
849 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
850 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
856 for (
int be = 0;
be < 2;
be++) {
857 sden = nd_dir +
chainName + triggerES[ies] +
"_Turn_On_Curve_wrt_MuidSA" + bestr[
be] +
"_Denominator";
858 snum = nd_dir +
chainName + triggerES[ies] +
"_L2MuonSA" +
"_Turn_On_Curve_wrt" +
"_L1" + bestr[
be] +
860 seff = eff_dir +
chainName + triggerES[ies] +
"_L1" + bestr[
be] +
"_Turn_On_Curve_wrt_MuidSA";
861 seffg = seff +
"_Fit";
862 stmp =
chainName + triggerES[ies] +
"_L1" + bestr[
be] +
"_Turn_On_Curve_wrt_MuidSA";
863 stmpg =
chainName + triggerES[ies] +
"_L1" + bestr[
be] +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
864 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
865 if (!h1num)
continue;
867 h1tmp = (
TH1F*) h1den->Clone();
868 h1tmp->SetName(stmp);
869 h1tmp->SetTitle(stmp);
870 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
872 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
875 h1tmpg =
new TGraphAsymmErrors();
876 h1tmpg->SetName(stmpg);
877 h1tmpg->SetMarkerStyle(20);
878 h1tmpg->SetMinimum(0.0);
879 h1tmpg->SetMaximum(1.05);
880 h1tmpg->BayesDivide(h1num, h1den);
881 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
882 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
890 sden = nd_dir +
chainName + triggerES[ies] +
"_Turn_On_Curve_wrt_MuidSA_Denominator";
891 snum = nd_dir +
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_Numerator";
892 seff = eff_dir +
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA";
893 seffg = seff +
"_Fit";
894 stmp =
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA";
895 stmpg =
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
896 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
897 if (!h1num)
continue;
899 h1tmp = (
TH1F*) h1den->Clone();
900 h1tmp->SetName(stmp);
901 h1tmp->SetTitle(stmp);
902 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
904 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
907 h1tmpg =
new TGraphAsymmErrors();
908 h1tmpg->SetName(stmpg);
909 h1tmpg->SetMarkerStyle(20);
910 h1tmpg->SetMinimum(0.0);
911 h1tmpg->SetMaximum(1.05);
912 h1tmpg->BayesDivide(h1num, h1den);
913 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
914 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
919 if (0 ==
alg || 2 ==
alg) {
920 if (ESTAG == ies || ESINDEP == ies) {
921 double sumeff, sumerr;
922 double sumn = h1num->Integral(iMSL, iMSH);
923 double sumd = h1den->Integral(iMSL, iMSH);
928 sumeff = (
double) sumn / (
double) sumd;
929 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
933 iholx =
static_cast<int>(iL2MuonSA);
934 }
else if (2 ==
alg) {
935 iholx =
static_cast<int>(iEFSA);
939 TString
s = eff_dir +
chainName +
"_highpt_effsummary_by" + triggerES[ies];
940 h1sumeff = getHPointer(
s);
941 if (!h1sumeff)
continue;
942 h1sumeff->GetYaxis()->SetTitleOffset(1.3);
943 h1sumeff->SetBinContent(iholx + 1, sumeff);
944 h1sumeff->SetBinError(iholx + 1, sumerr);
945 h1sumeff->SetMinimum(0.0);
946 h1sumeff->SetMaximum(1.05);
949 h1sumeff->Write(
"", TObject::kOverwrite);
956 if (0 ==
alg || 2 ==
alg) {
957 for (
int be = 0;
be < 2;
be++) {
959 sden = nd_dir +
chainName +
"_Turn_On_Curve_wrt_MuidSA" + bestr[
be] +
"_Denominator";
960 snum = nd_dir +
chainName + alg2[
alg] + bestr[
be] +
"_Turn_On_Curve_Numerator";
961 seff = eff_dir +
chainName + alg2[
alg] + bestr[
be] +
"_Turn_On_Curve_wrt_MuidSA";
962 seffg = seff +
"_Fit";
963 stmp =
chainName + alg2[
alg] + bestr[
be] +
"_Turn_On_Curve_wrt_MuidSA";
964 stmpg =
chainName + alg2[
alg] + bestr[
be] +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
965 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
966 if (!h1num)
continue;
968 h1tmp = (
TH1F*) h1den->Clone();
969 h1tmp->SetName(stmp);
970 h1tmp->SetTitle(stmp);
971 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
973 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
976 h1tmpg =
new TGraphAsymmErrors();
977 h1tmpg->SetName(stmpg);
978 h1tmpg->SetMarkerStyle(20);
979 h1tmpg->SetMinimum(0.0);
980 h1tmpg->SetMaximum(1.05);
981 h1tmpg->BayesDivide(h1num, h1den);
982 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
983 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
991 sden = nd_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg] +
"_Denominator";
992 snum = nd_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_Numerator";
993 seff = eff_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg];
994 seffg = seff +
"_Fit";
996 stmpg =
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg] +
"_Fit";
997 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
998 if (!h1num)
continue;
1000 h1tmp = (
TH1F*) h1den->Clone();
1001 h1tmp->SetName(stmp);
1002 h1tmp->SetTitle(stmp);
1003 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
1005 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
1008 h1tmpg =
new TGraphAsymmErrors();
1009 h1tmpg->SetName(stmpg);
1010 h1tmpg->SetMarkerStyle(20);
1011 h1tmpg->SetMinimum(0.0);
1012 h1tmpg->SetMaximum(1.05);
1013 h1tmpg->BayesDivide(h1num, h1den);
1014 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1015 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1023 for (
int ies = 0; ies <= maxESbr; ies++) {
1024 if (!MS_mon_ESbr[ies])
continue;
1025 sden = nd_dir +
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg] +
1027 snum = nd_dir +
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_Numerator";
1028 seff = eff_dir +
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg];
1029 seffg = seff +
"_Fit";
1030 stmp =
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg];
1031 stmpg =
chainName + triggerES[ies] + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg] +
"_Fit";
1032 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1033 if (!h1num)
continue;
1035 h1tmp = (
TH1F*) h1den->Clone();
1036 h1tmp->SetName(stmp);
1037 h1tmp->SetTitle(stmp);
1038 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
1040 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
1043 h1tmpg =
new TGraphAsymmErrors();
1044 h1tmpg->SetName(stmpg);
1045 h1tmpg->SetMarkerStyle(20);
1046 h1tmpg->SetMinimum(0.0);
1047 h1tmpg->SetMaximum(1.05);
1048 h1tmpg->BayesDivide(h1num, h1den);
1049 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1050 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1057 if (0 ==
alg || 2 ==
alg) {
1058 for (
int be = 0;
be < 2;
be++) {
1060 sden = nd_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg] + bestr[
be] +
"_Denominator";
1061 snum = nd_dir +
chainName + alg2[
alg] + bestr[
be] +
"_Turn_On_Curve_Numerator";
1062 seff = eff_dir +
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg] + bestr[
be];
1063 seffg = seff +
"_Fit";
1065 stmpg =
chainName + alg2[
alg] +
"_Turn_On_Curve_wrt" + wrtalg2[
alg] + bestr[
be] +
"_Fit";
1066 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1067 if (!h1num)
continue;
1069 h1tmp = (
TH1F*) h1den->Clone();
1070 h1tmp->SetName(stmp);
1071 h1tmp->SetTitle(stmp);
1072 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
1074 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
1077 h1tmpg =
new TGraphAsymmErrors();
1078 h1tmpg->SetName(stmpg);
1079 h1tmpg->SetMarkerStyle(20);
1080 h1tmpg->SetMinimum(0.0);
1081 h1tmpg->SetMaximum(1.05);
1082 h1tmpg->BayesDivide(h1num, h1den);
1083 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1084 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1095 dir =
mf.GetDirectory(rr_dir);
1098 std::cerr <<
"HLTMuonHistogramDivision: directory " << rr_dir <<
" not found" << std::endl;
1104 std::string
type[3] = {
1107 std::string off[3] = {
1108 "Moore_MS_",
"Moore_SA_",
"Muid_"
1110 std::string
cut[2] = {
1114 for (
int itype = 0; itype < 3; itype++) {
1115 for (
int icut = 0; icut < 2; icut++) {
1116 seff = rr_dir +
"EF_" +
type[itype] +
"Over_" + off[itype] +
cut[icut] +
"GeV_Cut";
1117 snum = rate_dir +
"Number_Of_EF_" +
type[itype] +
"Muons_" +
cut[icut] +
"GeV_Cut";
1118 sden = rate_dir +
"Number_Of_" + off[itype] +
"Muons_" +
cut[icut] +
"GeV_Cut";
1119 stmp =
"EF_" +
type[itype] +
"Over_" + off[itype] +
cut[icut] +
"GeV_Cut";
1120 stmpg =
"EF_" +
type[itype] +
"Over_" + off[itype] +
cut[icut] +
"GeV_Cut" +
"_Fit";
1121 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1122 if (!h1num)
continue;
1124 h1tmp = (
TH1F*) h1den->Clone();
1125 h1tmp->SetName(stmp);
1126 h1tmp->SetTitle(stmp);
1127 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
1129 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
1137 std::vector<TString>
chains;
1138 std::vector<TString> chains2;
1141 std::map<std::string, std::string> ztpmap;
1143 ztpmap[
"muChain1"] =
"L1_MU15";
1144 ztpmap[
"muChain2"] =
"L1_MU15";
1145 ztpmap[
"muChainEFiso1"] =
"L1_MU15";
1146 ztpmap[
"muChainEFiso2"] =
"L1_MU15";
1147 ztpmap[
"muChainMSonly1"] =
"L1_MU15";
1148 ztpmap[
"muChainMSonly2"] =
"L1_MU15";
1150 std::map<std::string, int> ztp_isomap;
1151 ztp_isomap[
"muChain1"] = 0;
1152 ztp_isomap[
"muChain2"] = 0;
1153 ztp_isomap[
"muChainEFiso1"] = 1;
1154 ztp_isomap[
"muChainEFiso2"] = 1;
1155 ztp_isomap[
"muChainMSonly1"] = 0;
1156 ztp_isomap[
"muChainMSonly2"] = 0;
1159 TString histdirmuztp = run_dir +
"/HLT/MuonMon/MuZTP/" + itmap->first;
1160 TDirectory* ztpdir =
mf.GetDirectory(histdirmuztp);
1161 bool isefisochain = ztp_isomap[itmap->first] > 0;
1164 std::vector<std::string>
var;
1165 var.push_back(
"_Pt_");
1166 var.push_back(
"_Pt_EC_");
1167 var.push_back(
"_Pt_B_");
1168 var.push_back(
"_Pt_4bins_");
1169 var.push_back(
"_Pt_B_4bins_");
1170 var.push_back(
"_Eta_");
1171 var.push_back(
"_Phi_");
1172 var.push_back(
"_Phi_EC_");
1173 var.push_back(
"_Phi_B_");
1174 for (
unsigned int k = 0;
k <
var.size();
k++) {
1175 std::vector<std::string>
level;
1176 level.push_back(
"L1");
1177 level.push_back(
"L2");
1178 level.push_back(
"EF");
1179 if (isefisochain)
level.push_back(
"EFIso");
1180 for (
unsigned int j = 0; j <
level.size(); j++) {
1182 seffg = histdirmuztp +
"/muZTP_eff_" +
level[j] +
var[
k] + itmap->first;
1183 snum = histdirmuztp +
"/muZTP" +
var[
k] +
level[j] +
"fired_" + itmap->first;
1184 sden = histdirmuztp +
"/muZTP" +
var[
k] + itmap->first;
1185 stmp =
"muZTP_eff_" +
level[j] +
var[
k] + itmap->first;
1186 stmpg =
"muZTP_eff_" +
level[j] +
var[
k] + itmap->first;
1187 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1188 if (!h1num)
continue;
1190 h1tmpg =
new TGraphAsymmErrors();
1191 h1tmpg->SetName(stmpg);
1192 h1tmpg->SetMarkerStyle(20);
1193 h1tmpg->SetMinimum(0.0);
1194 h1tmpg->SetMaximum(1.05);
1195 h1tmpg->BayesDivide(h1num, h1den);
1196 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1197 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1203 seffg = histdirmuztp +
"/muZTP_eff_" +
level[j] +
"_Eta_1bin_" + itmap->first;
1204 snum = histdirmuztp +
"/muZTP_Eta_1bin_" +
level[j] +
"fired_" + itmap->first;
1205 sden = histdirmuztp +
"/muZTP_Eta_1bin_" + itmap->first;
1206 stmpg =
"muZTP_eff_" +
level[j] +
"_Eta_1bin_" + itmap->first;
1207 const auto & [h1num2, h1den2] = getHistogramPair(snum, sden);
1208 if (!h1num2)
continue;
1210 h1tmpg =
new TGraphAsymmErrors();
1211 h1tmpg->SetName(stmpg);
1212 h1tmpg->SetMarkerStyle(20);
1213 h1tmpg->SetMinimum(0.0);
1214 h1tmpg->SetMaximum(1.05);
1215 h1tmpg->BayesDivide(h1num2, h1den2);
1216 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1217 h1tmpg->GetXaxis()->SetTitle(h1den2->GetXaxis()->GetTitle());
1223 seffg = histdirmuztp +
"/muZTP_eff_" +
level[j] +
"_Eta_2bins_" + itmap->first;
1224 snum = histdirmuztp +
"/muZTP_Eta_2bins_" +
level[j] +
"fired_" + itmap->first;
1225 sden = histdirmuztp +
"/muZTP_Eta_2bins_" + itmap->first;
1226 stmpg =
"muZTP_eff_" +
level[j] +
"_Eta_2bins_" + itmap->first;
1227 const auto & [h1num3, h1den3] = getHistogramPair(snum, sden);
1230 if (!h1num3)
continue;
1234 h1tmpg =
new TGraphAsymmErrors();
1235 h1tmpg->SetName(stmp);
1236 h1tmpg->SetMarkerStyle(20);
1237 h1tmpg->SetMinimum(0.0);
1238 h1tmpg->SetMaximum(1.05);
1239 h1tmpg->BayesDivide(h1num3, h1den3);
1240 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1241 h1tmpg->GetXaxis()->SetTitle(h1den3->GetXaxis()->GetTitle());
1247 seffg = histdirmuztp +
"/muZTP_eff_" +
level[j] +
"_Eta_1bin_cut_" + itmap->first;
1248 snum = histdirmuztp +
"/muZTP_Eta_1bin_cut_" +
level[j] +
"fired_" + itmap->first;
1249 sden = histdirmuztp +
"/muZTP_Eta_1bin_cut_" + itmap->first;
1250 stmpg =
"muZTP_eff_" +
level[j] +
"_Eta_1bin_cut_" + itmap->first;
1251 const auto & [h1num4, h1den4] = getHistogramPair(snum, sden);
1252 if (!h1num4)
continue;
1254 h1tmpg =
new TGraphAsymmErrors();
1255 h1tmpg->SetName(stmpg);
1256 h1tmpg->SetMarkerStyle(20);
1257 h1tmpg->SetMinimum(0.0);
1258 h1tmpg->SetMaximum(1.05);
1259 h1tmpg->BayesDivide(h1num4, h1den4);
1260 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1261 h1tmpg->GetXaxis()->SetTitle(h1den4->GetXaxis()->GetTitle());
1267 seffg = histdirmuztp +
"/muZTP_eff_" +
level[j] +
"_Eta_2bins_cut_" + itmap->first;
1268 snum = histdirmuztp +
"/muZTP_Eta_2bins_cut_" +
level[j] +
"fired_" + itmap->first;
1269 sden = histdirmuztp +
"/muZTP_Eta_2bins_cut_" + itmap->first;
1270 stmpg =
"muZTP_eff_" +
level[j] +
"_Eta_2bins_cut_" + itmap->first;
1271 const auto & [h1num5, h1den5] = getHistogramPair(snum, sden);
1272 if (!h1num5)
continue;
1274 h1tmpg =
new TGraphAsymmErrors();
1275 h1tmpg->SetName(stmpg);
1276 h1tmpg->SetMarkerStyle(20);
1277 h1tmpg->SetMinimum(0.0);
1278 h1tmpg->SetMaximum(1.05);
1279 h1tmpg->BayesDivide(h1num5, h1den5);
1280 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1281 h1tmpg->GetXaxis()->SetTitle(h1den5->GetXaxis()->GetTitle());
1288 seff = histdirmuztp +
"/muZTP_eff_EtaPhi_" +
level[j] +
"_" + itmap->first;
1289 snum = histdirmuztp +
"/muZTP_EtaPhi_" +
level[j] +
"_" + itmap->first;
1290 sden = histdirmuztp +
"/muZTP_EtaPhi_all_" + itmap->first;
1291 stmp =
"muZTP_eff_EtaPhi_" +
level[j] +
"_" + itmap->first;
1297 h2num = getH2Pointer(snum);
1298 if (!h2num)
continue;
1299 h2den = getH2Pointer(sden);
1300 if (!h2den)
continue;
1302 h2tmp = (
TH2F*) h1den->Clone();
1303 h2tmp->SetName(stmp);
1304 h2tmp->SetTitle(stmp);
1305 h2tmp->GetYaxis()->SetTitle(
"Efficiency");
1307 h2tmp->Divide(h1num, h1den, 1., 1.,
"B");
1314 seffg = histdirmuztp +
"/muZTP_eff_EFwrtL2" +
var[
k] + itmap->first;
1315 snum = histdirmuztp +
"/muZTP" +
var[
k] +
"EFL2fired_" + itmap->first;
1316 sden = histdirmuztp +
"/muZTP" +
var[
k] +
"L2fired_" + itmap->first;
1317 stmpg =
"muZTP_eff_EFwrtL2" +
var[
k] + itmap->first;
1318 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1319 if (!h1num)
continue;
1321 h1tmpg =
new TGraphAsymmErrors();
1322 h1tmpg->SetName(stmpg);
1323 h1tmpg->SetMarkerStyle(20);
1324 h1tmpg->SetMinimum(0.0);
1325 h1tmpg->SetMaximum(1.05);
1326 h1tmpg->BayesDivide(h1num, h1den);
1327 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1328 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1334 seffg = histdirmuztp +
"/muZTP_eff_EFwrtL1" +
var[
k] + itmap->first;
1335 snum = histdirmuztp +
"/muZTP" +
var[
k] +
"EFfired_" + itmap->first;
1336 sden = histdirmuztp +
"/muZTP" +
var[
k] +
"L1fired_" + itmap->first;
1337 stmpg =
"muZTP_eff_EFwrtL1" +
var[
k] + itmap->first;
1338 const auto & [h1num2, h1den2] = getHistogramPair(snum, sden);
1339 if (!h1num2)
continue;
1341 h1tmpg =
new TGraphAsymmErrors();
1342 h1tmpg->SetName(stmpg);
1343 h1tmpg->SetMarkerStyle(20);
1344 h1tmpg->SetMinimum(0.0);
1345 h1tmpg->SetMaximum(1.05);
1346 h1tmpg->BayesDivide(h1num2, h1den2);
1347 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1348 h1tmpg->GetXaxis()->SetTitle(h1den2->GetXaxis()->GetTitle());
1354 seffg = histdirmuztp +
"/muZTP_eff_L2wrtL1" +
var[
k] + itmap->first;
1355 snum = histdirmuztp +
"/muZTP" +
var[
k] +
"L2fired_" + itmap->first;
1356 sden = histdirmuztp +
"/muZTP" +
var[
k] +
"L1fired_" + itmap->first;
1357 stmpg =
"muZTP_eff_L2wrtL1" +
var[
k] + itmap->first;
1358 const auto & [h1num3, h1den3] = getHistogramPair(snum, sden);
1359 if (!h1num3)
continue;
1361 h1tmpg =
new TGraphAsymmErrors();
1362 h1tmpg->SetName(stmpg);
1363 h1tmpg->SetMarkerStyle(20);
1364 h1tmpg->SetMinimum(0.0);
1365 h1tmpg->SetMaximum(1.05);
1366 h1tmpg->BayesDivide(h1num3, h1den3);
1367 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1368 h1tmpg->GetXaxis()->SetTitle(h1den3->GetXaxis()->GetTitle());
1375 seffg = histdirmuztp +
"/muZTP_eff_EFIsowrtEF" +
var[
k] + itmap->first;
1376 snum = histdirmuztp +
"/muZTP" +
var[
k] +
"EFIsofired_" + itmap->first;
1377 sden = histdirmuztp +
"/muZTP" +
var[
k] +
"EFfired_" + itmap->first;
1378 stmpg =
"muZTP_eff_EFIsowrtEF" +
var[
k] + itmap->first;
1379 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1380 if (!h1num)
continue;
1382 h1tmpg =
new TGraphAsymmErrors();
1383 h1tmpg->SetName(stmpg);
1384 h1tmpg->SetMarkerStyle(20);
1385 h1tmpg->SetMinimum(0.0);
1386 h1tmpg->SetMaximum(1.05);
1387 h1tmpg->BayesDivide(h1num, h1den);
1388 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1389 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1402 TDirectory* efdir =
mf.GetDirectory(eff_dir);
1405 std::cerr <<
"HLTMuonHistogramDivision: directory " << eff_dir <<
" not found" << std::endl;
1411 const int MAXARR = 6;
1412 std::string charr[MAXARR] = {
1413 "muChain1",
"muChain2",
"muChainEFiso1",
"muChainEFiso2",
"muChainMSonly1",
"muChainMSonly2"
1415 std::string monarr[MAXARR] = {
1416 "_EFmuon",
"_EFmuon",
"_EFmuon",
"_EFmuon",
"_MuonEFSA",
"_MuonEFSA"
1418 std::string monL2arr[MAXARR] = {
1419 "_L2MuonSA",
"_L2MuonSA",
"_L2MuonSA",
"_L2MuonSA",
"_L2MuonSA",
"_L2MuonSA"
1421 bool isBarrelMon[MAXARR] = {
1422 false,
false,
false,
false,
true,
true
1424 bool isMSbMon[MAXARR] = {
1425 true,
true,
false,
false,
false,
false
1427 bool monL1[MAXARR] = {
1428 true,
true,
true,
true,
false,
false
1430 bool isefIsolation[MAXARR] = {
1431 false,
false,
true,
true,
false,
false
1435 for (
int ialg = 0; ialg < MAXARR; ialg++) {
1437 std::string MoniAlg = monarr[ialg];
1438 std::string MoniL2Alg = monL2arr[ialg];
1441 TString hdirztp = muon_dir +
"MuZTP/" +
chainName +
"/";
1442 TString histZtpNum, histZtpDen;
1443 if (!isBarrelMon[ialg]) {
1444 histZtpNum = hdirztp +
"muZTP_Pt_4bins_EFfired_" +
chainName;
1445 histZtpDen = hdirztp +
"muZTP_Pt_4bins_L1fired_" +
chainName;
1447 histZtpNum = hdirztp +
"muZTP_Pt_B_4bins_EFfired_" +
chainName;
1448 histZtpDen = hdirztp +
"muZTP_Pt_B_4bins_L1fired_" +
chainName;
1450 if (isefIsolation[ialg]) histZtpNum = hdirztp +
"muZTP_Pt_4bins_EFIsofired_" +
chainName;
1451 TString histZtpEff = eff_dir +
chainName +
"_highpt3bins_effwrtL1";
1452 const auto & [h1num, h1den] = getHistogramPair(histZtpNum, histZtpDen);
1453 if (!h1num)
continue;
1454 h1eff = getHPointer(histZtpEff);
1455 if (!h1eff)
continue;
1458 for (
int ibin = 2; ibin <= 3; ibin++) {
1460 double sumeff {}, sumerr {};
1461 double sumn = h1num->Integral(ibin, ibin);
1462 if (isBarrelMon[ialg] || isMSbMon[ialg]) sumn = h1num->Integral(ibin + 1, ibin + 1);
1463 double sumd = h1den->Integral(ibin, ibin);
1464 if (isBarrelMon[ialg] || isMSbMon[ialg]) sumd = h1den->Integral(ibin + 1, ibin + 1);
1466 sumeff = (
double) sumn / (
double) sumd;
1467 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
1469 h1eff->GetYaxis()->SetTitle(
"Efficiency");
1470 h1eff->SetBinContent(ibin - 1, sumeff);
1471 h1eff->SetBinError(ibin - 1, sumerr);
1472 h1eff->SetMinimum(0.0);
1473 h1eff->SetMaximum(1.05);
1479 h1eff->Write(
"", TObject::kOverwrite);
1482 TString hdirztp = muon_dir +
"MuZTP/" +
chainName +
"/";
1483 TString histZtpNumB = hdirztp +
"muZTP_Pt_B_L1fired_" +
chainName;
1484 TString histZtpDenB = hdirztp +
"muZTP_Pt_B_" +
chainName;
1485 TString histZtpNumE = hdirztp +
"muZTP_Pt_EC_L1fired_" +
chainName;
1486 TString histZtpDenE = hdirztp +
"muZTP_Pt_EC_" +
chainName;
1487 TString histZtpL1sum = eff_dir +
chainName +
"_highptL1plateau_wrtOffline";
1489 TH1F* h1numb = getHPointer(histZtpNumB);
1490 if (!h1numb)
continue;
1491 TH1F* h1nume = getHPointer(histZtpNumE);
1492 if (!h1nume)
continue;
1493 TH1F* h1denb = getHPointer(histZtpDenB);
1494 if (!h1denb)
continue;
1495 TH1F* h1dene = getHPointer(histZtpDenE);
1496 if (!h1dene)
continue;
1497 TH1F* h1sumL = getHPointer(histZtpL1sum);
1498 if (!h1sumL)
continue;
1500 double sumeff, sumerr;
1501 double sumn = h1numb->Integral(13, 25);
1502 if (HI_pp_key) sumn = h1numb->Integral(13, 20);
1503 double sumd = h1denb->Integral(13, 25);
1504 if (HI_pp_key) sumd = h1denb->Integral(13, 20);
1509 sumeff = (
double) sumn / (
double) sumd;
1510 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
1512 h1sumL->SetBinContent(1, sumeff);
1513 h1sumL->SetBinError(1, sumerr);
1515 sumn = h1nume->Integral(13, 25);
1516 if (HI_pp_key) sumn = h1numb->Integral(13, 20);
1517 sumd = h1dene->Integral(13, 25);
1518 if (HI_pp_key) sumd = h1denb->Integral(13, 20);
1523 sumeff = (
double) sumn / (
double) sumd;
1524 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
1526 h1sumL->GetYaxis()->SetTitle(
"Efficiency");
1527 h1sumL->SetBinContent(2, sumeff);
1528 h1sumL->SetBinError(2, sumerr);
1529 h1sumL->SetMinimum(0.0);
1530 h1sumL->SetMaximum(1.05);
1532 h1sumL->Write(
"", TObject::kOverwrite);
1542 TString monalg[3] = {
1543 "_L2MuonSA",
"_MuComb",
"_EFmuon"
1545 TString wrtalg[3] = {
1546 "_L1",
"_L2MuonSA",
"_MuComb"
1549 TString histdireff = eff_dir;
1551 TDirectory* efdir =
mf.GetDirectory(eff_dir);
1554 std::cerr <<
"HLTMuonHistogramDivision: directory " << eff_dir <<
" not found" << std::endl;
1560 chainsGeneric.insert(chainsGeneric.end(), chainsEFiso.begin(), chainsEFiso.end());
1562 for (
unsigned int i = 0;
i < chainsGeneric.size();
i++) {
1565 std::cout <<
"proc generic " <<
chainName << std::endl;
1571 numer =
chainName + monalg[
alg] +
"_Turn_On_Curve_Numerator";
1575 denom =
chainName + MSchainName +
"_Turn_On_Curve_wrt_MuidCB_Denominator";
1576 numer =
chainName + MSchainName + monalg[
alg] +
"_Turn_On_Curve_Numerator";
1577 effi =
chainName + MSchainName + monalg[
alg] +
"_Turn_On_Curve_wrt_MuidCB";
1583 numer =
chainName + monalg[
alg] +
"_Turn_On_Curve_Numerator";
1588 denom =
chainName + MSchainName + monalg[
alg] +
"_Turn_On_Curve_wrt" + wrtalg[
alg] +
"_Denominator";
1589 numer =
chainName + MSchainName + monalg[
alg] +
"_Turn_On_Curve_Numerator";
1594 for (
int i = 0;
i <= maxESbr;
i++) {
1595 if (!CB_mon_ESbr[
i])
continue;
1599 denom =
chainName + triggerES[
i] +
"_Turn_On_Curve_wrt_MuidCB_Denominator";
1600 numer =
chainName + triggerES[
i] +
"_L2MuonSA" +
"_Turn_On_Curve_wrt" +
"_L1" +
"_Denominator";
1601 effi =
chainName + triggerES[
i] +
"_L1" +
"_Turn_On_Curve_wrt_MuidCB";
1605 for (
int be = 0;
be < 2;
be++) {
1606 denom =
chainName + triggerES[
i] +
"_Turn_On_Curve_wrt_MuidCB" + bestr[
be] +
"_Denominator";
1607 numer =
chainName + triggerES[
i] +
"_L2MuonSA" +
"_Turn_On_Curve_wrt" +
"_L1" + bestr[
be] +
1609 effi =
chainName + triggerES[
i] +
"_L1" + bestr[
be] +
"_Turn_On_Curve_wrt_MuidCB";
1611 const auto & [h1num, h1den] = getHistogramPair(nd_dir + numer, nd_dir +
denom);
1612 if (!h1num)
continue;
1616 double sumeff {}, sumerr {};
1617 double sumn = h1num->Integral(iSTDL, iSTDH);
1618 double sumd = h1den->Integral(iSTDL, iSTDH);
1621 sumeff = (
double) sumn / (
double) sumd;
1622 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
1625 TString
s = histdireff +
chainName +
"_L1plateau_wrtOffline_by_ESindep";
1626 TH1F* h1effL1 = getHPointer(
s);
1627 if (!h1effL1)
continue;
1628 h1effL1->SetBinContent(
be + 1, sumeff);
1629 h1effL1->SetBinError(
be + 1, sumerr);
1630 h1eff->SetMinimum(0.0);
1631 h1eff->SetMaximum(1.05);
1633 h1effL1->Write(
"", TObject::kOverwrite);
1638 denom =
chainName + triggerES[
i] +
"_Turn_On_Curve_wrt_MuidCB_Denominator";
1639 numer =
chainName + triggerES[
i] + monalg[
alg] +
"_Turn_On_Curve_Numerator";
1642 const auto & [h1num, h1den] = getHistogramPair(nd_dir + numer, nd_dir +
denom);
1646 if (!h1num)
continue;
1648 double sumd {}, sumn {}, sumeff {}, sumerr {};
1649 sumn = h1num->Integral(iSTDL, iSTDH);
1650 sumd = h1den->Integral(iSTDL, iSTDH);
1653 sumeff = (
double) sumn / (
double) sumd;
1654 sumerr = std::sqrt((
double) sumn * (1. - sumeff)) / (
double) sumd;
1658 iholx =
static_cast<int>(iL2MuonSA);
1659 }
else if (1 ==
alg) {
1660 iholx =
static_cast<int>(iMuComb);
1661 }
else if (2 ==
alg) {
1662 iholx =
static_cast<int>(iEFCB);
1665 TString
s = histdireff +
chainName +
"_highpt_effsummary_by" + triggerES[
i];
1666 h1effsum = getHPointer(
s);
1667 if (!h1effsum)
continue;
1669 h1effsum->GetYaxis()->SetTitleOffset(1.3);
1670 h1effsum->SetBinContent(iholx + 1, sumeff);
1671 h1effsum->SetBinError(iholx + 1, sumerr);
1672 h1effsum->SetMinimum(0.0);
1673 h1effsum->SetMaximum(1.05);
1675 h1effsum->Write(
"", TObject::kOverwrite);
1678 denom =
chainName + triggerES[
i] + monalg[
alg] +
"_Turn_On_Curve_wrt" + wrtalg[
alg] +
"_Denominator";
1679 numer =
chainName + triggerES[
i] + monalg[
alg] +
"_Turn_On_Curve_Numerator";
1687 for (
int be = 0;
be < 2;
be++) {
1688 denom =
chainName +
"_Turn_On_Curve_wrt_MuidCB" + bestr[
be] +
"_Denominator";
1689 numer =
chainName + monalg[
alg] + bestr[
be] +
"_Turn_On_Curve_Numerator";
1694 for (
int be = 0;
be < 2;
be++) {
1695 denom =
chainName + MSchainName +
"_Turn_On_Curve_wrt_MuidCB" + bestr[
be] +
"_Denominator";
1696 numer =
chainName + MSchainName + monalg[
alg] + bestr[
be] +
"_Turn_On_Curve_Numerator";
1697 effi =
chainName + MSchainName + monalg[
alg] + bestr[
be] +
"_Turn_On_Curve_wrt_MuidCB";
1701 for (
int be = 0;
be < 2;
be++) {
1703 numer =
chainName + monalg[
alg] + bestr[
be] +
"_Turn_On_Curve_Numerator";
1709 for (
int be = 0;
be < 2;
be++) {
1712 numer =
chainName + MSchainName + monalg[
alg] + bestr[
be] +
"_Turn_On_Curve_Numerator";
1723 TString sdir, TString snum, TString sden, TString seff, TString seffg) {
1728 std::cerr <<
"HLTMuon PostProcessing: no such histogram!! " <<
hname << std::endl;
1735 TGraphAsymmErrors* h1tmpfg =
new TGraphAsymmErrors();
1738 TString stmp = seff + seffg;
1740 h1num = getHPointer(sdir +
"NumDenom/" + snum);
1743 h1den = getHPointer(sdir +
"NumDenom/" + sden);
1746 TDirectory*
dir =
mf.GetDirectory(sdir);
1748 h1tmpf = (
TH1F*) h1den->Clone();
1749 h1tmpf->SetName(stmp);
1750 h1tmpf->SetTitle(stmp);
1751 h1tmpf->GetYaxis()->SetTitle(
"Efficiency");
1753 h1tmpf->Divide(h1num, h1den, 1., 1.,
"B");
1754 h1tmpf->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1755 h1tmpf->SetMinimum(0.0);
1756 h1tmpfg->SetMaximum(1.05);
1757 h1tmpf->SetName(stmp);
1760 h1tmpfg->SetMarkerStyle(20);
1761 h1tmpfg->SetMinimum(0.0);
1762 h1tmpfg->SetMaximum(1.05);
1763 h1tmpfg->BayesDivide(h1num, h1den);
1764 h1tmpfg->GetYaxis()->SetTitle(
"Efficiency");
1765 h1tmpfg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1767 h1tmpfg->SetName(stmp);