11 #include <initializer_list>
45 #include "TLorentzVector.h"
66 vector<LeafCandidate> &from,
67 vector<LeafCandidate> &
to,
68 double deltaRMatchingCut,
72 vector<double> &
xBins,
74 vector<double> &
yBins,
79 vector<double> &
xBins,
81 vector<double> &
yBins,
87 vector<double> &
xBins,
89 vector<double> &
yBins,
94 vector<double> &
xBins,
96 vector<double> &
yBins,
142 map<TString, MonitorElement *>
ME;
150 triggerProcessName(
pset.getUntrackedParameter<
string>(
"TriggerProcessName")),
151 triggerPathName(
pset.getUntrackedParameter<
string>(
"TriggerPathName")),
152 motherIDs(
pset.getUntrackedParameter<
vector<
int> >(
"MotherIDs")),
153 genGlobDeltaRMatchingCut(
pset.getUntrackedParameter<double>(
"GenGlobDeltaRMatchingCut")),
154 globL1DeltaRMatchingCut(
pset.getUntrackedParameter<double>(
"GlobL1DeltaRMatchingCut")),
155 globL2DeltaRMatchingCut(
pset.getUntrackedParameter<double>(
"GlobL2DeltaRMatchingCut")),
156 globL3DeltaRMatchingCut(
pset.getUntrackedParameter<double>(
"GlobL3DeltaRMatchingCut")),
157 deltaEtaBins(
pset.getUntrackedParameter<
vector<double> >(
"DeltaEtaBins")),
158 deltaPhiBins(
pset.getUntrackedParameter<
vector<double> >(
"DeltaPhiBins")),
159 muonPtBins(
pset.getUntrackedParameter<
vector<double> >(
"MuonPtBins")),
160 muonEtaBins(
pset.getUntrackedParameter<
vector<double> >(
"MuonEtaBins")),
161 muonPhiBins(
pset.getUntrackedParameter<
vector<double> >(
"MuonPhiBins")),
162 dimuonPtBins(
pset.getUntrackedParameter<
vector<double> >(
"DimuonPtBins")),
163 dimuonEtaBins(
pset.getUntrackedParameter<
vector<double> >(
"DimuonEtaBins")),
164 dimuonDRBins(
pset.getUntrackedParameter<
vector<double> >(
"DimuonDRBins")),
183 LogDebug(
"HLTriggerOfflineHeavyFlavor")
184 <<
"Successfully initialized HLTConfigProvider with process name: " <<
triggerProcessName << endl;
187 <<
"Could not initialize HLTConfigProvider with process name: " <<
triggerProcessName << endl;
232 TString::Format(
"filt%dMuon_recoEtaPt",
int(
i + 1)),
245 TString::Format(
"resFilt%dGlob_recoEtaPt",
int(
i + 1)),
260 TString::Format(
"filt%dDimuon_recoEtaPt",
int(
i + 1)),
272 TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
i + 1)),
287 TString::Format(
"filt%dMuon_recoEtaPhi",
int(
i + 1)),
302 TString::Format(
"filt%dDimuon_recoRapPt",
int(
i + 1)),
310 "pathDimuon_recoRapPt",
319 TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
i + 1)),
327 "diPathDimuon_recoRapPt",
339 TString::Format(
"filt%dDimuon_recoPtDR",
int(
i + 1)),
343 "#mu#mu #Delta R at IP",
347 "pathDimuon_recoPtDR",
351 "#mu#mu #Delta R at IP",
355 TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
i + 1)),
359 "#mu#mu #Delta R at IP",
363 "diPathDimuon_recoPtDR",
367 "#mu#mu #Delta R at IP",
374 TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
i + 1)),
378 "#mu#mu #Delta R in MS",
382 "pathDimuon_recoPtDRpos",
386 "#mu#mu #Delta R in MS",
390 TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
i + 1)),
394 "#mu#mu #Delta R in MS",
398 "diPathDimuon_recoPtDRpos",
402 "#mu#mu #Delta R in MS",
411 TString::Format(
"filt%dGlob_deltaEtaDeltaPhi",
int(
i + 1)),
421 vector<double> sizeBins;
422 sizeBins.push_back(10);
423 sizeBins.push_back(0);
424 sizeBins.push_back(10);
425 myBook1D(ibooker,
"genMuon_size", sizeBins,
"container size");
426 myBook1D(ibooker,
"globMuon_size", sizeBins,
"container size");
444 if (
p->status() == 1 &&
std::abs(
p->pdgId()) == 13 &&
451 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not access GenParticleCollection" << endl;
455 LogDebug(
"HLTriggerOfflineHeavyFlavor")
458 vector<LeafCandidate> globMuons;
459 vector<LeafCandidate> globMuons_position;
462 if (recoMuonsHandle.
isValid()) {
463 for (MuonCollection::const_iterator
p = recoMuonsHandle->begin();
p != recoMuonsHandle->end(); ++
p) {
464 if (
p->isGlobalMuon()) {
465 globMuons.push_back(*
p);
468 p->outerTrack()->innerPosition().y(),
469 p->outerTrack()->innerPosition().z(),
474 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not access reco Muons" << endl;
476 ME[
"globMuon_size"]->Fill(globMuons.size());
477 LogDebug(
"HLTriggerOfflineHeavyFlavor")
478 <<
"Global Muons from " <<
recoMuonsTag <<
" has size: " << globMuons.size() << endl;
481 vector<vector<LeafCandidate> > muonsAtFilter;
482 vector<vector<LeafCandidate> > muonPositionsAtFilter;
484 muonsAtFilter.push_back(vector<LeafCandidate>());
485 muonPositionsAtFilter.push_back(vector<LeafCandidate>());
489 if (rawTriggerEvent.
isValid()) {
492 if (index < rawTriggerEvent->
size()) {
494 vector<L1MuonParticleRef> l1Cands;
496 for (
size_t j = 0;
j < l1Cands.size();
j++) {
497 muonsAtFilter[
i].push_back(*l1Cands[
j]);
500 vector<RecoChargedCandidateRef> hltCands;
502 for (
size_t j = 0;
j < hltCands.size();
j++) {
503 muonsAtFilter[
i].push_back(*hltCands[
j]);
505 muonPositionsAtFilter[
i].push_back(
508 hltCands[
j]->
track()->innerPosition().
y(),
509 hltCands[
j]->
track()->innerPosition().
z(),
515 ME[TString::Format(
"filt%dMuon_size",
int(
i + 1))]->Fill(muonsAtFilter[
i].
size());
516 LogDebug(
"HLTriggerOfflineHeavyFlavor")
517 <<
"Filter \"" <<
filterNamesLevels[
i].first <<
"\" has " << muonsAtFilter[
i].size() <<
" muons" << endl;
520 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not access RAWTriggerEvent" << endl;
524 vector<LeafCandidate> pathMuons;
527 if (aodTriggerEvent.
isValid()) {
532 for (
size_t j = 0;
j <
keys.size();
j++) {
534 allObjects[
keys[
j]].
id() > 0 ? 1 : -1,
540 ME[
"pathMuon_size"]->Fill(pathMuons.size());
541 LogDebug(
"HLTriggerOfflineHeavyFlavor")
542 <<
"Path \"" <<
triggerPathName <<
"\" has " << pathMuons.size() <<
" muons at last filter \""
545 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not access AODTriggerEvent" << endl;
549 bool triggerFired =
false;
555 bool hlt_exists =
false;
572 vector<int> glob_gen(
genMuons.size(), -1);
574 vector<vector<int> > filt_glob;
576 filt_glob.push_back(vector<int>(globMuons.size(), -1));
578 match(
ME[TString::Format(
"filt%dGlob_deltaEtaDeltaPhi",
int(
i + 1))],
584 match(
ME[TString::Format(
"filt%dGlob_deltaEtaDeltaPhi",
int(
i + 1))],
586 muonPositionsAtFilter[
i],
590 match(
ME[TString::Format(
"filt%dGlob_deltaEtaDeltaPhi",
int(
i + 1))],
597 vector<int> path_glob(globMuons.size(), -1);
611 if (glob_gen[
i] != -1) {
612 ME[
"resGlobGen_genEtaPt"]->Fill(
616 ME[
"globMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
617 ME[
"globMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
619 if (filt_glob[
f][glob_gen[
i]] != -1) {
620 ME[TString::Format(
"resFilt%dGlob_recoEtaPt",
int(
f + 1))]->Fill(
621 globMuons[glob_gen[
i]].
eta(),
622 globMuons[glob_gen[
i]].
pt(),
623 (muonsAtFilter[
f][filt_glob[
f][glob_gen[
i]]].
pt() - globMuons[glob_gen[
i]].
pt()) /
624 globMuons[glob_gen[
i]].
pt());
625 ME[TString::Format(
"filt%dMuon_recoEtaPt",
int(
f + 1))]->Fill(globMuons[glob_gen[
i]].
eta(),
626 globMuons[glob_gen[
i]].
pt());
627 ME[TString::Format(
"filt%dMuon_recoEtaPhi",
int(
f + 1))]->Fill(globMuons[glob_gen[
i]].
eta(),
628 globMuons[glob_gen[
i]].
phi());
633 if (path_glob[glob_gen[
i]] != -1) {
634 ME[
"resPathGlob_recoEtaPt"]->Fill(
635 globMuons[glob_gen[
i]].
eta(),
636 globMuons[glob_gen[
i]].
pt(),
637 (pathMuons[path_glob[glob_gen[
i]]].
pt() - globMuons[glob_gen[
i]].
pt()) / globMuons[glob_gen[
i]].
pt());
638 ME[
"pathMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
639 ME[
"pathMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
645 ME[
"resultMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
646 ME[
"resultMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
660 if (secondMuon > 0) {
664 double genDimuonRap = (
genMuons[0].p4() +
genMuons[secondMuon].p4()).Rapidity();
665 double genDimuonDR = deltaR<LeafCandidate, LeafCandidate>(
genMuons[0],
genMuons[secondMuon]);
667 ME[
"genDimuon_genEtaPt"]->Fill(genDimuonEta, genDimuonPt);
668 ME[
"genDimuon_genRapPt"]->Fill(genDimuonRap, genDimuonPt);
670 ME[
"genDimuon_genPtDR"]->Fill(genDimuonPt, genDimuonDR);
672 if (glob_gen[0] != -1 && glob_gen[secondMuon] != -1) {
673 ME[
"globDimuon_genEtaPt"]->Fill(genDimuonEta, genDimuonPt);
674 ME[
"globDimuon_genRapPt"]->Fill(genDimuonRap, genDimuonPt);
676 ME[
"globDimuon_genPtDR"]->Fill(genDimuonPt, genDimuonDR);
677 double globDimuonPt = (globMuons[glob_gen[0]].p4() + globMuons[glob_gen[secondMuon]].p4()).
pt();
678 double globDimuonEta = (globMuons[glob_gen[0]].p4() + globMuons[glob_gen[secondMuon]].p4()).
eta();
679 double globDimuonRap = (globMuons[glob_gen[0]].p4() + globMuons[glob_gen[secondMuon]].p4()).Rapidity();
680 double globDimuonDR =
681 deltaR<LeafCandidate, LeafCandidate>(globMuons[glob_gen[0]], globMuons[glob_gen[secondMuon]]);
682 double globDimuonDRpos = deltaR<LeafCandidate, LeafCandidate>(globMuons_position[glob_gen[0]],
683 globMuons_position[glob_gen[secondMuon]]);
684 ME[
"globDimuon_recoEtaPt"]->Fill(globDimuonEta, globDimuonPt);
685 ME[
"globDimuon_recoRapPt"]->Fill(globDimuonRap, globDimuonPt);
687 ME[
"globDimuon_recoPtDR"]->Fill(globDimuonPt, globDimuonDR);
689 ME[
"globDimuon_recoPtDRpos"]->Fill(globDimuonPt, globDimuonDRpos);
692 if (filt_glob[
f][glob_gen[0]] != -1 && filt_glob[
f][glob_gen[secondMuon]] != -1) {
693 ME[TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
f + 1))]->Fill(globDimuonEta, globDimuonPt);
694 ME[TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
f + 1))]->Fill(globDimuonRap, globDimuonPt);
696 ME[TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
f + 1))]->Fill(globDimuonPt, globDimuonDR);
698 ME[TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
f + 1))]->Fill(globDimuonPt, globDimuonDRpos);
705 if (filt_glob[
f][glob_gen[0]] != -1 || filt_glob[
f][glob_gen[secondMuon]] != -1) {
706 ME[TString::Format(
"filt%dDimuon_recoEtaPt",
int(
f + 1))]->Fill(globDimuonEta, globDimuonPt);
707 ME[TString::Format(
"filt%dDimuon_recoRapPt",
int(
f + 1))]->Fill(globDimuonRap, globDimuonPt);
709 ME[TString::Format(
"filt%dDimuon_recoPtDR",
int(
f + 1))]->Fill(globDimuonPt, globDimuonDR);
711 ME[TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
f + 1))]->Fill(globDimuonPt, globDimuonDRpos);
717 if (path_glob[glob_gen[0]] != -1 && path_glob[glob_gen[secondMuon]] != -1) {
718 ME[
"diPathDimuon_recoEtaPt"]->Fill(globDimuonEta, globDimuonPt);
719 ME[
"diPathDimuon_recoRapPt"]->Fill(globDimuonRap, globDimuonPt);
721 ME[
"diPathDimuon_recoPtDR"]->Fill(globDimuonPt, globDimuonDR);
723 ME[
"diPathDimuon_recoPtDRpos"]->Fill(globDimuonPt, globDimuonDRpos);
726 if (path_glob[glob_gen[0]] != -1 || path_glob[glob_gen[secondMuon]] != -1) {
727 ME[
"pathDimuon_recoEtaPt"]->Fill(globDimuonEta, globDimuonPt);
728 ME[
"pathDimuon_recoRapPt"]->Fill(globDimuonRap, globDimuonPt);
730 ME[
"pathDimuon_recoPtDR"]->Fill(globDimuonPt, globDimuonDR);
732 ME[
"pathDimuon_recoPtDRpos"]->Fill(globDimuonPt, globDimuonDRpos);
736 ME[
"resultDimuon_recoEtaPt"]->Fill(globDimuonEta, globDimuonPt);
737 ME[
"resultDimuon_recoRapPt"]->Fill(globDimuonRap, globDimuonPt);
739 ME[
"resultDimuon_recoPtDR"]->Fill(globDimuonPt, globDimuonDR);
741 ME[
"resultDimuon_recoPtDRpos"]->Fill(globDimuonPt, globDimuonDRpos);
750 if (mother->
pdgId() ==
p->pdgId()) {
753 return mother->
pdgId();
761 vector<LeafCandidate> &from,
762 vector<LeafCandidate> &
to,
763 double dRMatchingCut,
765 vector<double>
dR(from.size());
766 for (
size_t i = 0;
i < from.size();
i++) {
770 for (
size_t j = 0;
j <
to.size();
j++) {
782 if (
dR[
i] > dRMatchingCut) {
787 for (
size_t k = 0;
k <
i;
k++) {
810 Double_t *
pt =
new Double_t[ptN];
811 for (
int i = 0;
i < ptN;
i++) {
815 Double_t *
eta =
new Double_t[etaN];
816 for (
int i = 0;
i < etaN;
i++) {
820 h->SetXTitle(ptLabel);
821 h->SetYTitle(etaLabel);
836 Double_t *
pt =
new Double_t[ptN];
837 for (
int i = 0;
i < ptN;
i++) {
841 Double_t *
eta =
new Double_t[etaN];
842 for (
int i = 0;
i < etaN;
i++) {
845 TProfile2D *
h =
new TProfile2D(
name,
name, ptN - 1,
pt, etaN - 1,
eta);
846 h->SetXTitle(ptLabel);
847 h->SetYTitle(etaLabel);
857 Double_t *myBins =
new Double_t[binsN];
858 for (
int i = 0;
i < binsN;
i++) {
861 TH1F *
h =
new TH1F(
name,
name, binsN - 1, myBins);
871 return s.find(sub) != std::string::npos;
875 const auto containsAny = [](
const std::string &
s,
const std::vector<std::string> &subs) ->
bool {
876 for (
const auto &sub : subs) {
877 if (
s.find(sub) != std::string::npos)
884 const auto isAnyOf = [](
const std::string &
s,
const std::vector<std::string> &ms) ->
bool {
885 for (
const auto &
m : ms) {
901 const std::string l2Filter =
"HLTMuonL2FromL1TPreFilter";
902 const std::vector<std::string> l3Filters = {
"HLTMuonDimuonL3Filter",
"HLTMuonL3PreFilter"};
903 const std::vector<std::string> l4Filters = {
904 "HLTDisplacedmumuFilter",
"HLTDiMuonGlbTrkFilter",
"HLTMuonTrackMassFilter"};
905 const std::vector<std::string> l5Filters = {
"HLTmumutkFilter",
"HLT2MuonMuonDZ",
"HLTDisplacedmumuFilter"};
918 if (containsAny(
moduleName, {
"DisplacedmumuFilter",
"DiMuon",
"MuonL3Filtered",
"TrackMassFiltered"}) &&