CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTStatusFlag.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2010/01/20 18:20:08 $
5  * $Revision: 1.12 $
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 
36 DTStatusFlag::DTStatusFlag( const std::string& version ):
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  noiseFlag( false ),
55  feMask( false ),
56  tdcMask( false ),
57  trigMask( false ),
58  deadFlag( false ),
59  nohvFlag( false ) {
60 }
61 
62 
63 //--------------
64 // Destructor --
65 //--------------
67 // DTDataBuffer<int,int>::dropBuffer( mapName() );
68  delete dBuf;
69 }
70 
71 
73 }
74 
75 
77 }
78 
79 
80 //--------------
81 // Operations --
82 //--------------
83 int DTStatusFlag::get( int wheelId,
84  int stationId,
85  int sectorId,
86  int slId,
87  int layerId,
88  int cellId,
89  bool& noiseFlag,
90  bool& feMask,
91  bool& tdcMask,
92  bool& trigMask,
93  bool& deadFlag,
94  bool& nohvFlag ) const {
95 
96  noiseFlag =
97  feMask =
98  tdcMask =
99  trigMask =
100  deadFlag =
101  nohvFlag = false;
102 
103 // std::string mName = mapName();
104 // DTBufferTree<int,int>* dBuf =
105 // DTDataBuffer<int,int>::findBuffer( mName );
106 // if ( dBuf == 0 ) {
107 // cacheMap();
108 // dBuf =
109 // DTDataBuffer<int,int>::findBuffer( mName );
110 // }
111  if ( dBuf == 0 ) cacheMap();
112 
113  std::vector<int> chanKey;
114  chanKey.reserve(6);
115  chanKey.push_back( wheelId );
116  chanKey.push_back( stationId );
117  chanKey.push_back( sectorId );
118  chanKey.push_back( slId );
119  chanKey.push_back( layerId );
120  chanKey.push_back( cellId );
121  int ientry;
122  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
123  if ( !searchStatus ) {
124  const DTStatusFlagData& data( dataList[ientry].second );
125  noiseFlag = data.noiseFlag;
126  feMask = data. feMask;
127  tdcMask = data. tdcMask;
128  trigMask = data. trigMask;
129  deadFlag = data. deadFlag;
130  nohvFlag = data. nohvFlag;
131  }
132 
133  return searchStatus;
134 
135 }
136 
137 
139  bool& noiseFlag,
140  bool& feMask,
141  bool& tdcMask,
142  bool& trigMask,
143  bool& deadFlag,
144  bool& nohvFlag ) const {
145  return get( id.wheel(),
146  id.station(),
147  id.sector(),
148  id.superLayer(),
149  id.layer(),
150  id.wire(),
151  noiseFlag, feMask, tdcMask,
152  trigMask, deadFlag, nohvFlag );
153 }
154 
155 
156 const
157 std::string& DTStatusFlag::version() const {
158  return dataVersion;
159 }
160 
161 
162 std::string& DTStatusFlag::version() {
163  return dataVersion;
164 }
165 
166 
168 // DTDataBuffer<int,int>::dropBuffer( mapName() );
169  delete dBuf;
170  dBuf = 0;
171  dataList.clear();
172  return;
173 }
174 
175 
176 int DTStatusFlag::set( int wheelId,
177  int stationId,
178  int sectorId,
179  int slId,
180  int layerId,
181  int cellId,
182  bool noiseFlag,
183  bool feMask,
184  bool tdcMask,
185  bool trigMask,
186  bool deadFlag,
187  bool nohvFlag ) {
188 
189 // std::string mName = mapName();
190 // DTBufferTree<int,int>* dBuf =
191 // DTDataBuffer<int,int>::findBuffer( mName );
192 // if ( dBuf == 0 ) {
193 // cacheMap();
194 // dBuf =
195 // DTDataBuffer<int,int>::findBuffer( mName );
196 // }
197  if ( dBuf == 0 ) cacheMap();
198  std::vector<int> chanKey;
199  chanKey.reserve(6);
200  chanKey.push_back( wheelId );
201  chanKey.push_back( stationId );
202  chanKey.push_back( sectorId );
203  chanKey.push_back( slId );
204  chanKey.push_back( layerId );
205  chanKey.push_back( cellId );
206  int ientry;
207  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
208 
209  if ( !searchStatus ) {
210  DTStatusFlagData& data( dataList[ientry].second );
211  data.noiseFlag = noiseFlag;
212  data. feMask = feMask;
213  data. tdcMask = tdcMask;
214  data. trigMask = trigMask;
215  data. deadFlag = deadFlag;
216  data. nohvFlag = nohvFlag;
217  return -1;
218  }
219  else {
221  key. wheelId = wheelId;
222  key.stationId = stationId;
223  key. sectorId = sectorId;
224  key. slId = slId;
225  key. layerId = layerId;
226  key. cellId = cellId;
228  data.noiseFlag = noiseFlag;
229  data. feMask = feMask;
230  data. tdcMask = tdcMask;
231  data. trigMask = trigMask;
232  data. deadFlag = deadFlag;
233  data. nohvFlag = nohvFlag;
234  ientry = dataList.size();
235  dataList.push_back( std::pair<const DTStatusFlagId,
236  DTStatusFlagData>( key, data ) );
237  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
238  return 0;
239  }
240 
241  return 99;
242 
243 }
244 
245 
247  bool noiseFlag,
248  bool feMask,
249  bool tdcMask,
250  bool trigMask,
251  bool deadFlag,
252  bool nohvFlag ) {
253  return set( id.wheel(),
254  id.station(),
255  id.sector(),
256  id.superLayer(),
257  id.layer(),
258  id.wire(),
259  noiseFlag, feMask, tdcMask,
260  trigMask, deadFlag, nohvFlag );
261 }
262 
263 
264 int DTStatusFlag::setCellNoise( int wheelId,
265  int stationId,
266  int sectorId,
267  int slId,
268  int layerId,
269  int cellId,
270  bool flag ) {
271 
272  bool noiseFlag;
273  bool feMask;
274  bool tdcMask;
275  bool trigMask;
276  bool deadFlag;
277  bool nohvFlag;
278  int status = get( wheelId,
279  stationId,
280  sectorId,
281  slId,
282  layerId,
283  cellId,
284  noiseFlag,
285  feMask,
286  tdcMask,
287  trigMask,
288  deadFlag,
289  nohvFlag );
290  set( wheelId,
291  stationId,
292  sectorId,
293  slId,
294  layerId,
295  cellId,
296  flag,
297  feMask,
298  tdcMask,
299  trigMask,
300  deadFlag,
301  nohvFlag );
302  return status;
303 
304 }
305 
306 
308  bool flag ) {
309  return setCellNoise( id.wheel(),
310  id.station(),
311  id.sector(),
312  id.superLayer(),
313  id.layer(),
314  id.wire(),
315  flag );
316 }
317 
318 
320  int stationId,
321  int sectorId,
322  int slId,
323  int layerId,
324  int cellId,
325  bool mask ) {
326 
327  bool noiseFlag;
328  bool feMask;
329  bool tdcMask;
330  bool trigMask;
331  bool deadFlag;
332  bool nohvFlag;
333  int status = get( wheelId,
334  stationId,
335  sectorId,
336  slId,
337  layerId,
338  cellId,
339  noiseFlag,
340  feMask,
341  tdcMask,
342  trigMask,
343  deadFlag,
344  nohvFlag );
345  set( wheelId,
346  stationId,
347  sectorId,
348  slId,
349  layerId,
350  cellId,
351  noiseFlag,
352  mask,
353  tdcMask,
354  trigMask,
355  deadFlag,
356  nohvFlag );
357  return status;
358 
359 }
360 
361 
363  bool mask ) {
364  return setCellFEMask( id.wheel(),
365  id.station(),
366  id.sector(),
367  id.superLayer(),
368  id.layer(),
369  id.wire(),
370  mask );
371 }
372 
373 
375  int stationId,
376  int sectorId,
377  int slId,
378  int layerId,
379  int cellId,
380  bool mask ) {
381 
382  bool noiseFlag;
383  bool feMask;
384  bool tdcMask;
385  bool trigMask;
386  bool deadFlag;
387  bool nohvFlag;
388  int status = get( wheelId,
389  stationId,
390  sectorId,
391  slId,
392  layerId,
393  cellId,
394  noiseFlag,
395  feMask,
396  tdcMask,
397  trigMask,
398  deadFlag,
399  nohvFlag );
400  set( wheelId,
401  stationId,
402  sectorId,
403  slId,
404  layerId,
405  cellId,
406  noiseFlag,
407  feMask,
408  mask,
409  trigMask,
410  deadFlag,
411  nohvFlag );
412  return status;
413 
414 }
415 
416 
418  bool mask ) {
419  return setCellTDCMask( id.wheel(),
420  id.station(),
421  id.sector(),
422  id.superLayer(),
423  id.layer(),
424  id.wire(),
425  mask );
426 }
427 
428 
430  int stationId,
431  int sectorId,
432  int slId,
433  int layerId,
434  int cellId,
435  bool mask ) {
436 
437  bool noiseFlag;
438  bool feMask;
439  bool tdcMask;
440  bool trigMask;
441  bool deadFlag;
442  bool nohvFlag;
443  int status = get( wheelId,
444  stationId,
445  sectorId,
446  slId,
447  layerId,
448  cellId,
449  noiseFlag,
450  feMask,
451  tdcMask,
452  trigMask,
453  deadFlag,
454  nohvFlag );
455  set( wheelId,
456  stationId,
457  sectorId,
458  slId,
459  layerId,
460  cellId,
461  noiseFlag,
462  feMask,
463  tdcMask,
464  mask,
465  deadFlag,
466  nohvFlag );
467  return status;
468 
469 }
470 
471 
473  bool mask ) {
474  return setCellTrigMask( id.wheel(),
475  id.station(),
476  id.sector(),
477  id.superLayer(),
478  id.layer(),
479  id.wire(),
480  mask );
481 }
482 
483 
484 int DTStatusFlag::setCellDead( int wheelId,
485  int stationId,
486  int sectorId,
487  int slId,
488  int layerId,
489  int cellId,
490  bool flag ) {
491 
492  bool noiseFlag;
493  bool feMask;
494  bool tdcMask;
495  bool trigMask;
496  bool deadFlag;
497  bool nohvFlag;
498  int status = get( wheelId,
499  stationId,
500  sectorId,
501  slId,
502  layerId,
503  cellId,
504  noiseFlag,
505  feMask,
506  tdcMask,
507  trigMask,
508  deadFlag,
509  nohvFlag );
510  set( wheelId,
511  stationId,
512  sectorId,
513  slId,
514  layerId,
515  cellId,
516  noiseFlag,
517  feMask,
518  tdcMask,
519  trigMask,
520  flag,
521  nohvFlag );
522  return status;
523 
524 }
525 
526 
528  bool flag ) {
529  return setCellDead( id.wheel(),
530  id.station(),
531  id.sector(),
532  id.superLayer(),
533  id.layer(),
534  id.wire(),
535  flag );
536 }
537 
538 
539 int DTStatusFlag::setCellNoHV( int wheelId,
540  int stationId,
541  int sectorId,
542  int slId,
543  int layerId,
544  int cellId,
545  bool flag ) {
546 
547  bool noiseFlag;
548  bool feMask;
549  bool tdcMask;
550  bool trigMask;
551  bool deadFlag;
552  bool nohvFlag;
553  int status = get( wheelId,
554  stationId,
555  sectorId,
556  slId,
557  layerId,
558  cellId,
559  noiseFlag,
560  feMask,
561  tdcMask,
562  trigMask,
563  deadFlag,
564  nohvFlag );
565  set( wheelId,
566  stationId,
567  sectorId,
568  slId,
569  layerId,
570  cellId,
571  noiseFlag,
572  feMask,
573  tdcMask,
574  trigMask,
575  deadFlag,
576  flag );
577  return status;
578 
579 }
580 
581 
583  bool flag ) {
584  return setCellNoHV( id.wheel(),
585  id.station(),
586  id.sector(),
587  id.superLayer(),
588  id.layer(),
589  id.wire(),
590  flag );
591 }
592 
593 
595  return dataList.begin();
596 }
597 
598 
600  return dataList.end();
601 }
602 
603 
604 std::string DTStatusFlag::mapName() const {
605  std::stringstream name;
606  name << dataVersion << "_map_StatusFlag" << this;
607  return name.str();
608 }
609 
610 
612 
613 // std::string mName = mapName();
614 // DTBufferTree<int,int>* dBuf =
615 // DTDataBuffer<int,int>::openBuffer( mName );
616  DTBufferTree<int,int>** pBuf;
617  pBuf = const_cast<DTBufferTree<int,int>**>( &dBuf );
618  *pBuf = new DTBufferTree<int,int>;
619 
620  int entryNum = 0;
621  int entryMax = dataList.size();
622  std::vector<int> chanKey;
623  chanKey.reserve(6);
624  while ( entryNum < entryMax ) {
625 
626  const DTStatusFlagId& chan = dataList[entryNum].first;
627 
628  chanKey.clear();
629  chanKey.push_back( chan. wheelId );
630  chanKey.push_back( chan.stationId );
631  chanKey.push_back( chan. sectorId );
632  chanKey.push_back( chan. slId );
633  chanKey.push_back( chan. layerId );
634  chanKey.push_back( chan. cellId );
635  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
636 
637  }
638 
639  return;
640 
641 }
642 
int set(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool noiseFlag, bool feMask, bool tdcMask, bool trigMask, bool deadFlag, bool nohvFlag)
long int flag
Definition: mlp_lapack.h:47
const_iterator end() const
int setCellDead(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
int insert(ElementKey fKey, ElementKey lKey, const Content &cont)
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool &noiseFlag, bool &feMask, bool &tdcMask, bool &trigMask, bool &deadFlag, bool &nohvFlag) const
Definition: DTStatusFlag.cc:83
int setCellTrigMask(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool mask)
U second(std::pair< T, U > const &p)
std::vector< std::pair< DTStatusFlagId, DTStatusFlagData > > dataList
Definition: DTStatusFlag.h:263
int setCellNoise(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
std::string dataVersion
Definition: DTStatusFlag.h:261
std::vector< std::pair< DTStatusFlagId, DTStatusFlagData > >::const_iterator const_iterator
Access methods to data.
Definition: DTStatusFlag.h:255
void cacheMap() const
read and store full content
int find(ElementKey fKey, ElementKey lKey, Content &cont)
const std::string & version() const
access version
void clear()
reset content
int setCellNoHV(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
std::string mapName() const
DTBufferTree< int, int > * dBuf
Definition: DTStatusFlag.h:265
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
list key
Definition: combine.py:13
int setCellTDCMask(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool mask)
int setCellFEMask(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool mask)
tuple status
Definition: ntuplemaker.py:245
const_iterator begin() const