CMS 3D CMS Logo

DTHVStatus.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Paolo Ronchese INFN Padova
5  *
6  */
7 
8 //----------------------
9 // This Class' Header --
10 //----------------------
12 
13 //-------------------------------
14 // Collaborating Class Headers --
15 //-------------------------------
20 
21 //---------------
22 // C++ Headers --
23 //---------------
24 #include <iostream>
25 #include <sstream>
26 
27 //-------------------
28 // Initializations --
29 //-------------------
30 
31 //----------------
32 // Constructors --
33 //----------------
34 DTHVStatus::DTHVStatus() : dataVersion(" "), dBuf(new DTBufferTree<int, int>) { dataList.reserve(10); }
35 
36 DTHVStatus::DTHVStatus(const std::string& version) : dataVersion(version), dBuf(new DTBufferTree<int, int>) {
37  dataList.reserve(10);
38 }
39 
40 DTHVStatusId::DTHVStatusId() : wheelId(0), stationId(0), sectorId(0), slId(0), layerId(0), partId(0) {}
41 
42 DTHVStatusData::DTHVStatusData() : flagA(0), flagC(0), flagS(0) {}
43 
44 //--------------
45 // Destructor --
46 //--------------
48 
50 
52 
53 //--------------
54 // Operations --
55 //--------------
56 int DTHVStatus::get(int wheelId,
57  int stationId,
58  int sectorId,
59  int slId,
60  int layerId,
61  int partId,
62  int& fCell,
63  int& lCell,
64  int& flagA,
65  int& flagC,
66  int& flagS) const {
67  fCell = lCell = flagA = flagC = flagS = 0;
68 
69  std::vector<int> chanKey;
70  chanKey.reserve(6);
71  chanKey.push_back(wheelId);
72  chanKey.push_back(stationId);
73  chanKey.push_back(sectorId);
74  chanKey.push_back(slId);
75  chanKey.push_back(layerId);
76  chanKey.push_back(partId);
77  int ientry;
78  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
79  if (!searchStatus) {
80  const DTHVStatusData& data(dataList[ientry].second);
81  fCell = data.fCell;
82  lCell = data.lCell;
83  flagA = data.flagA;
84  flagC = data.flagC;
85  flagS = data.flagS;
86  }
87 
88  return searchStatus;
89 }
90 
91 int DTHVStatus::get(const DTLayerId& id, int partId, int& fCell, int& lCell, int& flagA, int& flagC, int& flagS) const {
92  return get(
93  id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), partId, fCell, lCell, flagA, flagC, flagS);
94 }
95 
96 int DTHVStatus::get(const DTWireId& id, int& flagA, int& flagC, int& flagS) const {
97  flagA = flagC = flagS = 0;
98  int iCell = id.wire();
99  int fCell;
100  int lCell;
101  int fCheck =
102  get(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), 0, fCell, lCell, flagA, flagC, flagS);
103  if ((fCheck == 0) && (fCell <= iCell) && (lCell >= iCell))
104  return 0;
105  fCheck =
106  get(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), 1, fCell, lCell, flagA, flagC, flagS);
107  if ((fCheck == 0) && (fCell <= iCell) && (lCell >= iCell))
108  return 0;
109  flagA = flagC = flagS = 0;
110  return 1;
111 }
112 
114  int offNum = 0;
117  while (iter != iend) {
118  const std::pair<DTHVStatusId, DTHVStatusData>& entry = *iter++;
119  DTHVStatusId hvId = entry.first;
120  DTHVStatusData data = entry.second;
121  int offA = data.flagA & 1;
122  int offC = data.flagC & 1;
123  int offS = data.flagS & 1;
124  if (offA || offC || offS)
125  offNum += (1 + data.lCell - data.fCell);
126  }
127  return offNum;
128 }
129 
131  int offNum = 0;
134  while (iter != iend) {
135  const std::pair<DTHVStatusId, DTHVStatusData>& entry = *iter++;
136  DTHVStatusId hvId = entry.first;
137  DTHVStatusData data = entry.second;
138  if (hvId.wheelId != id.wheel())
139  continue;
140  if (hvId.stationId != id.station())
141  continue;
142  if (hvId.sectorId != id.sector())
143  continue;
144  int offA = data.flagA & 1;
145  int offC = data.flagC & 1;
146  int offS = data.flagS & 1;
147  if (offA || offC || offS)
148  offNum += (1 + data.lCell - data.fCell);
149  }
150  return offNum;
151 }
152 
154  int offNum = 0;
157  while (iter != iend) {
158  const std::pair<DTHVStatusId, DTHVStatusData>& entry = *iter++;
159  DTHVStatusId hvId = entry.first;
160  DTHVStatusData data = entry.second;
161  if (data.flagA || data.flagC || data.flagS)
162  offNum += (1 + data.lCell - data.fCell);
163  }
164  return offNum;
165 }
166 
168  int offNum = 0;
171  while (iter != iend) {
172  const std::pair<DTHVStatusId, DTHVStatusData>& entry = *iter++;
173  DTHVStatusId hvId = entry.first;
174  DTHVStatusData data = entry.second;
175  if (hvId.wheelId != id.wheel())
176  continue;
177  if (hvId.stationId != id.station())
178  continue;
179  if (hvId.sectorId != id.sector())
180  continue;
181  if (data.flagA || data.flagC || data.flagS)
182  offNum += (1 + data.lCell - data.fCell);
183  }
184  return offNum;
185 }
186 
187 const std::string& DTHVStatus::version() const { return dataVersion; }
188 
190 
192  dataList.clear();
193  dataList.reserve(10);
194  initialize();
195  return;
196 }
197 
198 int DTHVStatus::set(int wheelId,
199  int stationId,
200  int sectorId,
201  int slId,
202  int layerId,
203  int partId,
204  int fCell,
205  int lCell,
206  int flagA,
207  int flagC,
208  int flagS) {
209  std::vector<int> chanKey;
210  chanKey.reserve(6);
211  chanKey.push_back(wheelId);
212  chanKey.push_back(stationId);
213  chanKey.push_back(sectorId);
214  chanKey.push_back(slId);
215  chanKey.push_back(layerId);
216  chanKey.push_back(partId);
217  int ientry;
218  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
219 
220  if (!searchStatus) {
222  data.fCell = fCell;
223  data.lCell = lCell;
224  data.flagA = flagA;
225  data.flagC = flagC;
226  data.flagS = flagS;
227  return -1;
228  } else {
230  key.wheelId = wheelId;
231  key.stationId = stationId;
232  key.sectorId = sectorId;
233  key.slId = slId;
234  key.layerId = layerId;
235  key.partId = partId;
237  data.fCell = fCell;
238  data.lCell = lCell;
239  data.flagA = flagA;
240  data.flagC = flagC;
241  data.flagS = flagS;
242  ientry = dataList.size();
243  dataList.push_back(std::pair<DTHVStatusId, DTHVStatusData>(key, data));
244  dBuf->insert(chanKey.begin(), chanKey.end(), ientry);
245  return 0;
246  }
247 
248  return 99;
249 }
250 
251 int DTHVStatus::set(const DTLayerId& id, int partId, int fCell, int lCell, int flagA, int flagC, int flagS) {
252  return set(
253  id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), partId, fCell, lCell, flagA, flagC, flagS);
254 }
255 
256 int DTHVStatus::setFlagA(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag) {
257  int fCell;
258  int lCell;
259  int flagA;
260  int flagC;
261  int flagS;
262  get(wheelId, stationId, sectorId, slId, layerId, partId, fCell, lCell, flagA, flagC, flagS);
263  return set(wheelId, stationId, sectorId, slId, layerId, partId, fCell, lCell, flag, flagC, flagS);
264 }
265 
266 int DTHVStatus::setFlagA(const DTLayerId& id, int partId, int flag) {
267  return setFlagA(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), partId, flag);
268 }
269 
270 int DTHVStatus::setFlagC(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag) {
271  int fCell;
272  int lCell;
273  int flagA;
274  int flagC;
275  int flagS;
276  get(wheelId, stationId, sectorId, slId, layerId, partId, fCell, lCell, flagA, flagC, flagS);
277  return set(wheelId, stationId, sectorId, slId, layerId, partId, fCell, lCell, flagA, flag, flagS);
278 }
279 
280 int DTHVStatus::setFlagC(const DTLayerId& id, int partId, int flag) {
281  return setFlagC(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), partId, flag);
282 }
283 
284 int DTHVStatus::setFlagS(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag) {
285  int fCell;
286  int lCell;
287  int flagA;
288  int flagC;
289  int flagS;
290  get(wheelId, stationId, sectorId, slId, layerId, partId, fCell, lCell, flagA, flagC, flagS);
291  return set(wheelId, stationId, sectorId, slId, layerId, partId, fCell, lCell, flagA, flagC, flag);
292 }
293 
294 int DTHVStatus::setFlagS(const DTLayerId& id, int partId, int flag) {
295  return setFlagS(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), partId, flag);
296 }
297 
299 
301 
303  std::stringstream name;
304  name << dataVersion << "_map_HV" << this;
305  return name.str();
306 }
307 
309  dBuf->clear();
310 
311  int entryNum = 0;
312  int entryMax = dataList.size();
313  std::vector<int> chanKey;
314  chanKey.reserve(6);
315  while (entryNum < entryMax) {
316  const DTHVStatusId& chan = dataList[entryNum].first;
317 
318  chanKey.clear();
319  chanKey.push_back(chan.wheelId);
320  chanKey.push_back(chan.stationId);
321  chanKey.push_back(chan.sectorId);
322  chanKey.push_back(chan.slId);
323  chanKey.push_back(chan.layerId);
324  chanKey.push_back(chan.partId);
325  dBuf->insert(chanKey.begin(), chanKey.end(), entryNum++);
326  }
327 
328  return;
329 }
const std::string & version() const
access version
Definition: DTHVStatus.cc:187
int setFlagS(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag)
Definition: DTHVStatus.cc:284
void clear()
reset content
Definition: DTHVStatus.cc:191
int badChannelsNumber() const
Definition: DTHVStatus.cc:153
int setFlagC(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag)
Definition: DTHVStatus.cc:270
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
int setFlagA(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag)
Definition: DTHVStatus.cc:256
U second(std::pair< T, U > const &p)
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int &fCell, int &lCell, int &flagA, int &flagC, int &flagS) const
get content
Definition: DTHVStatus.cc:56
std::string mapName() const
read and store full content
Definition: DTHVStatus.cc:302
std::vector< std::pair< DTHVStatusId, DTHVStatusData > > dataList
Definition: DTHVStatus.h:139
std::vector< std::pair< DTHVStatusId, DTHVStatusData > >::const_iterator const_iterator
Access methods to data.
Definition: DTHVStatus.h:130
void initialize()
Definition: DTHVStatus.cc:308
int set(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int fCell, int lCell, int flagA, int flagC, int flagS)
Definition: DTHVStatus.cc:198
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
int insert(ElementKey fKey, ElementKey lKey, Content cont)
std::string dataVersion
Definition: DTHVStatus.h:137
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
Definition: DTHVStatus.h:141
const_iterator begin() const
Definition: DTHVStatus.cc:298
int offChannelsNumber() const
Definition: DTHVStatus.cc:113
const_iterator end() const
Definition: DTHVStatus.cc:300