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.

◆ chainNameToIndex()

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

Definition at line 139 of file TrigMatchToolCore.cxx.

140{
141 lock_t lock (m_mutex);
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{
177 lock_t lock (m_mutex);
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{
158 lock_t lock (m_mutex);
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
193 lock_t lock (m_mutex);
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 boost::regex compiled( chainName );
202 boost::cmatch what;
203 std::string chains;
204
205 std::map< std::string, std::string >::const_iterator iter =
206 m_l1l2Map.begin();
207 std::map< std::string, std::string >::const_iterator end =
208 m_l1l2Map.end();
209 for( ; iter != end; ++iter ) {
210 // check if the l1 chain matches the regex supplied by chainName
211 if( boost::regex_match( iter->first.c_str(), what, compiled ) ) {
212 if( chains.empty() ) {
213 chains += iter->second;
214 } else {
215 chains += "|" + iter->second;
216 }
217 }
218 }
219
220 // add it to the cache
222 }
223
224 // if it wasn't in the cache before, it will be now, so pull it out
225 std::string output = m_l1l2Map[ chainName ];
226 if( output.find( "|" ) != std::string::npos ) {
227 output = "(" + output + ")";
228 }
229
230 return output;
231}
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: