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";
60 TIter nextcd0(gDirectory->GetListOfKeys());
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");
173 for (std::vector<TString>::iterator it = effnames.begin(); it != effnames.end(); ++it) {
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");
202 for (std::vector<TString>::iterator it = effnames.begin(); it != effnames.end(); ++it) {
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");
227 for (std::vector<TString>::iterator it = effnames.begin(); it != effnames.end(); ++it) {
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");
313 for (std::vector<TString>::iterator it = effnames.begin(); it != effnames.end(); ++it) {
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++) {
457 TString chainName = chainsEFFS.at(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++) {
688 TString chainName = chainsMSonly.at(i);
691 for (
int trg = 0; trg < maxindep; trg++) {
692 sden = nd_dir + chainName +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered_Denominator";
694 for (
int alg = 0; alg < 3; alg++) {
695 snum = nd_dir + chainName + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered_Numerator";
696 seff = eff_dir + chainName + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered";
697 seffg = seff +
"_Fit";
698 stmp = chainName + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered";
699 stmpg = chainName + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA" + trigger[trg] +
"_Triggered" +
"_Fit";
700 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
701 if (!h1num)
continue;
703 h1tmp = (TH1F*) h1den->Clone();
704 h1tmp->SetName(stmp);
705 h1tmp->SetTitle(stmp);
706 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
708 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
711 h1tmpg =
new TGraphAsymmErrors();
712 h1tmpg->SetName(stmpg);
713 h1tmpg->SetMarkerStyle(20);
714 h1tmpg->SetMinimum(0.0);
715 h1tmpg->SetMaximum(1.05);
716 h1tmpg->BayesDivide(h1num, h1den);
717 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
718 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
724 if (0 == alg || 2 == alg) {
726 double sumeff {}, sumerr {};
727 double sumn = h1num->Integral(iMSL, iMSH);
728 double sumd = h1den->Integral(iMSL, iMSH);
730 sumeff = (double) sumn / (
double) sumd;
731 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (double) sumd;
735 iholx =
static_cast<int>(iL2MuonSA);
736 }
else if (2 == alg) {
737 iholx =
static_cast<int>(iEFSA);
741 TString s = eff_dir + chainName +
"_highpt_effsummary_by" + vectkwd.at(2);
742 h1sumeff = getHPointer(s);
743 if (!h1sumeff)
continue;
745 h1sumeff->SetBinContent(iholx + 1, sumeff);
746 h1sumeff->SetBinError(iholx + 1, sumerr);
747 h1sumeff->GetYaxis()->SetTitleOffset(1.3);
748 h1sumeff->SetMinimum(0.0);
749 h1sumeff->SetMaximum(1.05);
752 h1sumeff->Write(
"", TObject::kOverwrite);
761 for (
int alg = 0; alg < 3; alg++) {
763 sden = nd_dir + chainName +
"_Turn_On_Curve_wrt_MuidSA_Denominator";
764 snum = nd_dir + chainName + alg2[alg] +
"_Turn_On_Curve_Numerator";
765 seff = eff_dir + chainName + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA";
766 seffg = seff +
"_Fit";
767 stmp = chainName + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA";
768 stmpg = chainName + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
769 const auto & [pNum, pDen] = getHistogramPair(snum, sden);
772 h1tmp = (TH1F*) pDen->Clone();
773 h1tmp->SetName(stmp);
774 h1tmp->SetTitle(stmp);
775 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
777 h1tmp->Divide(pNum, pDen, 1., 1.,
"B");
780 h1tmpg =
new TGraphAsymmErrors();
781 h1tmpg->SetName(stmpg);
782 h1tmpg->SetMarkerStyle(20);
783 h1tmpg->SetMinimum(0.0);
784 h1tmpg->SetMaximum(1.05);
785 h1tmpg->BayesDivide(pNum, pDen);
786 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
787 h1tmpg->GetXaxis()->SetTitle(pDen->GetXaxis()->GetTitle());
792 if (0 == alg || 2 == alg) {
793 double sumeff {}, sumerr {};
794 double sumn = pNum->Integral(iMSL, iMSH);
795 double sumd = pDen->Integral(iMSL, iMSH);
797 sumeff = (double) sumn / (
double) sumd;
798 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (double) sumd;
802 iholx =
static_cast<int>(iL2MuonSA);
803 }
else if (2 == alg) {
804 iholx =
static_cast<int>(iEFSA);
808 TString s = eff_dir + chainName +
"_highpt_effsummary_by" + vectkwd.at(3);
809 h1sumeff = getHPointer(s);
810 if (!h1sumeff)
continue;
811 h1sumeff->GetYaxis()->SetTitleOffset(1.3);
812 h1sumeff->SetBinContent(iholx + 1, sumeff);
813 h1sumeff->SetBinError(iholx + 1, sumerr);
814 h1sumeff->SetMinimum(0.0);
815 h1sumeff->SetMaximum(1.05);
818 h1sumeff->Write(
"", TObject::kOverwrite);
824 for (
int ies = 0; ies <= maxESbr; ies++) {
825 if (!MS_mon_ESbr[ies])
continue;
828 sden = nd_dir + chainName + triggerES[ies] +
"_Turn_On_Curve_wrt_MuidSA_Denominator";
829 snum = nd_dir + chainName + triggerES[ies] +
"_L2MuonSA" +
"_Turn_On_Curve_wrt" +
"_L1" +
"_Denominator";
830 seff = eff_dir + chainName + triggerES[ies] +
"_L1" +
"_Turn_On_Curve_wrt_MuidSA";
831 seffg = seff +
"_Fit";
832 stmp = chainName + triggerES[alg] +
"_L1" +
"_Turn_On_Curve_wrt_MuidSA";
833 stmpg = chainName + triggerES[alg] +
"_L1" +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
834 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
835 if (!h1num)
continue;
837 h1tmp = (TH1F*) h1den->Clone();
838 h1tmp->SetName(stmp);
839 h1tmp->SetTitle(stmp);
840 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
842 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
845 h1tmpg =
new TGraphAsymmErrors();
846 h1tmpg->SetName(stmpg);
847 h1tmpg->SetMarkerStyle(20);
848 h1tmpg->SetMinimum(0.0);
849 h1tmpg->SetMaximum(1.05);
850 h1tmpg->BayesDivide(h1num, h1den);
851 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
852 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
858 for (
int be = 0; be < 2; be++) {
859 sden = nd_dir + chainName + triggerES[ies] +
"_Turn_On_Curve_wrt_MuidSA" + bestr[be] +
"_Denominator";
860 snum = nd_dir + chainName + triggerES[ies] +
"_L2MuonSA" +
"_Turn_On_Curve_wrt" +
"_L1" + bestr[be] +
862 seff = eff_dir + chainName + triggerES[ies] +
"_L1" + bestr[be] +
"_Turn_On_Curve_wrt_MuidSA";
863 seffg = seff +
"_Fit";
864 stmp = chainName + triggerES[ies] +
"_L1" + bestr[be] +
"_Turn_On_Curve_wrt_MuidSA";
865 stmpg = chainName + triggerES[ies] +
"_L1" + bestr[be] +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
866 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
867 if (!h1num)
continue;
869 h1tmp = (TH1F*) h1den->Clone();
870 h1tmp->SetName(stmp);
871 h1tmp->SetTitle(stmp);
872 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
874 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
877 h1tmpg =
new TGraphAsymmErrors();
878 h1tmpg->SetName(stmpg);
879 h1tmpg->SetMarkerStyle(20);
880 h1tmpg->SetMinimum(0.0);
881 h1tmpg->SetMaximum(1.05);
882 h1tmpg->BayesDivide(h1num, h1den);
883 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
884 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
892 sden = nd_dir + chainName + triggerES[ies] +
"_Turn_On_Curve_wrt_MuidSA_Denominator";
893 snum = nd_dir + chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_Numerator";
894 seff = eff_dir + chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA";
895 seffg = seff +
"_Fit";
896 stmp = chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA";
897 stmpg = chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
898 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
899 if (!h1num)
continue;
901 h1tmp = (TH1F*) h1den->Clone();
902 h1tmp->SetName(stmp);
903 h1tmp->SetTitle(stmp);
904 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
906 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
909 h1tmpg =
new TGraphAsymmErrors();
910 h1tmpg->SetName(stmpg);
911 h1tmpg->SetMarkerStyle(20);
912 h1tmpg->SetMinimum(0.0);
913 h1tmpg->SetMaximum(1.05);
914 h1tmpg->BayesDivide(h1num, h1den);
915 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
916 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
921 if (0 == alg || 2 == alg) {
922 if (ESTAG == ies || ESINDEP == ies) {
923 double sumeff, sumerr;
924 double sumn = h1num->Integral(iMSL, iMSH);
925 double sumd = h1den->Integral(iMSL, iMSH);
930 sumeff = (double) sumn / (
double) sumd;
931 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (double) sumd;
935 iholx =
static_cast<int>(iL2MuonSA);
936 }
else if (2 == alg) {
937 iholx =
static_cast<int>(iEFSA);
941 TString s = eff_dir + chainName +
"_highpt_effsummary_by" + triggerES[ies];
942 h1sumeff = getHPointer(s);
943 if (!h1sumeff)
continue;
944 h1sumeff->GetYaxis()->SetTitleOffset(1.3);
945 h1sumeff->SetBinContent(iholx + 1, sumeff);
946 h1sumeff->SetBinError(iholx + 1, sumerr);
947 h1sumeff->SetMinimum(0.0);
948 h1sumeff->SetMaximum(1.05);
951 h1sumeff->Write(
"", TObject::kOverwrite);
958 if (0 == alg || 2 == alg) {
959 for (
int be = 0; be < 2; be++) {
961 sden = nd_dir + chainName +
"_Turn_On_Curve_wrt_MuidSA" + bestr[be] +
"_Denominator";
962 snum = nd_dir + chainName + alg2[alg] + bestr[be] +
"_Turn_On_Curve_Numerator";
963 seff = eff_dir + chainName + alg2[alg] + bestr[be] +
"_Turn_On_Curve_wrt_MuidSA";
964 seffg = seff +
"_Fit";
965 stmp = chainName + alg2[alg] + bestr[be] +
"_Turn_On_Curve_wrt_MuidSA";
966 stmpg = chainName + alg2[alg] + bestr[be] +
"_Turn_On_Curve_wrt_MuidSA" +
"_Fit";
967 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
968 if (!h1num)
continue;
970 h1tmp = (TH1F*) h1den->Clone();
971 h1tmp->SetName(stmp);
972 h1tmp->SetTitle(stmp);
973 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
975 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
978 h1tmpg =
new TGraphAsymmErrors();
979 h1tmpg->SetName(stmpg);
980 h1tmpg->SetMarkerStyle(20);
981 h1tmpg->SetMinimum(0.0);
982 h1tmpg->SetMaximum(1.05);
983 h1tmpg->BayesDivide(h1num, h1den);
984 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
985 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
993 sden = nd_dir + chainName + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg] +
"_Denominator";
994 snum = nd_dir + chainName + alg2[alg] +
"_Turn_On_Curve_Numerator";
995 seff = eff_dir + chainName + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg];
996 seffg = seff +
"_Fit";
997 stmp = chainName + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg];
998 stmpg = chainName + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg] +
"_Fit";
999 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1000 if (!h1num)
continue;
1002 h1tmp = (TH1F*) h1den->Clone();
1003 h1tmp->SetName(stmp);
1004 h1tmp->SetTitle(stmp);
1005 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
1007 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
1010 h1tmpg =
new TGraphAsymmErrors();
1011 h1tmpg->SetName(stmpg);
1012 h1tmpg->SetMarkerStyle(20);
1013 h1tmpg->SetMinimum(0.0);
1014 h1tmpg->SetMaximum(1.05);
1015 h1tmpg->BayesDivide(h1num, h1den);
1016 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1017 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1025 for (
int ies = 0; ies <= maxESbr; ies++) {
1026 if (!MS_mon_ESbr[ies])
continue;
1027 sden = nd_dir + chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg] +
1029 snum = nd_dir + chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_Numerator";
1030 seff = eff_dir + chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg];
1031 seffg = seff +
"_Fit";
1032 stmp = chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg];
1033 stmpg = chainName + triggerES[ies] + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg] +
"_Fit";
1034 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1035 if (!h1num)
continue;
1037 h1tmp = (TH1F*) h1den->Clone();
1038 h1tmp->SetName(stmp);
1039 h1tmp->SetTitle(stmp);
1040 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
1042 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
1045 h1tmpg =
new TGraphAsymmErrors();
1046 h1tmpg->SetName(stmpg);
1047 h1tmpg->SetMarkerStyle(20);
1048 h1tmpg->SetMinimum(0.0);
1049 h1tmpg->SetMaximum(1.05);
1050 h1tmpg->BayesDivide(h1num, h1den);
1051 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1052 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1059 if (0 == alg || 2 == alg) {
1060 for (
int be = 0; be < 2; be++) {
1062 sden = nd_dir + chainName + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg] + bestr[be] +
"_Denominator";
1063 snum = nd_dir + chainName + alg2[alg] + bestr[be] +
"_Turn_On_Curve_Numerator";
1064 seff = eff_dir + chainName + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg] + bestr[be];
1065 seffg = seff +
"_Fit";
1066 stmp = chainName + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg] + bestr[be];
1067 stmpg = chainName + alg2[alg] +
"_Turn_On_Curve_wrt" + wrtalg2[alg] + bestr[be] +
"_Fit";
1068 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1069 if (!h1num)
continue;
1071 h1tmp = (TH1F*) h1den->Clone();
1072 h1tmp->SetName(stmp);
1073 h1tmp->SetTitle(stmp);
1074 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
1076 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
1079 h1tmpg =
new TGraphAsymmErrors();
1080 h1tmpg->SetName(stmpg);
1081 h1tmpg->SetMarkerStyle(20);
1082 h1tmpg->SetMinimum(0.0);
1083 h1tmpg->SetMaximum(1.05);
1084 h1tmpg->BayesDivide(h1num, h1den);
1085 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1086 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1097 dir = mf.GetDirectory(rr_dir);
1100 std::cerr <<
"HLTMuonHistogramDivision: directory " << rr_dir <<
" not found" << std::endl;
1106 std::string
type[3] = {
1109 std::string off[3] = {
1110 "Moore_MS_",
"Moore_SA_",
"Muid_"
1112 std::string cut[2] = {
1116 for (
int itype = 0; itype < 3; itype++) {
1117 for (
int icut = 0; icut < 2; icut++) {
1118 seff = rr_dir +
"EF_" +
type[itype] +
"Over_" + off[itype] + cut[icut] +
"GeV_Cut";
1119 snum = rate_dir +
"Number_Of_EF_" +
type[itype] +
"Muons_" + cut[icut] +
"GeV_Cut";
1120 sden = rate_dir +
"Number_Of_" + off[itype] +
"Muons_" + cut[icut] +
"GeV_Cut";
1121 stmp =
"EF_" +
type[itype] +
"Over_" + off[itype] + cut[icut] +
"GeV_Cut";
1122 stmpg =
"EF_" +
type[itype] +
"Over_" + off[itype] + cut[icut] +
"GeV_Cut" +
"_Fit";
1123 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1124 if (!h1num)
continue;
1126 h1tmp = (TH1F*) h1den->Clone();
1127 h1tmp->SetName(stmp);
1128 h1tmp->SetTitle(stmp);
1129 h1tmp->GetYaxis()->SetTitle(
"Efficiency");
1131 h1tmp->Divide(h1num, h1den, 1., 1.,
"B");
1139 std::vector<TString> chains;
1140 std::vector<TString> chains2;
1143 std::map<std::string, std::string> ztpmap;
1145 ztpmap[
"muChain1"] =
"L1_MU15";
1146 ztpmap[
"muChain2"] =
"L1_MU15";
1147 ztpmap[
"muChainEFiso1"] =
"L1_MU15";
1148 ztpmap[
"muChainEFiso2"] =
"L1_MU15";
1149 ztpmap[
"muChainMSonly1"] =
"L1_MU15";
1150 ztpmap[
"muChainMSonly2"] =
"L1_MU15";
1152 std::map<std::string, int> ztp_isomap;
1153 ztp_isomap[
"muChain1"] = 0;
1154 ztp_isomap[
"muChain2"] = 0;
1155 ztp_isomap[
"muChainEFiso1"] = 1;
1156 ztp_isomap[
"muChainEFiso2"] = 1;
1157 ztp_isomap[
"muChainMSonly1"] = 0;
1158 ztp_isomap[
"muChainMSonly2"] = 0;
1160 for (std::map<std::string, std::string>::iterator itmap = ztpmap.begin(); itmap != ztpmap.end(); ++itmap) {
1161 TString histdirmuztp = run_dir +
"/HLT/MuonMon/MuZTP/" + itmap->first;
1162 TDirectory* ztpdir = mf.GetDirectory(histdirmuztp);
1163 bool isefisochain = ztp_isomap[itmap->first] > 0;
1166 std::vector<std::string> var;
1167 var.push_back(
"_Pt_");
1168 var.push_back(
"_Pt_EC_");
1169 var.push_back(
"_Pt_B_");
1170 var.push_back(
"_Pt_4bins_");
1171 var.push_back(
"_Pt_B_4bins_");
1172 var.push_back(
"_Eta_");
1173 var.push_back(
"_Phi_");
1174 var.push_back(
"_Phi_EC_");
1175 var.push_back(
"_Phi_B_");
1176 for (
unsigned int k = 0; k < var.size(); k++) {
1177 std::vector<std::string> level;
1178 level.push_back(
"L1");
1179 level.push_back(
"L2");
1180 level.push_back(
"EF");
1181 if (isefisochain) level.push_back(
"EFIso");
1182 for (
unsigned int j = 0; j < level.size(); j++) {
1184 seffg = histdirmuztp +
"/muZTP_eff_" + level[j] + var[k] + itmap->first;
1185 snum = histdirmuztp +
"/muZTP" + var[k] + level[j] +
"fired_" + itmap->first;
1186 sden = histdirmuztp +
"/muZTP" + var[k] + itmap->first;
1187 stmp =
"muZTP_eff_" + level[j] + var[k] + itmap->first;
1188 stmpg =
"muZTP_eff_" + level[j] + var[k] + itmap->first;
1189 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1190 if (!h1num)
continue;
1192 h1tmpg =
new TGraphAsymmErrors();
1193 h1tmpg->SetName(stmpg);
1194 h1tmpg->SetMarkerStyle(20);
1195 h1tmpg->SetMinimum(0.0);
1196 h1tmpg->SetMaximum(1.05);
1197 h1tmpg->BayesDivide(h1num, h1den);
1198 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1199 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1205 seffg = histdirmuztp +
"/muZTP_eff_" + level[j] +
"_Eta_1bin_" + itmap->first;
1206 snum = histdirmuztp +
"/muZTP_Eta_1bin_" + level[j] +
"fired_" + itmap->first;
1207 sden = histdirmuztp +
"/muZTP_Eta_1bin_" + itmap->first;
1208 stmpg =
"muZTP_eff_" + level[j] +
"_Eta_1bin_" + itmap->first;
1209 const auto & [h1num2, h1den2] = getHistogramPair(snum, sden);
1210 if (!h1num2)
continue;
1212 h1tmpg =
new TGraphAsymmErrors();
1213 h1tmpg->SetName(stmpg);
1214 h1tmpg->SetMarkerStyle(20);
1215 h1tmpg->SetMinimum(0.0);
1216 h1tmpg->SetMaximum(1.05);
1217 h1tmpg->BayesDivide(h1num2, h1den2);
1218 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1219 h1tmpg->GetXaxis()->SetTitle(h1den2->GetXaxis()->GetTitle());
1225 seffg = histdirmuztp +
"/muZTP_eff_" + level[j] +
"_Eta_2bins_" + itmap->first;
1226 snum = histdirmuztp +
"/muZTP_Eta_2bins_" + level[j] +
"fired_" + itmap->first;
1227 sden = histdirmuztp +
"/muZTP_Eta_2bins_" + itmap->first;
1228 stmpg =
"muZTP_eff_" + level[j] +
"_Eta_2bins_" + itmap->first;
1229 const auto & [h1num3, h1den3] = getHistogramPair(snum, sden);
1232 if (!h1num3)
continue;
1236 h1tmpg =
new TGraphAsymmErrors();
1237 h1tmpg->SetName(stmp);
1238 h1tmpg->SetMarkerStyle(20);
1239 h1tmpg->SetMinimum(0.0);
1240 h1tmpg->SetMaximum(1.05);
1241 h1tmpg->BayesDivide(h1num3, h1den3);
1242 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1243 h1tmpg->GetXaxis()->SetTitle(h1den3->GetXaxis()->GetTitle());
1249 seffg = histdirmuztp +
"/muZTP_eff_" + level[j] +
"_Eta_1bin_cut_" + itmap->first;
1250 snum = histdirmuztp +
"/muZTP_Eta_1bin_cut_" + level[j] +
"fired_" + itmap->first;
1251 sden = histdirmuztp +
"/muZTP_Eta_1bin_cut_" + itmap->first;
1252 stmpg =
"muZTP_eff_" + level[j] +
"_Eta_1bin_cut_" + itmap->first;
1253 const auto & [h1num4, h1den4] = getHistogramPair(snum, sden);
1254 if (!h1num4)
continue;
1256 h1tmpg =
new TGraphAsymmErrors();
1257 h1tmpg->SetName(stmpg);
1258 h1tmpg->SetMarkerStyle(20);
1259 h1tmpg->SetMinimum(0.0);
1260 h1tmpg->SetMaximum(1.05);
1261 h1tmpg->BayesDivide(h1num4, h1den4);
1262 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1263 h1tmpg->GetXaxis()->SetTitle(h1den4->GetXaxis()->GetTitle());
1269 seffg = histdirmuztp +
"/muZTP_eff_" + level[j] +
"_Eta_2bins_cut_" + itmap->first;
1270 snum = histdirmuztp +
"/muZTP_Eta_2bins_cut_" + level[j] +
"fired_" + itmap->first;
1271 sden = histdirmuztp +
"/muZTP_Eta_2bins_cut_" + itmap->first;
1272 stmpg =
"muZTP_eff_" + level[j] +
"_Eta_2bins_cut_" + itmap->first;
1273 const auto & [h1num5, h1den5] = getHistogramPair(snum, sden);
1274 if (!h1num5)
continue;
1276 h1tmpg =
new TGraphAsymmErrors();
1277 h1tmpg->SetName(stmpg);
1278 h1tmpg->SetMarkerStyle(20);
1279 h1tmpg->SetMinimum(0.0);
1280 h1tmpg->SetMaximum(1.05);
1281 h1tmpg->BayesDivide(h1num5, h1den5);
1282 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1283 h1tmpg->GetXaxis()->SetTitle(h1den5->GetXaxis()->GetTitle());
1290 seff = histdirmuztp +
"/muZTP_eff_EtaPhi_" + level[j] +
"_" + itmap->first;
1291 snum = histdirmuztp +
"/muZTP_EtaPhi_" + level[j] +
"_" + itmap->first;
1292 sden = histdirmuztp +
"/muZTP_EtaPhi_all_" + itmap->first;
1293 stmp =
"muZTP_eff_EtaPhi_" + level[j] +
"_" + itmap->first;
1299 h2num = getH2Pointer(snum);
1300 if (!h2num)
continue;
1301 h2den = getH2Pointer(sden);
1302 if (!h2den)
continue;
1304 h2tmp = (TH2F*) h1den->Clone();
1305 h2tmp->SetName(stmp);
1306 h2tmp->SetTitle(stmp);
1307 h2tmp->GetYaxis()->SetTitle(
"Efficiency");
1309 h2tmp->Divide(h1num, h1den, 1., 1.,
"B");
1316 seffg = histdirmuztp +
"/muZTP_eff_EFwrtL2" + var[k] + itmap->first;
1317 snum = histdirmuztp +
"/muZTP" + var[k] +
"EFL2fired_" + itmap->first;
1318 sden = histdirmuztp +
"/muZTP" + var[k] +
"L2fired_" + itmap->first;
1319 stmpg =
"muZTP_eff_EFwrtL2" + var[k] + itmap->first;
1320 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1321 if (!h1num)
continue;
1323 h1tmpg =
new TGraphAsymmErrors();
1324 h1tmpg->SetName(stmpg);
1325 h1tmpg->SetMarkerStyle(20);
1326 h1tmpg->SetMinimum(0.0);
1327 h1tmpg->SetMaximum(1.05);
1328 h1tmpg->BayesDivide(h1num, h1den);
1329 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1330 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1336 seffg = histdirmuztp +
"/muZTP_eff_EFwrtL1" + var[k] + itmap->first;
1337 snum = histdirmuztp +
"/muZTP" + var[k] +
"EFfired_" + itmap->first;
1338 sden = histdirmuztp +
"/muZTP" + var[k] +
"L1fired_" + itmap->first;
1339 stmpg =
"muZTP_eff_EFwrtL1" + var[k] + itmap->first;
1340 const auto & [h1num2, h1den2] = getHistogramPair(snum, sden);
1341 if (!h1num2)
continue;
1343 h1tmpg =
new TGraphAsymmErrors();
1344 h1tmpg->SetName(stmpg);
1345 h1tmpg->SetMarkerStyle(20);
1346 h1tmpg->SetMinimum(0.0);
1347 h1tmpg->SetMaximum(1.05);
1348 h1tmpg->BayesDivide(h1num2, h1den2);
1349 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1350 h1tmpg->GetXaxis()->SetTitle(h1den2->GetXaxis()->GetTitle());
1356 seffg = histdirmuztp +
"/muZTP_eff_L2wrtL1" + var[k] + itmap->first;
1357 snum = histdirmuztp +
"/muZTP" + var[k] +
"L2fired_" + itmap->first;
1358 sden = histdirmuztp +
"/muZTP" + var[k] +
"L1fired_" + itmap->first;
1359 stmpg =
"muZTP_eff_L2wrtL1" + var[k] + itmap->first;
1360 const auto & [h1num3, h1den3] = getHistogramPair(snum, sden);
1361 if (!h1num3)
continue;
1363 h1tmpg =
new TGraphAsymmErrors();
1364 h1tmpg->SetName(stmpg);
1365 h1tmpg->SetMarkerStyle(20);
1366 h1tmpg->SetMinimum(0.0);
1367 h1tmpg->SetMaximum(1.05);
1368 h1tmpg->BayesDivide(h1num3, h1den3);
1369 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1370 h1tmpg->GetXaxis()->SetTitle(h1den3->GetXaxis()->GetTitle());
1377 seffg = histdirmuztp +
"/muZTP_eff_EFIsowrtEF" + var[k] + itmap->first;
1378 snum = histdirmuztp +
"/muZTP" + var[k] +
"EFIsofired_" + itmap->first;
1379 sden = histdirmuztp +
"/muZTP" + var[k] +
"EFfired_" + itmap->first;
1380 stmpg =
"muZTP_eff_EFIsowrtEF" + var[k] + itmap->first;
1381 const auto & [h1num, h1den] = getHistogramPair(snum, sden);
1382 if (!h1num)
continue;
1384 h1tmpg =
new TGraphAsymmErrors();
1385 h1tmpg->SetName(stmpg);
1386 h1tmpg->SetMarkerStyle(20);
1387 h1tmpg->SetMinimum(0.0);
1388 h1tmpg->SetMaximum(1.05);
1389 h1tmpg->BayesDivide(h1num, h1den);
1390 h1tmpg->GetYaxis()->SetTitle(
"Efficiency");
1391 h1tmpg->GetXaxis()->SetTitle(h1den->GetXaxis()->GetTitle());
1404 TDirectory* efdir = mf.GetDirectory(eff_dir);
1407 std::cerr <<
"HLTMuonHistogramDivision: directory " << eff_dir <<
" not found" << std::endl;
1413 const int MAXARR = 6;
1414 std::string charr[MAXARR] = {
1415 "muChain1",
"muChain2",
"muChainEFiso1",
"muChainEFiso2",
"muChainMSonly1",
"muChainMSonly2"
1417 std::string monarr[MAXARR] = {
1418 "_EFmuon",
"_EFmuon",
"_EFmuon",
"_EFmuon",
"_MuonEFSA",
"_MuonEFSA"
1420 std::string monL2arr[MAXARR] = {
1421 "_L2MuonSA",
"_L2MuonSA",
"_L2MuonSA",
"_L2MuonSA",
"_L2MuonSA",
"_L2MuonSA"
1423 bool isBarrelMon[MAXARR] = {
1424 false,
false,
false,
false,
true,
true
1426 bool isMSbMon[MAXARR] = {
1427 true,
true,
false,
false,
false,
false
1429 bool monL1[MAXARR] = {
1430 true,
true,
true,
true,
false,
false
1432 bool isefIsolation[MAXARR] = {
1433 false,
false,
true,
true,
false,
false
1437 for (
int ialg = 0; ialg < MAXARR; ialg++) {
1438 std::string chainName = charr[ialg];
1439 std::string MoniAlg = monarr[ialg];
1440 std::string MoniL2Alg = monL2arr[ialg];
1443 TString hdirztp = muon_dir +
"MuZTP/" + chainName +
"/";
1444 TString histZtpNum, histZtpDen;
1445 if (!isBarrelMon[ialg]) {
1446 histZtpNum = hdirztp +
"muZTP_Pt_4bins_EFfired_" + chainName;
1447 histZtpDen = hdirztp +
"muZTP_Pt_4bins_L1fired_" + chainName;
1449 histZtpNum = hdirztp +
"muZTP_Pt_B_4bins_EFfired_" + chainName;
1450 histZtpDen = hdirztp +
"muZTP_Pt_B_4bins_L1fired_" + chainName;
1452 if (isefIsolation[ialg]) histZtpNum = hdirztp +
"muZTP_Pt_4bins_EFIsofired_" + chainName;
1453 TString histZtpEff = eff_dir + chainName +
"_highpt3bins_effwrtL1";
1454 const auto & [h1num, h1den] = getHistogramPair(histZtpNum, histZtpDen);
1455 if (!h1num)
continue;
1456 h1eff = getHPointer(histZtpEff);
1457 if (!h1eff)
continue;
1460 for (
int ibin = 2; ibin <= 3; ibin++) {
1462 double sumeff {}, sumerr {};
1463 double sumn = h1num->Integral(ibin, ibin);
1464 if (isBarrelMon[ialg] || isMSbMon[ialg]) sumn = h1num->Integral(ibin + 1, ibin + 1);
1465 double sumd = h1den->Integral(ibin, ibin);
1466 if (isBarrelMon[ialg] || isMSbMon[ialg]) sumd = h1den->Integral(ibin + 1, ibin + 1);
1468 sumeff = (double) sumn / (
double) sumd;
1469 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (double) sumd;
1471 h1eff->GetYaxis()->SetTitle(
"Efficiency");
1472 h1eff->SetBinContent(ibin - 1, sumeff);
1473 h1eff->SetBinError(ibin - 1, sumerr);
1474 h1eff->SetMinimum(0.0);
1475 h1eff->SetMaximum(1.05);
1481 h1eff->Write(
"", TObject::kOverwrite);
1484 TString hdirztp = muon_dir +
"MuZTP/" + chainName +
"/";
1485 TString histZtpNumB = hdirztp +
"muZTP_Pt_B_L1fired_" + chainName;
1486 TString histZtpDenB = hdirztp +
"muZTP_Pt_B_" + chainName;
1487 TString histZtpNumE = hdirztp +
"muZTP_Pt_EC_L1fired_" + chainName;
1488 TString histZtpDenE = hdirztp +
"muZTP_Pt_EC_" + chainName;
1489 TString histZtpL1sum = eff_dir + chainName +
"_highptL1plateau_wrtOffline";
1491 TH1F* h1numb = getHPointer(histZtpNumB);
1492 if (!h1numb)
continue;
1493 TH1F* h1nume = getHPointer(histZtpNumE);
1494 if (!h1nume)
continue;
1495 TH1F* h1denb = getHPointer(histZtpDenB);
1496 if (!h1denb)
continue;
1497 TH1F* h1dene = getHPointer(histZtpDenE);
1498 if (!h1dene)
continue;
1499 TH1F* h1sumL = getHPointer(histZtpL1sum);
1500 if (!h1sumL)
continue;
1502 double sumeff, sumerr;
1503 double sumn = h1numb->Integral(13, 25);
1504 if (HI_pp_key) sumn = h1numb->Integral(13, 20);
1505 double sumd = h1denb->Integral(13, 25);
1506 if (HI_pp_key) sumd = h1denb->Integral(13, 20);
1511 sumeff = (double) sumn / (
double) sumd;
1512 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (double) sumd;
1514 h1sumL->SetBinContent(1, sumeff);
1515 h1sumL->SetBinError(1, sumerr);
1517 sumn = h1nume->Integral(13, 25);
1518 if (HI_pp_key) sumn = h1numb->Integral(13, 20);
1519 sumd = h1dene->Integral(13, 25);
1520 if (HI_pp_key) sumd = h1denb->Integral(13, 20);
1525 sumeff = (double) sumn / (
double) sumd;
1526 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (double) sumd;
1528 h1sumL->GetYaxis()->SetTitle(
"Efficiency");
1529 h1sumL->SetBinContent(2, sumeff);
1530 h1sumL->SetBinError(2, sumerr);
1531 h1sumL->SetMinimum(0.0);
1532 h1sumL->SetMaximum(1.05);
1534 h1sumL->Write(
"", TObject::kOverwrite);
1544 TString monalg[3] = {
1545 "_L2MuonSA",
"_MuComb",
"_EFmuon"
1547 TString wrtalg[3] = {
1548 "_L1",
"_L2MuonSA",
"_MuComb"
1550 TString numer, denom, effi;
1551 TString histdireff = eff_dir;
1553 TDirectory* efdir = mf.GetDirectory(eff_dir);
1556 std::cerr <<
"HLTMuonHistogramDivision: directory " << eff_dir <<
" not found" << std::endl;
1562 chainsGeneric.insert(chainsGeneric.end(), chainsEFiso.begin(), chainsEFiso.end());
1564 for (
unsigned int i = 0; i < chainsGeneric.size(); i++) {
1565 TString chainName = chainsGeneric.at(i);
1567 std::cout <<
"proc generic " << chainName << std::endl;
1571 for (
int alg = 0; alg < 3; alg++) {
1572 denom = chainName +
"_Turn_On_Curve_wrt_MuidCB_Denominator";
1573 numer = chainName + monalg[alg] +
"_Turn_On_Curve_Numerator";
1574 effi = chainName + monalg[alg] +
"_Turn_On_Curve_wrt_MuidCB";
1575 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1577 denom = chainName + MSchainName +
"_Turn_On_Curve_wrt_MuidCB_Denominator";
1578 numer = chainName + MSchainName + monalg[alg] +
"_Turn_On_Curve_Numerator";
1579 effi = chainName + MSchainName + monalg[alg] +
"_Turn_On_Curve_wrt_MuidCB";
1580 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1584 denom = chainName + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg] +
"_Denominator";
1585 numer = chainName + monalg[alg] +
"_Turn_On_Curve_Numerator";
1586 effi = chainName + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg];
1587 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1590 denom = chainName + MSchainName + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg] +
"_Denominator";
1591 numer = chainName + MSchainName + monalg[alg] +
"_Turn_On_Curve_Numerator";
1592 effi = chainName + MSchainName + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg];
1593 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1596 for (
int i = 0; i <= maxESbr; i++) {
1597 if (!CB_mon_ESbr[i])
continue;
1601 denom = chainName + triggerES[i] +
"_Turn_On_Curve_wrt_MuidCB_Denominator";
1602 numer = chainName + triggerES[i] +
"_L2MuonSA" +
"_Turn_On_Curve_wrt" +
"_L1" +
"_Denominator";
1603 effi = chainName + triggerES[i] +
"_L1" +
"_Turn_On_Curve_wrt_MuidCB";
1604 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1607 for (
int be = 0; be < 2; be++) {
1608 denom = chainName + triggerES[i] +
"_Turn_On_Curve_wrt_MuidCB" + bestr[be] +
"_Denominator";
1609 numer = chainName + triggerES[i] +
"_L2MuonSA" +
"_Turn_On_Curve_wrt" +
"_L1" + bestr[be] +
1611 effi = chainName + triggerES[i] +
"_L1" + bestr[be] +
"_Turn_On_Curve_wrt_MuidCB";
1612 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1613 const auto & [h1num, h1den] = getHistogramPair(nd_dir + numer, nd_dir + denom);
1614 if (!h1num)
continue;
1618 double sumeff {}, sumerr {};
1619 double sumn = h1num->Integral(iSTDL, iSTDH);
1620 double sumd = h1den->Integral(iSTDL, iSTDH);
1623 sumeff = (double) sumn / (
double) sumd;
1624 sumerr = sqrt((
double) sumn * (1. - sumeff)) / (double) sumd;
1627 TString s = histdireff + chainName +
"_L1plateau_wrtOffline_by_ESindep";
1628 TH1F* h1effL1 = getHPointer(s);
1629 if (!h1effL1)
continue;
1630 h1effL1->SetBinContent(be + 1, sumeff);
1631 h1effL1->SetBinError(be + 1, sumerr);
1632 h1eff->SetMinimum(0.0);
1633 h1eff->SetMaximum(1.05);
1635 h1effL1->Write(
"", TObject::kOverwrite);
1640 denom = chainName + triggerES[i] +
"_Turn_On_Curve_wrt_MuidCB_Denominator";
1641 numer = chainName + triggerES[i] + monalg[alg] +
"_Turn_On_Curve_Numerator";
1642 effi = chainName + triggerES[i] + monalg[alg] +
"_Turn_On_Curve_wrt_MuidCB";
1643 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1644 const auto & [h1num, h1den] = getHistogramPair(nd_dir + numer, nd_dir + denom);
1648 if (!h1num)
continue;
1649 if (0 == alg || 1 == alg || 2 == alg) {
1650 double sumd {}, sumn {}, sumeff {}, sumerr {};
1651 sumn = h1num->Integral(iSTDL, iSTDH);
1652 sumd = h1den->Integral(iSTDL, iSTDH);
1655 sumeff = (double) sumn / (
double) sumd;
1656 sumerr = std::sqrt((
double) sumn * (1. - sumeff)) / (double) sumd;
1660 iholx =
static_cast<int>(iL2MuonSA);
1661 }
else if (1 == alg) {
1662 iholx =
static_cast<int>(iMuComb);
1663 }
else if (2 == alg) {
1664 iholx =
static_cast<int>(iEFCB);
1667 TString s = histdireff + chainName +
"_highpt_effsummary_by" + triggerES[i];
1668 h1effsum = getHPointer(s);
1669 if (!h1effsum)
continue;
1671 h1effsum->GetYaxis()->SetTitleOffset(1.3);
1672 h1effsum->SetBinContent(iholx + 1, sumeff);
1673 h1effsum->SetBinError(iholx + 1, sumerr);
1674 h1effsum->SetMinimum(0.0);
1675 h1effsum->SetMaximum(1.05);
1677 h1effsum->Write(
"", TObject::kOverwrite);
1680 denom = chainName + triggerES[i] + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg] +
"_Denominator";
1681 numer = chainName + triggerES[i] + monalg[alg] +
"_Turn_On_Curve_Numerator";
1682 effi = chainName + triggerES[i] + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg];
1683 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1688 if (0 == alg || 1 == alg || 2 == alg) {
1689 for (
int be = 0; be < 2; be++) {
1690 denom = chainName +
"_Turn_On_Curve_wrt_MuidCB" + bestr[be] +
"_Denominator";
1691 numer = chainName + monalg[alg] + bestr[be] +
"_Turn_On_Curve_Numerator";
1692 effi = chainName + monalg[alg] + bestr[be] +
"_Turn_On_Curve_wrt_MuidCB";
1693 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1696 for (
int be = 0; be < 2; be++) {
1697 denom = chainName + MSchainName +
"_Turn_On_Curve_wrt_MuidCB" + bestr[be] +
"_Denominator";
1698 numer = chainName + MSchainName + monalg[alg] + bestr[be] +
"_Turn_On_Curve_Numerator";
1699 effi = chainName + MSchainName + monalg[alg] + bestr[be] +
"_Turn_On_Curve_wrt_MuidCB";
1700 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1703 for (
int be = 0; be < 2; be++) {
1704 denom = chainName + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg] + bestr[be] +
"_Denominator";
1705 numer = chainName + monalg[alg] + bestr[be] +
"_Turn_On_Curve_Numerator";
1706 effi = chainName + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg] + bestr[be];
1707 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");
1711 for (
int be = 0; be < 2; be++) {
1712 denom = chainName + MSchainName + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg] + bestr[be] +
1714 numer = chainName + MSchainName + monalg[alg] + bestr[be] +
"_Turn_On_Curve_Numerator";
1715 effi = chainName + MSchainName + monalg[alg] +
"_Turn_On_Curve_wrt" + wrtalg[alg] + bestr[be];
1716 HLTMuonHDiv(mf, histdireff, numer, denom, effi,
"_Fit");