38 std::vector<FilterIndex> interestingFilters(
const HLTConfigProvider& HLTCP,
bool doRefAnalysis) {
39 const std::vector<std::string>& moduleLabels = HLTCP.
moduleLabels(name_);
40 std::vector<std::string> leptonTauFilters;
41 allInterestingFilters_.clear();
45 LogTrace(
"HLTTauDQMOffline") <<
"Path " << name_
46 <<
", list of all filters (preceded by the module index in the path)";
47 for (
auto iLabel = moduleLabels.begin(); iLabel != moduleLabels.end(); ++iLabel) {
51 LogTrace(
"HLTTauDQMOffline") <<
" " <<
std::distance(moduleLabels.begin(), iLabel) <<
" " << *iLabel <<
" " 53 if (
type.find(
"Selector") != std::string::npos)
55 if (
type ==
"HLTTriggerTypeFilter" ||
type ==
"HLTBool")
57 if (iLabel->find(
'-') == 0)
59 if (
type ==
"L2TauTagFilter")
61 if (
type ==
"HLT2PhotonPFTau" ||
type ==
"HLT2ElectronPFTau" ||
type ==
"HLT2MuonPFTau" ||
62 type ==
"HLT2PhotonTau" ||
type ==
"HLT2ElectronTau" ||
type ==
"HLT2MuonTau")
63 leptonTauFilters.emplace_back(*iLabel);
66 allInterestingFilters_.emplace_back(*iLabel,
type, iLabel - moduleLabels.begin(), HLTCP.
saveTags(*iLabel));
70 for (
const std::string& leptonTauLabel : leptonTauFilters) {
78 auto func = [&](
const FilterIndexSave&
a,
unsigned idxb) {
return std::get<kModuleIndex>(
a) < idxb; };
81 if (
found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx1)
84 if (
found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx2)
88 std::vector<FilterIndex> selectedFilters;
92 for (
const auto&
item : allInterestingFilters_) {
93 if (!doRefAnalysis || (doRefAnalysis && std::get<kSaveTags>(
item))) {
94 selectedFilters.emplace_back(std::get<kName>(
item), std::get<kType>(
item), std::get<kModuleIndex>(
item));
98 return selectedFilters;
103 if (
type ==
"PFRecoTauProducer" ||
type ==
"RecoTauPiZeroUnembedder" ||
104 type ==
"BTagProbabilityToDiscriminator") {
105 LogDebug(
"HLTTauDQMOffline") <<
"Found tau producer " <<
type <<
" with label " << producerLabel
106 <<
" from path " << name_;
114 if (
type ==
"EgammaHLTPixelMatchElectronProducers") {
115 LogDebug(
"HLTTauDQMOffline") <<
"Found electron producer " <<
type <<
" with label " << producerLabel
116 <<
" from path " << name_;
124 if (
type ==
"L3MuonCandidateProducer" ||
type ==
"L3MuonCombinedRelativeIsolationProducer") {
125 LogDebug(
"HLTTauDQMOffline") <<
"Found muon producer " <<
type <<
" with label " << producerLabel
126 <<
" from path " << name_;
134 if (
pset.exists(
"inputTag"))
136 if (
pset.exists(
"inputTag1"))
138 if (
pset.exists(
"inputTag2"))
140 if (
pset.exists(
"taus"))
147 if (
pset.exists(
"inputTag"))
149 if (
pset.exists(
"inputTag1"))
151 if (
pset.exists(
"inputTag2"))
158 if (
pset.exists(
"inputTag"))
160 if (
pset.exists(
"inputTag1"))
162 if (
pset.exists(
"inputTag2"))
170 for (
const auto&
filter : allInterestingFilters_) {
171 if (isL3TauFilter(HLTCP, std::get<kName>(
filter)))
172 return std::get<kModuleIndex>(
filter);
180 for (
const auto&
filter : allInterestingFilters_) {
181 if (isL3ElectronFilter(HLTCP, std::get<kName>(
filter)))
182 return std::get<kModuleIndex>(
filter);
190 for (
const auto&
filter : allInterestingFilters_) {
191 if (isL3MuonFilter(HLTCP, std::get<kName>(
filter)))
192 return std::get<kModuleIndex>(
filter);
202 std::vector<FilterIndexSave> allInterestingFilters_;
209 if (
pset.existsAs<
int>(parameterName))
210 return pset.getParameter<
int>(parameterName);
212 edm::LogWarning(
"HLTTauDQMOfflineSource") <<
"No parameter '" << parameterName <<
"' in configuration of filter " 218 struct TauLeptonMultiplicity {
230 TauLeptonMultiplicity
n;
232 if (moduleType ==
"HLTL1TSeed") {
234 if (
filterName.find(
"Single") != std::string::npos) {
235 if (
filterName.find(
"Mu") != std::string::npos) {
237 }
else if (
filterName.find(
"EG") != std::string::npos) {
240 }
else if (
filterName.find(
"Double") != std::string::npos &&
filterName.find(
"Tau") != std::string::npos) {
244 if (
filterName.find(
"Mu") != std::string::npos) {
248 if (
filterName.find(
"EG") != std::string::npos &&
filterName.find(
"Tau") != std::string::npos) {
252 if (
filterName.find(
"ETM") != std::string::npos) {
255 }
else if (moduleType ==
"HLT1CaloMET") {
260 }
else if (moduleType ==
"HLT1CaloJet") {
263 n.tau = getParameterSafe(HLTCP,
filterName,
"MinN");
265 }
else if (moduleType ==
"TauTagFilter") {
267 n.tau = getParameterSafe(HLTCP,
filterName,
"nExpected");
268 }
else if (moduleType ==
"HLT1PFJet") {
274 n.tau = getParameterSafe(HLTCP,
filterName,
"MinN");
276 }
else if (moduleType ==
"HLTCaloJetTag") {
282 n.tau = getParameterSafe(HLTCP,
filterName,
"MinJets");
284 }
else if (moduleType ==
"HLT1Tau" || moduleType ==
"HLT1PFTau") {
287 n.tau = getParameterSafe(HLTCP,
filterName,
"MinN");
288 }
else if (moduleType ==
"HLTPFTauPairDzMatchFilter") {
291 }
else if (moduleType ==
"HLTEgammaGenericFilter") {
293 n.electron = getParameterSafe(HLTCP,
filterName,
"ncandcut");
294 }
else if (moduleType ==
"HLTElectronGenericFilter") {
297 n.electron = getParameterSafe(HLTCP,
filterName,
"ncandcut");
298 }
else if (moduleType ==
"HLTMuonL2PreFilter") {
301 n.muon = getParameterSafe(HLTCP,
filterName,
"MinN");
302 }
else if (moduleType ==
"HLTMuonIsoFilter" || moduleType ==
"HLTMuonL3PreFilter") {
304 n.muon = getParameterSafe(HLTCP,
filterName,
"MinN");
305 }
else if (moduleType ==
"HLTMuonGenericFilter") {
308 }
else if (moduleType ==
"HLT2ElectronTau" || moduleType ==
"HLT2ElectronPFTau" || moduleType ==
"HLT2PhotonTau" ||
309 moduleType ==
"HLT2PhotonPFTau") {
315 }
else if (moduleType ==
"HLT2MuonTau" || moduleType ==
"HLT2MuonPFTau") {
321 }
else if (moduleType ==
"HLTPrescaler") {
325 <<
"HLTTauDQMPath.cc, inferTauLeptonMultiplicity(): module type '" << moduleType
327 <<
"' will be ignored for offline matching." << std::endl;
332 template <
typename T1,
typename T2>
333 bool deltaRmatch(
const T1&
obj,
334 const std::vector<T2>& refColl,
336 std::vector<bool>& refMask,
337 std::vector<T2>& matchedRefs) {
338 double minDr = 2 *
dR;
339 size_t found = refColl.size();
341 for (
size_t i = 0;
i < refColl.size(); ++
i) {
352 if (
found < refColl.size()) {
353 matchedRefs.emplace_back(refColl[
found]);
354 refMask[
found] =
false;
366 doRefAnalysis_(doRefAnalysis),
368 pathIndex_(HLTCP.triggerIndex(pathName_)),
369 lastFilterBeforeL2TauIndex_(0),
370 lastL2TauFilterIndex_(0),
371 lastFilterBeforeL3TauIndex_(0),
372 lastL3TauFilterIndex_(0),
373 lastFilterBeforeL2ElectronIndex_(0),
374 lastL2ElectronFilterIndex_(0),
375 lastFilterBeforeL2MuonIndex_(0),
376 lastL2MuonFilterIndex_(0),
377 lastFilterBeforeL2METIndex_(0),
378 lastL2METFilterIndex_(0),
379 firstFilterBeforeL2METIndex_(0),
380 firstL2METFilterIndex_(0),
382 isFirstL1Seed_(
false),
385 std::stringstream
ss;
392 edm::LogInfo(
"HLTTauDQMOffline") <<
"HLTTauDQMPath: " <<
pathName_ <<
" no interesting filters found";
397 ss <<
" Interesting filters (preceded by the module index in the path)";
426 ss <<
"\n " <<
i <<
" " << std::get<kModuleIndex>(filterIndice) <<
" " <<
filterName <<
" " << moduleType
427 <<
" ntau " <<
n.tau <<
" nele " <<
n.electron <<
" nmu " <<
n.muon;
441 const size_t firstL3TauFilterIndex = thePath.firstL3TauFilterIndex(HLTCP);
443 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 tau producer as input in path " <<
pathName_;
445 const size_t firstL3ElectronFilterIndex = thePath.firstL3ElectronFilterIndex(HLTCP);
447 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 electron producer as input in path " 450 const size_t firstL3MuonFilterIndex = thePath.firstL3MuonFilterIndex(HLTCP);
452 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 muon producer as input in path " <<
pathName_;
579 std::vector<Object>& retval)
const {
585 for (
size_t i = 0;
i <
keys.size(); ++
i) {
596 std::vector<Object>& matchedTriggerObjects,
599 std::vector<bool> offlineMask;
601 int matchedObjects = 0;
602 offlineMask.resize(offlineObjects.
taus.size());
603 std::fill(offlineMask.begin(), offlineMask.end(),
true);
608 if (deltaRmatch(trgObj.object, offlineObjects.
taus,
dR, offlineMask, matchedOfflineObjects.
taus)) {
610 matchedTriggerObjects.emplace_back(trgObj);
618 int matchedObjects = 0;
619 offlineMask.resize(offlineObjects.
electrons.size());
620 std::fill(offlineMask.begin(), offlineMask.end(),
true);
626 if (deltaRmatch(trgObj.object, offlineObjects.
electrons,
dR, offlineMask, matchedOfflineObjects.
electrons)) {
628 matchedTriggerObjects.emplace_back(trgObj);
635 int matchedObjects = 0;
636 offlineMask.resize(offlineObjects.
muons.size());
637 std::fill(offlineMask.begin(), offlineMask.end(),
true);
642 if (deltaRmatch(trgObj.object, offlineObjects.
muons,
dR, offlineMask, matchedOfflineObjects.
muons)) {
644 matchedTriggerObjects.emplace_back(trgObj);
651 int matchedObjects = 0;
652 offlineMask.resize(offlineObjects.
met.size());
653 std::fill(offlineMask.begin(), offlineMask.end(),
true);
659 matchedTriggerObjects.emplace_back(trgObj);
668 return a.pt() >
b.pt();
672 [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt(); });
674 return a.pt() >
b.pt();
676 matchedOfflineObjects.
met = offlineObjects.
met;
const std::string pathName_
bool isValid_(value_type const &hash)
size_t lastL3ElectronFilterIndex_
std::vector< LV > electrons
The single EDProduct to be saved for each event (AOD case)
std::vector< int > filterMET_
int getFilterNElectrons(size_t i) const
enum start value shifted to 81 so as to avoid clashes with PDG codes
size_t lastFilterBeforeL2METIndex_
std::tuple< std::string, std::string, size_t > FilterIndex
const std::string moduleType(const std::string &module) const
C++ class name of module.
size_t lastFilterBeforeL3ElectronIndex_
math::XYZTLorentzVectorD LV
static const std::string kType("type")
size_t lastFilterBeforeL3MuonIndex_
std::vector< int > filterLevel_
const std::string hltProcess_
Single trigger physics object (e.g., an isolated muon)
const unsigned int pathIndex_
bool saveTags(const std::string &module) const
Is module an L3 filter (ie, tracked saveTags=true)
size_t lastFilterBeforeL2TauIndex_
const edm::ParameterSet & modulePSet(const std::string &module) const
ParameterSet of module.
static constexpr size_t kName
size_t filtersSize() const
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
int getFilterMET(size_t i) const
size_t lastFilterBeforeL3TauIndex_
int getFilterNMuons(size_t i) const
static std::string const triggerResults
int getFilterLevel(size_t i) const
size_t lastFilterBeforeL2ElectronIndex_
std::vector< int > filterTauN_
size_t lastL2MuonFilterIndex_
std::vector< FilterIndex > filterIndices_
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const std::string moduleEDMType(const std::string &module) const
C++ base class name of module.
HLTTauDQMPath(std::string pathName, std::string hltProcess, bool doRefAnalysis, const HLTConfigProvider &HLTCP)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Log< level::Info, false > LogInfo
const bool doRefAnalysis_
std::vector< size_type > Keys
int getFilterNTaus(size_t i) const
size_t lastL3TauFilterIndex_
void getFilterObjects(const trigger::TriggerEvent &triggerEvent, size_t i, std::vector< Object > &retval) const
static constexpr size_t kType
size_t lastL2TauFilterIndex_
bool goodOfflineEvent(size_t i, const HLTTauDQMOfflineObjects &offlineObjects) const
std::vector< int > filterElectronN_
size_t lastL3MuonFilterIndex_
size_t lastL2ElectronFilterIndex_
size_t firstFilterBeforeL2METIndex_
unsigned int moduleIndex(unsigned int trigger, const std::string &module) const
slot position of module on trigger path (0 to size-1)
Log< level::Warning, false > LogWarning
int lastPassedFilter(const edm::TriggerResults &triggerResults) const
const std::string & getFilterName(size_t i) const
std::vector< int > filterMuonN_
static constexpr size_t kModuleIndex
bool fired(const edm::TriggerResults &triggerResults) const
static constexpr size_t kInvalidIndex
size_t lastL2METFilterIndex_
bool offlineMatching(size_t i, const std::vector< Object > &triggerObjects, const HLTTauDQMOfflineObjects &offlineObjects, double dR, std::vector< Object > &matchedTriggerObjects, HLTTauDQMOfflineObjects &matchedOfflineObjects) const
size_t lastFilterBeforeL2MuonIndex_
size_t firstL2METFilterIndex_