7 #include <boost/algorithm/string.hpp> 106 if ( nameVec.empty() )
return false;
108 if ( name.find_first_not_of(
wildcard_ ) == std::string::npos )
return true;
110 std::vector< std::string > namePartsVec;
113 for ( std::vector< std::string >::const_iterator iVec = nameVec.begin(); iVec != nameVec.end(); ++iVec ) {
119 for ( std::vector< std::string >::const_iterator iName = namePartsVec.begin(); iName != namePartsVec.end(); ++iName ) {
123 if ( iName->length() == 0 )
continue;
126 index = iVec->find( *iName, index );
130 if ( index == std::string::npos || ( iName == namePartsVec.begin() && index > 0 ) ) {
135 index += iName->length();
138 if (
index < iVec->length() && namePartsVec.back().length() != 0 ) failed =
true;
140 if ( ! failed )
return true;
160 }
else if ( pathLastFilterAccepted || pathL3FilterAccepted ) {
183 if ( !
hasL3Filter() ) pathL3FilterAccepted =
false;
185 if ( ! pathLastFilterAccepted && ! pathL3FilterAccepted )
return pathNames_;
187 std::vector< std::string > paths;
189 for (
unsigned iPath = 0; iPath <
pathNames_.size(); ++iPath ) {
218 if ( !
hasL3Filter() ) pathL3FilterAccepted =
false;
222 if ( match ==
pathNames_.end() )
return false;
223 if ( ! pathLastFilterAccepted && ! pathL3FilterAccepted )
return true;
227 return ( foundLastFilter && foundL3Filter );
251 if ( collName.find(
wildcard_ ) != std::string::npos ) {
258 if ( collTag.
process().empty() ) {
274 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");
279 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");
288 throw cms::Exception(
"RuntimeError",
"Error, trying to pack a partially packed TriggerObjectStandAlone");
295 std::vector<uint16_t> indices(n);
296 for (
unsigned int i = 0;
i <
n; ++
i) {
299 static std::atomic<int> _warn(0);
300 if (++_warn < 5)
edm::LogWarning(
"TriggerObjectStandAlone::packPathNames()") <<
"Warning: can't resolve '" <<
pathNames_[
i] <<
"' to a path index" << std::endl;
315 throw cms::Exception(
"RuntimeError",
"Error, trying to unpack a partially unpacked TriggerObjectStandAlone");
321 std::vector<std::string> paths(n);
322 for (
unsigned int i = 0;
i <
n; ++
i) {
332 throw cms::Exception(
"RuntimeError",
"Error, trying to pack filter labels for an already packed TriggerObjectStandAlone");
334 std::vector<std::string> unmatched;
335 std::vector<uint16_t> indices;
338 auto nStart = names.begin(), nEnd = names.end();
342 indices.push_back(
match - nStart);
344 static std::atomic<int> _warn(0);
345 if(++_warn < 5)
edm::LogWarning(
"TriggerObjectStandAlone::packFilterLabels()") <<
"Warning: can't resolve '" <<
filterLabels_[
i] <<
"' to a label index. idx: " << i <<std::endl;
349 std::sort(indices.begin(), indices.end());
383 MiniFloatConverter::reduceMantissaToNbitsRounding<14>(
pt()),
384 MiniFloatConverter::reduceMantissaToNbitsRounding<11>(
eta()),
385 MiniFloatConverter::reduceMantissaToNbits<11>(
phi()),
386 MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
mass()) ));
395 typedef tbb::concurrent_unordered_map<edm::ParameterSetID, std::vector<std::string>, key_hash> AllLabelsMap;
396 [[cms::thread_safe]]
static AllLabelsMap allLabelsMap;
403 AllLabelsMap::const_iterator iter =
404 allLabelsMap.find(psetid);
405 if (iter != allLabelsMap.end()) {
406 return &iter->second;
409 auto triggerNames=
event.triggerNames(res);
412 if (0!=(pset=psetRegistry->
getMapped(psetid ))) {
418 const unsigned int n(triggerNames.size());
419 std::set<std::string> saveTags;
420 for (
unsigned int i=0;
i!=
n; ++
i) {
421 if (pset->
existsAs<vector<string> >(triggerNames.triggerName(
i),
true)) {
427 if (pset->
exists(moduleStrip)) {
429 if (modulePSet.existsAs<
bool>(
"saveTags",
true) and
430 modulePSet.getParameter<
bool>(
"saveTags") ) {
431 saveTags.
insert(moduleStrip);
437 std::vector<std::string> allModules(saveTags.begin(),saveTags.end());
438 std::pair<AllLabelsMap::iterator, bool> ret =
439 allLabelsMap.insert(std::pair<
edm::ParameterSetID, std::vector<std::string> >(psetid, allModules));
440 return &(ret.first->second);
void packFilterLabels(const edm::EventBase &event, const edm::TriggerResults &res)
T getParameter(std::string const &) const
virtual double pt() const final
transverse momentum
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
virtual double mass() const final
mass
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...
virtual double eta() const final
momentum pseudorapidity
bool id(trigger::TriggerObjectType triggerObjectType) const
virtual bool hasCollection(const std::string &collName) const
Checks, if a certain label of original collection is assigned (method overrides)
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...
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 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)
virtual double phi() const final
momentum azimuthal angle
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.
virtual int pdgId() const final
PDG identifier.
TriggerObjectStandAlone()
Constructors and Destructor.
bool getMapped(key_type const &k, value_type &result) const
std::vector< std::string > const * allLabels(edm::ParameterSetID const &psetid, const edm::EventBase &event, const edm::TriggerResults &res) const
std::vector< int > triggerObjectTypes() const
Get all trigger object type identifiers.
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.
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
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
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
void addTriggerObjectType(trigger::TriggerObjectType triggerObjectType)
Add a new trigger object type identifier.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< bool > pathLastFilterAccepted_
void unpackNamesAndLabels(const edm::EventBase &event, const edm::TriggerResults &res)
unpack both filter labels and trigger names
static Registry * instance()