11 #include <initializer_list> 43 #include "TLorentzVector.h" 64 vector<LeafCandidate> &from,
65 vector<LeafCandidate> &
to,
66 double deltaRMatchingCut,
70 vector<double> &
xBins,
72 vector<double> &
yBins,
77 vector<double> &
xBins,
79 vector<double> &
yBins,
85 vector<double> &
xBins,
87 vector<double> &
yBins,
92 vector<double> &
xBins,
94 vector<double> &
yBins,
140 map<TString, MonitorElement *>
ME;
148 triggerProcessName(
pset.getUntrackedParameter<
string>(
"TriggerProcessName")),
149 triggerPathName(
pset.getUntrackedParameter<
string>(
"TriggerPathName")),
150 motherIDs(
pset.getUntrackedParameter<
vector<
int> >(
"MotherIDs")),
151 genGlobDeltaRMatchingCut(
pset.getUntrackedParameter<double>(
"GenGlobDeltaRMatchingCut")),
152 globL1DeltaRMatchingCut(
pset.getUntrackedParameter<double>(
"GlobL1DeltaRMatchingCut")),
153 globL2DeltaRMatchingCut(
pset.getUntrackedParameter<double>(
"GlobL2DeltaRMatchingCut")),
154 globL3DeltaRMatchingCut(
pset.getUntrackedParameter<double>(
"GlobL3DeltaRMatchingCut")),
155 deltaEtaBins(
pset.getUntrackedParameter<
vector<double> >(
"DeltaEtaBins")),
156 deltaPhiBins(
pset.getUntrackedParameter<
vector<double> >(
"DeltaPhiBins")),
157 muonPtBins(
pset.getUntrackedParameter<
vector<double> >(
"MuonPtBins")),
158 muonEtaBins(
pset.getUntrackedParameter<
vector<double> >(
"MuonEtaBins")),
159 muonPhiBins(
pset.getUntrackedParameter<
vector<double> >(
"MuonPhiBins")),
160 dimuonPtBins(
pset.getUntrackedParameter<
vector<double> >(
"DimuonPtBins")),
161 dimuonEtaBins(
pset.getUntrackedParameter<
vector<double> >(
"DimuonEtaBins")),
162 dimuonDRBins(
pset.getUntrackedParameter<
vector<double> >(
"DimuonDRBins")),
181 LogDebug(
"HLTriggerOfflineHeavyFlavor")
182 <<
"Successfully initialized HLTConfigProvider with process name: " <<
triggerProcessName << endl;
185 <<
"Could not initialize HLTConfigProvider with process name: " <<
triggerProcessName << endl;
230 TString::Format(
"filt%dMuon_recoEtaPt",
int(
i + 1)),
243 TString::Format(
"resFilt%dGlob_recoEtaPt",
int(
i + 1)),
258 TString::Format(
"filt%dDimuon_recoEtaPt",
int(
i + 1)),
270 TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
i + 1)),
285 TString::Format(
"filt%dMuon_recoEtaPhi",
int(
i + 1)),
300 TString::Format(
"filt%dDimuon_recoRapPt",
int(
i + 1)),
308 "pathDimuon_recoRapPt",
317 TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
i + 1)),
325 "diPathDimuon_recoRapPt",
337 TString::Format(
"filt%dDimuon_recoPtDR",
int(
i + 1)),
341 "#mu#mu #Delta R at IP",
345 "pathDimuon_recoPtDR",
349 "#mu#mu #Delta R at IP",
353 TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
i + 1)),
357 "#mu#mu #Delta R at IP",
361 "diPathDimuon_recoPtDR",
365 "#mu#mu #Delta R at IP",
372 TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
i + 1)),
376 "#mu#mu #Delta R in MS",
380 "pathDimuon_recoPtDRpos",
384 "#mu#mu #Delta R in MS",
388 TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
i + 1)),
392 "#mu#mu #Delta R in MS",
396 "diPathDimuon_recoPtDRpos",
400 "#mu#mu #Delta R in MS",
409 TString::Format(
"filt%dGlob_deltaEtaDeltaPhi",
int(
i + 1)),
419 vector<double> sizeBins;
420 sizeBins.push_back(10);
421 sizeBins.push_back(0);
422 sizeBins.push_back(10);
423 myBook1D(ibooker,
"genMuon_size", sizeBins,
"container size");
424 myBook1D(ibooker,
"globMuon_size", sizeBins,
"container size");
442 if (
p->status() == 1 &&
std::abs(
p->pdgId()) == 13 &&
449 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not access GenParticleCollection" << endl;
453 LogDebug(
"HLTriggerOfflineHeavyFlavor")
456 vector<LeafCandidate> globMuons;
457 vector<LeafCandidate> globMuons_position;
460 if (recoMuonsHandle.
isValid()) {
461 for (MuonCollection::const_iterator
p = recoMuonsHandle->begin();
p != recoMuonsHandle->end(); ++
p) {
462 if (
p->isGlobalMuon()) {
463 globMuons.push_back(*
p);
466 p->outerTrack()->innerPosition().y(),
467 p->outerTrack()->innerPosition().z(),
472 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not access reco Muons" << endl;
474 ME[
"globMuon_size"]->Fill(globMuons.size());
475 LogDebug(
"HLTriggerOfflineHeavyFlavor")
476 <<
"Global Muons from " <<
recoMuonsTag <<
" has size: " << globMuons.size() << endl;
479 vector<vector<LeafCandidate> > muonsAtFilter;
480 vector<vector<LeafCandidate> > muonPositionsAtFilter;
482 muonsAtFilter.push_back(vector<LeafCandidate>());
483 muonPositionsAtFilter.push_back(vector<LeafCandidate>());
487 if (rawTriggerEvent.
isValid()) {
490 if (index < rawTriggerEvent->
size()) {
492 vector<L1MuonParticleRef> l1Cands;
494 for (
size_t j = 0;
j < l1Cands.size();
j++) {
495 muonsAtFilter[
i].push_back(*l1Cands[
j]);
498 vector<RecoChargedCandidateRef> hltCands;
500 for (
size_t j = 0;
j < hltCands.size();
j++) {
501 muonsAtFilter[
i].push_back(*hltCands[
j]);
503 muonPositionsAtFilter[
i].push_back(
506 hltCands[
j]->
track()->innerPosition().
y(),
507 hltCands[
j]->
track()->innerPosition().
z(),
513 ME[TString::Format(
"filt%dMuon_size",
int(
i + 1))]->Fill(muonsAtFilter[
i].
size());
514 LogDebug(
"HLTriggerOfflineHeavyFlavor")
515 <<
"Filter \"" <<
filterNamesLevels[
i].first <<
"\" has " << muonsAtFilter[
i].size() <<
" muons" << endl;
518 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not access RAWTriggerEvent" << endl;
522 vector<LeafCandidate> pathMuons;
525 if (aodTriggerEvent.
isValid()) {
530 for (
size_t j = 0;
j <
keys.size();
j++) {
532 allObjects[
keys[
j]].
id() > 0 ? 1 : -1,
538 ME[
"pathMuon_size"]->Fill(pathMuons.size());
539 LogDebug(
"HLTriggerOfflineHeavyFlavor")
540 <<
"Path \"" <<
triggerPathName <<
"\" has " << pathMuons.size() <<
" muons at last filter \"" 543 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not access AODTriggerEvent" << endl;
547 bool triggerFired =
false;
553 bool hlt_exists =
false;
570 vector<int> glob_gen(
genMuons.size(), -1);
572 vector<vector<int> > filt_glob;
574 filt_glob.push_back(vector<int>(globMuons.size(), -1));
576 match(
ME[TString::Format(
"filt%dGlob_deltaEtaDeltaPhi",
int(
i + 1))],
582 match(
ME[TString::Format(
"filt%dGlob_deltaEtaDeltaPhi",
int(
i + 1))],
584 muonPositionsAtFilter[
i],
588 match(
ME[TString::Format(
"filt%dGlob_deltaEtaDeltaPhi",
int(
i + 1))],
595 vector<int> path_glob(globMuons.size(), -1);
609 if (glob_gen[
i] != -1) {
610 ME[
"resGlobGen_genEtaPt"]->Fill(
614 ME[
"globMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
615 ME[
"globMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
617 if (filt_glob[
f][glob_gen[
i]] != -1) {
618 ME[TString::Format(
"resFilt%dGlob_recoEtaPt",
int(
f + 1))]->Fill(
619 globMuons[glob_gen[
i]].
eta(),
620 globMuons[glob_gen[
i]].
pt(),
621 (muonsAtFilter[
f][filt_glob[
f][glob_gen[
i]]].
pt() - globMuons[glob_gen[
i]].
pt()) /
622 globMuons[glob_gen[
i]].
pt());
623 ME[TString::Format(
"filt%dMuon_recoEtaPt",
int(
f + 1))]->Fill(globMuons[glob_gen[
i]].
eta(),
624 globMuons[glob_gen[
i]].
pt());
625 ME[TString::Format(
"filt%dMuon_recoEtaPhi",
int(
f + 1))]->Fill(globMuons[glob_gen[
i]].
eta(),
626 globMuons[glob_gen[
i]].
phi());
631 if (path_glob[glob_gen[
i]] != -1) {
632 ME[
"resPathGlob_recoEtaPt"]->Fill(
633 globMuons[glob_gen[
i]].
eta(),
634 globMuons[glob_gen[
i]].
pt(),
635 (pathMuons[path_glob[glob_gen[
i]]].
pt() - globMuons[glob_gen[
i]].
pt()) / globMuons[glob_gen[
i]].
pt());
636 ME[
"pathMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
637 ME[
"pathMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
643 ME[
"resultMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
644 ME[
"resultMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
658 if (secondMuon > 0) {
662 double genDimuonRap = (
genMuons[0].p4() +
genMuons[secondMuon].p4()).Rapidity();
663 double genDimuonDR = deltaR<LeafCandidate, LeafCandidate>(
genMuons[0],
genMuons[secondMuon]);
665 ME[
"genDimuon_genEtaPt"]->Fill(genDimuonEta, genDimuonPt);
666 ME[
"genDimuon_genRapPt"]->Fill(genDimuonRap, genDimuonPt);
668 ME[
"genDimuon_genPtDR"]->Fill(genDimuonPt, genDimuonDR);
670 if (glob_gen[0] != -1 && glob_gen[secondMuon] != -1) {
671 ME[
"globDimuon_genEtaPt"]->Fill(genDimuonEta, genDimuonPt);
672 ME[
"globDimuon_genRapPt"]->Fill(genDimuonRap, genDimuonPt);
674 ME[
"globDimuon_genPtDR"]->Fill(genDimuonPt, genDimuonDR);
675 double globDimuonPt = (globMuons[glob_gen[0]].p4() + globMuons[glob_gen[secondMuon]].p4()).
pt();
676 double globDimuonEta = (globMuons[glob_gen[0]].p4() + globMuons[glob_gen[secondMuon]].p4()).
eta();
677 double globDimuonRap = (globMuons[glob_gen[0]].p4() + globMuons[glob_gen[secondMuon]].p4()).Rapidity();
678 double globDimuonDR =
679 deltaR<LeafCandidate, LeafCandidate>(globMuons[glob_gen[0]], globMuons[glob_gen[secondMuon]]);
680 double globDimuonDRpos = deltaR<LeafCandidate, LeafCandidate>(globMuons_position[glob_gen[0]],
681 globMuons_position[glob_gen[secondMuon]]);
682 ME[
"globDimuon_recoEtaPt"]->Fill(globDimuonEta, globDimuonPt);
683 ME[
"globDimuon_recoRapPt"]->Fill(globDimuonRap, globDimuonPt);
685 ME[
"globDimuon_recoPtDR"]->Fill(globDimuonPt, globDimuonDR);
687 ME[
"globDimuon_recoPtDRpos"]->Fill(globDimuonPt, globDimuonDRpos);
690 if (filt_glob[
f][glob_gen[0]] != -1 && filt_glob[
f][glob_gen[secondMuon]] != -1) {
691 ME[TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
f + 1))]->Fill(globDimuonEta, globDimuonPt);
692 ME[TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
f + 1))]->Fill(globDimuonRap, globDimuonPt);
694 ME[TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
f + 1))]->Fill(globDimuonPt, globDimuonDR);
696 ME[TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
f + 1))]->Fill(globDimuonPt, globDimuonDRpos);
703 if (filt_glob[
f][glob_gen[0]] != -1 || filt_glob[
f][glob_gen[secondMuon]] != -1) {
704 ME[TString::Format(
"filt%dDimuon_recoEtaPt",
int(
f + 1))]->Fill(globDimuonEta, globDimuonPt);
705 ME[TString::Format(
"filt%dDimuon_recoRapPt",
int(
f + 1))]->Fill(globDimuonRap, globDimuonPt);
707 ME[TString::Format(
"filt%dDimuon_recoPtDR",
int(
f + 1))]->Fill(globDimuonPt, globDimuonDR);
709 ME[TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
f + 1))]->Fill(globDimuonPt, globDimuonDRpos);
715 if (path_glob[glob_gen[0]] != -1 && path_glob[glob_gen[secondMuon]] != -1) {
716 ME[
"diPathDimuon_recoEtaPt"]->Fill(globDimuonEta, globDimuonPt);
717 ME[
"diPathDimuon_recoRapPt"]->Fill(globDimuonRap, globDimuonPt);
719 ME[
"diPathDimuon_recoPtDR"]->Fill(globDimuonPt, globDimuonDR);
721 ME[
"diPathDimuon_recoPtDRpos"]->Fill(globDimuonPt, globDimuonDRpos);
724 if (path_glob[glob_gen[0]] != -1 || path_glob[glob_gen[secondMuon]] != -1) {
725 ME[
"pathDimuon_recoEtaPt"]->Fill(globDimuonEta, globDimuonPt);
726 ME[
"pathDimuon_recoRapPt"]->Fill(globDimuonRap, globDimuonPt);
728 ME[
"pathDimuon_recoPtDR"]->Fill(globDimuonPt, globDimuonDR);
730 ME[
"pathDimuon_recoPtDRpos"]->Fill(globDimuonPt, globDimuonDRpos);
734 ME[
"resultDimuon_recoEtaPt"]->Fill(globDimuonEta, globDimuonPt);
735 ME[
"resultDimuon_recoRapPt"]->Fill(globDimuonRap, globDimuonPt);
737 ME[
"resultDimuon_recoPtDR"]->Fill(globDimuonPt, globDimuonDR);
739 ME[
"resultDimuon_recoPtDRpos"]->Fill(globDimuonPt, globDimuonDRpos);
748 if (mother->
pdgId() ==
p->pdgId()) {
751 return mother->
pdgId();
759 vector<LeafCandidate> &from,
760 vector<LeafCandidate> &
to,
761 double dRMatchingCut,
763 vector<double>
dR(from.size());
764 for (
size_t i = 0;
i < from.size();
i++) {
768 for (
size_t j = 0;
j <
to.size();
j++) {
769 double dRtmp = deltaR<double>(from[
i].eta(), from[
i].phi(),
to[
j].eta(),
to[
j].phi());
780 if (
dR[
i] > dRMatchingCut) {
785 for (
size_t k = 0;
k <
i;
k++) {
808 Double_t *
pt =
new Double_t[ptN];
809 for (
int i = 0;
i < ptN;
i++) {
813 Double_t *
eta =
new Double_t[etaN];
814 for (
int i = 0;
i < etaN;
i++) {
818 h->SetXTitle(ptLabel);
819 h->SetYTitle(etaLabel);
834 Double_t *
pt =
new Double_t[ptN];
835 for (
int i = 0;
i < ptN;
i++) {
839 Double_t *
eta =
new Double_t[etaN];
840 for (
int i = 0;
i < etaN;
i++) {
843 TProfile2D *
h =
new TProfile2D(
name,
name, ptN - 1,
pt, etaN - 1,
eta);
844 h->SetXTitle(ptLabel);
845 h->SetYTitle(etaLabel);
855 Double_t *myBins =
new Double_t[binsN];
856 for (
int i = 0;
i < binsN;
i++) {
859 TH1F *
h =
new TH1F(
name,
name, binsN - 1, myBins);
869 return s.find(sub) != std::string::npos;
873 const auto containsAny = [](
const std::string &
s,
const std::vector<std::string> &subs) ->
bool {
874 for (
const auto &sub : subs) {
875 if (
s.find(sub) != std::string::npos)
882 const auto isAnyOf = [](
const std::string &
s,
const std::vector<std::string> &ms) ->
bool {
883 for (
const auto &
m : ms) {
899 const std::string l2Filter =
"HLTMuonL2FromL1TPreFilter";
900 const std::vector<std::string> l3Filters = {
"HLTMuonDimuonL3Filter",
"HLTMuonL3PreFilter"};
901 const std::vector<std::string> l4Filters = {
902 "HLTDisplacedmumuFilter",
"HLTDiMuonGlbTrkFilter",
"HLTMuonTrackMassFilter"};
903 const std::vector<std::string> l5Filters = {
"HLTmumutkFilter",
"HLT2MuonMuonDZ",
"HLTDisplacedmumuFilter"};
916 if (containsAny(
moduleName, {
"DisplacedmumuFilter",
"DiMuon",
"MuonL3Filtered",
"TrackMassFiltered"}) &&
double globL1DeltaRMatchingCut
vector< double > dimuonPtBins
const Keys & filterKeys(trigger::size_type index) const
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
bool contains(EventRange const &lh, EventID const &rh)
void myBook2D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel, TString title)
virtual void setCurrentFolder(std::string const &fullpath)
void analyze(const edm::Event &, const edm::EventSetup &) override
enum start value shifted to 81 so as to avoid clashes with PDG codes
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
vector< double > deltaPhiBins
#define DEFINE_FWK_MODULE(type)
trigger::size_type sizeFilters() const
double globL3DeltaRMatchingCut
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
string triggerProcessName
vector< double > dimuonEtaBins
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const edm::InputTag filterTag(trigger::size_type index) const
std::vector< TPRegexp > filters
int getFilterLevel(const std::string &moduleName, const HLTConfigProvider &hltConfig)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
EDGetTokenT< TriggerEvent > triggerSummaryAODTag
example_stream void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
U second(std::pair< T, U > const &p)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void myBookProfile2D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel, TString title)
vector< double > dimuonDRBins
int getMotherId(const Candidate *p)
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
void match(MonitorElement *me, vector< LeafCandidate > &from, vector< LeafCandidate > &to, double deltaRMatchingCut, vector< int > &map)
EDGetTokenT< TriggerEventWithRefs > triggerSummaryRAWTag
Abs< T >::type abs(const T &t)
const TriggerObjectCollection & getObjects() const
void myBook1D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString label, TString title)
static std::string const triggerResults
double genGlobDeltaRMatchingCut
vector< double > muonPtBins
HeavyFlavorValidation(const edm::ParameterSet &)
double globL2DeltaRMatchingCut
~HeavyFlavorValidation() override
virtual int pdgId() const =0
PDG identifier.
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
vector< double > deltaEtaBins
void myBook2D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel)
EDGetTokenT< MuonCollection > recoMuonsToken
std::vector< size_type > Keys
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
vector< double > muonPhiBins
EDGetTokenT< GenParticleCollection > genParticlesToken
void myBookProfile2D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void myBook1D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString label)
EDGetTokenT< TriggerResults > triggerResultsToken
Log< level::Warning, false > LogWarning
InputTag triggerResultsTag
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
map< TString, MonitorElement * > ME
vector< pair< string, int > > filterNamesLevels
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
vector< double > muonEtaBins
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type