36 constexpr
static size_t kSaveTags = 3;
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 <<
" "
52 << type <<
" saveTags " << HLTCP.
saveTags(*iLabel);
53 if (type.find(
"Selector") != std::string::npos)
55 if (type ==
"HLTTriggerTypeFilter" || type ==
"HLTBool")
57 if (type ==
"HLT2PhotonPFTau" || type ==
"HLT2ElectronPFTau" || type ==
"HLT2MuonPFTau" ||
58 type ==
"HLT2PhotonTau" || type ==
"HLT2ElectronTau" || type ==
"HLT2MuonTau")
59 leptonTauFilters.emplace_back(*iLabel);
62 allInterestingFilters_.emplace_back(*iLabel, type, iLabel - moduleLabels.begin(), HLTCP.
saveTags(*iLabel));
66 for (
const std::string& leptonTauLabel : leptonTauFilters) {
74 auto func = [&](
const FilterIndexSave&
a,
unsigned idxb) {
return std::get<kModuleIndex>(
a) < idxb; };
77 if (
found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx1)
78 allInterestingFilters_.emplace(
found, input1, type, idx1, HLTCP.
saveTags(input1));
80 if (
found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx2)
81 allInterestingFilters_.emplace(
found, input2, type, idx2, HLTCP.
saveTags(input1));
84 std::vector<FilterIndex> selectedFilters;
88 for (
const auto&
item : allInterestingFilters_) {
89 if (!doRefAnalysis || (doRefAnalysis && std::get<kSaveTags>(
item))) {
90 selectedFilters.emplace_back(std::get<kName>(
item), std::get<kType>(
item), std::get<kModuleIndex>(
item));
94 return selectedFilters;
99 if (type ==
"PFRecoTauProducer" || type ==
"RecoTauPiZeroUnembedder") {
100 LogDebug(
"HLTTauDQMOffline") <<
"Found tau producer " << type <<
" with label " << producerLabel
101 <<
" from path " << name_;
109 if (type ==
"EgammaHLTPixelMatchElectronProducers") {
110 LogDebug(
"HLTTauDQMOffline") <<
"Found electron producer " << type <<
" with label " << producerLabel
111 <<
" from path " << name_;
119 if (type ==
"L3MuonCandidateProducer" || type ==
"L3MuonCombinedRelativeIsolationProducer") {
120 LogDebug(
"HLTTauDQMOffline") <<
"Found muon producer " << type <<
" with label " << producerLabel
121 <<
" from path " << name_;
129 if (pset.
exists(
"inputTag"))
131 if (pset.
exists(
"inputTag1"))
133 if (pset.
exists(
"inputTag2"))
140 if (pset.
exists(
"inputTag"))
142 if (pset.
exists(
"inputTag1"))
144 if (pset.
exists(
"inputTag2"))
151 if (pset.
exists(
"inputTag"))
153 if (pset.
exists(
"inputTag1"))
155 if (pset.
exists(
"inputTag2"))
163 for (
const auto&
filter : allInterestingFilters_) {
164 if (isL3TauFilter(HLTCP, std::get<kName>(
filter)))
165 return std::get<kModuleIndex>(
filter);
173 for (
const auto&
filter : allInterestingFilters_) {
174 if (isL3ElectronFilter(HLTCP, std::get<kName>(
filter)))
175 return std::get<kModuleIndex>(
filter);
183 for (
const auto&
filter : allInterestingFilters_) {
184 if (isL3MuonFilter(HLTCP, std::get<kName>(
filter)))
185 return std::get<kModuleIndex>(
filter);
195 std::vector<FilterIndexSave> allInterestingFilters_;
202 if (pset.
existsAs<
int>(parameterName))
205 edm::LogWarning(
"HLTTauDQMOfflineSource") <<
"No parameter '" << parameterName <<
"' in configuration of filter "
206 << filterName <<
" pset " << pset.
dump() << std::endl;
211 struct TauLeptonMultiplicity {
223 TauLeptonMultiplicity
n;
225 if (moduleType ==
"HLTL1TSeed") {
227 if (filterName.find(
"Single") != std::string::npos) {
228 if (filterName.find(
"Mu") != std::string::npos) {
230 }
else if (filterName.find(
"EG") != std::string::npos) {
233 }
else if (filterName.find(
"Double") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
237 if (filterName.find(
"Mu") != std::string::npos) {
241 if (filterName.find(
"EG") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
245 if (filterName.find(
"ETM") != std::string::npos) {
248 }
else if (moduleType ==
"HLT1CaloMET") {
253 }
else if (moduleType ==
"HLT1CaloJet") {
256 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
258 }
else if (moduleType ==
"HLT1PFJet") {
264 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
266 }
else if (moduleType ==
"HLTCaloJetTag") {
272 n.tau = getParameterSafe(HLTCP, filterName,
"MinJets");
274 }
else if (moduleType ==
"HLT1Tau" || moduleType ==
"HLT1PFTau") {
277 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
278 }
else if (moduleType ==
"HLTPFTauPairDzMatchFilter") {
281 }
else if (moduleType ==
"HLTEgammaGenericFilter") {
283 n.electron = getParameterSafe(HLTCP, filterName,
"ncandcut");
284 }
else if (moduleType ==
"HLTElectronGenericFilter") {
287 n.electron = getParameterSafe(HLTCP, filterName,
"ncandcut");
288 }
else if (moduleType ==
"HLTMuonL2PreFilter") {
291 n.muon = getParameterSafe(HLTCP, filterName,
"MinN");
292 }
else if (moduleType ==
"HLTMuonIsoFilter" || moduleType ==
"HLTMuonL3PreFilter") {
294 n.muon = getParameterSafe(HLTCP, filterName,
"MinN");
295 }
else if (moduleType ==
"HLTMuonGenericFilter") {
298 }
else if (moduleType ==
"HLT2ElectronTau" || moduleType ==
"HLT2ElectronPFTau" || moduleType ==
"HLT2PhotonTau" ||
299 moduleType ==
"HLT2PhotonPFTau") {
302 int num = getParameterSafe(HLTCP, filterName,
"MinN");
305 }
else if (moduleType ==
"HLT2MuonTau" || moduleType ==
"HLT2MuonPFTau") {
308 int num = getParameterSafe(HLTCP, filterName,
"MinN");
311 }
else if (moduleType ==
"HLTPrescaler") {
315 <<
"HLTTauDQMPath.cc, inferTauLeptonMultiplicity(): module type '" << moduleType
316 <<
"' not recognized, filter '" << filterName <<
"' in path '" << pathName
317 <<
"' will be ignored for offline matching." << std::endl;
322 template <
typename T1,
typename T2>
323 bool deltaRmatch(
const T1&
obj,
324 const std::vector<T2>& refColl,
326 std::vector<bool>& refMask,
327 std::vector<T2>& matchedRefs) {
328 double minDr = 2 * dR;
329 size_t found = refColl.size();
331 for (
size_t i = 0;
i < refColl.size(); ++
i) {
342 if (found < refColl.size()) {
343 matchedRefs.emplace_back(refColl[found]);
344 refMask[
found] =
false;
355 : hltProcess_(std::
move(hltProcess)),
356 doRefAnalysis_(doRefAnalysis),
357 pathName_(std::
move(pathName)),
358 pathIndex_(HLTCP.triggerIndex(pathName_)),
359 lastFilterBeforeL2TauIndex_(0),
360 lastL2TauFilterIndex_(0),
361 lastFilterBeforeL3TauIndex_(0),
362 lastL3TauFilterIndex_(0),
363 lastFilterBeforeL2ElectronIndex_(0),
364 lastL2ElectronFilterIndex_(0),
365 lastFilterBeforeL2MuonIndex_(0),
366 lastL2MuonFilterIndex_(0),
367 lastFilterBeforeL2METIndex_(0),
368 lastL2METFilterIndex_(0),
369 firstFilterBeforeL2METIndex_(0),
370 firstL2METFilterIndex_(0),
372 isFirstL1Seed_(
false),
375 std::stringstream
ss;
376 ss <<
"HLTTauDQMPath: " <<
pathName_ <<
"\n";
382 edm::LogInfo(
"HLTTauDQMOffline") <<
"HLTTauDQMPath: " << pathName_ <<
" no interesting filters found";
387 ss <<
" Interesting filters (preceded by the module index in the path)";
403 const std::string& filterName = std::get<kName>(filterIndice);
406 TauLeptonMultiplicity n = inferTauLeptonMultiplicity(HLTCP, filterName, moduleType, pathName_);
414 ss <<
"\n " << i <<
" " << std::get<kModuleIndex>(filterIndice) <<
" " << filterName <<
" " << moduleType
415 <<
" ntau " << n.tau <<
" nele " << n.electron <<
" nmu " << n.muon;
420 LogDebug(
"HLTTauDQMOffline") << ss.str();
429 const size_t firstL3TauFilterIndex = thePath.firstL3TauFilterIndex(HLTCP);
431 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 tau producer as input in path " <<
pathName_;
433 const size_t firstL3ElectronFilterIndex = thePath.firstL3ElectronFilterIndex(HLTCP);
435 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 electron producer as input in path "
438 const size_t firstL3MuonFilterIndex = thePath.firstL3MuonFilterIndex(HLTCP);
440 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 muon producer as input in path " <<
pathName_;
547 if (
fired(triggerResults)) {
555 if (std::get<kModuleIndex>(
filterIndices_[i]) < firstFailedFilter) {
556 lastPassedFilter =
i;
567 std::vector<Object>& retval)
const {
573 for (
size_t i = 0; i < keys.size(); ++
i) {
575 retval.emplace_back(
Object{object, ids[
i]});
581 const std::vector<Object>& triggerObjects,
584 std::vector<Object>& matchedTriggerObjects,
587 std::vector<bool> offlineMask;
589 int matchedObjects = 0;
590 offlineMask.resize(offlineObjects.
taus.size());
591 std::fill(offlineMask.begin(), offlineMask.end(),
true);
592 for (
const Object& trgObj : triggerObjects) {
596 if (deltaRmatch(trgObj.object, offlineObjects.
taus, dR, offlineMask, matchedOfflineObjects.
taus)) {
598 matchedTriggerObjects.emplace_back(trgObj);
606 int matchedObjects = 0;
607 offlineMask.resize(offlineObjects.
electrons.size());
608 std::fill(offlineMask.begin(), offlineMask.end(),
true);
609 for (
const Object& trgObj : triggerObjects) {
614 if (deltaRmatch(trgObj.object, offlineObjects.
electrons, dR, offlineMask, matchedOfflineObjects.
electrons)) {
616 matchedTriggerObjects.emplace_back(trgObj);
623 int matchedObjects = 0;
624 offlineMask.resize(offlineObjects.
muons.size());
625 std::fill(offlineMask.begin(), offlineMask.end(),
true);
626 for (
const Object& trgObj : triggerObjects) {
630 if (deltaRmatch(trgObj.object, offlineObjects.
muons, dR, offlineMask, matchedOfflineObjects.
muons)) {
632 matchedTriggerObjects.emplace_back(trgObj);
639 int matchedObjects = 0;
640 offlineMask.resize(offlineObjects.
met.size());
641 std::fill(offlineMask.begin(), offlineMask.end(),
true);
642 for (
const Object& trgObj : triggerObjects) {
647 matchedTriggerObjects.emplace_back(trgObj);
655 std::sort(matchedOfflineObjects.
taus.begin(), matchedOfflineObjects.
taus.end(), [](
const LV&
a,
const LV&
b) {
656 return a.pt() >
b.pt();
658 std::sort(matchedOfflineObjects.
electrons.begin(),
660 [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt(); });
661 std::sort(matchedOfflineObjects.
muons.begin(), matchedOfflineObjects.
muons.end(), [](
const LV&
a,
const LV&
b) {
662 return a.pt() >
b.pt();
664 matchedOfflineObjects.
met = offlineObjects.
met;
const std::string pathName_
int getFilterLevel(size_t i) const
bool saveTags(const std::string &module) const
Is module an L3 filter (ie, tracked saveTags=true)
bool isValid_(value_type const &hash)
bool goodOfflineEvent(size_t i, const HLTTauDQMOfflineObjects &offlineObjects) const
const std::string moduleType(const std::string &module) const
C++ class name of module.
size_t lastL3ElectronFilterIndex_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
std::vector< LV > electrons
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
std::vector< int > filterMET_
std::string dump(unsigned int indent=0) const
enum start value shifted to 81 so as to avoid clashes with PDG codes
size_t lastFilterBeforeL2METIndex_
bool accept() const
Has at least one path accepted the event?
std::tuple< std::string, std::string, size_t > FilterIndex
const Keys & filterKeys(trigger::size_type index) const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
bool exists(std::string const ¶meterName) const
checks if a parameter exists
const std::string moduleEDMType(const std::string &module) const
C++ base class name of module.
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t Func __host__ __device__ V int Func func
int lastPassedFilter(const edm::TriggerResults &triggerResults) const
size_t lastFilterBeforeL3ElectronIndex_
math::XYZTLorentzVectorD LV
static const std::string kType("type")
const edm::ParameterSet & modulePSet(const std::string &module) const
ParameterSet of module.
int getFilterNElectrons(size_t i) const
int getFilterNTaus(size_t i) const
size_t lastFilterBeforeL3MuonIndex_
std::vector< int > filterLevel_
const std::string hltProcess_
Single trigger physics object (e.g., an isolated muon)
const Vids & filterIds(trigger::size_type index) const
void getFilterObjects(const trigger::TriggerEvent &triggerEvent, size_t i, std::vector< Object > &retval) const
unsigned int moduleIndex(unsigned int trigger, const std::string &module) const
slot position of module on trigger path (0 to size-1)
int getFilterNMuons(size_t i) const
const unsigned int pathIndex_
size_t lastFilterBeforeL2TauIndex_
const TriggerObjectCollection & getObjects() const
static constexpr size_t kName
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
size_t filtersSize() const
size_t lastFilterBeforeL3TauIndex_
static std::string const triggerResults
size_t lastFilterBeforeL2ElectronIndex_
bool offlineMatching(size_t i, const std::vector< Object > &triggerObjects, const HLTTauDQMOfflineObjects &offlineObjects, double dR, std::vector< Object > &matchedTriggerObjects, HLTTauDQMOfflineObjects &matchedOfflineObjects) const
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::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
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_
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
std::vector< size_type > Keys
const std::string & getFilterName(size_t i) const
T getParameter(std::string const &) const
size_t lastL3TauFilterIndex_
bool fired(const edm::TriggerResults &triggerResults) const
static constexpr size_t kType
size_t lastL2TauFilterIndex_
int getFilterMET(size_t i) const
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
std::vector< int > filterElectronN_
size_t lastL3MuonFilterIndex_
size_t lastL2ElectronFilterIndex_
size_t firstFilterBeforeL2METIndex_
Log< level::Warning, false > LogWarning
std::vector< int > filterMuonN_
static constexpr size_t kModuleIndex
static constexpr size_t kInvalidIndex
size_t lastL2METFilterIndex_
size_t lastFilterBeforeL2MuonIndex_
size_t firstL2METFilterIndex_