ATLAS Offline Software
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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()) {
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() ) {
128  m_l1l2Map[ l1 ] = chainName;
129  } else {
130  m_l1l2Map[ l1 ] = m_l1l2Map[ l1 ] + "|" + chainName;
131  }
132  }
133  }
134  }
135 }

◆ chainName()

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

Definition at line 166 of file TrigMatchToolCore.cxx.

167 {
168  lock_t lock (m_mutex);
170  return m_chainNames.at (index);
171 }

◆ 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);
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 }

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:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TrigMatchToolCore::ChainNameIndex::m_mutex
mutex_t m_mutex
Definition: TrigMatchToolCore.h:420
index
Definition: index.py:1
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TrigMatchToolCore::ChainNameIndex::assertConfiguredChainNames
void assertConfiguredChainNames()
Definition: TrigMatchToolCore.cxx:109
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TrigMatchToolCore::ChainNameIndex::m_chainIndexMap
chainIndexMap_t m_chainIndexMap
Definition: TrigMatchToolCore.h:433
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigMatchToolCore::ChainNameIndex::m_chainNames
std::vector< std::string > m_chainNames
Definition: TrigMatchToolCore.h:428
TrigMatchToolCore::ChainNameIndex::m_l1l2Map
std::map< std::string, std::string > m_l1l2Map
Definition: TrigMatchToolCore.h:437
merge.output
output
Definition: merge.py:17
python.ExitCodes.what
def what(code)
Definition: ExitCodes.py:73
python.copyTCTOutput.chains
chains
Definition: copyTCTOutput.py:81
TrigMatchToolCore::ChainNameIndex::lock_t
std::lock_guard< mutex_t > lock_t
Definition: TrigMatchToolCore.h:418
TrigMatchToolCore::lowerChainName
virtual std::string lowerChainName(const std::string &chainName) const =0
TrigMatchToolCore::ChainNameIndex::m_core
TrigMatchToolCore * m_core
Definition: TrigMatchToolCore.h:422
TrigMatchToolCore::ChainNameIndex::chainName
std::string chainName(size_t index)
Definition: TrigMatchToolCore.cxx:166
skel.l1
l1
Definition: skel.GENtoEVGEN.py:425
TrigMatchToolCore::getConfiguredChainNames
virtual std::vector< std::string > getConfiguredChainNames() const =0
TrigMatchToolCore::ChainNameIndex::m_nConfiguredChainNames
size_t m_nConfiguredChainNames
Definition: TrigMatchToolCore.h:429