ATLAS Offline Software
ChainNameParser.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TrigCompositeUtils_ChainNameParser_h
6 #define TrigCompositeUtils_ChainNameParser_h
7 
8 #include <string>
9 #include <vector>
10 #include <set>
11 #include <iterator>
12 #include "xAODBase/ObjectType.h"
13 
14 namespace ChainNameParser {
16  struct LegInfo
17  {
19  std::string legName() const;
21  xAODType::ObjectType type() const;
23  std::size_t multiplicity{};
25  std::string signature{};
27  int threshold{-1};
29  std::vector<std::string> legParts;
30  };
31 
36  {
37  public:
38  using iterator_category = std::input_iterator_tag;
40  using reference = const value_type &;
41  using pointer = const value_type *;
42  using difference_type = std::ptrdiff_t;
43 
45  LegInfoIterator() = default;
46 
51  LegInfoIterator(const std::string &chain);
52 
54  bool operator==(const LegInfoIterator &other) const;
55  bool operator!=(const LegInfoIterator &other) const;
56 
62  reference operator *() const;
63  pointer operator->() const;
64 
69 
71  bool exhausted() const;
72  private:
73  std::string::const_iterator m_itr;
74  std::string::const_iterator m_end;
76  std::size_t m_peekMultiplicity{0};
77  std::string m_peekSignature{""};
78  int m_peekThreshold{-1};
79  bool advance();
80  };
81 
83  class HLTChainInfo {
84  public:
86 
87  HLTChainInfo(const std::string &chain) : m_chain(chain) {}
88 
90  const std::string &chain() const { return m_chain; }
91 
95  const_iterator end() const { return LegInfoIterator(); }
97  std::string l1Item() const;
98 
99  private:
100  std::string m_chain;
101  }; //> end class HLTChainInfo
102 
104  const std::vector<std::string> &allSignatures();
105 
107  const std::vector<std::string> &allSignaturePostfixQualifiers();
108 
110  const std::set<std::string> &singleLegIdentifiers();
111 
112  /*
113  * @brief The regex pattern to match the part at the start of each leg
114  *
115  * The pattern has three capture groups, the first contains the multiplicity which is either
116  * a digit or empty (implying a multiplicity of 1). The second is the signature and the third
117  * is the threshold. The threshold will usually be an integer but can also be empty.
118  */
119  std::string legHeadPattern();
120 
121  /*
122  * returns multiplicities of the chain legs given the chain name.
123  * e.g. for: HLT_2g10_loose_mu20 it would be [ 2 1 ]
124  */
125  std::vector<int> multiplicities(const std::string& chain);
126  /*
127  * returns signatures of the chain given the name
128  * e.g. for: HLT_2g10_loose_mu20 it would be [ "g" "mu" ]
129  * It matches the the multiplicities returned by the above method
130  */
131  std::vector<std::string> signatures(const std::string& chain);
132 
133 }
134 
135 #endif //
ChainNameParser::allSignatures
const std::vector< std::string > & allSignatures()
A list of all signature names.
Definition: ChainNameParser.cxx:191
ChainNameParser::LegInfoIterator::difference_type
std::ptrdiff_t difference_type
Definition: ChainNameParser.h:42
ChainNameParser::LegInfo::type
xAODType::ObjectType type() const
The type of xAOD IParticle produced by this signature if relevant.
Definition: ChainNameParser.cxx:50
ChainNameParser::LegInfoIterator::operator->
pointer operator->() const
Definition: ChainNameParser.cxx:103
ChainNameParser::LegInfoIterator
Iterate over the legs of a chain.
Definition: ChainNameParser.h:36
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
ChainNameParser::HLTChainInfo::end
const_iterator end() const
Iterator to the end of the leg infos.
Definition: ChainNameParser.h:95
ChainNameParser::LegInfoIterator::m_peekThreshold
int m_peekThreshold
Definition: ChainNameParser.h:78
ChainNameParser::HLTChainInfo
Helper class that provides access to information about individual legs.
Definition: ChainNameParser.h:83
ChainNameParser::LegInfoIterator::m_current
LegInfo m_current
Definition: ChainNameParser.h:75
ChainNameParser::LegInfo::signature
std::string signature
The HLT signature responsible for creating the object.
Definition: ChainNameParser.h:25
ChainNameParser::LegInfoIterator::operator*
reference operator*() const
Dereference the iterator.
Definition: ChainNameParser.cxx:98
ChainNameParser::LegInfoIterator::exhausted
bool exhausted() const
Whether the iterator is exhausted.
Definition: ChainNameParser.cxx:140
ChainNameParser
Definition: ChainNameParser.cxx:35
ChainNameParser::LegInfoIterator::m_peekMultiplicity
std::size_t m_peekMultiplicity
Definition: ChainNameParser.h:76
ObjectType.h
ChainNameParser::LegInfoIterator::m_itr
std::string::const_iterator m_itr
Definition: ChainNameParser.h:73
ChainNameParser::LegInfoIterator::LegInfoIterator
LegInfoIterator()=default
Default constructor creates a past-the-end iterator.
ChainNameParser::HLTChainInfo::chain
const std::string & chain() const
The chain.
Definition: ChainNameParser.h:90
ChainNameParser::LegInfoIterator::m_end
std::string::const_iterator m_end
Definition: ChainNameParser.h:74
ChainNameParser::LegInfoIterator::operator==
bool operator==(const LegInfoIterator &other) const
Check (in)equality against another iterator.
Definition: ChainNameParser.cxx:88
ChainNameParser::HLTChainInfo::begin
const_iterator begin() const
Iterator to the start of the leg infos.
Definition: ChainNameParser.h:93
ChainNameParser::HLTChainInfo::l1Item
std::string l1Item() const
Read the L1 item from the chain. Returns the empty string if the L1 item isn't in the chain name.
Definition: ChainNameParser.cxx:182
ChainNameParser::multiplicities
std::vector< int > multiplicities(const std::string &chain)
Definition: ChainNameParser.cxx:226
threshold
Definition: chainparser.cxx:74
ChainNameParser::LegInfo::legParts
std::vector< std::string > legParts
All the parts of the leg.
Definition: ChainNameParser.h:29
ChainNameParser::LegInfoIterator::operator!=
bool operator!=(const LegInfoIterator &other) const
Definition: ChainNameParser.cxx:93
ChainNameParser::signatures
std::vector< std::string > signatures(const std::string &chain)
Definition: ChainNameParser.cxx:237
ChainNameParser::LegInfo
Struct containing information on each leg of a chain.
Definition: ChainNameParser.h:17
ChainNameParser::allSignaturePostfixQualifiers
const std::vector< std::string > & allSignaturePostfixQualifiers()
A list of all post-fix qualifiers which may come immediately after the "XSigY" pattern,...
Definition: ChainNameParser.cxx:203
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
ChainNameParser::LegInfoIterator::m_peekSignature
std::string m_peekSignature
Definition: ChainNameParser.h:77
ChainNameParser::LegInfoIterator::operator++
LegInfoIterator & operator++()
pre-increment operator
Definition: ChainNameParser.cxx:108
ChainNameParser::singleLegIdentifiers
const std::set< std::string > & singleLegIdentifiers()
A set of identifiers which are actually single leg, even if followed by other identifiers.
Definition: ChainNameParser.cxx:211
ChainNameParser::HLTChainInfo::HLTChainInfo
HLTChainInfo(const std::string &chain)
Definition: ChainNameParser.h:87
ChainNameParser::HLTChainInfo::m_chain
std::string m_chain
Definition: ChainNameParser.h:100
ChainNameParser::legHeadPattern
std::string legHeadPattern()
Definition: ChainNameParser.cxx:219
xAODType::ObjectType
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition: ObjectType.h:32
ChainNameParser::LegInfo::legName
std::string legName() const
The name of the leg.
Definition: ChainNameParser.cxx:37
ChainNameParser::LegInfoIterator::iterator_category
std::input_iterator_tag iterator_category
Definition: ChainNameParser.h:38
ChainNameParser::LegInfoIterator::advance
bool advance()
Definition: ChainNameParser.cxx:145
ChainNameParser::LegInfo::multiplicity
std::size_t multiplicity
The multiplicity of the leg (number of objects returned by the leg)
Definition: ChainNameParser.h:23