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 ==
"HLT2PhotonPFTau" || type ==
"HLT2ElectronPFTau" || type ==
"HLT2MuonPFTau" || type ==
"HLT2PhotonTau" || 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(
"Single") != std::string::npos) {
146 if(filterName.find(
"Mu") != std::string::npos) {
149 else if(filterName.find(
"EG") != std::string::npos) {
153 else if(filterName.find(
"Double") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
156 else if(filterName.find(
"Mu") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
160 else if(filterName.find(
"EG") != std::string::npos && filterName.find(
"Tau") != std::string::npos) {
165 else if(moduleType ==
"HLT1CaloJet" || moduleType ==
"HLT1PFJet") {
170 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
173 else if(moduleType ==
"HLTCaloJetTag") {
178 n.tau = getParameterSafe(HLTCP, filterName,
"MinJets");
181 else if(moduleType ==
"HLT1Tau" || moduleType ==
"HLT1PFTau") {
183 n.tau = getParameterSafe(HLTCP, filterName,
"MinN");
185 else if(moduleType ==
"HLTPFTauPairDzMatchFilter") {
188 else if(moduleType ==
"HLTElectronGenericFilter" || moduleType ==
"HLTEgammaGenericFilter") {
190 n.electron = getParameterSafe(HLTCP, filterName,
"ncandcut");
192 else if(moduleType ==
"HLTMuonIsoFilter" || moduleType ==
"HLTMuonL3PreFilter") {
194 n.muon = getParameterSafe(HLTCP, filterName,
"MinN");
196 else if(moduleType ==
"HLT2ElectronTau" || moduleType ==
"HLT2ElectronPFTau" || moduleType ==
"HLT2PhotonTau" || moduleType ==
"HLT2PhotonPFTau") {
198 int num = getParameterSafe(HLTCP, filterName,
"MinN");
202 else if(moduleType ==
"HLT2MuonTau" || moduleType ==
"HLT2MuonPFTau") {
204 int num = getParameterSafe(HLTCP, filterName,
"MinN");
208 else if(moduleType ==
"HLTPrescaler" || moduleType ==
"HLT1CaloMET") {
212 edm::LogWarning(
"HLTTauDQMOfflineSource") <<
"HLTTauDQMPath.cc, inferTauLeptonMultiplicity(): module type '" << moduleType <<
"' not recognized, filter '" << filterName <<
"' in path '" << pathName <<
"' will be ignored for offline matching." << std::endl;
218 template <
typename T1,
typename T2>
219 bool deltaRmatch(
const T1&
obj,
const std::vector<T2>& refColl,
double dR, std::vector<bool>& refMask, std::vector<T2>& matchedRefs) {
221 size_t found = refColl.size();
223 for(
size_t i=0;
i<refColl.size(); ++
i) {
234 if(found < refColl.size()) {
235 matchedRefs.emplace_back(refColl[found]);
236 refMask[
found] =
false;
245 hltProcess_(hltProcess),
246 doRefAnalysis_(doRefAnalysis),
248 pathIndex_(HLTCP.triggerIndex(pathName_)),
249 lastFilterBeforeL2TauIndex_(0), lastL2TauFilterIndex_(0),
250 lastFilterBeforeL3TauIndex_(0), lastL3TauFilterIndex_(0),
251 isFirstL1Seed_(
false),
255 std::stringstream
ss;
256 ss <<
"HLTTauDQMPath: " <<
pathName_ <<
"\n";
263 edm::LogInfo(
"HLTTauDQMOffline") <<
"HLTTauDQMPath: " << pathName_ <<
" no interesting filters found";
268 ss <<
" Interesting filters (preceded by the module index in the path)";
281 TauLeptonMultiplicity n = inferTauLeptonMultiplicity(HLTCP, filterName, moduleType, pathName_);
291 <<
" nele " << n.electron
292 <<
" nmu " << n.muon;
297 LogDebug(
"HLTTauDQMOffline") << ss.str();
307 const size_t firstL3TauFilterIndex = thePath.firstL3TauFilterIndex(HLTCP);
309 edm::LogInfo(
"HLTTauDQMOffline") <<
"Did not find a filter with L3 tau producer as input in path " <<
pathName_;
345 if(
fired(triggerResults)) {
353 if(std::get<kModuleIndex>(
filterIndices_[i]) < firstFailedFilter) {
354 lastPassedFilter =
i;
371 for(
size_t i=0; i<keys.size(); ++
i) {
381 std::vector<bool> offlineMask;
383 int matchedObjects = 0;
384 offlineMask.resize(offlineObjects.
taus.size());
385 std::fill(offlineMask.begin(), offlineMask.end(),
true);
386 for(
const Object& trgObj: triggerObjects) {
391 if(deltaRmatch(trgObj.object, offlineObjects.
taus, dR, offlineMask, matchedOfflineObjects.
taus)) {
393 matchedTriggerObjects.emplace_back(trgObj);
400 int matchedObjects = 0;
401 offlineMask.resize(offlineObjects.
electrons.size());
402 std::fill(offlineMask.begin(), offlineMask.end(),
true);
403 for(
const Object& trgObj: triggerObjects) {
408 if(deltaRmatch(trgObj.object, offlineObjects.
electrons, dR, offlineMask, matchedOfflineObjects.
electrons)) {
410 matchedTriggerObjects.emplace_back(trgObj);
417 int matchedObjects = 0;
418 offlineMask.resize(offlineObjects.
muons.size());
419 std::fill(offlineMask.begin(), offlineMask.end(),
true);
420 for(
const Object& trgObj: triggerObjects) {
425 if(deltaRmatch(trgObj.object, offlineObjects.
muons, dR, offlineMask, matchedOfflineObjects.
muons)) {
427 matchedTriggerObjects.emplace_back(trgObj);
434 std::sort(matchedOfflineObjects.
taus.begin(), matchedOfflineObjects.
taus.end(), [](
const LV&
a,
const LV&
b) {
return a.pt() >
b.pt();});
436 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 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
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
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
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