CMS 3D CMS Logo

OmtfLinkMappingRpc.cc
Go to the documentation of this file.
2 
3 #include <fstream>
4 
8 
17 
20 
21 namespace omtf {
22 
24  const LinkBoardElectronicIndex& o2) const {
25  if (o1.dccId < o2.dccId)
26  return true;
27  else if (o1.dccId == o2.dccId && o1.dccInputChannelNum < o2.dccInputChannelNum)
28  return true;
29  else if (o1.dccId == o2.dccId && o1.dccInputChannelNum == o2.dccInputChannelNum &&
30  o1.tbLinkInputNum < o2.tbLinkInputNum)
31  return true;
32  else
33  return false;
34  }
35 
36  MapEleIndex2LBIndex translateOmtf2Pact(const RpcLinkMap& omtfLink2Ele, const RPCReadOutMapping* pactCabling) {
37  MapEleIndex2LBIndex omtf2rpc;
38 
39  std::vector<const DccSpec*> dccs = pactCabling->dccList();
40  for (auto it1 : dccs) {
41  const std::vector<TriggerBoardSpec>& rmbs = it1->triggerBoards();
42  for (auto const& it2 : rmbs) {
43  const std::vector<LinkConnSpec>& links = it2.linkConns();
44  for (auto const& it3 : links) {
45  const std::vector<LinkBoardSpec>& lbs = it3.linkBoards();
46  for (std::vector<LinkBoardSpec>::const_iterator it4 = lbs.begin(); it4 != lbs.end(); ++it4) {
47  std::string lbNameCH = it4->linkBoardName();
48  std::string lbName = lbNameCH.substr(0, lbNameCH.size() - 4);
49  std::vector<EleIndex> omtfEles = omtfLink2Ele.omtfEleIndex(lbName);
50  // if (!omtfEles.empty()) std::cout <<" isOK ! " << it4->linkBoardName() <<" has: " << omtfEles.size() << " first: "<< omtfEles[0] << std::endl;
51  LinkBoardElectronicIndex rpcEle = {
52  it1->id(), it2.dccInputChannelNum(), it3.triggerBoardInputNumber(), it4->linkBoardNumInLink()};
53  for (const auto& omtfEle : omtfEles)
54  omtf2rpc[omtfEle] = rpcEle;
55  }
56  }
57  }
58  }
59  LogTrace(" ") << " SIZE OF OMTF to RPC map TRANSLATION is: " << omtf2rpc.size() << std::endl;
60  return omtf2rpc;
61  }
62 
63  MapLBIndex2EleIndex translatePact2Omtf(const RpcLinkMap& omtfLink2Ele, const RPCReadOutMapping* pactCabling) {
64  MapLBIndex2EleIndex pact2omtfs;
65  MapEleIndex2LBIndex omtf2rpcs = translateOmtf2Pact(omtfLink2Ele, pactCabling);
66  for (const auto& omtf2rpc : omtf2rpcs) {
67  std::pair<EleIndex, EleIndex>& omtfs = pact2omtfs[omtf2rpc.second];
68  if (omtfs.first.fed() == 0)
69  omtfs.first = omtf2rpc.first;
70  else if (omtfs.second.fed() == 0)
71  omtfs.second = omtf2rpc.first;
72  else
73  edm::LogError(" translatePact2Omtf ") << " PROBLEM LinkBoardElectronicIndex already USED!!!! ";
74  }
75  return pact2omtfs;
76  }
77 
80  es.get<RPCOMTFLinkMapRcd>().get(amcMapping);
81  const RPCAMCLinkMap::map_type& amcMap = amcMapping->getMap();
82 
83  for (const auto& item : amcMap) {
84  unsigned int fedId = item.first.getFED();
85  unsigned int amcSlot = item.first.getAMCNumber();
86  unsigned int link = item.first.getAMCInput();
87  std::string lbName = item.second.getName();
88 
89  std::string processorNameStr = "OMTF";
90  ;
91  if (fedId == 1380)
92  processorNameStr = "OMTFn";
93  else
94  processorNameStr = "OMTFp";
95  processorNameStr += std::to_string(amcSlot / 2 + 1);
96  std::string processorName = processorNameStr;
97 
98  std::map<unsigned int, std::string>& li2lb = link2lbName[processorName];
99  std::map<std::string, unsigned int>& lb2li = lbName2link[processorName];
100  li2lb[link] = lbName;
101  lb2li[lbName] = link;
102  EleIndex ele(processorName, link);
103  lbName2OmtfIndex[lbName].push_back(ele);
104  }
105  }
106 
108  std::ifstream inFile;
109  inFile.open(fName);
110  if (inFile) {
111  LogTrace("") << " reading OmtfRpcLinksMap from: " << fName;
112  } else {
113  LogTrace("") << " Unable to open file " << fName;
114 
115  throw std::runtime_error("Unable to open OmtfRpcLinksMap file " + fName);
116  }
117 
119  while (std::getline(inFile, line)) {
120  line.erase(0, line.find_first_not_of(" \t\r\n")); //cut first character
121  if (line.empty() || !line.compare(0, 2, "--"))
122  continue; // empty or comment line
123  std::stringstream ss(line);
124  std::string processorName, lbName;
125  unsigned int link, dbId;
126  if (ss >> processorName >> link >> lbName >> dbId) {
127  std::map<unsigned int, std::string>& li2lb = link2lbName[processorName];
128  std::map<std::string, unsigned int>& lb2li = lbName2link[processorName];
129  li2lb[link] = lbName;
130  lb2li[lbName] = link;
131  EleIndex ele(processorName, link);
132  lbName2OmtfIndex[lbName].push_back(ele);
133  }
134  }
135  inFile.close();
136  }
137 
138  std::vector<EleIndex> RpcLinkMap::omtfEleIndex(const std::string& lbName) const {
139  const auto pos = lbName2OmtfIndex.find(lbName);
140  return pos != lbName2OmtfIndex.end() ? pos->second : std::vector<EleIndex>();
141  }
142 
143 } // namespace omtf
ESTransientHandle.h
MessageLogger.h
RPCReadOutMapping.h
OmtfLinkMappingRpc.h
omtf::RpcLinkMap::lbName2link
std::map< std::string, std::map< std::string, unsigned int > > lbName2link
Definition: OmtfLinkMappingRpc.h:52
RPCOMTFLinkMapRcd
Definition: RPCOMTFLinkMapRcd.h:6
LinkBoardElectronicIndex::dccId
int dccId
Definition: LinkBoardElectronicIndex.h:11
pos
Definition: PixelAliasList.h:18
omtf::RpcLinkMap::lbName
const std::string & lbName(const std::string &board, unsigned int link) const
Definition: OmtfLinkMappingRpc.h:40
omtf::RpcLinkMap::init
void init(const edm::EventSetup &es)
Definition: OmtfLinkMappingRpc.cc:78
RPCEMapRcd.h
MainPageGenerator.fName
fName
Definition: MainPageGenerator.py:301
RPCAMCLinkMap.h
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
LinkBoardElectronicIndex::dccInputChannelNum
int dccInputChannelNum
Definition: LinkBoardElectronicIndex.h:12
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
omtf::lessLinkBoardElectronicIndex::operator()
bool operator()(const LinkBoardElectronicIndex &o1, const LinkBoardElectronicIndex &o2) const
Definition: OmtfLinkMappingRpc.cc:23
omtf::EleIndex
Definition: OmtfEleIndex.h:9
edm::ESHandle< RPCAMCLinkMap >
omtf::RpcLinkMap::omtfEleIndex
std::vector< EleIndex > omtfEleIndex(const std::string &lbName) const
Definition: OmtfLinkMappingRpc.cc:138
CastorDigiReco.o1
o1
Definition: CastorDigiReco.py:84
omtf::RpcLinkMap::link2lbName
std::map< std::string, std::map< unsigned int, std::string > > link2lbName
Definition: OmtfLinkMappingRpc.h:51
omtf::RpcLinkMap
Definition: OmtfLinkMappingRpc.h:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LinkBoardElectronicIndex::tbLinkInputNum
int tbLinkInputNum
Definition: LinkBoardElectronicIndex.h:13
edm::LogError
Definition: MessageLogger.h:183
LinkBoardSpec.h
omtf::RpcLinkMap::lbName2OmtfIndex
std::map< std::string, std::vector< EleIndex > > lbName2OmtfIndex
Definition: OmtfLinkMappingRpc.h:53
omtf::translateOmtf2Pact
MapEleIndex2LBIndex translateOmtf2Pact(const RpcLinkMap &omtfLnks, const RPCReadOutMapping *pactCabling)
Definition: OmtfLinkMappingRpc.cc:36
RPCReadOutMapping
Definition: RPCReadOutMapping.h:22
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:57
RPCReadOutMapping::dccList
std::vector< const DccSpec * > dccList() const
all FEDs in map
Definition: RPCReadOutMapping.cc:26
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:82
omtf::translatePact2Omtf
MapLBIndex2EleIndex translatePact2Omtf(const RpcLinkMap &omtfLnks, const RPCReadOutMapping *pactCabling)
Definition: OmtfLinkMappingRpc.cc:63
get
#define get
LinkBoardElectronicIndex.h
RPCOMTFLinkMapRcd.h
TriggerBoardSpec.h
LinkBoardElectronicIndex
Definition: LinkBoardElectronicIndex.h:10
omtf::MapLBIndex2EleIndex
std::map< LinkBoardElectronicIndex, std::pair< EleIndex, EleIndex >, lessLinkBoardElectronicIndex > MapLBIndex2EleIndex
Definition: OmtfLinkMappingRpc.h:29
electronStore.links
links
Definition: electronStore.py:149
EventSetup.h
omtf::MapEleIndex2LBIndex
std::map< EleIndex, LinkBoardElectronicIndex > MapEleIndex2LBIndex
Definition: OmtfLinkMappingRpc.h:20
LinkBoardPackedStrip.h
RPCEMap.h
RPCAMCLinkMap::getMap
map_type & getMap()
Definition: RPCAMCLinkMap.h:27
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
mps_splice.line
line
Definition: mps_splice.py:76
omtf
Definition: OmtfCscDataWord64.h:7
omtf::RpcLinkMap::link
unsigned int link(const std::string &board, const std::string &lbName) const
Definition: OmtfLinkMappingRpc.h:44
RPCAMCLinkMap::map_type
std::map< RPCAMCLink, RPCLBLink > map_type
Definition: RPCAMCLinkMap.h:13
DccSpec.h