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 edm::EventSetup &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 28 of file OmtfLinkMappingRpc.h.

Constructor & Destructor Documentation

omtf::RpcLinkMap::RpcLinkMap ( )
inline

Definition at line 30 of file OmtfLinkMappingRpc.h.

References init, and AlCaHLTBitMon_QueryRunRegistry::string.

30 { }

Member Function Documentation

void omtf::RpcLinkMap::init ( const edm::EventSetup es)

Definition at line 69 of file OmtfLinkMappingRpc.cc.

References l1t::stage2::layer2::fedId, edm::EventSetup::get(), RPCAMCLinkMap::getMap(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

69  {
70 
72  es.get<RPCOMTFLinkMapRcd>().get(amcMapping);
73  const RPCAMCLinkMap::map_type & amcMap = amcMapping->getMap();
74 
75  for (const auto & item : amcMap ) {
76  unsigned int fedId = item.first.getFED();
77  unsigned int amcSlot = item.first.getAMCNumber();
78  unsigned int link = item.first.getAMCInput();
79  std::string lbName = item.second.getName();
80 
81  std::string processorNameStr = "OMTF";;
82  if (fedId==1380) processorNameStr = "OMTFn"; else processorNameStr = "OMTFp";
83  processorNameStr += std::to_string(amcSlot/2+1);
84  std::string processorName = processorNameStr;
85 
86  std::map< unsigned int, std::string > & li2lb = link2lbName[processorName];
87  std::map< std::string, unsigned int > & lb2li = lbName2link[processorName];
88  li2lb[link] = lbName;
89  lb2li[lbName] = link;
90  EleIndex ele(processorName, link);
91  lbName2OmtfIndex[lbName].push_back(ele);
92  }
93 }
unsigned int link(const std::string &board, const std::string &lbName) const
std::map< std::string, std::map< unsigned int, std::string > > link2lbName
std::map< std::string, std::vector< EleIndex > > lbName2OmtfIndex
std::map< std::string, std::map< std::string, unsigned int > > lbName2link
map_type & getMap()
Definition: RPCAMCLinkMap.h:28
std::map< RPCAMCLink, RPCLBLink > map_type
Definition: RPCAMCLinkMap.h:14
const std::string & lbName(const std::string &board, unsigned int link) const
T get() const
Definition: EventSetup.h:71
void omtf::RpcLinkMap::init ( const std::string &  fName)

Definition at line 95 of file OmtfLinkMappingRpc.cc.

References mps_splice::line, LogTrace, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 36 of file OmtfLinkMappingRpc.h.

36 { return link2lbName.at(board).at(link); }
unsigned int link(const std::string &board, const std::string &lbName) const
std::map< std::string, std::map< unsigned int, std::string > > link2lbName
unsigned int omtf::RpcLinkMap::link ( const std::string &  board,
const std::string &  lbName 
) const
inline

Definition at line 38 of file OmtfLinkMappingRpc.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

38 { return lbName2link.at(board).at(lbName); }
std::map< std::string, std::map< std::string, unsigned int > > lbName2link
const std::string & lbName(const std::string &board, unsigned int link) const
std::vector< EleIndex > omtf::RpcLinkMap::omtfEleIndex ( const std::string &  lbName) const

Definition at line 125 of file OmtfLinkMappingRpc.cc.

Referenced by omtf::translateOmtf2Pact().

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

Member Data Documentation

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

Definition at line 44 of file OmtfLinkMappingRpc.h.

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

Definition at line 45 of file OmtfLinkMappingRpc.h.

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

Definition at line 43 of file OmtfLinkMappingRpc.h.