31 bool> FilterIndexSave;
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_ <<
", list of all filters (preceded by the module index in the path)";
46 for(std::vector<std::string>::const_iterator iLabel = moduleLabels.begin(); iLabel != moduleLabels.end(); ++iLabel) {
50 LogTrace(
"HLTTauDQMOffline") <<
" " <<
std::distance(moduleLabels.begin(), iLabel) <<
" " << *iLabel <<
" " << type <<
" saveTags " << HLTCP.
saveTags(*iLabel);
51 if(type.find(
"Selector") != std::string::npos)
53 if(type ==
"HLTTriggerTypeFilter" || type ==
"HLTBool")
55 if(type ==
"HLT2PhotonPFTau" || type ==
"HLT2ElectronPFTau" || type ==
"HLT2MuonPFTau" || type ==
"HLT2PhotonTau" || type ==
"HLT2ElectronTau" || type ==
"HLT2MuonTau")
56 leptonTauFilters.emplace_back(*iLabel);
59 allInterestingFilters_.emplace_back(*iLabel, type, iLabel-moduleLabels.begin(), HLTCP.
saveTags(*iLabel));
63 for(
const std::string& leptonTauLabel: leptonTauFilters) {
71 auto func = [&](
const FilterIndexSave&
a,
unsigned idxb) {
72 return std::get<kModuleIndex>(
a) < idxb;
75 std::vector<FilterIndexSave>::iterator
found = std::lower_bound(allInterestingFilters_.begin(), allInterestingFilters_.end(), idx1, func);
76 if(found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx1)
77 allInterestingFilters_.emplace(found, input1, type, idx1, HLTCP.
saveTags(input1));
78 found = std::lower_bound(allInterestingFilters_.begin(), allInterestingFilters_.end(), idx2, func);
79 if(found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx2)
80 allInterestingFilters_.emplace(found, input2, type, idx2, HLTCP.
saveTags(input1));
83 std::vector<FilterIndex> selectedFilters;
87 for(
const auto& item: allInterestingFilters_) {
88 if(!doRefAnalysis || (doRefAnalysis && std::get<kSaveTags>(item))){
89 selectedFilters.emplace_back(std::get<kName>(item), std::get<kType>(item), std::get<kModuleIndex>(item));
93 return selectedFilters;
98 if(type ==
"PFRecoTauProducer" || type ==
"RecoTauPiZeroUnembedder") {
99 LogDebug(
"HLTTauDQMOffline") <<
"Found tau producer " << type <<
" with label " << producerLabel <<
" from path " << name_;
107 if(type ==
"EgammaHLTPixelMatchElectronProducers") {
108 LogDebug(
"HLTTauDQMOffline") <<
"Found electron producer " << type <<
" with label " << producerLabel <<
" from path " << name_;
116 if(type ==
"L3MuonCandidateProducer" || type ==
"L3MuonCombinedRelativeIsolationProducer") {
117 LogDebug(
"HLTTauDQMOffline") <<
"Found muon producer " << type <<
" with label " << producerLabel <<
" from path " << name_;
125 if(pset.
exists(
"inputTag"))
127 if(pset.
exists(
"inputTag1"))
129 if(pset.
exists(
"inputTag2"))
136 if(pset.
exists(
"inputTag"))
138 if(pset.
exists(
"inputTag1"))
140 if(pset.
exists(
"inputTag2"))
147 if(pset.
exists(
"inputTag"))
149 if(pset.
exists(
"inputTag1"))
151 if(pset.
exists(
"inputTag2"))
159 for(
const auto&
filter: allInterestingFilters_) {
160 if(isL3TauFilter(HLTCP, std::get<kName>(
filter)))
161 return std::get<kModuleIndex>(
filter);
169 for(
const auto&
filter: allInterestingFilters_) {
170 if(isL3ElectronFilter(HLTCP, std::get<kName>(
filter)))
171 return std::get<kModuleIndex>(
filter);
179 for(
const auto&
filter: allInterestingFilters_) {
180 if(isL3MuonFilter(HLTCP, std::get<kName>(
filter)))
181 return std::get<kModuleIndex>(
filter);
191 std::vector<FilterIndexSave> allInterestingFilters_;
196 if(pset.
existsAs<
int>(parameterName))
199 edm::LogWarning(
"HLTTauDQMOfflineSource") <<
"No parameter '" << parameterName <<
"' in configuration of filter " << filterName <<
" pset " << pset.
dump() << std::endl;
204 struct TauLeptonMultiplicity {
213 TauLeptonMultiplicity
n;
215 if(moduleType ==
"HLTLevel1GTSeed") {
217 if(filterName.find(
"Single") != std::string::npos) {
218 if(filterName.find(
"Mu") != std::string::npos) {
221 else if(filterName.find(
"EG") != std::string::npos) {
225 else if(filterName.find(
"Double") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
229 if(filterName.find(
"Mu") != std::string::npos) {
233 if(filterName.find(
"EG") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
237 if(filterName.find(
"ETM") != std::string::npos) {
241 else if(moduleType ==
"HLT1CaloMET") {
247 else if(moduleType ==
"HLT1CaloJet") {
250 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
253 else if(moduleType ==
"HLT1PFJet") {
259 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
262 else if(moduleType ==
"HLTCaloJetTag") {
268 n.tau = getParameterSafe(HLTCP, filterName,
"MinJets");
271 else if(moduleType ==
"HLT1Tau" || moduleType ==
"HLT1PFTau") {
274 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
276 else if(moduleType ==
"HLTPFTauPairDzMatchFilter") {
280 else if(moduleType ==
"HLTEgammaGenericFilter") {
282 n.electron = getParameterSafe(HLTCP, filterName,
"ncandcut");
284 else if(moduleType ==
"HLTElectronGenericFilter") {
287 n.electron = getParameterSafe(HLTCP, filterName,
"ncandcut");
289 else if(moduleType ==
"HLTMuonL2PreFilter") {
292 n.muon = getParameterSafe(HLTCP, filterName,
"MinN");
294 else if(moduleType ==
"HLTMuonIsoFilter" || moduleType ==
"HLTMuonL3PreFilter") {
296 n.muon = getParameterSafe(HLTCP, filterName,
"MinN");
298 else if(moduleType ==
"HLTMuonGenericFilter") {
302 else if(moduleType ==
"HLT2ElectronTau" || moduleType ==
"HLT2ElectronPFTau" || moduleType ==
"HLT2PhotonTau" || moduleType ==
"HLT2PhotonPFTau") {
305 int num = getParameterSafe(HLTCP, filterName,
"MinN");
309 else if(moduleType ==
"HLT2MuonTau" || moduleType ==
"HLT2MuonPFTau") {
312 int num = getParameterSafe(HLTCP, filterName,
"MinN");
316 else if(moduleType ==
"HLTPrescaler"){
320 edm::LogWarning(
"HLTTauDQMOfflineSource") <<
"HLTTauDQMPath.cc, inferTauLeptonMultiplicity(): module type '" << moduleType <<
"' not recognized, filter '" << filterName <<
"' in path '" << pathName <<
"' will be ignored for offline matching." << std::endl;
325 template <
typename T1,
typename T2>
326 bool deltaRmatch(
const T1&
obj,
const std::vector<T2>& refColl,
double dR, std::vector<bool>& refMask, std::vector<T2>& matchedRefs) {
328 size_t found = refColl.size();
330 for(
size_t i=0;
i<refColl.size(); ++
i) {
341 if(found < refColl.size()) {
342 matchedRefs.emplace_back(refColl[found]);
343 refMask[
found] =
false;
352 hltProcess_(hltProcess),
353 doRefAnalysis_(doRefAnalysis),
355 pathIndex_(HLTCP.triggerIndex(pathName_)),
356 lastFilterBeforeL2TauIndex_(0), lastL2TauFilterIndex_(0),
357 lastFilterBeforeL3TauIndex_(0), lastL3TauFilterIndex_(0),
358 lastFilterBeforeL2ElectronIndex_(0), lastL2ElectronFilterIndex_(0),
359 lastFilterBeforeL2MuonIndex_(0), lastL2MuonFilterIndex_(0),
360 lastFilterBeforeL2METIndex_(0), lastL2METFilterIndex_(0),
361 firstFilterBeforeL2METIndex_(0), firstL2METFilterIndex_(0),
363 isFirstL1Seed_(
false),
367 std::stringstream
ss;
368 ss <<
"HLTTauDQMPath: " <<
pathName_ <<
"\n";
374 edm::LogInfo(
"HLTTauDQMOffline") <<
"HLTTauDQMPath: " << pathName_ <<
" no interesting filters found";
379 ss <<
" Interesting filters (preceded by the module index in the path)";
395 TauLeptonMultiplicity n = inferTauLeptonMultiplicity(HLTCP, filterName, moduleType, pathName_);
407 <<
" nele " << n.electron
408 <<
" nmu " << n.muon;
412 LogDebug(
"HLTTauDQMOffline") << ss.str();
421 const size_t firstL3TauFilterIndex = thePath.firstL3TauFilterIndex(HLTCP);
423 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 tau producer as input in path " <<
pathName_;
425 const size_t firstL3ElectronFilterIndex = thePath.firstL3ElectronFilterIndex(HLTCP);
427 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 electron producer as input in path " <<
pathName_;
429 const size_t firstL3MuonFilterIndex = thePath.firstL3MuonFilterIndex(HLTCP);
431 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 muon producer as input in path " <<
pathName_;
543 if(
fired(triggerResults)) {
551 if(std::get<kModuleIndex>(
filterIndices_[i]) < firstFailedFilter) {
552 lastPassedFilter =
i;
568 for(
size_t i=0; i<keys.size(); ++
i) {
577 std::vector<bool> offlineMask;
579 int matchedObjects = 0;
580 offlineMask.resize(offlineObjects.
taus.size());
581 std::fill(offlineMask.begin(), offlineMask.end(),
true);
582 for(
const Object& trgObj: triggerObjects) {
587 if(deltaRmatch(trgObj.object, offlineObjects.
taus, dR, offlineMask, matchedOfflineObjects.
taus)) {
589 matchedTriggerObjects.emplace_back(trgObj);
594 if(matchedObjects == 0)
598 int matchedObjects = 0;
599 offlineMask.resize(offlineObjects.
electrons.size());
600 std::fill(offlineMask.begin(), offlineMask.end(),
true);
601 for(
const Object& trgObj: triggerObjects) {
606 if(deltaRmatch(trgObj.object, offlineObjects.
electrons, dR, offlineMask, matchedOfflineObjects.
electrons)) {
608 matchedTriggerObjects.emplace_back(trgObj);
615 int matchedObjects = 0;
616 offlineMask.resize(offlineObjects.
muons.size());
617 std::fill(offlineMask.begin(), offlineMask.end(),
true);
618 for(
const Object& trgObj: triggerObjects) {
623 if(deltaRmatch(trgObj.object, offlineObjects.
muons, dR, offlineMask, matchedOfflineObjects.
muons)) {
625 matchedTriggerObjects.emplace_back(trgObj);
632 int matchedObjects = 0;
633 offlineMask.resize(offlineObjects.
met.size());
634 std::fill(offlineMask.begin(), offlineMask.end(),
true);
635 for(
const Object& trgObj: triggerObjects) {
640 matchedTriggerObjects.emplace_back(trgObj);
648 std::sort(matchedOfflineObjects.
taus.begin(), matchedOfflineObjects.
taus.end(), [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt();});
650 std::sort(matchedOfflineObjects.
muons.begin(), matchedOfflineObjects.
muons.end(), [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt();});
651 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_
static const std::string kType("type")
double deltaR(const T1 &t1, const T2 &t2)
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_
math::XYZTLorentzVectorD LV
size_t lastL2MuonFilterIndex_
std::vector< FilterIndex > filterIndices_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
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
HLTTauDQMPath(const std::string &pathName, const std::string &hltProcess, bool doRefAnalysis, const HLTConfigProvider &HLTCP)
std::vector< int > filterElectronN_
size_t lastL3MuonFilterIndex_
size_t lastL2ElectronFilterIndex_
size_t firstFilterBeforeL2METIndex_
volatile std::atomic< bool > shutdown_flag false
std::vector< int > filterMuonN_
static constexpr size_t kModuleIndex
static constexpr size_t kInvalidIndex
size_t lastL2METFilterIndex_
size_t lastFilterBeforeL2MuonIndex_
size_t firstL2METFilterIndex_