32 bool> FilterIndexSave;
39 std::vector<FilterIndex> interestingFilters(
const HLTConfigProvider& HLTCP,
bool doRefAnalysis) {
40 const std::vector<std::string>& moduleLabels = HLTCP.
moduleLabels(name_);
41 std::vector<std::string> leptonTauFilters;
42 allInterestingFilters_.clear();
46 LogTrace(
"HLTTauDQMOffline") <<
"Path " << name_ <<
", 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 <<
" " << type <<
" saveTags " << HLTCP.
saveTags(*iLabel);
52 if(type.find(
"Selector") != std::string::npos)
54 if(type ==
"HLTTriggerTypeFilter" || type ==
"HLTBool")
56 if(type ==
"HLT2PhotonPFTau" || type ==
"HLT2ElectronPFTau" || type ==
"HLT2MuonPFTau" || type ==
"HLT2PhotonTau" || type ==
"HLT2ElectronTau" || type ==
"HLT2MuonTau")
57 leptonTauFilters.emplace_back(*iLabel);
60 allInterestingFilters_.emplace_back(*iLabel, type, iLabel-moduleLabels.begin(), HLTCP.
saveTags(*iLabel));
64 for(
const std::string& leptonTauLabel: leptonTauFilters) {
72 auto func = [&](
const FilterIndexSave&
a,
unsigned idxb) {
73 return std::get<kModuleIndex>(
a) < idxb;
76 auto found = std::lower_bound(allInterestingFilters_.begin(), allInterestingFilters_.end(), idx1,
func);
77 if(
found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx1)
78 allInterestingFilters_.emplace(
found, input1, type, idx1, HLTCP.
saveTags(input1));
79 found = std::lower_bound(allInterestingFilters_.begin(), allInterestingFilters_.end(), idx2,
func);
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 <<
" from path " << name_;
108 if(type ==
"EgammaHLTPixelMatchElectronProducers") {
109 LogDebug(
"HLTTauDQMOffline") <<
"Found electron producer " << type <<
" with label " << producerLabel <<
" from path " << name_;
117 if(type ==
"L3MuonCandidateProducer" || type ==
"L3MuonCombinedRelativeIsolationProducer") {
118 LogDebug(
"HLTTauDQMOffline") <<
"Found muon producer " << type <<
" with label " << producerLabel <<
" from path " << name_;
126 if(pset.
exists(
"inputTag"))
128 if(pset.
exists(
"inputTag1"))
130 if(pset.
exists(
"inputTag2"))
137 if(pset.
exists(
"inputTag"))
139 if(pset.
exists(
"inputTag1"))
141 if(pset.
exists(
"inputTag2"))
148 if(pset.
exists(
"inputTag"))
150 if(pset.
exists(
"inputTag1"))
152 if(pset.
exists(
"inputTag2"))
160 for(
const auto&
filter: allInterestingFilters_) {
161 if(isL3TauFilter(HLTCP, std::get<kName>(
filter)))
162 return std::get<kModuleIndex>(
filter);
170 for(
const auto&
filter: allInterestingFilters_) {
171 if(isL3ElectronFilter(HLTCP, std::get<kName>(
filter)))
172 return std::get<kModuleIndex>(
filter);
180 for(
const auto&
filter: allInterestingFilters_) {
181 if(isL3MuonFilter(HLTCP, std::get<kName>(
filter)))
182 return std::get<kModuleIndex>(
filter);
192 std::vector<FilterIndexSave> allInterestingFilters_;
197 if(pset.
existsAs<
int>(parameterName))
200 edm::LogWarning(
"HLTTauDQMOfflineSource") <<
"No parameter '" << parameterName <<
"' in configuration of filter " << filterName <<
" pset " << pset.
dump() << std::endl;
205 struct TauLeptonMultiplicity {
214 TauLeptonMultiplicity
n;
216 if(moduleType ==
"HLTL1TSeed") {
218 if(filterName.find(
"Single") != std::string::npos) {
219 if(filterName.find(
"Mu") != std::string::npos) {
222 else if(filterName.find(
"EG") != std::string::npos) {
226 else if(filterName.find(
"Double") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
230 if(filterName.find(
"Mu") != std::string::npos) {
234 if(filterName.find(
"EG") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
238 if(filterName.find(
"ETM") != std::string::npos) {
242 else if(moduleType ==
"HLT1CaloMET") {
248 else if(moduleType ==
"HLT1CaloJet") {
251 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
254 else if(moduleType ==
"HLT1PFJet") {
260 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
263 else if(moduleType ==
"HLTCaloJetTag") {
269 n.tau = getParameterSafe(HLTCP, filterName,
"MinJets");
272 else if(moduleType ==
"HLT1Tau" || moduleType ==
"HLT1PFTau") {
275 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
277 else if(moduleType ==
"HLTPFTauPairDzMatchFilter") {
281 else if(moduleType ==
"HLTEgammaGenericFilter") {
283 n.electron = getParameterSafe(HLTCP, filterName,
"ncandcut");
285 else if(moduleType ==
"HLTElectronGenericFilter") {
288 n.electron = getParameterSafe(HLTCP, filterName,
"ncandcut");
290 else if(moduleType ==
"HLTMuonL2PreFilter") {
293 n.muon = getParameterSafe(HLTCP, filterName,
"MinN");
295 else if(moduleType ==
"HLTMuonIsoFilter" || moduleType ==
"HLTMuonL3PreFilter") {
297 n.muon = getParameterSafe(HLTCP, filterName,
"MinN");
299 else if(moduleType ==
"HLTMuonGenericFilter") {
303 else if(moduleType ==
"HLT2ElectronTau" || moduleType ==
"HLT2ElectronPFTau" || moduleType ==
"HLT2PhotonTau" || moduleType ==
"HLT2PhotonPFTau") {
306 int num = getParameterSafe(HLTCP, filterName,
"MinN");
310 else if(moduleType ==
"HLT2MuonTau" || moduleType ==
"HLT2MuonPFTau") {
313 int num = getParameterSafe(HLTCP, filterName,
"MinN");
317 else if(moduleType ==
"HLTPrescaler"){
321 edm::LogInfo(
"HLTTauDQMOfflineSource") <<
"HLTTauDQMPath.cc, inferTauLeptonMultiplicity(): module type '" << moduleType <<
"' not recognized, filter '" << filterName <<
"' in path '" << pathName <<
"' will be ignored for offline matching." << std::endl;
326 template <
typename T1,
typename T2>
327 bool deltaRmatch(
const T1&
obj,
const std::vector<T2>& refColl,
double dR, std::vector<bool>& refMask, std::vector<T2>& matchedRefs) {
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;
353 hltProcess_(
std::
move(hltProcess)),
354 doRefAnalysis_(doRefAnalysis),
355 pathName_(
std::
move(pathName)),
356 pathIndex_(HLTCP.triggerIndex(pathName_)),
357 lastFilterBeforeL2TauIndex_(0), lastL2TauFilterIndex_(0),
358 lastFilterBeforeL3TauIndex_(0), lastL3TauFilterIndex_(0),
359 lastFilterBeforeL2ElectronIndex_(0), lastL2ElectronFilterIndex_(0),
360 lastFilterBeforeL2MuonIndex_(0), lastL2MuonFilterIndex_(0),
361 lastFilterBeforeL2METIndex_(0), lastL2METFilterIndex_(0),
362 firstFilterBeforeL2METIndex_(0), firstL2METFilterIndex_(0),
364 isFirstL1Seed_(
false),
368 std::stringstream ss;
369 ss <<
"HLTTauDQMPath: " <<
pathName_ <<
"\n";
375 edm::LogInfo(
"HLTTauDQMOffline") <<
"HLTTauDQMPath: " << pathName_ <<
" no interesting filters found";
380 ss <<
" Interesting filters (preceded by the module index in the path)";
393 const std::string& filterName = std::get<kName>(filterIndice);
396 TauLeptonMultiplicity n = inferTauLeptonMultiplicity(HLTCP, filterName, moduleType, pathName_);
404 ss <<
"\n " << i <<
" " << std::get<kModuleIndex>(filterIndices_[
i])
408 <<
" nele " << n.electron
409 <<
" nmu " << n.muon;
413 LogDebug(
"HLTTauDQMOffline") << ss.str();
422 const size_t firstL3TauFilterIndex = thePath.firstL3TauFilterIndex(HLTCP);
424 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 tau producer as input in path " <<
pathName_;
426 const size_t firstL3ElectronFilterIndex = thePath.firstL3ElectronFilterIndex(HLTCP);
428 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 electron producer as input in path " <<
pathName_;
430 const size_t firstL3MuonFilterIndex = thePath.firstL3MuonFilterIndex(HLTCP);
432 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 muon producer as input in path " <<
pathName_;
544 if(
fired(triggerResults)) {
552 if(std::get<kModuleIndex>(
filterIndices_[i]) < firstFailedFilter) {
553 lastPassedFilter =
i;
569 for(
size_t i=0; i<keys.size(); ++
i) {
578 std::vector<bool> offlineMask;
580 int matchedObjects = 0;
581 offlineMask.resize(offlineObjects.
taus.size());
582 std::fill(offlineMask.begin(), offlineMask.end(),
true);
583 for(
const Object& trgObj: triggerObjects) {
587 if(deltaRmatch(trgObj.object, offlineObjects.
taus, dR, offlineMask, matchedOfflineObjects.
taus)) {
589 matchedTriggerObjects.emplace_back(trgObj);
597 int matchedObjects = 0;
598 offlineMask.resize(offlineObjects.
electrons.size());
599 std::fill(offlineMask.begin(), offlineMask.end(),
true);
600 for(
const Object& trgObj: triggerObjects) {
605 if(deltaRmatch(trgObj.object, offlineObjects.
electrons, dR, offlineMask, matchedOfflineObjects.
electrons)) {
607 matchedTriggerObjects.emplace_back(trgObj);
614 int matchedObjects = 0;
615 offlineMask.resize(offlineObjects.
muons.size());
616 std::fill(offlineMask.begin(), offlineMask.end(),
true);
617 for(
const Object& trgObj: triggerObjects) {
622 if(deltaRmatch(trgObj.object, offlineObjects.
muons, dR, offlineMask, matchedOfflineObjects.
muons)) {
624 matchedTriggerObjects.emplace_back(trgObj);
631 int matchedObjects = 0;
632 offlineMask.resize(offlineObjects.
met.size());
633 std::fill(offlineMask.begin(), offlineMask.end(),
true);
634 for(
const Object& trgObj: triggerObjects) {
639 matchedTriggerObjects.emplace_back(trgObj);
647 std::sort(matchedOfflineObjects.
taus.begin(), matchedOfflineObjects.
taus.end(), [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt();});
648 std::sort(matchedOfflineObjects.
electrons.begin(), matchedOfflineObjects.
electrons.end(), [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt();});
649 std::sort(matchedOfflineObjects.
muons.begin(), matchedOfflineObjects.
muons.end(), [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt();});
650 matchedOfflineObjects.
met = offlineObjects.
met;
T getParameter(std::string const &) const
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 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.
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)
const bool doRefAnalysis_
std::vector< size_type > Keys
const std::string & getFilterName(size_t i) 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
std::vector< int > filterElectronN_
size_t lastL3MuonFilterIndex_
size_t lastL2ElectronFilterIndex_
size_t firstFilterBeforeL2METIndex_
std::vector< int > filterMuonN_
static constexpr size_t kModuleIndex
static constexpr size_t kInvalidIndex
size_t lastL2METFilterIndex_
size_t lastFilterBeforeL2MuonIndex_
size_t firstL2METFilterIndex_