26 bool> FilterIndexSave;
32 std::vector<FilterIndex> interestingFilters(
const HLTConfigProvider& HLTCP,
bool doRefAnalysis) {
33 const std::vector<std::string>& moduleLabels = HLTCP.
moduleLabels(name_);
34 std::vector<std::string> leptonTauFilters;
35 allInterestingFilters_.clear();
39 LogTrace(
"HLTTauDQMOffline") <<
"Path " << name_ <<
", list of all filters (preceded by the module index in the path)";
40 for(std::vector<std::string>::const_iterator iLabel = moduleLabels.begin(); iLabel != moduleLabels.end(); ++iLabel) {
44 LogTrace(
"HLTTauDQMOffline") <<
" " << std::distance(moduleLabels.begin(), iLabel) <<
" " << *iLabel <<
" " << type <<
" saveTags " << HLTCP.
saveTags(*iLabel);
45 if(type.find(
"Selector") != std::string::npos)
47 if(type ==
"HLTTriggerTypeFilter" || type ==
"HLTBool")
49 if(type ==
"HLT2ElectronPFTau" || type ==
"HLT2MuonPFTau" || type ==
"HLT2ElectronTau" || type ==
"HLT2MuonTau")
50 leptonTauFilters.emplace_back(*iLabel);
51 else if(type.find(
"Electron") != std::string::npos || type.find(
"Egamma") != std::string::npos || type.find(
"Muon") != std::string::npos)
53 allInterestingFilters_.emplace_back(*iLabel, iLabel-moduleLabels.begin(), HLTCP.
saveTags(*iLabel));
57 for(
const std::string& leptonTauLabel: leptonTauFilters) {
64 auto func = [&](
const FilterIndexSave&
a,
unsigned idxb) {
65 return std::get<kModuleIndex>(
a) < idxb;
67 std::vector<FilterIndexSave>::iterator
found = std::lower_bound(allInterestingFilters_.begin(), allInterestingFilters_.end(), idx1, func);
68 if(found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx1)
69 allInterestingFilters_.emplace(found, input1, idx1, HLTCP.
saveTags(input1));
70 found = std::lower_bound(allInterestingFilters_.begin(), allInterestingFilters_.end(), idx2, func);
71 if(found == allInterestingFilters_.end() || std::get<kModuleIndex>(*found) != idx2)
72 allInterestingFilters_.emplace(found, input2, idx2, HLTCP.
saveTags(input1));
75 std::vector<FilterIndex> selectedFilters;
79 for(
const auto& item: allInterestingFilters_) {
80 if(!doRefAnalysis || (doRefAnalysis && std::get<kSaveTags>(item)))
81 selectedFilters.emplace_back(std::get<kName>(item), std::get<kModuleIndex>(item));
84 return selectedFilters;
89 if(type ==
"PFRecoTauProducer" || type ==
"RecoTauPiZeroUnembedder") {
90 LogDebug(
"HLTTauDQMOffline") <<
"Found tau producer " << type <<
" with label " << producerLabel <<
" from path " << name_;
98 if(pset.
exists(
"inputTag"))
100 if(pset.
exists(
"inputTag1"))
102 if(pset.
exists(
"inputTag2"))
110 for(
const auto&
filter: allInterestingFilters_) {
111 if(isL3TauFilter(HLTCP, std::get<kName>(
filter)))
112 return std::get<kModuleIndex>(
filter);
122 std::vector<FilterIndexSave> allInterestingFilters_;
127 if(pset.
existsAs<
int>(parameterName))
130 edm::LogWarning(
"HLTTauDQMOfflineSource") <<
"No parameter '" << parameterName <<
"' in configuration of filter " << filterName <<
" pset " << pset.
dump() << std::endl;
135 struct TauLeptonMultiplicity {
142 TauLeptonMultiplicity
n;
144 if(moduleType ==
"HLTLevel1GTSeed") {
145 if(filterName.find(
"SingleMu") != std::string::npos) {
148 else if(filterName.find(
"SingleEG") != std::string::npos) {
151 else if(filterName.find(
"DoubleTau") != std::string::npos) {
155 else if(moduleType ==
"HLT1CaloJet" || moduleType ==
"HLT1PFJet") {
160 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
163 else if(moduleType ==
"HLTCaloJetTag") {
168 n.tau = getParameterSafe(HLTCP, filterName,
"MinJets");
171 else if(moduleType ==
"HLT1Tau" || moduleType ==
"HLT1PFTau") {
173 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
175 else if(moduleType ==
"HLTPFTauPairDzMatchFilter") {
178 else if(moduleType ==
"HLTElectronGenericFilter") {
180 n.electron = getParameterSafe(HLTCP, filterName,
"ncandcut");
182 else if(moduleType ==
"HLTMuonIsoFilter" || moduleType ==
"HLTMuonL3PreFilter") {
185 else if(moduleType ==
"HLT2ElectronTau" || moduleType ==
"HLT2ElectronPFTau") {
187 int num = getParameterSafe(HLTCP, filterName,
"MinN");
191 else if(moduleType ==
"HLT2MuonTau" || moduleType ==
"HLT2MuonPFTau") {
193 int num = getParameterSafe(HLTCP, filterName,
"MinN");
197 else if(moduleType ==
"HLTPrescaler" || moduleType ==
"HLT1CaloMET") {
201 edm::LogWarning(
"HLTTauDQMOfflineSource") <<
"HLTTauDQMPath.cc, inferTauLeptonMultiplicity(): module type '" << moduleType <<
"' not recognized, filter '" << filterName <<
"' in path '" << pathName <<
"' will be ignored for offline matching." << std::endl;
207 template <
typename T1,
typename T2>
208 bool deltaRmatch(
const T1&
obj,
const std::vector<T2>& refColl,
double dR, std::vector<bool>& refMask, std::vector<T2>& matchedRefs) {
210 size_t found = refColl.size();
212 for(
size_t i=0;
i<refColl.size(); ++
i) {
223 if(found < refColl.size()) {
224 matchedRefs.emplace_back(refColl[found]);
225 refMask[
found] =
false;
234 hltProcess_(hltProcess),
235 doRefAnalysis_(doRefAnalysis),
237 pathIndex_(HLTCP.triggerIndex(pathName_)),
238 lastFilterBeforeL2TauIndex_(0), lastL2TauFilterIndex_(0),
239 lastFilterBeforeL3TauIndex_(0), lastL3TauFilterIndex_(0),
240 isFirstL1Seed_(
false),
244 std::stringstream
ss;
245 ss <<
"HLTTauDQMPath: " <<
pathName_ <<
"\n";
252 edm::LogInfo(
"HLTTauDQMOffline") <<
"HLTTauDQMPath: " << pathName_ <<
" no interesting filters found";
257 ss <<
" Interesting filters (preceded by the module index in the path)";
270 TauLeptonMultiplicity n = inferTauLeptonMultiplicity(HLTCP, filterName, moduleType, pathName_);
280 <<
" nele " << n.electron
281 <<
" nmu " << n.muon;
286 LogDebug(
"HLTTauDQMOffline") << ss.str();
296 const size_t firstL3TauFilterIndex = thePath.firstL3TauFilterIndex(HLTCP);
298 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 tau producer as input in path " <<
pathName_;
334 if(
fired(triggerResults)) {
342 if(std::get<kModuleIndex>(
filterIndices_[i]) < firstFailedFilter) {
343 lastPassedFilter =
i;
360 for(
size_t i=0; i<keys.size(); ++
i) {
370 std::vector<bool> offlineMask;
372 int matchedObjects = 0;
373 offlineMask.resize(offlineObjects.
taus.size());
374 std::fill(offlineMask.begin(), offlineMask.end(),
true);
375 for(
const Object& trgObj: triggerObjects) {
380 if(deltaRmatch(trgObj.object, offlineObjects.
taus, dR, offlineMask, matchedOfflineObjects.
taus)) {
382 matchedTriggerObjects.emplace_back(trgObj);
389 int matchedObjects = 0;
390 offlineMask.resize(offlineObjects.
electrons.size());
391 std::fill(offlineMask.begin(), offlineMask.end(),
true);
392 for(
const Object& trgObj: triggerObjects) {
397 if(deltaRmatch(trgObj.object, offlineObjects.
electrons, dR, offlineMask, matchedOfflineObjects.
electrons)) {
399 matchedTriggerObjects.emplace_back(trgObj);
406 int matchedObjects = 0;
407 offlineMask.resize(offlineObjects.
muons.size());
408 std::fill(offlineMask.begin(), offlineMask.end(),
true);
409 for(
const Object& trgObj: triggerObjects) {
414 if(deltaRmatch(trgObj.object, offlineObjects.
muons, dR, offlineMask, matchedOfflineObjects.
muons)) {
416 matchedTriggerObjects.emplace_back(trgObj);
423 std::sort(matchedOfflineObjects.
taus.begin(), matchedOfflineObjects.
taus.end(), [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt();});
425 std::sort(matchedOfflineObjects.
muons.begin(), matchedOfflineObjects.
muons.end(), [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt();});
T getParameter(std::string const &) const
const std::string pathName_
std::tuple< std::string, size_t > FilterIndex
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.
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::string dump(unsigned int indent=0) const
enum start value shifted to 81 so as to avoid clashes with PDG codes
bool accept() const
Has at least one path accepted the event?
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
const edm::ParameterSet & modulePSet(const std::string &module) const
ParameterSet of module.
int getFilterNElectrons(size_t i) const
int getFilterNTaus(size_t i) const
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
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
size_t lastFilterBeforeL3TauIndex_
static std::string const triggerResults
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
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)
size_t getFilterIndex(size_t i) const
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
size_t lastL2TauFilterIndex_
HLTTauDQMPath(const std::string &pathName, const std::string &hltProcess, bool doRefAnalysis, const HLTConfigProvider &HLTCP)
std::vector< int > filterElectronN_
volatile std::atomic< bool > shutdown_flag false
std::vector< int > filterMuonN_
static constexpr size_t kModuleIndex
static constexpr size_t kInvalidIndex