CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Masks.cc
Go to the documentation of this file.
1 // $Id: Masks.cc,v 1.18 2012/04/27 13:46:04 yiiyama Exp $
2 
11 #include <sstream>
12 #include <iomanip>
13 
17 
20 
22 
24 
25 //-------------------------------------------------------------------------
26 
29 
30 bool Masks::init = false;
31 
32 //-------------------------------------------------------------------------
33 
35 
36  if ( Masks::init ) return;
37 
38  if ( verbose ) std::cout << "Initializing EcalDQMChannelStatus and EcalDQMTowerStatus ..." << std::endl;
39 
40  Masks::init = true;
41 
42  if ( setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMChannelStatusRcd>() ) ) {
44  setup.get<EcalDQMChannelStatusRcd>().get(handle);
45  if ( handle.isValid() ) Masks::channelStatus = handle.product();
46  }
47 
48  if ( setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMTowerStatusRcd>() ) ) {
50  setup.get<EcalDQMTowerStatusRcd>().get(handle);
51  if ( handle.isValid() ) Masks::towerStatus = handle.product();
52  }
53 
54  if ( verbose ) std::cout << "done." << std::endl;
55 
56 }
57 
58 //-------------------------------------------------------------------------
59 
60 bool Masks::maskChannel( int ism, int i1, int i2, uint32_t bits, const EcalSubdetector subdet ) throw( cms::Exception ) {
61 
62  bool mask = false;
63 
64  if ( subdet == EcalBarrel ) {
65 
66  int jsm = Numbers::iSM(ism, EcalBarrel);
67  int ic = 20*(i1-1)+(i2-1)+1;
68 
69  EBDetId id(jsm, ic, EBDetId::SMCRYSTALMODE);
70  if ( Masks::channelStatus ) {
71  EcalDQMChannelStatus::const_iterator it = Masks::channelStatus->find( id.rawId() );
72  if ( it != Masks::channelStatus->end() ) mask |= it->getStatusCode() & bits;
73  }
74  if ( Masks::towerStatus ) {
75  EcalDQMTowerStatus::const_iterator it = Masks::towerStatus->find( id.tower().rawId() );
76  if ( it != Masks::towerStatus->end() ) mask |= it->getStatusCode() & bits;
77  }
78 
79  } else if ( subdet == EcalEndcap ) {
80 
81  int jx = i1 + Numbers::ix0EE(ism);
82  int jy = i2 + Numbers::iy0EE(ism);
83 
84  if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
85 
86  if ( Numbers::validEE(ism, jx, jy) ) {
87  EEDetId id(jx, jy, (ism>=1&&ism<=9)?-1:+1);
88  if ( Masks::channelStatus ) {
89  EcalDQMChannelStatus::const_iterator it = Masks::channelStatus->find( id.rawId() );
90  if ( it != Masks::channelStatus->end() ) mask |= it->getStatusCode() & bits;
91  }
92  if ( Masks::towerStatus ) {
93  EcalDQMTowerStatus::const_iterator it = Masks::towerStatus->find( id.sc().rawId() );
94  if ( it != Masks::towerStatus->end() ) mask |= it->getStatusCode() & bits;
95  }
96  }
97 
98  } else {
99 
100  std::ostringstream s;
101  s << "Invalid subdetector: subdet = " << subdet;
102  throw( cms::Exception( s.str() ) );
103 
104  }
105 
106  return ( mask );
107 
108 }
109 
110 //-------------------------------------------------------------------------
111 
112 bool Masks::maskPn( int ism, int i1, uint32_t bits, const EcalSubdetector subdet ) throw( cms::Exception ) {
113 
114  bool mask = false;
115 
116  if ( subdet == EcalBarrel ) {
117 
118  // EB-03
119  if ( ism == 3 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
120  if ( ism == 3 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
121 
122  // EB-07
123  if ( ism == 7 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
124  if ( ism == 7 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
125 
126  // EB-15
127  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
128  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
129  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
130  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
131  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
132  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
133  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
134  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
135  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
136  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
137  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
138  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
139  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
140  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
141  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
142  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
143  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
144  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
145  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
146  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
147  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
148  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
149  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
150  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
151  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
152 
153  // EB+06
154  if ( ism == 24 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
155 
156  // EB+07
157  if ( ism == 25 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
158  if ( ism == 25 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
159 
160  // EB+12
161  if ( ism == 30 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
162  if ( ism == 30 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
163 
164  // EB+15
165  if ( ism == 15 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
166  if ( ism == 15 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
167  if ( ism == 15 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
168 
169  } else if ( subdet == EcalEndcap ) {
170 
171  // EE-02
172  if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
173  if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
174  if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
175  if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
176 
177  // EE-03
178  if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
179  if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
180 
181  // EE-07
182  if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
183  if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
184  if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
185  if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
186 
187  // EE-08
188  if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
189  if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
190  if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
191  if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
192  if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
193  if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
194  if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
195 
196  } else {
197 
198  std::ostringstream s;
199  s << "Invalid subdetector: subdet = " << subdet;
200  throw( cms::Exception( s.str() ) );
201 
202  }
203 
204  return ( mask );
205 
206 }
207 
208 //-------------------------------------------------------------------------
209 
static const int LED_MEAN_ERROR
static bool validEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:832
static const int LASER_MEAN_ERROR
static bool maskChannel(int ism, int i1, int i2, uint32_t bits, const EcalSubdetector subdet)
Definition: Masks.cc:60
static bool init
Definition: Masks.h:40
Some &quot;id&quot; conversions.
static const EcalDQMTowerStatus * towerStatus
Definition: Masks.h:45
static const int PEDESTAL_HIGH_GAIN_MEAN_ERROR
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
static const int TT_SIZE_ERROR
static int ix0EE(const unsigned ism)
Definition: Numbers.cc:773
const_iterator find(uint32_t rawId) const
static bool maskPn(int ism, int i1, uint32_t bits, const EcalSubdetector subdet)
Definition: Masks.cc:112
static int iy0EE(const unsigned ism)
Definition: Numbers.cc:812
static const int STATUS_FLAG_ERROR
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
channel masking
tuple handle
Definition: patZpeak.py:22
#define end
Definition: vmac.h:38
static void initMasking(const edm::EventSetup &setup, bool verbose=false)
Definition: Masks.cc:34
static const int PEDESTAL_LOW_GAIN_MEAN_ERROR
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
T const * product() const
Definition: ESHandle.h:62
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:246
static const EcalDQMChannelStatus * channelStatus
Definition: Masks.h:44
const_iterator find(uint32_t rawId) const
tuple cout
Definition: gather_cfg.py:121
std::vector< Item >::const_iterator const_iterator
static const int TESTPULSE_HIGH_GAIN_MEAN_ERROR
bool isValid() const
Definition: ESHandle.h:37
static const int SMCRYSTALMODE
Definition: EBDetId.h:168
EcalSubdetector
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")