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;
122 string path = * iPath;
124 if (path ==
"NoFilters") {
131 vector<string> moduleLabels;
134 for (
size_t i = 0;
i < moduleLabels.size();
i++)
135 if (moduleLabels[
i].
find(
"Filtered") != string::npos)
138 double cutMaxEta = 2.4;
143 TPRegexp ptRegexp(
"Mu([0-9]*)");
144 TObjArray * regexArray = ptRegexp.MatchS(path);
145 if (regexArray->GetEntriesFast() == 2) {
146 threshold = atoi(((TObjString *)regexArray->At(1))->GetString());
152 double cutMinPt = ceil(threshold * 1.1) - 0.01;
153 if (cutMinPt < 0. || path ==
"NoFilters") cutMinPt = 0.;
156 string baseDir =
"HLT/Muon/Distributions/";
157 string pathSansSuffix =
path;
158 if (path.rfind(
"_v") < path.length())
159 pathSansSuffix = path.substr(0, path.rfind(
"_v"));
162 if (
dbe_->
get(baseDir + path +
"/CutMinPt") == 0) {
166 elements_[path +
"_" +
"CutMinPt" ]->Fill(cutMinPt);
167 elements_[path +
"_" +
"CutMaxEta"]->Fill(cutMaxEta);
193 for (
size_t i = 0; i < sources.size(); i++) {
215 static int eventNumber = 0;
217 LogTrace(
"HLTMuonVal") <<
"In HLTMuonValidator::analyze, "
218 <<
"Event: " << eventNumber;
224 iEvent.
getByLabel(
"hltTriggerSummaryRAW", rawTriggerEvent);
226 {
LogError(
"HLTMuonVal") <<
"No trigger summary found";
return;}
230 vector<string> sources;
231 if (genParticles.
isValid()) sources.push_back(
"gen");
232 if ( recMuons.
isValid()) sources.push_back(
"rec");
234 for (
size_t sourceNo = 0; sourceNo < sources.size(); sourceNo++) {
236 string source = sources[sourceNo];
245 vector<MatchStruct> matches;
246 if (source ==
"gen" && genParticles.
isValid())
247 for (
size_t i = 0;
i < genParticles->size();
i++)
250 if (source ==
"rec" && recMuons.
isValid())
251 for (
size_t i = 0;
i < recMuons->size();
i++)
258 set<string>::iterator iPath;
260 analyzePath(iEvent, * iPath, source, matches, rawTriggerEvent);
272 vector<MatchStruct> matches,
276 const bool skipFilters = (path ==
"NoFilters");
278 const float maxEta =
elements_[path +
"_" +
"CutMaxEta"]->getFloatValue();
279 const bool isDoubleMuonPath = (path.find(
"Double") != string::npos);
282 const size_t nStepsHlt = nSteps - 2;
283 const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1;
284 vector< L1MuonParticleRef > candsL1;
285 vector< vector< RecoChargedCandidateRef > > refsHlt(nStepsHlt);
286 vector< vector< const RecoChargedCandidate * > > candsHlt(nStepsHlt);
288 for (
size_t i = 0;
i < nFilters;
i++) {
289 const int hltStep =
i - 1;
291 size_t iFilter = rawTriggerEvent->filterIndex(tag);
292 if (iFilter < rawTriggerEvent->
size()) {
294 rawTriggerEvent->getObjects(iFilter,
TriggerL1Mu, candsL1);
299 else if (!skipFilters)
300 LogTrace(
"HLTMuonVal") <<
"No collection with label " <<
tag;
308 for (
size_t i = 0;
i < handleCandsL2->size();
i++)
309 candsHlt[0].push_back(& handleCandsL2->at(
i));
311 for (
size_t i = 0;
i < handleCandsL3->size();
i++)
312 candsHlt[1].push_back(& handleCandsL3->at(
i));
314 else for (
size_t i = 0;
i < nStepsHlt;
i++)
315 for (
size_t j = 0;
j < refsHlt[
i].size();
j++)
316 if (refsHlt[
i][
j].isAvailable()) {
317 candsHlt[
i].push_back(& * refsHlt[
i][
j]);
320 <<
"Ref refsHlt[i][j]: product not available "
327 vector<size_t> matchesInEtaRange;
328 vector<bool> hasMatch(matches.size(),
true);
332 const size_t hltStep = (
step >= 2) ?
step - 2 : 0;
335 (
step == 3) ? ((nStepsHlt == 4) ? 2 : 3) :
339 for (
size_t j = 0;
j < matches.size();
j++) {
341 if (fabs(matches[
j].candBase->eta()) < maxEta)
342 matchesInEtaRange.push_back(
j);
344 else if (level == 1) {
345 if (matches[
j].candL1 == 0)
348 else if (level >= 2) {
349 if (matches[
j].candHlt[hltStep] == 0)
351 else if (!hasMatch[
j]) {
352 LogTrace(
"HLTMuonVal") <<
"Match found for HLT step " << hltStep
353 <<
" of " << nStepsHlt
354 <<
" without previous match!";
360 if (
std::count(hasMatch.begin(), hasMatch.end(),
true) <
364 string pre = path +
"_" + source +
"Pass";
367 for (
size_t j = 0;
j < matches.size();
j++) {
368 float pt = matches[
j].candBase->pt();
369 float eta = matches[
j].candBase->eta();
370 float phi = matches[
j].candBase->phi();
372 if (matchesInEtaRange.size() >= 1 && j == matchesInEtaRange[0])
374 if (matchesInEtaRange.size() >= 2 && j == matchesInEtaRange[1])
377 elements_[pre +
"Eta" + post]->Fill(eta);
378 if (fabs(eta) < maxEta)
379 elements_[pre +
"Phi" + post]->Fill(phi);
392 vector<MatchStruct> & matches,
393 vector<L1MuonParticleRef> candsL1,
394 vector< vector< const RecoChargedCandidate *> > candsHlt)
397 set<size_t>::iterator it;
399 set<size_t> indicesL1;
400 for (
size_t i = 0;
i < candsL1.size();
i++)
403 vector< set<size_t> > indicesHlt(candsHlt.size());
404 for (
size_t i = 0;
i < candsHlt.size();
i++)
405 for (
size_t j = 0;
j < candsHlt[
i].size();
j++)
408 for (
size_t i = 0;
i < matches.size();
i++) {
412 double bestDeltaR =
cutsDr_[0];
413 size_t bestMatch =
kNull;
414 for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
415 if (candsL1[*it].isAvailable()) {
417 candsL1[*it]->eta(), candsL1[*it]->phi());
418 if (dR < bestDeltaR) {
432 <<
"Ref candsL1[*it]: product not available "
436 if (bestMatch !=
kNull)
437 matches[
i].candL1 = & * candsL1[bestMatch];
438 indicesL1.erase(bestMatch);
440 matches[
i].candHlt.assign(candsHlt.size(), 0);
441 for (
size_t j = 0;
j < candsHlt.size();
j++) {
442 size_t level = (candsHlt.size() == 4) ? (
j < 2) ? 2 : 3 :
443 (candsHlt.size() == 2) ? (
j < 1) ? 2 : 3 :
445 bestDeltaR =
cutsDr_[level - 2];
447 for (it = indicesHlt[
j].
begin(); it != indicesHlt[
j].end(); it++) {
449 candsHlt[
j][*it]->eta(), candsHlt[
j][*it]->phi());
450 if (dR < bestDeltaR) {
455 if (bestMatch !=
kNull)
456 matches[
i].candHlt[
j] = candsHlt[
j][bestMatch];
457 indicesHlt[
j].erase(bestMatch);
480 string sourceUpper =
source;
481 sourceUpper[0] = toupper(sourceUpper[0]);
482 string name = source +
"Pass" + type +
"_" +
label;
483 string rootName = path +
"_" +
name;
486 if (type.find(
"MaxPt") != string::npos) {
487 string desc = (type ==
"MaxPt1") ?
"Leading" :
"Next-to-Leading";
488 string title =
"pT of " + desc +
" " + sourceUpper +
" Muon "+
489 "matched to " +
label;
491 float *
edges =
new float[nBins + 1];
493 h =
new TH1F(rootName.c_str(), title.c_str(), nBins,
edges);
497 string symbol = (type ==
"Eta") ?
"#eta" :
"#phi";
498 string title = symbol +
" of " + sourceUpper +
" Muons " +
499 "matched to " +
label;
501 int nBins = (int)params[0];
502 double min = params[1];
503 double max = params[2];
504 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)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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")
vector< ParameterSet > Parameters
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::string hltProcessName_
std::vector< double > parametersEta_
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