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 <iterator>
11 #include "xAODBase/ObjectType.h"
12 
13 namespace ChainNameParser {
15  struct LegInfo
16  {
18  std::string legName() const;
20  xAODType::ObjectType type() const;
22  std::size_t multiplicity{};
24  std::string signature{};
26  int threshold{-1};
28  std::vector<std::string> legParts;
29  };
30 
35  {
36  public:
37  using iterator_category = std::input_iterator_tag;
39  using reference = const value_type &;
40  using pointer = const value_type *;
41  using difference_type = std::ptrdiff_t;
42 
44  LegInfoIterator() = default;
45 
50  LegInfoIterator(const std::string &chain);
51 
53  bool operator==(const LegInfoIterator &other) const;
54  bool operator!=(const LegInfoIterator &other) const;
55 
61  reference operator *() const;
62  pointer operator->() const;
63 
68 
70  bool exhausted() const;
71  private:
72  std::string::const_iterator m_itr;
73  std::string::const_iterator m_end;
75  std::size_t m_peekMultiplicity{0};
76  std::string m_peekSignature{""};
77  int m_peekThreshold{-1};
78  bool advance();
79  };
80 
82  class HLTChainInfo {
83  public:
85 
86  HLTChainInfo(const std::string &chain) : m_chain(chain) {}
87 
89  const std::string &chain() const { return m_chain; }
90 
94  const_iterator end() const { return LegInfoIterator(); }
96  std::string l1Item() const;
97 
98  private:
99  std::string m_chain;
100  }; //> end class HLTChainInfo
101 
103  const std::vector<std::string> &allSignatures();
104 
105  /*
106  * @brief The regex pattern to match the part at the start of each leg
107  *
108  * The pattern has three capture groups, the first contains the multiplicity which is either
109  * a digit or empty (implying a multiplicity of 1). The second is the signature and the third
110  * is the threshold. The threshold will usually be an integer but can also be empty.
111  */
112  std::string legHeadPattern();
113 
114  /*
115  * returns multiplicities of the chain legs given the chain name.
116  * e.g. for: HLT_2g10_loose_mu20 it would be [ 2 1 ]
117  */
118  std::vector<int> multiplicities(const std::string& chain);
119  /*
120  * returns signatures of the chain given the name
121  * e.g. for: HLT_2g10_loose_mu20 it would be [ "g" "mu" ]
122  * It matches the the multiplicities returned by the above method
123  */
124  std::vector<std::string> signatures(const std::string& chain);
125 
126 
127 }
128 
129 #endif //
ChainNameParser::allSignatures
const std::vector< std::string > & allSignatures()
A list of all signature names.
Definition: ChainNameParser.cxx:188
ChainNameParser::LegInfoIterator::difference_type
std::ptrdiff_t difference_type
Definition: ChainNameParser.h:41
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:101
ChainNameParser::LegInfoIterator
Iterate over the legs of a chain.
Definition: ChainNameParser.h:35
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:94
ChainNameParser::LegInfoIterator::m_peekThreshold
int m_peekThreshold
Definition: ChainNameParser.h:77
ChainNameParser::HLTChainInfo
Helper class that provides access to information about individual legs.
Definition: ChainNameParser.h:82
ChainNameParser::LegInfoIterator::m_current
LegInfo m_current
Definition: ChainNameParser.h:74
ChainNameParser::LegInfo::signature
std::string signature
The HLT signature responsible for creating the object.
Definition: ChainNameParser.h:24
ChainNameParser::LegInfoIterator::operator*
reference operator*() const
Dereference the iterator.
Definition: ChainNameParser.cxx:96
ChainNameParser::LegInfoIterator::exhausted
bool exhausted() const
Whether the iterator is exhausted.
Definition: ChainNameParser.cxx:138
ChainNameParser
Definition: ChainNameParser.cxx:35
ChainNameParser::LegInfoIterator::m_peekMultiplicity
std::size_t m_peekMultiplicity
Definition: ChainNameParser.h:75
ObjectType.h
ChainNameParser::LegInfoIterator::m_itr
std::string::const_iterator m_itr
Definition: ChainNameParser.h:72
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:89
ChainNameParser::LegInfoIterator::m_end
std::string::const_iterator m_end
Definition: ChainNameParser.h:73
ChainNameParser::LegInfoIterator::operator==
bool operator==(const LegInfoIterator &other) const
Check (in)equality against another iterator.
Definition: ChainNameParser.cxx:86
ChainNameParser::HLTChainInfo::begin
const_iterator begin() const
Iterator to the start of the leg infos.
Definition: ChainNameParser.h:92
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:179
ChainNameParser::multiplicities
std::vector< int > multiplicities(const std::string &chain)
Definition: ChainNameParser.cxx:202
threshold
Definition: chainparser.cxx:74
ChainNameParser::LegInfo::legParts
std::vector< std::string > legParts
All the parts of the leg.
Definition: ChainNameParser.h:28
ChainNameParser::LegInfoIterator::operator!=
bool operator!=(const LegInfoIterator &other) const
Definition: ChainNameParser.cxx:91
ChainNameParser::signatures
std::vector< std::string > signatures(const std::string &chain)
Definition: ChainNameParser.cxx:210
ChainNameParser::LegInfo
Struct containing information on each leg of a chain.
Definition: ChainNameParser.h:16
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
ChainNameParser::LegInfoIterator::m_peekSignature
std::string m_peekSignature
Definition: ChainNameParser.h:76
ChainNameParser::LegInfoIterator::operator++
LegInfoIterator & operator++()
pre-increment operator
Definition: ChainNameParser.cxx:106
ChainNameParser::HLTChainInfo::HLTChainInfo
HLTChainInfo(const std::string &chain)
Definition: ChainNameParser.h:86
ChainNameParser::HLTChainInfo::m_chain
std::string m_chain
Definition: ChainNameParser.h:99
ChainNameParser::legHeadPattern
std::string legHeadPattern()
Definition: ChainNameParser.cxx:197
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:37
ChainNameParser::LegInfoIterator::advance
bool advance()
Definition: ChainNameParser.cxx:143
ChainNameParser::LegInfo::multiplicity
std::size_t multiplicity
The multiplicity of the leg (number of objects returned by the leg)
Definition: ChainNameParser.h:22