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 //----------------
33 // Constructors --
34 //----------------
36  dataVersion( " " ),
37  dBuf(new DTBufferTree<int,int>) {
38  dataList.reserve( 10 );
39 }
40 
41 
43  dataVersion( version ),
44  dBuf(new DTBufferTree<int,int>) {
45  dataList.reserve( 10 );
46 }
47 
48 
50  wheelId( 0 ),
51  stationId( 0 ),
52  sectorId( 0 ),
53  slId( 0 ),
54  layerId( 0 ),
55  partId( 0 ) {
56 }
57 
58 
60  flagA( 0 ),
61  flagC( 0 ),
62  flagS( 0 ) {
63 }
64 
65 
66 //--------------
67 // Destructor --
68 //--------------
70 }
71 
72 
74 }
75 
76 
78 }
79 
80 
81 //--------------
82 // Operations --
83 //--------------
84 int DTHVStatus::get( int wheelId,
85  int stationId,
86  int sectorId,
87  int slId,
88  int layerId,
89  int partId,
90  int& fCell,
91  int& lCell,
92  int& flagA,
93  int& flagC,
94  int& flagS ) const {
95  fCell =
96  lCell =
97  flagA =
98  flagC =
99  flagS = 0;
100 
101  std::vector<int> chanKey;
102  chanKey.reserve(6);
103  chanKey.push_back( wheelId );
104  chanKey.push_back( stationId );
105  chanKey.push_back( sectorId );
106  chanKey.push_back( slId );
107  chanKey.push_back( layerId );
108  chanKey.push_back( partId );
109  int ientry;
110  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
111  if ( !searchStatus ) {
112  const DTHVStatusData& data( dataList[ientry].second );
113  fCell = data.fCell;
114  lCell = data.lCell;
115  flagA = data.flagA;
116  flagC = data.flagC;
117  flagS = data.flagS;
118  }
119 
120  return searchStatus;
121 
122 }
123 
124 
125 int DTHVStatus::get( const DTLayerId& id,
126  int partId,
127  int& fCell,
128  int& lCell,
129  int& flagA,
130  int& flagC,
131  int& flagS ) const {
132  return get( id.wheel(),
133  id.station(),
134  id.sector(),
135  id.superLayer(),
136  id.layer(),
137  partId,
138  fCell, lCell, flagA, flagC, flagS );
139 }
140 
141 
142 int DTHVStatus::get( const DTWireId& id,
143  int& flagA,
144  int& flagC,
145  int& flagS ) const {
146  flagA = flagC = flagS = 0;
147  int iCell = id.wire();
148  int fCell;
149  int lCell;
150  int
151  fCheck = get( id.wheel(),
152  id.station(),
153  id.sector(),
154  id.superLayer(),
155  id.layer(),
156  0, fCell, lCell,
157  flagA, flagC, flagS );
158  if ( ( fCheck == 0 ) &&
159  ( fCell <= iCell ) &&
160  ( lCell >= iCell ) ) return 0;
161  fCheck = get( id.wheel(),
162  id.station(),
163  id.sector(),
164  id.superLayer(),
165  id.layer(),
166  1, fCell, lCell,
167  flagA, flagC, flagS );
168  if ( ( fCheck == 0 ) &&
169  ( fCell <= iCell ) &&
170  ( lCell >= iCell ) ) return 0;
171  flagA = flagC = flagS = 0;
172  return 1;
173 }
174 
175 
177  int offNum = 0;
180  while ( iter != iend ) {
181  const std::pair<DTHVStatusId,DTHVStatusData>& entry = *iter++;
182  DTHVStatusId hvId = entry.first;
183  DTHVStatusData data = entry.second;
184  int offA = data.flagA & 1;
185  int offC = data.flagC & 1;
186  int offS = data.flagS & 1;
187  if ( offA || offC || offS )
188  offNum += ( 1 + data.lCell - data.fCell );
189  }
190  return offNum;
191 }
192 
193 
195  int offNum = 0;
198  while ( iter != iend ) {
199  const std::pair<DTHVStatusId,DTHVStatusData>& entry = *iter++;
200  DTHVStatusId hvId = entry.first;
201  DTHVStatusData data = entry.second;
202  if ( hvId. wheelId != id. wheel() ) continue;
203  if ( hvId.stationId != id.station() ) continue;
204  if ( hvId. sectorId != id. sector() ) continue;
205  int offA = data.flagA & 1;
206  int offC = data.flagC & 1;
207  int offS = data.flagS & 1;
208  if ( offA || offC || offS )
209  offNum += ( 1 + data.lCell - data.fCell );
210  }
211  return offNum;
212 }
213 
214 
216  int offNum = 0;
219  while ( iter != iend ) {
220  const std::pair<DTHVStatusId,DTHVStatusData>& entry = *iter++;
221  DTHVStatusId hvId = entry.first;
222  DTHVStatusData data = entry.second;
223  if ( data.flagA || data.flagC || data.flagS )
224  offNum += ( 1 + data.lCell - data.fCell );
225  }
226  return offNum;
227 }
228 
229 
231  int offNum = 0;
234  while ( iter != iend ) {
235  const std::pair<DTHVStatusId,DTHVStatusData>& entry = *iter++;
236  DTHVStatusId hvId = entry.first;
237  DTHVStatusData data = entry.second;
238  if ( hvId. wheelId != id. wheel() ) continue;
239  if ( hvId.stationId != id.station() ) continue;
240  if ( hvId. sectorId != id. sector() ) continue;
241  if ( data.flagA || data.flagC || data.flagS )
242  offNum += ( 1 + data.lCell - data.fCell );
243  }
244  return offNum;
245 }
246 
247 
248 const
250  return dataVersion;
251 }
252 
253 
255  return dataVersion;
256 }
257 
258 
260  dataList.clear();
261  dataList.reserve( 10 );
262  initialize();
263  return;
264 }
265 
266 
267 int DTHVStatus::set( int wheelId,
268  int stationId,
269  int sectorId,
270  int slId,
271  int layerId,
272  int partId,
273  int fCell,
274  int lCell,
275  int flagA,
276  int flagC,
277  int flagS ) {
278 
279  std::vector<int> chanKey;
280  chanKey.reserve(6);
281  chanKey.push_back( wheelId );
282  chanKey.push_back( stationId );
283  chanKey.push_back( sectorId );
284  chanKey.push_back( slId );
285  chanKey.push_back( layerId );
286  chanKey.push_back( partId );
287  int ientry;
288  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
289 
290  if ( !searchStatus ) {
291  DTHVStatusData& data( dataList[ientry].second );
292  data.fCell = fCell;
293  data.lCell = lCell;
294  data.flagA = flagA;
295  data.flagC = flagC;
296  data.flagS = flagS;
297  return -1;
298  }
299  else {
301  key. wheelId = wheelId;
302  key.stationId = stationId;
303  key. sectorId = sectorId;
304  key. slId = slId;
305  key. layerId = layerId;
306  key. partId = partId;
308  data.fCell = fCell;
309  data.lCell = lCell;
310  data.flagA = flagA;
311  data.flagC = flagC;
312  data.flagS = flagS;
313  ientry = dataList.size();
314  dataList.push_back( std::pair<DTHVStatusId,
315  DTHVStatusData>( key, data ) );
316  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
317  return 0;
318  }
319 
320  return 99;
321 
322 }
323 
324 
325 int DTHVStatus::set( const DTLayerId& id,
326  int partId,
327  int fCell,
328  int lCell,
329  int flagA,
330  int flagC,
331  int flagS ) {
332  return set( id.wheel(),
333  id.station(),
334  id.sector(),
335  id.superLayer(),
336  id.layer(),
337  partId,
338  fCell, lCell, flagA, flagC, flagS );
339 }
340 
341 
342 int DTHVStatus::setFlagA( int wheelId,
343  int stationId,
344  int sectorId,
345  int slId,
346  int layerId,
347  int partId,
348  int flag ) {
349  int fCell;
350  int lCell;
351  int flagA;
352  int flagC;
353  int flagS;
354  get( wheelId,
355  stationId,
356  sectorId,
357  slId,
358  layerId,
359  partId,
360  fCell,
361  lCell,
362  flagA,
363  flagC,
364  flagS );
365  return set( wheelId,
366  stationId,
367  sectorId,
368  slId,
369  layerId,
370  partId,
371  fCell,
372  lCell,
373  flag,
374  flagC,
375  flagS );
376 }
377 
378 
380  int partId,
381  int flag ) {
382  return setFlagA( id.wheel(),
383  id.station(),
384  id.sector(),
385  id.superLayer(),
386  id.layer(),
387  partId,
388  flag );
389 }
390 
391 
392 int DTHVStatus::setFlagC( int wheelId,
393  int stationId,
394  int sectorId,
395  int slId,
396  int layerId,
397  int partId,
398  int flag ) {
399  int fCell;
400  int lCell;
401  int flagA;
402  int flagC;
403  int flagS;
404  get( wheelId,
405  stationId,
406  sectorId,
407  slId,
408  layerId,
409  partId,
410  fCell,
411  lCell,
412  flagA,
413  flagC,
414  flagS );
415  return set( wheelId,
416  stationId,
417  sectorId,
418  slId,
419  layerId,
420  partId,
421  fCell,
422  lCell,
423  flagA,
424  flag,
425  flagS );
426 }
427 
428 
430  int partId,
431  int flag ) {
432  return setFlagC( id.wheel(),
433  id.station(),
434  id.sector(),
435  id.superLayer(),
436  id.layer(),
437  partId,
438  flag );
439 }
440 
441 
442 int DTHVStatus::setFlagS( int wheelId,
443  int stationId,
444  int sectorId,
445  int slId,
446  int layerId,
447  int partId,
448  int flag ) {
449  int fCell;
450  int lCell;
451  int flagA;
452  int flagC;
453  int flagS;
454  get( wheelId,
455  stationId,
456  sectorId,
457  slId,
458  layerId,
459  partId,
460  fCell,
461  lCell,
462  flagA,
463  flagC,
464  flagS );
465  return set( wheelId,
466  stationId,
467  sectorId,
468  slId,
469  layerId,
470  partId,
471  fCell,
472  lCell,
473  flagA,
474  flagC,
475  flag );
476 }
477 
478 
480  int partId,
481  int flag ) {
482  return setFlagS( id.wheel(),
483  id.station(),
484  id.sector(),
485  id.superLayer(),
486  id.layer(),
487  partId,
488  flag );
489 }
490 
491 
493  return dataList.begin();
494 }
495 
496 
498  return dataList.end();
499 }
500 
501 
503  std::stringstream name;
504  name << dataVersion << "_map_HV" << this;
505  return name.str();
506 }
507 
508 
510 
511  dBuf->clear();
512 
513  int entryNum = 0;
514  int entryMax = dataList.size();
515  std::vector<int> chanKey;
516  chanKey.reserve(6);
517  while ( entryNum < entryMax ) {
518 
519  const DTHVStatusId& chan = dataList[entryNum].first;
520 
521  chanKey.clear();
522  chanKey.push_back( chan. wheelId );
523  chanKey.push_back( chan.stationId );
524  chanKey.push_back( chan. sectorId );
525  chanKey.push_back( chan. slId );
526  chanKey.push_back( chan. layerId );
527  chanKey.push_back( chan. partId );
528  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
529 
530  }
531 
532  return;
533 
534 }
535 
536 
static AlgebraicMatrix initialize()
std::vector< std::pair< DTHVStatusId, DTHVStatusData > > dataList
Definition: DTHVStatus.h:193
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:84
int setFlagS(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag)
Definition: DTHVStatus.cc:442
void clear()
reset content
Definition: DTHVStatus.cc:259
int setFlagC(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag)
Definition: DTHVStatus.cc:392
int setFlagA(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int flag)
Definition: DTHVStatus.cc:342
U second(std::pair< T, U > const &p)
std::string mapName() const
read and store full content
Definition: DTHVStatus.cc:502
int offChannelsNumber() const
Definition: DTHVStatus.cc:176
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
Definition: DTHVStatus.h:195
int badChannelsNumber() const
Definition: DTHVStatus.cc:215
#define end
Definition: vmac.h:39
std::vector< std::pair< DTHVStatusId, DTHVStatusData > >::const_iterator const_iterator
Access methods to data.
Definition: DTHVStatus.h:180
void initialize()
Definition: DTHVStatus.cc:509
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:267
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
#define begin
Definition: vmac.h:32
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const_iterator end() const
Definition: DTHVStatus.cc:497
std::string dataVersion
Definition: DTHVStatus.h:191
const_iterator begin() const
Definition: DTHVStatus.cc:492
const std::string & version() const
access version
Definition: DTHVStatus.cc:249