19 #include "TObjArray.h" 20 #include "TObjString.h" 23 const unsigned int kNull = (
unsigned int)-1;
28 const std::vector<std::string> &moduleLabels,
29 const std::vector<std::string> &stepLabels,
35 hltProcessName_(
pset.getParameter<
std::
string>(
"hltProcessName")),
36 moduleLabels_(moduleLabels),
37 stepLabels_(stepLabels),
38 triggerEventWithRefsToken_(triggerEventWithRefsToken),
39 genParticleToken_(genParticlesToken),
40 recMuonToken_(recoMuonsToken),
41 genMuonSelector_(
pset.getParameter<
std::
string>(
"genMuonCut")),
42 recMuonSelector_(
pset.getParameter<
std::
string>(
"recMuonCut")),
44 parametersEta_(
pset.getParameter<
std::
vector<double>>(
"parametersEta")),
45 parametersPhi_(
pset.getParameter<
std::
vector<double>>(
"parametersPhi")),
46 parametersTurnOn_(
pset.getParameter<
std::
vector<double>>(
"parametersTurnOn")),
47 l1Matcher_(l1Matcher),
50 edm::LogError(
"HLTMuonPlotter") <<
"Invalid inputs: 'moduleLabels_' is empty." 51 <<
"\nMonitorElements for HLT path '" <<
hltPath_ <<
"' will not be produced.";
55 err <<
"Invalid inputs: 'stepLabels_.size()' must equal 'moduleLabels_.size() + 1'.";
56 err <<
"\nMonitorElements for HLT path '" <<
hltPath_ <<
"' will not be produced.";
57 err <<
"\n stepLabels_ = (";
61 err <<
"\n moduleLabels_ = (";
76 if (
hltPath_.find(
"eta2p1") != std::string::npos)
81 TPRegexp ptRegexp(
"Mu([0-9]+)");
82 TObjArray *regexArray = ptRegexp.MatchS(
hltPath_);
83 if (regexArray->GetEntriesFast() == 2) {
84 threshold = atoi(((TObjString *)regexArray->At(1))->GetString());
97 std::vector<std::string>
sources(2);
122 if (triggerEventWithRefsHandle.failedToGet()) {
123 edm::LogError(
"HLTMuonPlotter") <<
"No trigger summary found";
130 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] --------------";
131 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] Event: " <<
iEvent.id();
136 const int nStepsHlt = hasStepL1 ? nSteps - 2 : nSteps - 1;
137 const bool isDoubleMuonPath = (
hltPath_.find(
"Double") != std::string::npos);
138 const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1;
140 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] HLTPath=" <<
hltPath_ <<
" nFilters=" << nFilters
141 <<
" nSteps=" << nSteps <<
" hasStepL1=" << hasStepL1 <<
" nStepsHlt=" << nStepsHlt
142 <<
" isDoubleMuonPath=" << isDoubleMuonPath
143 <<
" nObjectsToPassPath=" << nObjectsToPassPath;
145 if (nFilters + 1 == nSteps) {
146 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] stepLabels | moduleLabels";
147 for (
int istep = 0; istep < nSteps; ++istep) {
155 std::vector<std::string>
sources;
156 if (genParticlesHandle.isValid())
158 if (recoMuonsHandle.isValid())
161 for (
size_t sourceNo = 0; sourceNo <
sources.size(); sourceNo++) {
164 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] source=" <<
source;
167 std::vector<MatchStruct>
matches;
170 if (genParticlesHandle.isValid()) {
172 for (
auto const &
genp : *genParticlesHandle)
176 }
else if (
source ==
"rec") {
177 if (recoMuonsHandle.isValid()) {
179 for (
auto const &recomu : *recoMuonsHandle)
189 std::vector<std::vector<reco::RecoChargedCandidateRef>> refsHlt(nStepsHlt);
190 std::vector<std::vector<const reco::RecoChargedCandidate *>> candsHlt(nStepsHlt);
192 for (
int idx = 0;
idx < nFilters; ++
idx) {
193 auto const moduleLabelStripped =
196 auto const iFilter = triggerEventWithRefsHandle->filterIndex(iTag);
197 auto const iFilterValid = (iFilter < triggerEventWithRefsHandle->size());
201 <<
", valid = " << iFilterValid <<
")";
204 if (
idx == 0 and hasStepL1)
207 auto const hltStep = hasStepL1 ?
idx - 1 :
idx;
211 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] No collection with " << iTag;
214 for (
int i = 0;
i < nStepsHlt;
i++) {
215 for (
size_t j = 0;
j < refsHlt[
i].size();
j++) {
216 if (refsHlt[
i][
j].isAvailable())
219 edm::LogWarning(
"HLTMuonPlotter") <<
"Ref refsHlt[i][j]: product not available " <<
i <<
" " <<
j;
226 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] Number of Candidates = " <<
matches.size();
228 for (
auto const &match_i :
matches) {
229 if (!match_i.candBase)
231 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] CandBase: pt=" << match_i.candBase->pt()
232 <<
" eta=" << match_i.candBase->eta() <<
" phi=" << match_i.candBase->phi();
234 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] CandL1: pt=" << match_i.candL1->pt()
235 <<
" eta=" << match_i.candL1->eta() <<
" phi=" << match_i.candL1->phi();
237 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] CandL1: NULL";
240 for (
auto const *chlt : match_i.candHlt) {
243 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] CandHLT[" << ihlt <<
"]: pt=" << chlt->pt()
244 <<
" eta=" << chlt->eta() <<
" phi=" << chlt->phi();
246 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] CandHLT[" << ihlt <<
"]: NULL";
250 std::vector<size_t> matchesInEtaRange;
251 std::vector<bool> hasMatch(
matches.size(),
true);
254 int const hltStep = hasStepL1 ?
step - 2 :
step - 1;
276 matchesInEtaRange.push_back(
j);
277 }
else if (
level == 1) {
280 }
else if (
level >= 2) {
281 if (
matches[
j].candHlt.at(hltStep) ==
nullptr)
283 else if (!hasMatch[
j]) {
284 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] match found for " <<
source <<
" candidate " <<
j 285 <<
" in HLT step " << hltStep <<
" of " << nStepsHlt
286 <<
" without previous match!";
292 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] (step=" <<
step <<
", level=" <<
level 293 <<
", hltStep=" << hltStep <<
") matchesInEtaRange: [ " 296 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] (step=" <<
step <<
", level=" <<
level 297 <<
", hltStep=" << hltStep <<
") hasMatch: [ " << this->
vector_to_string(hasMatch)
300 if (
std::count(hasMatch.begin(), hasMatch.end(),
true) < nObjectsToPassPath)
311 if (!matchesInEtaRange.empty() &&
j == matchesInEtaRange[0]) {
313 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] FILL(" << pre +
"MaxPt1" + post <<
") value = " <<
pt;
315 if (matchesInEtaRange.size() >= 2 &&
j == matchesInEtaRange[1]) {
317 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] FILL(" << pre +
"MaxPt2" + post <<
") value = " <<
pt;
321 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] FILL(" << pre +
"Eta" + post <<
") value = " <<
eta;
324 LogTrace(
"HLTMuonPlotter") <<
"[HLTMuonPlotter] FILL(" << pre +
"Phi" + post <<
") value = " <<
phi;
335 const std::vector<std::vector<const reco::RecoChargedCandidate *>> &candsHlt) {
336 std::set<size_t>::iterator it;
338 std::set<size_t> indicesL1;
339 for (
size_t i = 0;
i < candsL1.size();
i++)
342 std::vector<set<size_t>> indicesHlt(candsHlt.size());
343 for (
size_t i = 0;
i < candsHlt.size();
i++)
344 for (
size_t j = 0;
j < candsHlt[
i].size();
j++)
350 double bestDeltaR =
cutsDr_[0];
352 for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
353 if (candsL1[*it].isAvailable()) {
354 double dR =
deltaR(
cand->eta(),
cand->phi(), candsL1[*it]->eta(), candsL1[*it]->phi());
355 if (
dR < bestDeltaR) {
368 edm::LogWarning(
"HLTMuonPlotter") <<
"Ref candsL1[*it]: product not available " << *it;
376 matches[
i].candHlt.assign(candsHlt.size(),
nullptr);
377 for (
size_t j = 0;
j < candsHlt.size();
j++) {
378 size_t level = (candsHlt.size() == 4) ? (
j < 2) ? 2 : 3 : (candsHlt.size() == 2) ? (
j < 1) ? 2 : 3 : 2;
381 for (it = indicesHlt[
j].begin(); it != indicesHlt[
j].end(); it++) {
382 double dR =
deltaR(
cand->eta(),
cand->phi(), candsHlt[
j][*it]->eta(), candsHlt[
j][*it]->phi());
383 if (
dR < bestDeltaR) {
401 sourceUpper[0] = toupper(sourceUpper[0]);
405 if (
type.find(
"MaxPt") != std::string::npos) {
410 for (
size_t i = 0;
i <
nBins + 1;
i++)
void bookHist(DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &)
constexpr int32_t ceil(float num)
std::string const hltPath_
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
genp
produce generated paricles in acceptance #
virtual void setCurrentFolder(std::string const &fullpath)
enum start value shifted to 81 so as to avoid clashes with PDG codes
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)
std::string removeSchedulingTokensFromModuleLabel(std::string iLabel)
StringCutObjectSelector< reco::Muon > const recMuonSelector_
Log< level::Error, false > LogError
std::string const hltProcessName_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::EDGetTokenT< trigger::TriggerEventWithRefs > const triggerEventWithRefsToken_
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators...
void findMatches(std::vector< MatchStruct > &, const l1t::MuonVectorRef &candsL1, const std::vector< std::vector< const reco::RecoChargedCandidate *>> &)
std::vector< MuonRef > MuonVectorRef
std::unordered_map< std::string, MonitorElement * > elements_
std::vector< double > const cutsDr_
std::vector< double > const parametersTurnOn_
std::string vector_to_string(std::vector< T > const &vec, std::string const &delimiter=" ") const
Abs< T >::type abs(const T &t)
void analyze(const edm::Event &, const edm::EventSetup &)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
HLTMuonPlotter(const edm::ParameterSet &, const std::string &, const std::vector< std::string > &, const std::vector< std::string > &, const edm::EDGetTokenT< trigger::TriggerEventWithRefs > &, const edm::EDGetTokenT< reco::GenParticleCollection > &, const edm::EDGetTokenT< reco::MuonCollection > &, const L1MuonMatcherAlgoForDQM &)
std::vector< std::string > const moduleLabels_
std::vector< double > const parametersEta_
def bestMatch(object, matchCollection)
edm::EDGetTokenT< reco::GenParticleCollection > const genParticleToken_
std::vector< double > const parametersPhi_
L1MuonMatcherAlgoForDQM l1Matcher_
edm::EDGetTokenT< reco::MuonCollection > const recMuonToken_
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
std::vector< std::string > const stepLabels_
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
StringCutObjectSelector< reco::GenParticle > const genMuonSelector_
static std::string const source