1 #include <tbb/concurrent_unordered_map.h>
2 #include <boost/algorithm/string.hpp>
85 if (name.find_first_not_of(
wildcard_) == std::string::npos)
88 std::vector<std::string> namePartsVec;
91 for (std::vector<std::string>::const_iterator iVec = nameVec.begin(); iVec != nameVec.end(); ++iVec) {
97 for (std::vector<std::string>::const_iterator iName = namePartsVec.begin(); iName != namePartsVec.end(); ++iName) {
101 if (iName->length() == 0)
105 index = iVec->find(*iName, index);
109 if (index == std::string::npos || (iName == namePartsVec.begin() && index > 0)) {
114 index += iName->length();
129 bool pathLastFilterAccepted,
130 bool pathL3FilterAccepted) {
141 }
else if (pathLastFilterAccepted || pathL3FilterAccepted) {
159 bool pathL3FilterAccepted)
const {
164 pathLastFilterAccepted =
false;
166 pathL3FilterAccepted =
false;
168 if (!pathLastFilterAccepted && !pathL3FilterAccepted)
171 std::vector<std::string>
paths;
173 for (
unsigned iPath = 0; iPath <
pathNames_.size(); ++iPath) {
187 if (name.find(
wildcard_) != std::string::npos)
195 bool pathLastFilterAccepted,
196 bool pathL3FilterAccepted)
const {
200 if (name.find(
wildcard_) != std::string::npos)
204 pathLastFilterAccepted =
false;
206 pathL3FilterAccepted =
false;
212 if (!pathLastFilterAccepted && !pathL3FilterAccepted)
217 return (foundLastFilter && foundL3Filter);
237 if (collName.find(
wildcard_) != std::string::npos) {
245 if (collTag.
process().empty()) {
261 if (!unpacked && throwIfPacked)
263 "This TriggerObjectStandAlone object has packed trigger path names. Before accessing path "
264 "names you must call unpackPathNames with an edm::TriggerNames object. You can get the latter "
265 "from the edm::Event or fwlite::Event and the TriggerResults\n");
270 if (!unpacked && throwIfPacked)
272 "This TriggerObjectStandAlone object has packed trigger filter labels. Before accessing path "
273 "names you must call unpackFilterLabels with an edm::EventBase object. Both the edm::Event or "
274 "fwlite::Event are derived from edm::EventBase and can be passed\n");
281 throw cms::Exception(
"RuntimeError",
"Error, trying to pack a partially packed TriggerObjectStandAlone");
288 std::vector<uint16_t>
indices(n);
289 for (
unsigned int i = 0;
i <
n; ++
i) {
292 static std::atomic<int> _warn(0);
295 <<
"Warning: can't resolve '" <<
pathNames_[
i] <<
"' to a path index" << std::endl;
311 throw cms::Exception(
"RuntimeError",
"Error, trying to unpack a partially unpacked TriggerObjectStandAlone");
317 std::vector<std::string>
paths(n);
318 for (
unsigned int i = 0;
i <
n; ++
i) {
320 throw cms::Exception(
"RuntimeError",
"Error, path index out of bounds");
330 "Error, trying to pack filter labels for an already packed TriggerObjectStandAlone");
332 std::vector<std::string> unmatched;
336 auto nStart = names.begin(), nEnd = names.end();
340 indices.push_back(
match - nStart);
342 static std::atomic<int> _warn(0);
345 <<
"Warning: can't resolve '" <<
filterLabels_[
i] <<
"' to a label index. idx: " << i << std::endl;
349 std::sort(indices.begin(), indices.end());
370 throw cms::Exception(
"RuntimeError",
"Error, filter label index out of bounds");
382 MiniFloatConverter::reduceMantissaToNbitsRounding<11>(
eta()),
383 MiniFloatConverter::reduceMantissaToNbits<11>(
phi()),
384 MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
mass())));
391 typedef tbb::concurrent_unordered_map<edm::ParameterSetID, std::vector<std::string>, key_hash> AllLabelsMap;
400 AllLabelsMap::const_iterator iter = allLabelsMap.find(psetid);
401 if (iter != allLabelsMap.end()) {
402 return &iter->second;
411 using namespace trigger;
415 for (
unsigned int i = 0;
i !=
n; ++
i) {
422 if (pset->
exists(moduleStrip)) {
424 if (modulePSet.existsAs<
bool>(
"saveTags",
true) and modulePSet.getParameter<
bool>(
"saveTags")) {
432 std::pair<AllLabelsMap::iterator, bool>
ret =
434 return &(
ret.first->second);
void packFilterLabels(const edm::EventBase &event, const edm::TriggerResults &res)
tuple ret
prodAgent to be discontinued
std::vector< std::string > pathsOrAlgorithms(bool pathLastFilterAccepted, bool pathL3FilterAccepted) const
Gets all HLT path or L1 algorithm names.
bool checkIfPathsAreUnpacked(bool throwIfPacked=true) const
Check if trigger names have been packed by calling packPathNames() and not yet unpacked.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
double pt() const final
transverse momentum
void packP4()
reduce the precision on the 4-vector
bool checkIfFiltersAreUnpacked(bool throwIfPacked=true) const
Check if trigger names have been packed by calling packFilterLabels() and not yet unpacked...
bool id(trigger::TriggerObjectType triggerObjectType) const
std::vector< uint16_t > filterLabelIndices_
static const char wildcard_
Constants.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
unsigned int triggerIndex(std::string_view name) const
void unpackPathNames(const edm::TriggerNames &names)
unpack trigger names into indices
virtual edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const =0
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Analysis-level trigger object class.
const std::string names[nVars_]
const LorentzVector & p4() const final
four-momentum Lorentz vector
bool hasAnyName(const std::string &name, const std::vector< std::string > &nameVec) const
Private methods.
void addPathOrAlgorithm(const std::string &name, bool pathLastFilterAccepted, bool pathL3FilterAccepted)
Adds a new HLT path or L1 algorithm name.
int pdgId() const final
PDG identifier.
Single trigger physics object (e.g., an isolated muon)
TriggerObject triggerObject()
Gets the pat::TriggerObject (parent class)
void setCollection(const std::string &collName)
Methods.
const_iterator end() const
last daughter const_iterator
bool hasCollection(const std::string &collName) const override
Checks, if a certain label of original collection is assigned (method overrides)
const std::string & collection() const
Get the label of the collection the trigger object originates from.
TriggerObjectStandAlone()
Constructors and Destructor.
std::vector< std::string > const * allLabels(edm::ParameterSetID const &psetid, const edm::EventBase &event, const edm::TriggerResults &res) const
std::vector< bool > pathLastFilterAccepted_
bool hasLastFilter() const
Check, if the usage indicator vectors have been filled.
unsigned int index
index type
void unpackFilterLabels(const std::vector< std::string > &labels)
unpack filter labels from indices
bool hasPathOrAlgorithm(const std::string &name, bool pathLastFilterAccepted, bool pathL3FilterAccepted) const
Checks, if a certain HLT path or L1 algorithm name is assigned.
ParameterSet const & getParameterSet(std::string const &) const
std::string const & triggerName(unsigned int index) const
void packPathNames(const edm::TriggerNames &names)
pack trigger names into indices
std::vector< std::string > pathNames_
Vector of names of all HLT paths or L1 algorithms the trigger objects has been used in...
size_t smallHash() const
returns a short hash which can be used with hashing containers
T getParameter(std::string const &) const
virtual bool hasCollection(const std::string &collName) const
Checks, if a certain label of original collection is assigned.
std::vector< std::string > filterLabels_
Vector of labels of all HLT filters or names of L1 conditions the trigger objects has been used in...
virtual TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const =0
double mass() const final
mass
edm::ParameterSetID psetId_
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
bool hasFilterOrCondition(const std::string &name) const
Checks, if a certain HLT filter label or L1 condition name is assigned.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Log< level::Warning, false > LogWarning
void addTriggerObjectType(trigger::TriggerObjectType triggerObjectType)
Add a new trigger object type identifier.
std::vector< int > triggerObjectTypes() const
Get all trigger object type identifiers.
double phi() const final
momentum azimuthal angle
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< uint16_t > pathIndices_
void setP4(const LorentzVector &p4) final
set 4-momentum
void unpackNamesAndLabels(const edm::EventBase &event, const edm::TriggerResults &res)
unpack both filter labels and trigger names
std::vector< bool > pathL3FilterAccepted_
double eta() const final
momentum pseudorapidity