29 const std::vector<string> &moduleLabels,
30 const std::vector<string> &stepLabels,
69 if (
hltPath_.find(
"eta2p1") != string::npos)
74 TPRegexp ptRegexp(
"Mu([0-9]+)");
75 TObjArray *regexArray = ptRegexp.MatchS(
hltPath_);
76 if (regexArray->GetEntriesFast() == 2) {
77 threshold = atoi(((TObjString *)regexArray->At(1))->GetString());
87 string baseDir =
"HLT/Muon/Distributions/";
90 vector<string> sources(2);
99 for (
size_t i = 0;
i < sources.size();
i++) {
111 static int eventNumber = 0;
113 LogTrace(
"HLTMuonVal") <<
"In HLTMuonPlotter::analyze, " 114 <<
"Event: " << eventNumber;
126 LogError(
"HLTMuonVal") <<
"No trigger summary found";
132 vector<string> sources;
134 sources.push_back(
"gen");
136 sources.push_back(
"rec");
138 for (
size_t sourceNo = 0; sourceNo < sources.size(); sourceNo++) {
139 string source = sources[sourceNo];
149 if (source ==
"gen" && genParticles.
isValid())
150 for (
size_t i = 0;
i < genParticles->size();
i++)
153 if (source ==
"rec" && recMuons.
isValid())
154 for (
size_t i = 0;
i < recMuons->size();
i++)
161 const bool isDoubleMuonPath = (
hltPath_.find(
"Double") != string::npos);
164 const size_t nStepsHlt = nSteps - 2;
165 const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1;
167 vector<vector<RecoChargedCandidateRef>> refsHlt(nStepsHlt);
168 vector<vector<const RecoChargedCandidate *>> candsHlt(nStepsHlt);
170 for (
size_t i = 0;
i < nFilters;
i++) {
171 const int hltStep =
i - 1;
173 size_t iFilter = rawTriggerEvent->
filterIndex(tag);
174 if (iFilter < rawTriggerEvent->
size()) {
180 LogTrace(
"HLTMuonVal") <<
"No collection with label " <<
tag;
182 for (
size_t i = 0;
i < nStepsHlt;
i++)
183 for (
size_t j = 0; j < refsHlt[
i].size(); j++)
184 if (refsHlt[
i][j].isAvailable()) {
185 candsHlt[
i].push_back(&*refsHlt[
i][j]);
187 LogWarning(
"HLTMuonPlotter") <<
"Ref refsHlt[i][j]: product not available " <<
i <<
" " << j;
193 vector<size_t> matchesInEtaRange;
194 vector<bool> hasMatch(matches.size(),
true);
197 size_t hltStep = (
step >= 2) ?
step - 2 : 0;
199 hltStep = hltStep - 1;
216 for (
size_t j = 0; j < matches.size(); j++) {
218 if (fabs(matches[j].candBase->eta()) <
cutMaxEta_)
219 matchesInEtaRange.push_back(j);
220 }
else if (level == 1) {
221 if (matches[j].candL1 ==
nullptr)
223 }
else if (level >= 2) {
224 if (matches[j].candHlt[hltStep] ==
nullptr)
226 else if (!hasMatch[j]) {
227 LogTrace(
"HLTMuonVal") <<
"Match found for HLT step " << hltStep <<
" of " << nStepsHlt
228 <<
" without previous match!";
234 if (
std::count(hasMatch.begin(), hasMatch.end(),
true) < nObjectsToPassPath)
237 string pre = source +
"Pass";
240 for (
size_t j = 0; j < matches.size(); j++) {
241 float pt = matches[j].candBase->pt();
242 float eta = matches[j].candBase->eta();
243 float phi = matches[j].candBase->phi();
245 if (!matchesInEtaRange.empty() && j == matchesInEtaRange[0])
247 if (matchesInEtaRange.size() >= 2 && j == matchesInEtaRange[1])
250 elements_[pre +
"Eta" + post]->Fill(eta);
252 elements_[pre +
"Phi" + post]->Fill(phi);
261 boost::tuple<edm::EDGetTokenT<trigger::TriggerEventWithRefs>,
272 boost::tuple<edm::EDGetTokenT<trigger::TriggerEventWithRefs>,
275 myTuple(_hltTriggerSummaryRAW, _genParticleLabel, _recMuonLabel);
282 const std::vector<vector<const RecoChargedCandidate *>> &candsHlt) {
283 set<size_t>::iterator it;
285 set<size_t> indicesL1;
286 for (
size_t i = 0;
i < candsL1.size();
i++)
289 vector<set<size_t>> indicesHlt(candsHlt.size());
290 for (
size_t i = 0;
i < candsHlt.size();
i++)
291 for (
size_t j = 0; j < candsHlt[
i].size(); j++)
294 for (
size_t i = 0;
i < matches.size();
i++) {
297 double bestDeltaR =
cutsDr_[0];
299 for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
300 if (candsL1[*it].isAvailable()) {
301 double dR =
deltaR(cand->
eta(), cand->
phi(), candsL1[*it]->eta(), candsL1[*it]->phi());
302 if (dR < bestDeltaR) {
315 LogWarning(
"HLTMuonPlotter") <<
"Ref candsL1[*it]: product not available " << *it;
319 if (bestMatch !=
kNull)
321 indicesL1.erase(bestMatch);
323 matches[
i].candHlt.assign(candsHlt.size(),
nullptr);
324 for (
size_t j = 0; j < candsHlt.size(); j++) {
325 size_t level = (candsHlt.size() == 4) ? (j < 2) ? 2 : 3 : (candsHlt.size() == 2) ? (j < 1) ? 2 : 3 : 2;
326 bestDeltaR =
cutsDr_[level - 2];
328 for (it = indicesHlt[j].
begin(); it != indicesHlt[j].end(); it++) {
329 double dR =
deltaR(cand->
eta(), cand->
phi(), candsHlt[j][*it]->eta(), candsHlt[j][*it]->phi());
330 if (dR < bestDeltaR) {
335 if (bestMatch !=
kNull)
336 matches[
i].candHlt[j] = candsHlt[j][
bestMatch];
337 indicesHlt[j].erase(bestMatch);
351 string sourceUpper =
source;
352 sourceUpper[0] = toupper(sourceUpper[0]);
353 string name = source +
"Pass" + type +
"_" +
label;
356 if (type.find(
"MaxPt") != string::npos) {
357 string desc = (type ==
"MaxPt1") ?
"Leading" :
"Next-to-Leading";
358 string title =
"pT of " + desc +
" " + sourceUpper +
" Muon " +
"matched to " +
label;
360 float *edges =
new float[nBins + 1];
361 for (
size_t i = 0;
i < nBins + 1;
i++)
363 h =
new TH1F(name.c_str(), title.c_str(), nBins, edges);
367 string symbol = (type ==
"Eta") ?
"#eta" :
"#phi";
368 string title = symbol +
" of " + sourceUpper +
" Muons " +
"matched to " +
label;
370 int nBins = (
int)params[0];
371 double min = params[1];
372 double max = params[2];
373 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
HLTMuonPlotter(const edm::ParameterSet &, std::string, const std::vector< std::string > &, const std::vector< std::string > &, const boost::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection >> &)
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
void init(const edm::EventSetup &iSetup)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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::vector< double > parametersEta_
L1MuonMatcherAlgo l1Matcher_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::string > moduleLabels_
std::vector< MuonRef > MuonVectorRef
std::vector< Muon > MuonCollection
collection of Muon objects
static boost::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection > > getTokens(const edm::ParameterSet &, edm::ConsumesCollector &&)
vector< ParameterSet > Parameters
void findMatches(std::vector< MatchStruct > &, const l1t::MuonVectorRef &candsL1, const std::vector< std::vector< const reco::RecoChargedCandidate * >> &)
void setCurrentFolder(std::string const &fullpath)
std::vector< double > cutsDr_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
edm::EDGetTokenT< reco::MuonCollection > recMuonLabel_
MonitorElement * book1D(Args &&...args)
void analyze(const edm::Event &, const edm::EventSetup &)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
StringCutObjectSelector< reco::GenParticle > * genMuonSelector_
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
std::vector< std::string > stepLabels_
virtual double eta() const =0
momentum pseudorapidity
void bookHist(DQMStore::IBooker &, std::string, std::string, std::string, std::string)
def bestMatch(object, matchCollection)
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
StringCutObjectSelector< reco::Muon > * recMuonSelector_
std::vector< double > parametersPhi_
MonitorElement * bookFloat(Args &&...args)
std::map< std::string, MonitorElement * > elements_
std::string hltProcessName_
edm::EDGetTokenT< reco::GenParticleCollection > genParticleLabel_
edm::EDGetTokenT< trigger::TriggerEventWithRefs > hltTriggerSummaryRAW_
std::vector< double > parametersTurnOn_
virtual double phi() const =0
momentum azimuthal angle
static std::string const source