CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
omtf::RpcLinkMap Class Reference

#include <OmtfLinkMappingRpc.h>

Public Member Functions

void init (const RPCAMCLinkMap &es)
 
void init (const std::string &fName)
 
const std::string & lbName (const std::string &board, unsigned int link) const
 
unsigned int link (const std::string &board, const std::string &lbName) const
 
std::vector< EleIndexomtfEleIndex (const std::string &lbName) const
 
 RpcLinkMap ()
 

Private Attributes

std::map< std::string, std::map< std::string, unsigned int > > lbName2link
 
std::map< std::string, std::vector< EleIndex > > lbName2OmtfIndex
 
std::map< std::string, std::map< unsigned int, std::string > > link2lbName
 

Detailed Description

Definition at line 30 of file OmtfLinkMappingRpc.h.

Constructor & Destructor Documentation

◆ RpcLinkMap()

omtf::RpcLinkMap::RpcLinkMap ( )
inline

Definition at line 32 of file OmtfLinkMappingRpc.h.

32 {}

Member Function Documentation

◆ init() [1/2]

void omtf::RpcLinkMap::init ( const RPCAMCLinkMap es)

Definition at line 75 of file OmtfLinkMappingRpc.cc.

References l1tstage2_dqm_sourceclient-live_cfg::fedId, RPCAMCLinkMap::getMap(), B2GTnPMonitor_cfi::item, lbName(), lbName2link, lbName2OmtfIndex, link(), link2lbName, AlCaHLTBitMon_QueryRunRegistry::string, and to_string().

Referenced by omtf::RpcPacker::init(), and omtf::RpcUnpacker::init().

75  {
76  const RPCAMCLinkMap::map_type& amcMap = amcMapping.getMap();
77 
78  for (const auto& item : amcMap) {
79  unsigned int fedId = item.first.getFED();
80  unsigned int amcSlot = item.first.getAMCNumber();
81  unsigned int link = item.first.getAMCInput();
82  std::string lbName = item.second.getName();
83 
84  std::string processorNameStr = "OMTF";
85  ;
86  if (fedId == 1380)
87  processorNameStr = "OMTFn";
88  else
89  processorNameStr = "OMTFp";
90  processorNameStr += std::to_string(amcSlot / 2 + 1);
91  std::string processorName = processorNameStr;
92 
93  std::map<unsigned int, std::string>& li2lb = link2lbName[processorName];
94  std::map<std::string, unsigned int>& lb2li = lbName2link[processorName];
95  li2lb[link] = lbName;
96  lb2li[lbName] = link;
97  EleIndex ele(processorName, link);
98  lbName2OmtfIndex[lbName].push_back(ele);
99  }
100  }
std::map< std::string, std::map< unsigned int, std::string > > link2lbName
std::map< std::string, std::vector< EleIndex > > lbName2OmtfIndex
static std::string to_string(const XMLCh *ch)
std::map< std::string, std::map< std::string, unsigned int > > lbName2link
std::map< RPCAMCLink, RPCLBLink > map_type
Definition: RPCAMCLinkMap.h:13
unsigned int link(const std::string &board, const std::string &lbName) const
const std::string & lbName(const std::string &board, unsigned int link) const

◆ init() [2/2]

void omtf::RpcLinkMap::init ( const std::string &  fName)

Definition at line 102 of file OmtfLinkMappingRpc.cc.

References isotrackTrainRegressor::fName, testHGCalDigi_cfg::inFile, lbName(), lbName2link, lbName2OmtfIndex, mps_splice::line, link(), link2lbName, LogTrace, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

102  {
103  std::ifstream inFile;
104  inFile.open(fName);
105  if (inFile) {
106  LogTrace("") << " reading OmtfRpcLinksMap from: " << fName;
107  } else {
108  LogTrace("") << " Unable to open file " << fName;
109 
110  throw std::runtime_error("Unable to open OmtfRpcLinksMap file " + fName);
111  }
112 
114  while (std::getline(inFile, line)) {
115  line.erase(0, line.find_first_not_of(" \t\r\n")); //cut first character
116  if (line.empty() || !line.compare(0, 2, "--"))
117  continue; // empty or comment line
118  std::stringstream ss(line);
119  std::string processorName, lbName;
120  unsigned int link, dbId;
121  if (ss >> processorName >> link >> lbName >> dbId) {
122  std::map<unsigned int, std::string>& li2lb = link2lbName[processorName];
123  std::map<std::string, unsigned int>& lb2li = lbName2link[processorName];
124  li2lb[link] = lbName;
125  lb2li[lbName] = link;
126  EleIndex ele(processorName, link);
127  lbName2OmtfIndex[lbName].push_back(ele);
128  }
129  }
130  inFile.close();
131  }
std::map< std::string, std::map< unsigned int, std::string > > link2lbName
std::map< std::string, std::vector< EleIndex > > lbName2OmtfIndex
#define LogTrace(id)
std::map< std::string, std::map< std::string, unsigned int > > lbName2link
unsigned int link(const std::string &board, const std::string &lbName) const
const std::string & lbName(const std::string &board, unsigned int link) const

◆ lbName()

const std::string& omtf::RpcLinkMap::lbName ( const std::string &  board,
unsigned int  link 
) const
inline

Definition at line 38 of file OmtfLinkMappingRpc.h.

References link(), and link2lbName.

Referenced by init(), link(), and omtfEleIndex().

38  {
39  return link2lbName.at(board).at(link);
40  }
std::map< std::string, std::map< unsigned int, std::string > > link2lbName
unsigned int link(const std::string &board, const std::string &lbName) const

◆ link()

unsigned int omtf::RpcLinkMap::link ( const std::string &  board,
const std::string &  lbName 
) const
inline

Definition at line 42 of file OmtfLinkMappingRpc.h.

References lbName(), and lbName2link.

Referenced by init(), and lbName().

42  {
43  return lbName2link.at(board).at(lbName);
44  }
std::map< std::string, std::map< std::string, unsigned int > > lbName2link
const std::string & lbName(const std::string &board, unsigned int link) const

◆ omtfEleIndex()

std::vector< EleIndex > omtf::RpcLinkMap::omtfEleIndex ( const std::string &  lbName) const

Definition at line 133 of file OmtfLinkMappingRpc.cc.

References lbName(), and lbName2OmtfIndex.

Referenced by omtf::translateOmtf2Pact().

133  {
134  const auto pos = lbName2OmtfIndex.find(lbName);
135  return pos != lbName2OmtfIndex.end() ? pos->second : std::vector<EleIndex>();
136  }
std::map< std::string, std::vector< EleIndex > > lbName2OmtfIndex
const std::string & lbName(const std::string &board, unsigned int link) const

Member Data Documentation

◆ lbName2link

std::map<std::string, std::map<std::string, unsigned int> > omtf::RpcLinkMap::lbName2link
private

Definition at line 50 of file OmtfLinkMappingRpc.h.

Referenced by init(), and link().

◆ lbName2OmtfIndex

std::map<std::string, std::vector<EleIndex> > omtf::RpcLinkMap::lbName2OmtfIndex
private

Definition at line 51 of file OmtfLinkMappingRpc.h.

Referenced by init(), and omtfEleIndex().

◆ link2lbName

std::map<std::string, std::map<unsigned int, std::string> > omtf::RpcLinkMap::link2lbName
private

Definition at line 49 of file OmtfLinkMappingRpc.h.

Referenced by init(), and lbName().