ATLAS Offline Software
Loading...
Searching...
No Matches
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
14namespace ChainNameParser {
16 struct LegInfo
17 {
19 std::string legName() 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{""};
79 bool advance();
80 };
81
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 //
HLTChainInfo(const std::string &chain)
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.
const_iterator begin() const
Iterator to the start of the leg infos.
const std::string & chain() const
The chain.
const_iterator end() const
Iterator to the end of the leg infos.
Iterate over the legs of a chain.
bool exhausted() const
Whether the iterator is exhausted.
std::input_iterator_tag iterator_category
LegInfoIterator & operator++()
pre-increment operator
LegInfoIterator()=default
Default constructor creates a past-the-end iterator.
std::string::const_iterator m_itr
reference operator*() const
Dereference the iterator.
std::string::const_iterator m_end
bool operator!=(const LegInfoIterator &other) const
bool operator==(const LegInfoIterator &other) const
Check (in)equality against another iterator.
const std::set< std::string > & singleLegIdentifiers()
A set of identifiers which are actually single leg, even if followed by other identifiers.
std::vector< int > multiplicities(const std::string &chain)
const std::vector< std::string > & allSignatures()
A list of all signature names.
std::string legHeadPattern()
const std::vector< std::string > & allSignaturePostfixQualifiers()
A list of all post-fix qualifiers which may come immediately after the "XSigY" pattern,...
std::vector< std::string > signatures(const std::string &chain)
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
Struct containing information on each leg of a chain.
std::size_t multiplicity
The multiplicity of the leg (number of objects returned by the leg)
xAODType::ObjectType type() const
The type of xAOD IParticle produced by this signature if relevant.
std::vector< std::string > legParts
All the parts of the leg.
std::string legName() const
The name of the leg.
int threshold
The threshold on the object.
std::string signature
The HLT signature responsible for creating the object.