CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTDeadFlag.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2009/09/25 12:03:19 $
5  * $Revision: 1.6 $
6  * \author Paolo Ronchese INFN Padova
7  *
8  */
9 
10 //----------------------
11 // This Class' Header --
12 //----------------------
14 
15 //-------------------------------
16 // Collaborating Class Headers --
17 //-------------------------------
18 //#include "CondFormats/DTObjects/interface/DTDataBuffer.h"
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 #include <iostream>
24 #include <sstream>
25 
26 //----------------
27 // Constructors --
28 //----------------
30  dataVersion( " " ) {
31  dataList.reserve( 1000 );
32  dBuf = 0;
33 }
34 
35 
37  dataVersion( version ) {
38  dataList.reserve( 1000 );
39  dBuf = 0;
40 }
41 
42 
44  wheelId( 0 ),
45  stationId( 0 ),
46  sectorId( 0 ),
47  slId( 0 ),
48  layerId( 0 ),
49  cellId( 0 ) {
50 }
51 
52 
54  dead_HV( false ),
55  dead_TP( false ),
56  dead_RO( false ),
57  discCat( false ) {
58 }
59 
60 
61 //--------------
62 // Destructor --
63 //--------------
65 // DTDataBuffer<int,int>::dropBuffer( mapName() );
66  delete dBuf;
67 }
68 
69 
71 }
72 
73 
75 }
76 
77 
78 //--------------
79 // Operations --
80 //--------------
81 int DTDeadFlag::get( int wheelId,
82  int stationId,
83  int sectorId,
84  int slId,
85  int layerId,
86  int cellId,
87  bool& dead_HV,
88  bool& dead_TP,
89  bool& dead_RO,
90  bool& discCat ) const {
91 
92  dead_HV =
93  dead_TP =
94  dead_RO =
95  discCat = false;
96 
97 // std::string mName = mapName();
98 // DTBufferTree<int,int>* dBuf =
99 // DTDataBuffer<int,int>::findBuffer( mName );
100 // if ( dBuf == 0 ) {
101 // cacheMap();
102 // dBuf =
103 // DTDataBuffer<int,int>::findBuffer( mName );
104 // }
105  if ( dBuf == 0 ) cacheMap();
106  std::vector<int> chanKey;
107  chanKey.reserve(6);
108  chanKey.push_back( wheelId );
109  chanKey.push_back( stationId );
110  chanKey.push_back( sectorId );
111  chanKey.push_back( slId );
112  chanKey.push_back( layerId );
113  chanKey.push_back( cellId );
114  int ientry;
115  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
116  if ( !searchStatus ) {
117  const DTDeadFlagData& data( dataList[ientry].second );
118  dead_HV = data.dead_HV;
119  dead_TP = data.dead_TP;
120  dead_RO = data.dead_RO;
121  discCat = data.discCat;
122  }
123 
124  return searchStatus;
125 
126 }
127 
128 
129 int DTDeadFlag::get( const DTWireId& id,
130  bool& dead_HV,
131  bool& dead_TP,
132  bool& dead_RO,
133  bool& discCat ) const {
134  return get( id.wheel(),
135  id.station(),
136  id.sector(),
137  id.superLayer(),
138  id.layer(),
139  id.wire(),
140  dead_HV, dead_TP, dead_RO, discCat );
141 }
142 
143 
144 bool DTDeadFlag::getCellDead_HV( int wheelId,
145  int stationId,
146  int sectorId,
147  int slId,
148  int layerId,
149  int cellId ) const {
150 
151  bool dead_HV;
152  bool dead_TP;
153  bool dead_RO;
154  bool discCat;
155  get( wheelId,
156  stationId,
157  sectorId,
158  slId,
159  layerId,
160  cellId,
161  dead_HV, dead_TP, dead_RO, discCat );
162  return dead_HV;
163 
164 }
165 
166 
167 bool DTDeadFlag::getCellDead_HV( const DTWireId& id ) const {
168  return getCellDead_HV( id.wheel(),
169  id.station(),
170  id.sector(),
171  id.superLayer(),
172  id.layer(),
173  id.wire() );
174 }
175 
176 
177 bool DTDeadFlag::getCellDead_TP( int wheelId,
178  int stationId,
179  int sectorId,
180  int slId,
181  int layerId,
182  int cellId ) const {
183 
184  bool dead_HV;
185  bool dead_TP;
186  bool dead_RO;
187  bool discCat;
188  get( wheelId,
189  stationId,
190  sectorId,
191  slId,
192  layerId,
193  cellId,
194  dead_HV, dead_TP, dead_RO, discCat );
195  return dead_TP;
196 
197 }
198 
199 
200 bool DTDeadFlag::getCellDead_TP( const DTWireId& id ) const {
201  return getCellDead_TP( id.wheel(),
202  id.station(),
203  id.sector(),
204  id.superLayer(),
205  id.layer(),
206  id.wire() );
207 }
208 
209 
210 bool DTDeadFlag::getCellDead_RO( int wheelId,
211  int stationId,
212  int sectorId,
213  int slId,
214  int layerId,
215  int cellId ) const {
216 
217  bool dead_HV;
218  bool dead_TP;
219  bool dead_RO;
220  bool discCat;
221  get( wheelId,
222  stationId,
223  sectorId,
224  slId,
225  layerId,
226  cellId,
227  dead_HV, dead_TP, dead_RO, discCat );
228  return dead_RO;
229 
230 }
231 
232 
233 bool DTDeadFlag::getCellDead_RO( const DTWireId& id ) const {
234  return getCellDead_RO( id.wheel(),
235  id.station(),
236  id.sector(),
237  id.superLayer(),
238  id.layer(),
239  id.wire() );
240 }
241 
242 
243 bool DTDeadFlag::getCellDiscCat( int wheelId,
244  int stationId,
245  int sectorId,
246  int slId,
247  int layerId,
248  int cellId ) const {
249 
250  bool dead_HV;
251  bool dead_TP;
252  bool dead_RO;
253  bool discCat;
254  get( wheelId,
255  stationId,
256  sectorId,
257  slId,
258  layerId,
259  cellId,
260  dead_HV, dead_TP, dead_RO, discCat );
261  return discCat;
262 
263 }
264 
265 
266 bool DTDeadFlag::getCellDiscCat( const DTWireId& id ) const {
267  return getCellDiscCat( id.wheel(),
268  id.station(),
269  id.sector(),
270  id.superLayer(),
271  id.layer(),
272  id.wire() );
273 }
274 
275 
276 const
278  return dataVersion;
279 }
280 
281 
283  return dataVersion;
284 }
285 
286 
288 // DTDataBuffer<int,int>::dropBuffer( mapName() );
289  delete dBuf;
290  dBuf = 0;
291  dataList.clear();
292  return;
293 }
294 
295 
296 int DTDeadFlag::set( int wheelId,
297  int stationId,
298  int sectorId,
299  int slId,
300  int layerId,
301  int cellId,
302  bool dead_HV,
303  bool dead_TP,
304  bool dead_RO,
305  bool discCat ) {
306 
307 // std::string mName = mapName();
308 // DTBufferTree<int,int>* dBuf =
309 // DTDataBuffer<int,int>::findBuffer( mName );
310 // if ( dBuf == 0 ) {
311 // cacheMap();
312 // dBuf =
313 // DTDataBuffer<int,int>::findBuffer( mName );
314 // }
315  if ( dBuf == 0 ) cacheMap();
316  std::vector<int> chanKey;
317  chanKey.reserve(6);
318  chanKey.push_back( wheelId );
319  chanKey.push_back( stationId );
320  chanKey.push_back( sectorId );
321  chanKey.push_back( slId );
322  chanKey.push_back( layerId );
323  chanKey.push_back( cellId );
324  int ientry;
325  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
326 
327  if ( !searchStatus ) {
328  DTDeadFlagData& data( dataList[ientry].second );
329  data.dead_HV = dead_HV;
330  data.dead_TP = dead_TP;
331  data.dead_RO = dead_RO;
332  data.discCat = discCat;
333  return -1;
334  }
335  else {
337  key. wheelId = wheelId;
338  key.stationId = stationId;
339  key. sectorId = sectorId;
340  key. slId = slId;
341  key. layerId = layerId;
342  key. cellId = cellId;
344  data.dead_HV = dead_HV;
345  data.dead_TP = dead_TP;
346  data.dead_RO = dead_RO;
347  data.discCat = discCat;
348  ientry = dataList.size();
349  dataList.push_back( std::pair<const DTDeadFlagId,
350  DTDeadFlagData>( key, data ) );
351  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
352  return 0;
353  }
354 
355  return 99;
356 
357 }
358 
359 
360 int DTDeadFlag::set( const DTWireId& id,
361  bool dead_HV,
362  bool dead_TP,
363  bool dead_RO,
364  bool discCat ) {
365  return set( id.wheel(),
366  id.station(),
367  id.sector(),
368  id.superLayer(),
369  id.layer(),
370  id.wire(),
371  dead_HV, dead_TP, dead_RO, discCat );
372 }
373 
374 
375 int DTDeadFlag::setCellDead_HV( int wheelId,
376  int stationId,
377  int sectorId,
378  int slId,
379  int layerId,
380  int cellId,
381  bool flag ) {
382 
383  bool dead_HV;
384  bool dead_TP;
385  bool dead_RO;
386  bool discCat;
387  int status = cellStatus( wheelId,
388  stationId,
389  sectorId,
390  slId,
391  layerId,
392  cellId,
393  dead_HV, dead_TP, dead_RO, discCat );
394  setCellStatus( wheelId,
395  stationId,
396  sectorId,
397  slId,
398  layerId,
399  cellId,
400  flag, dead_TP, dead_RO, discCat );
401  return status;
402 
403 }
404 
405 
407  bool flag ) {
408  return setCellDead_HV( id.wheel(),
409  id.station(),
410  id.sector(),
411  id.superLayer(),
412  id.layer(),
413  id.wire(),
414  flag );
415 }
416 
417 
418 int DTDeadFlag::setCellDead_TP( int wheelId,
419  int stationId,
420  int sectorId,
421  int slId,
422  int layerId,
423  int cellId,
424  bool flag ) {
425 
426  bool dead_HV;
427  bool dead_TP;
428  bool dead_RO;
429  bool discCat;
430  int status = cellStatus( wheelId,
431  stationId,
432  sectorId,
433  slId,
434  layerId,
435  cellId,
436  dead_HV, dead_TP, dead_RO, discCat );
437  setCellStatus( wheelId,
438  stationId,
439  sectorId,
440  slId,
441  layerId,
442  cellId,
443  dead_HV, flag, dead_RO, discCat );
444  return status;
445 
446 }
447 
448 
450  bool flag ) {
451  return setCellDead_TP( id.wheel(),
452  id.station(),
453  id.sector(),
454  id.superLayer(),
455  id.layer(),
456  id.wire(),
457  flag );
458 }
459 
460 
461 int DTDeadFlag::setCellDead_RO( int wheelId,
462  int stationId,
463  int sectorId,
464  int slId,
465  int layerId,
466  int cellId,
467  bool flag ) {
468 
469  bool dead_HV;
470  bool dead_TP;
471  bool dead_RO;
472  bool discCat;
473  int status = cellStatus( wheelId,
474  stationId,
475  sectorId,
476  slId,
477  layerId,
478  cellId,
479  dead_HV, dead_TP, dead_RO, discCat );
480  setCellStatus( wheelId,
481  stationId,
482  sectorId,
483  slId,
484  layerId,
485  cellId,
486  dead_HV, dead_TP, flag, discCat );
487  return status;
488 
489 }
490 
491 
493  bool flag ) {
494  return setCellDead_RO( id.wheel(),
495  id.station(),
496  id.sector(),
497  id.superLayer(),
498  id.layer(),
499  id.wire(),
500  flag );
501 }
502 
503 
504 int DTDeadFlag::setCellDiscCat( int wheelId,
505  int stationId,
506  int sectorId,
507  int slId,
508  int layerId,
509  int cellId,
510  bool flag ) {
511 
512  bool dead_HV;
513  bool dead_TP;
514  bool dead_RO;
515  bool discCat;
516  int status = cellStatus( wheelId,
517  stationId,
518  sectorId,
519  slId,
520  layerId,
521  cellId,
522  dead_HV, dead_TP, dead_RO, discCat );
523  setCellStatus( wheelId,
524  stationId,
525  sectorId,
526  slId,
527  layerId,
528  cellId,
529  dead_HV, dead_TP, dead_RO, flag );
530  return status;
531 
532 }
533 
534 
536  bool flag ) {
537  return setCellDiscCat( id.wheel(),
538  id.station(),
539  id.sector(),
540  id.superLayer(),
541  id.layer(),
542  id.wire(),
543  flag );
544 }
545 
546 
548  return dataList.begin();
549 }
550 
551 
553  return dataList.end();
554 }
555 
556 
558  std::stringstream name;
559  name << dataVersion << "_map_DeadFlag" << this;
560  return name.str();
561 }
562 
563 
564 void DTDeadFlag::cacheMap() const {
565 
566 // std::string mName = mapName();
567 // DTBufferTree<int,int>* dBuf =
568 // DTDataBuffer<int,int>::openBuffer( mName );
569  DTBufferTree<int,int>** pBuf;
570  pBuf = const_cast<DTBufferTree<int,int>**>( &dBuf );
571  *pBuf = new DTBufferTree<int,int>;
572 
573  int entryNum = 0;
574  int entryMax = dataList.size();
575  std::vector<int> chanKey;
576  chanKey.reserve(6);
577  while ( entryNum < entryMax ) {
578 
579  const DTDeadFlagId& chan = dataList[entryNum].first;
580 
581  chanKey.clear();
582  chanKey.push_back( chan. wheelId );
583  chanKey.push_back( chan.stationId );
584  chanKey.push_back( chan. sectorId );
585  chanKey.push_back( chan. slId );
586  chanKey.push_back( chan. layerId );
587  chanKey.push_back( chan. cellId );
588  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
589 
590  }
591 
592  return;
593 
594 }
595 
DTBufferTree< int, int > * dBuf
Definition: DTDeadFlag.h:245
bool getCellDiscCat(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId) const
Definition: DTDeadFlag.cc:243
int setCellDead_HV(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
Definition: DTDeadFlag.cc:375
int set(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool dead_HV, bool dead_TP, bool dead_RO, bool discCat)
Definition: DTDeadFlag.cc:296
int insert(ElementKey fKey, ElementKey lKey, const Content &cont)
const_iterator begin() const
Definition: DTDeadFlag.cc:547
bool getCellDead_TP(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId) const
Definition: DTDeadFlag.cc:177
std::vector< std::pair< DTDeadFlagId, DTDeadFlagData > > dataList
Definition: DTDeadFlag.h:243
int setCellDead_RO(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
Definition: DTDeadFlag.cc:461
U second(std::pair< T, U > const &p)
const_iterator end() const
Definition: DTDeadFlag.cc:552
std::string mapName() const
Definition: DTDeadFlag.cc:557
std::vector< std::pair< DTDeadFlagId, DTDeadFlagData > >::const_iterator const_iterator
Access methods to data.
Definition: DTDeadFlag.h:235
int setCellDiscCat(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
Definition: DTDeadFlag.cc:504
const std::string & version() const
access version
Definition: DTDeadFlag.cc:277
bool getCellDead_HV(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId) const
Definition: DTDeadFlag.cc:144
int setCellDead_TP(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
Definition: DTDeadFlag.cc:418
std::string dataVersion
Definition: DTDeadFlag.h:241
int setCellStatus(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool dead_HV, bool dead_TP, bool dead_RO, bool discCat)
Definition: DTDeadFlag.h:157
void cacheMap() const
read and store full content
Definition: DTDeadFlag.cc:564
int find(ElementKey fKey, ElementKey lKey, Content &cont)
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool &dead_HV, bool &dead_TP, bool &dead_RO, bool &discCat) const
Definition: DTDeadFlag.cc:81
int cellStatus(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool &dead_HV, bool &dead_TP, bool &dead_RO, bool &discCat) const
get content
Definition: DTDeadFlag.h:83
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
list key
Definition: combine.py:13
volatile std::atomic< bool > shutdown_flag false
tuple status
Definition: ntuplemaker.py:245
bool getCellDead_RO(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId) const
Definition: DTDeadFlag.cc:210
void clear()
reset content
Definition: DTDeadFlag.cc:287