ATLAS Offline Software
PixelCablingCondData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "Identifier/Identifier.h"
7 #include <fstream>
8 #include <iostream>
9 #include <sstream>
10 #include <utility>
11 
12 namespace{
13  constexpr Identifier invalidId{};
14 }
15 
16 
18  m_idMap_onoff(),
19  m_idMap_offon(),
20  m_idMap_offrob(),
21  m_idMap_rodrob(),
22  m_idMap_robrod(),
23  m_offlineListVect(),
24  m_idMapDCSoff(),
25  m_rodReadoutMap(),
26  m_allRods(),
27  m_allRobs()
28 { }
29 
31 
32 void PixelCablingCondData::add_entry_onoff(const uint64_t onlineId, const Identifier offlineId) {
33  m_idMap_onoff.insert(std::make_pair(onlineId, offlineId)); // add online identifier -> offline identifier pair in m_idMap_onoff
34 }
35 
36 void PixelCablingCondData::add_entry_offon(const Identifier offlineId, const uint64_t onlineId) {
37  m_idMap_offon.insert(std::make_pair(offlineId, onlineId)); // add offline identifier -> online identifier pair in m_idMap_offon
38 }
39 
40 void PixelCablingCondData::add_entry_offrob(const Identifier offlineId, const uint32_t robid) {
41  m_idMap_offrob.insert(std::make_pair(offlineId, robid)); // add offline identifier -> offline ROBId pair in m_idMap_offrob
42 }
43 
44 void PixelCablingCondData::add_entry_rodrob(int rodid, int robid) {
45  auto [iter, newElementAdded] = m_idMap_rodrob.insert(std::make_pair(rodid, robid)); // add RODId identifier -> offline ROBId pair in m_idMap_rodrob
46  if ( newElementAdded )
47  m_allRods.push_back(rodid);
48 }
49 
50 void PixelCablingCondData::add_entry_robrod(int robid, int rodid) {
51  auto [iter, newElementAdded] = m_idMap_robrod.insert(std::make_pair(robid, rodid));
52  if ( newElementAdded )
53  m_allRobs.push_back(robid);
54 }
55 
57  m_offlineListVect[robid].push_back(offlineId); // add ROBid -> offline identifier pair in m_offlineListVect
58 }
59 
60 void PixelCablingCondData::add_entry_DCSoffline(const std::string& DCSname, const Identifier offlineId) {
61  m_idMapDCSoff.insert(std::make_pair(DCSname, offlineId));
62 }
63 
64 void PixelCablingCondData::set_readout_map(std::map<uint32_t, bool> rodReadoutMap) {
65  m_rodReadoutMap = std::move(rodReadoutMap);
66 }
67 
69  // Search m_idMap_onoff for the onlineId
70  uint64_t searchId = onlineId;
71  Identifier offlineId(0);
72  std::unordered_map<uint64_t, Identifier>::const_iterator iter(m_idMap_onoff.find(searchId));
73 
74  // OnlineId has been found - get the offline identifier
75  if (iter != m_idMap_onoff.end()) offlineId = (*iter).second;
76 
77  // Is onlineId not found? Then check if this is a b-layer module; if it is read out at
78  // 80 Mbit, search again with link = 0, since FMT has enough info to identify the module
79  else {
80  uint32_t rodid = (onlineId & 0xFFFFFF); // last 24 bit are rodid
81 
82  if ((rodid & 0x130000) >> 16 == 0x13) {
83  std::map<uint32_t, bool>::const_iterator it = m_rodReadoutMap.find(rodid);
84 
85  if (it != m_rodReadoutMap.end()) {
86  if ((*it).second) { // true = is 80 MBit
87 
88  // Search again
89  searchId = onlineId & (0xF0FFFFFF);
90  iter = m_idMap_onoff.find(searchId);
91 
92  // Get identifier
93  if (iter != m_idMap_onoff.end()) offlineId = (*iter).second;
94  }
95  }
96  }
97  // If onlineId is still not found, the empty identifier is returned.
98  }
99  return offlineId;
100 }
101 
103  uint64_t onlineId; // declare online identifier
104  std::unordered_map<Identifier, uint64_t, idHasher>::const_iterator iter(m_idMap_offon.find(offlineId)); // find offline identifier in m_idMap_offon map
105  if (iter == m_idMap_offon.end()) { // if offline identifier not found in m_idMap_offon map -> ERROR
106  onlineId = 0; // fill online identifier with empty identifier
107  return onlineId; // return empty online identifier
108  }
109  onlineId = (*iter).second; // fill online identifier with found online identifier
110  return onlineId; // return found online identifier
111 }
112 
113 uint32_t
115  uint32_t robid{};
116  if (offlineId == invalidId) return robid;
117  const auto iter = m_idMap_offrob.find(offlineId);
118  if (iter == m_idMap_offrob.end()) {
119  return robid;
120  }
121  robid = (*iter).second; // fill ROBId with found ROBId
122  return robid; // return found ROBId
123 }
124 
125 int PixelCablingCondData::find_entry_rodrob(const int rodid) const {
126  std::unordered_map<int, int>::const_iterator iter(m_idMap_rodrob.find(rodid));
127  if (iter == m_idMap_rodrob.end()) {
128  return 0;
129  }
130  int robid = iter->second;
131  return robid;
132 }
133 
134 int PixelCablingCondData::find_entry_robrod(const int robid) const {
135  std::unordered_map<int,int>::const_iterator iter(m_idMap_robrod.find(robid));
136  if (iter == m_idMap_robrod.end()) return 0;
137  return iter->second;
138 }
139 
140 std::deque<Identifier> PixelCablingCondData::find_entry_offlineList(uint32_t robid) const {
141  std::deque<Identifier> offlineId; // declare collection identifier list for the ROBId
142  std::deque<Identifier>::const_iterator it1 = m_offlineListVect.at(robid).begin(); // first offline identifier for the ROBId
143  std::deque<Identifier>::const_iterator it2 = m_offlineListVect.at(robid).end(); // last offline identifier for the ROBId
144  for (; it1 != it2; ++it1) { // loop thrue offline identifiers
145  offlineId.push_back(*it1); // fill offline identifier into offline identifier list
146  }
147  return offlineId; // return the offline identifier list for the ROBId
148 }
149 
150 Identifier PixelCablingCondData::find_entry_DCSoffline(const std::string& DCSname) const {
151  std::unordered_map<std::string, Identifier>::const_iterator iter(m_idMapDCSoff.find(DCSname));
152  if (iter == m_idMapDCSoff.end()) {
153  return Identifier(0);
154  }
155  return iter->second;
156 }
157 
158 std::string PixelCablingCondData::find_entry_offlineDCS(const Identifier offlineId) const {
159  std::unordered_map<std::string, Identifier>::const_iterator iter = m_idMapDCSoff.begin();
160  for (; iter != m_idMapDCSoff.end(); ++iter) {
161  if (iter->second == offlineId)
162  return iter->first;
163  }
164  return ""; // not found
165 }
166 
167 const std::vector<uint32_t>& PixelCablingCondData::get_allRods() const {
168  return m_allRods;
169 }
170 
171 const std::vector<uint32_t>& PixelCablingCondData::get_allRobs() const {
172  return m_allRobs;
173 }
174 
176 // getOnlineIdFromRobId - returns the onlineId from the robId and the link number
177 // onlineId convention: onlineId is constructed as 0xAABBDDMMMM, where MMMM = robId,
178 // DD = subdetector id, AABB = link number.
179 // For pixels, there is only one link number per onlineId, so AA = 00.
182  uint32_t subDetId = (robid & 0xFFFFFF) >> 16;
183 
184  // Pixels:
185  if (subDetId < 0x14) return (robid & 0xFFFFFF) | (link << 24);
186 
187  // IBL / DBM:
188  else if (subDetId == 0x14 || subDetId == 0x15) {
189 
190  // Need to search the on-off map for the appropriate onlineId
191  uint32_t linknum_temp;
192  std::unordered_map<uint64_t, Identifier>::const_iterator itr = m_idMap_onoff.begin();
193  for (; itr != m_idMap_onoff.end(); ++itr) {
194  if ((itr->first & 0xFFFFFF) == robid) {
195  linknum_temp = (itr->first >> 24);
196  // Check for linknum in both first and third nibble
197  if ((linknum_temp & 0xF) == link || ((linknum_temp >> 8) & 0xF) == link) return itr->first;
198  }
199  }
200  }
201  return 0;
202 }
203 
204 const std::unordered_map<uint64_t, Identifier>& PixelCablingCondData::get_idMap_onoff() const {
205  return m_idMap_onoff;
206 }
207 
208 const std::unordered_map<Identifier, uint64_t, idHasher>& PixelCablingCondData::get_idMap_offon() const {
209  return m_idMap_offon;
210 }
211 
212 const std::unordered_map<Identifier, uint32_t, idHasher>& PixelCablingCondData::get_idMap_offrob() const {
213  return m_idMap_offrob;
214 }
215 
216 const std::unordered_map<int,int>& PixelCablingCondData::get_idMap_rodrob() const {
217  return m_idMap_rodrob;
218 }
219 
220 const std::unordered_map<int,int>& PixelCablingCondData::get_idMap_robrod() const {
221  return m_idMap_robrod;
222 }
223 
224 const std::unordered_map<std::string, Identifier>& PixelCablingCondData::get_idMapDCSoff() const {
225  return m_idMapDCSoff;
226 }
227 
229  m_idMap_onoff.clear();
230  m_idMap_offon.clear();
231  m_idMap_offrob.clear();
232  m_idMap_rodrob.clear();
233  m_idMap_robrod.clear();
234  m_offlineListVect.clear();
235  m_idMapDCSoff.clear();
236  m_rodReadoutMap.clear();
237  m_allRods.clear();
238  m_allRobs.clear();
239 }
240 
PixelCablingCondData::get_idMap_robrod
const std::unordered_map< int, int > & get_idMap_robrod() const
Definition: PixelCablingCondData.cxx:220
PixelCablingCondData::find_entry_robrod
int find_entry_robrod(const int robid) const
Definition: PixelCablingCondData.cxx:134
PixelCablingCondData::find_entry_onoff
Identifier find_entry_onoff(const uint64_t) const
Definition: PixelCablingCondData.cxx:68
PixelCablingCondData.h
PixelCablingCondData::clear
void clear()
Definition: PixelCablingCondData.cxx:228
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
PixelCablingCondData::PixelCablingCondData
PixelCablingCondData()
Definition: PixelCablingCondData.cxx:17
PixelCablingCondData::add_entry_offrob
void add_entry_offrob(const Identifier, const uint32_t)
Definition: PixelCablingCondData.cxx:40
PixelCablingCondData::add_entry_onoff
void add_entry_onoff(const uint64_t, const Identifier)
Definition: PixelCablingCondData.cxx:32
skel.it
it
Definition: skel.GENtoEVGEN.py:396
PixelCablingCondData::add_entry_DCSoffline
void add_entry_DCSoffline(const std::string &, const Identifier)
Definition: PixelCablingCondData.cxx:60
PixelCablingCondData::find_entry_offlineDCS
std::string find_entry_offlineDCS(const Identifier offlineId) const
Definition: PixelCablingCondData.cxx:158
PixelCablingCondData::find_entry_offrob
uint32_t find_entry_offrob(Identifier offlineId) const
Definition: PixelCablingCondData.cxx:114
PixelCablingCondData::getOnlineIdFromRobId
uint64_t getOnlineIdFromRobId(uint32_t robid, uint32_t link) const
Definition: PixelCablingCondData.cxx:181
PixelCablingCondData::m_idMap_offrob
std::unordered_map< Identifier, uint32_t, idHasher > m_idMap_offrob
offline identifier -> ROBId map
Definition: PixelCablingCondData.h:71
PixelCablingCondData::m_idMap_offon
std::unordered_map< Identifier, uint64_t, idHasher > m_idMap_offon
online identifier -> offline identifier map
Definition: PixelCablingCondData.h:70
PixelCablingCondData::add_entry_robrod
void add_entry_robrod(int robid, int rodid)
Definition: PixelCablingCondData.cxx:50
DetDescrDictionaryDict::it1
std::vector< HWIdentifier >::iterator it1
Definition: DetDescrDictionaryDict.h:17
PixelCablingCondData::find_entry_DCSoffline
Identifier find_entry_DCSoffline(const std::string &DCSname) const
Definition: PixelCablingCondData.cxx:150
PixelCablingCondData::m_idMap_rodrob
std::unordered_map< int, int > m_idMap_rodrob
RODId -> ROBId map.
Definition: PixelCablingCondData.h:72
PixelCablingCondData::m_idMap_onoff
std::unordered_map< uint64_t, Identifier > m_idMap_onoff
offline identifier -> online identifier map
Definition: PixelCablingCondData.h:69
PixelCablingCondData::find_entry_offon
uint64_t find_entry_offon(const Identifier) const
Definition: PixelCablingCondData.cxx:102
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
PixelCablingCondData::get_allRods
const std::vector< uint32_t > & get_allRods() const
Definition: PixelCablingCondData.cxx:167
PixelCablingCondData::get_idMap_onoff
const std::unordered_map< uint64_t, Identifier > & get_idMap_onoff() const
Definition: PixelCablingCondData.cxx:204
PixelCablingCondData::get_idMapDCSoff
const std::unordered_map< std::string, Identifier > & get_idMapDCSoff() const
Definition: PixelCablingCondData.cxx:224
PixelCablingCondData::get_idMap_offrob
const std::unordered_map< Identifier, uint32_t, idHasher > & get_idMap_offrob() const
Definition: PixelCablingCondData.cxx:212
PixelCablingCondData::m_rodReadoutMap
std::map< uint32_t, bool > m_rodReadoutMap
Readout speed for each ROD. false=40MBit, true=80MBit.
Definition: PixelCablingCondData.h:76
PixelCablingCondData::find_entry_rodrob
int find_entry_rodrob(const int rodid) const
Definition: PixelCablingCondData.cxx:125
PixelCablingCondData::get_allRobs
const std::vector< uint32_t > & get_allRobs() const
Definition: PixelCablingCondData.cxx:171
PixelCablingCondData::add_entry_rodrob
void add_entry_rodrob(int rodid, int robid)
Definition: PixelCablingCondData.cxx:44
PixelCablingCondData::m_idMap_robrod
std::unordered_map< int, int > m_idMap_robrod
ROBId -> RODId map (reverse of m_idMap_rodrob)
Definition: PixelCablingCondData.h:73
PixelCablingCondData::set_readout_map
void set_readout_map(std::map< uint32_t, bool > rodReadoutMap)
Definition: PixelCablingCondData.cxx:64
PixelCablingCondData::m_idMapDCSoff
std::unordered_map< std::string, Identifier > m_idMapDCSoff
DCS name -> offline identifier.
Definition: PixelCablingCondData.h:75
PixelCablingCondData::m_offlineListVect
std::map< uint32_t, std::deque< Identifier > > m_offlineListVect
ROBId -> offline identifier list.
Definition: PixelCablingCondData.h:74
PixelCablingCondData::get_idMap_rodrob
const std::unordered_map< int, int > & get_idMap_rodrob() const
Definition: PixelCablingCondData.cxx:216
PixelCablingCondData::m_allRods
std::vector< uint32_t > m_allRods
Definition: PixelCablingCondData.h:78
PixelCablingCondData::find_entry_offlineList
std::deque< Identifier > find_entry_offlineList(uint32_t robid) const
Definition: PixelCablingCondData.cxx:140
PixelCablingCondData::~PixelCablingCondData
virtual ~PixelCablingCondData()
PixelCablingCondData::add_entry_offon
void add_entry_offon(const Identifier, const uint64_t)
Definition: PixelCablingCondData.cxx:36
PixelCablingCondData::m_allRobs
std::vector< uint32_t > m_allRobs
Definition: PixelCablingCondData.h:79
PixelCablingCondData::get_idMap_offon
const std::unordered_map< Identifier, uint64_t, idHasher > & get_idMap_offon() const
Definition: PixelCablingCondData.cxx:208
PixelCablingCondData::add_entry_offlineList
void add_entry_offlineList(const uint32_t, const Identifier)
Definition: PixelCablingCondData.cxx:56
Identifier
Definition: IdentifierFieldParser.cxx:14