1 #include <tbb/concurrent_unordered_map.h> 2 #include <boost/algorithm/string.hpp> 103 if ( nameVec.empty() )
return false;
105 if ( name.find_first_not_of(
wildcard_ ) == std::string::npos )
return true;
107 std::vector< std::string > namePartsVec;
110 for ( std::vector< std::string >::const_iterator iVec = nameVec.begin(); iVec != nameVec.end(); ++iVec ) {
116 for ( std::vector< std::string >::const_iterator iName = namePartsVec.begin(); iName != namePartsVec.end(); ++iName ) {
120 if ( iName->length() == 0 )
continue;
123 index = iVec->find( *iName, index );
127 if ( index == std::string::npos || ( iName == namePartsVec.begin() && index > 0 ) ) {
132 index += iName->length();
135 if (
index < iVec->length() && namePartsVec.back().length() != 0 ) failed =
true;
137 if ( ! failed )
return true;
157 }
else if ( pathLastFilterAccepted || pathL3FilterAccepted ) {
180 if ( !
hasL3Filter() ) pathL3FilterAccepted =
false;
182 if ( ! pathLastFilterAccepted && ! pathL3FilterAccepted )
return pathNames_;
184 std::vector< std::string > paths;
186 for (
unsigned iPath = 0; iPath <
pathNames_.size(); ++iPath ) {
215 if ( !
hasL3Filter() ) pathL3FilterAccepted =
false;
219 if ( match ==
pathNames_.end() )
return false;
220 if ( ! pathLastFilterAccepted && ! pathL3FilterAccepted )
return true;
224 return ( foundLastFilter && foundL3Filter );
248 if ( collName.find(
wildcard_ ) != std::string::npos ) {
255 if ( collTag.
process().empty() ) {
271 if (!unpacked && throwIfPacked)
throw cms::Exception(
"RuntimeError",
"This TriggerObjectStandAlone object has packed trigger path names. Before accessing path names you must call unpackPathNames with an edm::TriggerNames object. You can get the latter from the edm::Event or fwlite::Event and the TriggerResults\n");
276 if (!unpacked && throwIfPacked)
throw cms::Exception(
"RuntimeError",
"This TriggerObjectStandAlone object has packed trigger filter labels. Before accessing path names you must call unpackFilterLabels with an edm::EventBase object. Both the edm::Event or fwlite::Event are derived from edm::EventBase and can be passed\n");
285 throw cms::Exception(
"RuntimeError",
"Error, trying to pack a partially packed TriggerObjectStandAlone");
292 std::vector<uint16_t> indices(n);
293 for (
unsigned int i = 0;
i <
n; ++
i) {
296 static std::atomic<int> _warn(0);
297 if (++_warn < 5)
edm::LogWarning(
"TriggerObjectStandAlone::packPathNames()") <<
"Warning: can't resolve '" <<
pathNames_[
i] <<
"' to a path index" << std::endl;
312 throw cms::Exception(
"RuntimeError",
"Error, trying to unpack a partially unpacked TriggerObjectStandAlone");
318 std::vector<std::string> paths(n);
319 for (
unsigned int i = 0;
i <
n; ++
i) {
329 throw cms::Exception(
"RuntimeError",
"Error, trying to pack filter labels for an already packed TriggerObjectStandAlone");
331 std::vector<std::string> unmatched;
332 std::vector<uint16_t> indices;
335 auto nStart = names.begin(), nEnd = names.end();
339 indices.push_back(
match - nStart);
341 static std::atomic<int> _warn(0);
342 if(++_warn < 5)
edm::LogWarning(
"TriggerObjectStandAlone::packFilterLabels()") <<
"Warning: can't resolve '" <<
filterLabels_[
i] <<
"' to a label index. idx: " << i <<std::endl;
346 std::sort(indices.begin(), indices.end());
380 MiniFloatConverter::reduceMantissaToNbitsRounding<14>(
pt()),
381 MiniFloatConverter::reduceMantissaToNbitsRounding<11>(
eta()),
382 MiniFloatConverter::reduceMantissaToNbits<11>(
phi()),
383 MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
mass()) ));
392 typedef tbb::concurrent_unordered_map<edm::ParameterSetID, std::vector<std::string>, key_hash> AllLabelsMap;
400 AllLabelsMap::const_iterator iter =
401 allLabelsMap.find(psetid);
402 if (iter != allLabelsMap.end()) {
403 return &iter->second;
406 const auto& triggerNames=
event.triggerNames(res);
415 const unsigned int n(triggerNames.size());
416 std::set<std::string> saveTags;
417 for (
unsigned int i=0;
i!=
n; ++
i) {
418 if (pset->
existsAs<vector<string> >(triggerNames.triggerName(
i),
true)) {
424 if (pset->
exists(moduleStrip)) {
426 if (modulePSet.existsAs<
bool>(
"saveTags",
true) and
427 modulePSet.getParameter<
bool>(
"saveTags") ) {
428 saveTags.
insert(moduleStrip);
434 std::vector<std::string> allModules(saveTags.begin(),saveTags.end());
435 std::pair<AllLabelsMap::iterator, bool> ret =
436 allLabelsMap.insert(std::pair<
edm::ParameterSetID, std::vector<std::string> >(psetid, allModules));
437 return &(ret.first->second);
void packFilterLabels(const edm::EventBase &event, const edm::TriggerResults &res)
T getParameter(std::string const &) const
int pdgId() const final
PDG identifier.
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.
double eta() const final
momentum pseudorapidity
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
void packP4()
reduce the precision on the 4-vector
static const HistoName names[]
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
static const char wildcard_
Constants.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< std::string > pathNames_
Vector of names of all HLT paths or L1 algorithms the trigger objects has been used in...
double pt() const final
transverse momentum
void insert(bool ok_to_replace, char const *, Entry const &)
std::vector< std::string > filterLabels_
Vector of labels of all HLT filters or names of L1 conditions the trigger objects has been used in...
Strings::size_type size() const
void unpackPathNames(const edm::TriggerNames &names)
unpack trigger names into indices
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool hasCollection(const std::string &collName) const override
Checks, if a certain label of original collection is assigned (method overrides)
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.
Single trigger physics object (e.g., an isolated muon)
TriggerObject triggerObject()
Gets the pat::TriggerObject (parent class)
unsigned int triggerIndex(std::string const &name) const
void setCollection(const std::string &collName)
Methods.
const_iterator end() const
last daughter const_iterator
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
const LorentzVector & p4() const final
four-momentum Lorentz vector
std::vector< int > triggerObjectTypes() const
Get all trigger object type identifiers.
virtual edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const =0
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.
std::vector< bool > pathL3FilterAccepted_
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
size_t smallHash() const
returns a short hash which can be used with hashing containers
virtual bool hasCollection(const std::string &collName) const
Checks, if a certain label of original collection is assigned.
edm::ParameterSetID psetId_
std::vector< uint16_t > pathIndices_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
std::vector< uint16_t > filterLabelIndices_
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.
virtual TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const =0
void addTriggerObjectType(trigger::TriggerObjectType triggerObjectType)
Add a new trigger object type identifier.
double phi() const final
momentum azimuthal angle
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< bool > pathLastFilterAccepted_
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
double mass() const final
mass