ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMatchToolCore::ChainNameIndex Class Reference
Collaboration diagram for TrigMatchToolCore::ChainNameIndex:

Public Member Functions

 ChainNameIndex (TrigMatchToolCore *core)
size_t chainNameToIndex (const std::string &chainName)
std::vector< std::string > configuredChainNames ()
std::string chainName (size_t index)
void clear ()
std::string propagateChainNames (const std::string &chainName)

Private Types

typedef std::mutex mutex_t
typedef std::lock_guard< mutex_tlock_t
typedef std::unordered_map< std::string, size_t > chainIndexMap_t

Private Member Functions

void assertConfiguredChainNames ()

Private Attributes

mutex_t m_mutex
TrigMatchToolCorem_core
std::vector< std::string > m_chainNames
size_t m_nConfiguredChainNames = 0
chainIndexMap_t m_chainIndexMap
std::map< std::string, std::string > m_l1l2Map

Detailed Description

Definition at line 403 of file TrigMatchToolCore.h.

Member Typedef Documentation

◆ chainIndexMap_t

typedef std::unordered_map<std::string, size_t> TrigMatchToolCore::ChainNameIndex::chainIndexMap_t
private

Definition at line 432 of file TrigMatchToolCore.h.

◆ lock_t

typedef std::lock_guard<mutex_t> TrigMatchToolCore::ChainNameIndex::lock_t
private

Definition at line 418 of file TrigMatchToolCore.h.

◆ mutex_t

typedef std::mutex TrigMatchToolCore::ChainNameIndex::mutex_t
private

Definition at line 417 of file TrigMatchToolCore.h.

Constructor & Destructor Documentation

◆ ChainNameIndex()

TrigMatchToolCore::ChainNameIndex::ChainNameIndex ( TrigMatchToolCore * core)

Definition at line 102 of file TrigMatchToolCore.cxx.

103 : m_core (core)
104{
105}

Member Function Documentation

◆ assertConfiguredChainNames()

void TrigMatchToolCore::ChainNameIndex::assertConfiguredChainNames ( )
private

Definition at line 109 of file TrigMatchToolCore.cxx.

110{
111 if (m_chainNames.empty()) {
112 m_chainNames = m_core->getConfiguredChainNames();
114 m_chainIndexMap.clear();
115 for (size_t i = 0; i < m_chainNames.size(); i++) {
116 const std::string& chainName = m_chainNames[i];
118
119 // Build the L1L2 map. Note that we ignore regex support
120 // at this stage - we'll implement regex support by matching
121 // to the keys in the cache later on. Also note that the
122 // cached version does not have parentheses around it (so
123 // they can easily be combined)
124 if (chainName.find("L2_") != std::string::npos) {
125 const std::string l1 = m_core->lowerChainName( chainName );
126
127 if( m_l1l2Map.find( l1 ) == m_l1l2Map.end() ) {
129 } else {
130 m_l1l2Map[ l1 ] = m_l1l2Map[ l1 ] + "|" + chainName;
131 }
132 }
133 }
134 }
135}
std::string chainName(size_t index)
std::vector< std::string > m_chainNames
std::map< std::string, std::string > m_l1l2Map

◆ chainName()

std::string TrigMatchToolCore::ChainNameIndex::chainName ( size_t index)

Definition at line 166 of file TrigMatchToolCore.cxx.

167{
170 return m_chainNames.at (index);
171}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
std::lock_guard< mutex_t > lock_t

◆ chainNameToIndex()

size_t TrigMatchToolCore::ChainNameIndex::chainNameToIndex ( const std::string & chainName)

Definition at line 139 of file TrigMatchToolCore.cxx.

140{
143 chainIndexMap_t::iterator it = m_chainIndexMap.find (chainName);
144 if (it == m_chainIndexMap.end()) {
145 size_t chainIndex = m_chainNames.size();
146 m_chainIndexMap[chainName] = chainIndex;
147 m_chainNames.push_back (chainName);
148 return chainIndex;
149 }
150 else
151 return it->second;
152}

◆ clear()

void TrigMatchToolCore::ChainNameIndex::clear ( )

Definition at line 175 of file TrigMatchToolCore.cxx.

176{
178 m_chainNames.clear();
179 m_chainIndexMap.clear();
181 m_l1l2Map.clear();
183}

◆ configuredChainNames()

std::vector< std::string > TrigMatchToolCore::ChainNameIndex::configuredChainNames ( )

Definition at line 156 of file TrigMatchToolCore.cxx.

157{
160 return std::vector<std::string> (m_chainNames.begin(),
162}

◆ propagateChainNames()

std::string TrigMatchToolCore::ChainNameIndex::propagateChainNames ( const std::string & chainName)

Definition at line 187 of file TrigMatchToolCore.cxx.

188{
189 // only applicable for L1 chains
190 if( chainName.find( "L1_" ) == std::string::npos )
191 return chainName;
192
194
195 // add it to the cache if necessary
196 if( m_l1l2Map.find( chainName ) == m_l1l2Map.end() ) {
197
198 // if its not in the cache, we need to check
199 // if we can build it from the cache.
200 // regex support
201 std::regex compiled( chainName );
202 std::string chains;
203
204 std::map< std::string, std::string >::const_iterator iter =
205 m_l1l2Map.begin();
206 std::map< std::string, std::string >::const_iterator end =
207 m_l1l2Map.end();
208 for( ; iter != end; ++iter ) {
209 // check if the l1 chain matches the regex supplied by chainName
210 if( std::regex_match( iter->first.c_str(), compiled ) ) {
211 if( chains.empty() ) {
212 chains += iter->second;
213 } else {
214 chains += "|" + iter->second;
215 }
216 }
217 }
218
219 // add it to the cache
221 }
222
223 // if it wasn't in the cache before, it will be now, so pull it out
224 std::string output = m_l1l2Map[ chainName ];
225 if( output.find( "|" ) != std::string::npos ) {
226 output = "(" + output + ")";
227 }
228
229 return output;
230}
output
Definition merge.py:16

Member Data Documentation

◆ m_chainIndexMap

chainIndexMap_t TrigMatchToolCore::ChainNameIndex::m_chainIndexMap
private

Definition at line 433 of file TrigMatchToolCore.h.

◆ m_chainNames

std::vector< std::string > TrigMatchToolCore::ChainNameIndex::m_chainNames
private

Definition at line 428 of file TrigMatchToolCore.h.

◆ m_core

TrigMatchToolCore* TrigMatchToolCore::ChainNameIndex::m_core
private

Definition at line 422 of file TrigMatchToolCore.h.

◆ m_l1l2Map

std::map< std::string, std::string > TrigMatchToolCore::ChainNameIndex::m_l1l2Map
private

Definition at line 437 of file TrigMatchToolCore.h.

◆ m_mutex

mutex_t TrigMatchToolCore::ChainNameIndex::m_mutex
private

Definition at line 420 of file TrigMatchToolCore.h.

◆ m_nConfiguredChainNames

size_t TrigMatchToolCore::ChainNameIndex::m_nConfiguredChainNames = 0
private

Definition at line 429 of file TrigMatchToolCore.h.


The documentation for this class was generated from the following files: