28 using namespace trigger;
29 using namespace l1extra;
87 LogError(
"HLTMuonVal") <<
"Initialization of HLTConfigProvider failed!!";
96 for (
size_t j = 0;
j < validTriggerNames.size();
j++)
97 if (TString(validTriggerNames[
j]).Contains(pattern))
100 if (TString(
"NoFilters").Contains(pattern))
114 vector<string> sources(2);
118 set<string>::iterator iPath;
119 TPRegexp suffixPtCut(
"[0-9]+$");
123 string path = * iPath;
125 if (path ==
"NoFilters") {
132 vector<string> moduleLabels;
135 for (
size_t i = 0;
i < moduleLabels.size();
i++)
136 if (moduleLabels[
i].
find(
"Filtered") != string::npos)
144 unsigned int index = TString(path).Index(suffixPtCut);
146 if (index < path.length()) threshold = atoi(path.substr(index).c_str());
150 double cutMinPt = ceil(threshold * 1.1) - 0.01;
151 if (cutMinPt < 0. || path ==
"NoFilters") cutMinPt = 0.;
154 string baseDir =
"HLT/Muon/Distributions/";
157 if (
dbe_->
get(baseDir + path +
"/CutMinPt") == 0) {
161 elements_[path +
"_" +
"CutMinPt" ]->Fill(cutMinPt);
162 elements_[path +
"_" +
"CutMaxEta"]->Fill(cutMaxEta);
188 for (
size_t i = 0; i < sources.size(); i++) {
210 static int eventNumber = 0;
212 LogTrace(
"HLTMuonVal") <<
"In HLTMuonValidator::analyze, "
213 <<
"Event: " << eventNumber;
219 iEvent.
getByLabel(
"hltTriggerSummaryRAW", rawTriggerEvent);
221 {
LogError(
"HLTMuonVal") <<
"No trigger summary found";
return;}
225 vector<string> sources;
226 if (genParticles.
isValid()) sources.push_back(
"gen");
227 if ( recMuons.
isValid()) sources.push_back(
"rec");
229 for (
size_t sourceNo = 0; sourceNo < sources.size(); sourceNo++) {
231 string source = sources[sourceNo];
240 vector<MatchStruct> matches;
241 if (source ==
"gen" && genParticles.
isValid())
242 for (
size_t i = 0;
i < genParticles->size();
i++)
245 if (source ==
"rec" && recMuons.
isValid())
246 for (
size_t i = 0;
i < recMuons->size();
i++)
253 set<string>::iterator iPath;
255 analyzePath(iEvent, * iPath, source, matches, rawTriggerEvent);
267 vector<MatchStruct> matches,
271 const bool skipFilters = (path ==
"NoFilters");
273 const float maxEta =
elements_[path +
"_" +
"CutMaxEta"]->getFloatValue();
274 const bool isDoubleMuonPath = (path.find(
"Double") != string::npos);
277 const size_t nStepsHlt = nSteps - 2;
278 const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1;
279 vector< L1MuonParticleRef > candsL1;
280 vector< vector< RecoChargedCandidateRef > > refsHlt(nStepsHlt);
281 vector< vector< const RecoChargedCandidate * > > candsHlt(nStepsHlt);
283 for (
size_t i = 0;
i < nFilters;
i++) {
284 const int hltStep =
i - 1;
286 size_t iFilter = rawTriggerEvent->filterIndex(tag);
287 if (iFilter < rawTriggerEvent->
size()) {
289 rawTriggerEvent->getObjects(iFilter,
TriggerL1Mu, candsL1);
294 else if (!skipFilters)
295 LogTrace(
"HLTMuonVal") <<
"No collection with label " <<
tag;
303 for (
size_t i = 0;
i < handleCandsL2->size();
i++)
304 candsHlt[0].push_back(& handleCandsL2->at(
i));
306 for (
size_t i = 0;
i < handleCandsL3->size();
i++)
307 candsHlt[1].push_back(& handleCandsL3->at(
i));
309 else for (
size_t i = 0;
i < nStepsHlt;
i++)
310 for (
size_t j = 0;
j < refsHlt[
i].size();
j++)
311 candsHlt[
i].push_back(& * refsHlt[
i][
j]);
316 vector<size_t> matchesInEtaRange;
317 vector<bool> hasMatch(matches.size(),
true);
321 const size_t hltStep = (
step >= 2) ?
step - 2 : 0;
324 (
step == 3) ? ((nStepsHlt == 4) ? 2 : 3) :
328 for (
size_t j = 0; j < matches.size(); j++) {
330 if (fabs(matches[j].candBase->eta()) < maxEta)
331 matchesInEtaRange.push_back(j);
333 else if (level == 1) {
334 if (matches[j].candL1 == 0)
337 else if (level >= 2) {
338 if (matches[j].candHlt[hltStep] == 0)
340 else if (!hasMatch[j]) {
341 LogTrace(
"HLTMuonVal") <<
"Match found for HLT step " << hltStep
342 <<
" of " << nStepsHlt
343 <<
" without previous match!";
349 if (
std::count(hasMatch.begin(), hasMatch.end(),
true) <
353 string pre = path +
"_" + source +
"Pass";
356 for (
size_t j = 0; j < matches.size(); j++) {
357 float pt = matches[
j].candBase->pt();
358 float eta = matches[
j].candBase->eta();
359 float phi = matches[
j].candBase->phi();
361 if (matchesInEtaRange.size() >= 1 && j == matchesInEtaRange[0])
362 elements_[pre +
"MaxPt1" + post]->Fill(pt);
363 if (matchesInEtaRange.size() >= 2 && j == matchesInEtaRange[1])
364 elements_[pre +
"MaxPt2" + post]->Fill(pt);
366 elements_[pre +
"Eta" + post]->Fill(eta);
367 elements_[pre +
"Phi" + post]->Fill(phi);
380 vector<MatchStruct> & matches,
381 vector<L1MuonParticleRef> candsL1,
382 vector< vector< const RecoChargedCandidate *> > candsHlt)
385 set<size_t>::iterator it;
387 set<size_t> indicesL1;
388 for (
size_t i = 0;
i < candsL1.size();
i++)
391 vector< set<size_t> > indicesHlt(candsHlt.size());
392 for (
size_t i = 0;
i < candsHlt.size();
i++)
393 for (
size_t j = 0;
j < candsHlt[
i].size();
j++)
396 for (
size_t i = 0;
i < matches.size();
i++) {
400 double bestDeltaR =
cutsDr_[0];
401 size_t bestMatch =
kNull;
402 for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
404 candsL1[*it]->eta(), candsL1[*it]->phi());
405 if (dR < bestDeltaR) {
418 if (bestMatch !=
kNull)
419 matches[
i].candL1 = & * candsL1[bestMatch];
420 indicesL1.erase(bestMatch);
422 matches[
i].candHlt.assign(candsHlt.size(), 0);
423 for (
size_t j = 0;
j < candsHlt.size();
j++) {
424 size_t level = (candsHlt.size() == 4) ? (
j < 2) ? 2 : 3 :
425 (candsHlt.size() == 2) ? (
j < 1) ? 2 : 3 :
427 bestDeltaR =
cutsDr_[level - 2];
429 for (it = indicesHlt[
j].
begin(); it != indicesHlt[
j].end(); it++) {
431 candsHlt[
j][*it]->eta(), candsHlt[
j][*it]->phi());
432 if (dR < bestDeltaR) {
437 if (bestMatch !=
kNull)
438 matches[
i].candHlt[
j] = candsHlt[
j][bestMatch];
439 indicesHlt[
j].erase(bestMatch);
462 string sourceUpper =
source;
463 sourceUpper[0] = toupper(sourceUpper[0]);
464 string name = source +
"Pass" + type +
"_" +
label;
465 string rootName = path +
"_" +
name;
468 if (type.find(
"MaxPt") != string::npos) {
469 string desc = (type ==
"MaxPt1") ?
"Leading" :
"Next-to-Leading";
470 string title =
"pT of " + desc +
" " + sourceUpper +
" Muon "+
471 "matched to " +
label;
473 float *
edges =
new float[nBins + 1];
475 h =
new TH1F(rootName.c_str(), title.c_str(), nBins,
edges);
479 string symbol = (type ==
"Eta") ?
"#eta" :
"#phi";
480 string title = symbol +
" of " + sourceUpper +
" Muons " +
481 "matched to " +
label;
483 int nBins = (int)params[0];
484 double min = params[1];
485 double max = params[2];
486 h =
new TH1F(rootName.c_str(), title.c_str(), nBins,
min,
max);
T getParameter(std::string const &) const
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators...
std::map< std::string, std::vector< std::string > > stepLabels_
std::string recMuonLabel_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
enum start value shifted to 81 so as to avoid clashes with PDG codes
#define DEFINE_FWK_MODULE(type)
const std::vector< std::string > & triggerNames() const
names of trigger paths
std::set< std::string > hltPaths_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< double > cutsDr_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::string > hltPathsToCheck_
MonitorElement * bookFloat(const char *name)
Book float.
StringCutObjectSelector< reco::GenParticle > * genMuonSelector_
std::vector< double > parametersPhi_
const T & max(const T &a, const T &b)
L1MuonMatcherAlgo l1Matcher_
void setVerbose(unsigned level)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
std::map< std::string, MonitorElement * > elements_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
StringCutObjectSelector< reco::Muon > * recMuonSelector_
std::map< std::string, std::vector< std::string > > filterLabels_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
double deltaR(double eta1, double eta2, double phi1, double phi2)
HLTConfigProvider hltConfig_
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
std::string genParticleLabel_
std::vector< double > parametersTurnOn_
void bookHist(std::string, std::string, std::string, std::string)
std::vector< AlignmentParameters * > Parameters
std::string hltProcessName_
std::vector< double > parametersEta_
TPRegexp kLooseL1Requirement("HLT_Mu3|Double|NoFilters")
void findMatches(std::vector< MatchStruct > &, std::vector< l1extra::L1MuonParticleRef >, std::vector< std::vector< const reco::RecoChargedCandidate * > >)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
bool insert(Storage &, ItemType *, const IdTag &)
void analyzePath(const edm::Event &, const std::string &, const std::string &, const std::vector< MatchStruct >, edm::Handle< trigger::TriggerEventWithRefs >)
tuple size
Write out results.
std::map< std::string, double > cutsMinPt_
void setCurrentFolder(const std::string &fullpath)
HLTMuonValidator(const edm::ParameterSet &)
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity