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 
8 #include <sstream>
9 #include <iomanip>
10 
14 
17 
19 
21 
22 //-------------------------------------------------------------------------
23 
26 
27 bool Masks::init = false;
28 
29 //-------------------------------------------------------------------------
30 
32 
33  if ( Masks::init ) return;
34 
35  if ( verbose ) std::cout << "Initializing EcalDQMChannelStatus and EcalDQMTowerStatus ..." << std::endl;
36 
37  Masks::init = true;
38 
39  if ( setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMChannelStatusRcd>() ) ) {
41  setup.get<EcalDQMChannelStatusRcd>().get(handle);
42  if ( handle.isValid() ) Masks::channelStatus = handle.product();
43  }
44 
45  if ( setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMTowerStatusRcd>() ) ) {
47  setup.get<EcalDQMTowerStatusRcd>().get(handle);
48  if ( handle.isValid() ) Masks::towerStatus = handle.product();
49  }
50 
51  if ( verbose ) std::cout << "done." << std::endl;
52 
53 }
54 
55 //-------------------------------------------------------------------------
56 
57 bool Masks::maskChannel( int ism, int i1, int i2, uint32_t bits, const EcalSubdetector subdet ) throw( cms::Exception ) {
58 
59  bool mask = false;
60 
61  if ( subdet == EcalBarrel ) {
62 
63  int jsm = Numbers::iSM(ism, EcalBarrel);
64  int ic = 20*(i1-1)+(i2-1)+1;
65 
66  EBDetId id(jsm, ic, EBDetId::SMCRYSTALMODE);
67  if ( Masks::channelStatus ) {
68  EcalDQMChannelStatus::const_iterator it = Masks::channelStatus->find( id.rawId() );
69  if ( it != Masks::channelStatus->end() ) mask |= it->getStatusCode() & bits;
70  }
71  if ( Masks::towerStatus ) {
72  EcalDQMTowerStatus::const_iterator it = Masks::towerStatus->find( id.tower().rawId() );
73  if ( it != Masks::towerStatus->end() ) mask |= it->getStatusCode() & bits;
74  }
75 
76  } else if ( subdet == EcalEndcap ) {
77 
78  int jx = i1 + Numbers::ix0EE(ism);
79  int jy = i2 + Numbers::iy0EE(ism);
80 
81  if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
82 
83  if ( Numbers::validEE(ism, jx, jy) ) {
84  EEDetId id(jx, jy, (ism>=1&&ism<=9)?-1:+1);
85  if ( Masks::channelStatus ) {
86  EcalDQMChannelStatus::const_iterator it = Masks::channelStatus->find( id.rawId() );
87  if ( it != Masks::channelStatus->end() ) mask |= it->getStatusCode() & bits;
88  }
89  if ( Masks::towerStatus ) {
90  EcalDQMTowerStatus::const_iterator it = Masks::towerStatus->find( id.sc().rawId() );
91  if ( it != Masks::towerStatus->end() ) mask |= it->getStatusCode() & bits;
92  }
93  }
94 
95  } else {
96 
97  std::ostringstream s;
98  s << "Invalid subdetector: subdet = " << subdet;
99  throw( cms::Exception( s.str() ) );
100 
101  }
102 
103  return ( mask );
104 
105 }
106 
107 //-------------------------------------------------------------------------
108 
109 bool Masks::maskPn( int ism, int i1, uint32_t bits, const EcalSubdetector subdet ) throw( cms::Exception ) {
110 
111  bool mask = false;
112 
113  if ( subdet == EcalBarrel ) {
114 
115  // EB-03
116  if ( ism == 3 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
117  if ( ism == 3 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
118 
119  // EB-07
120  if ( ism == 7 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
121  if ( ism == 7 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
122 
123  // EB-15
124  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
125  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
126  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
127  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
128  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
129  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
130  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
131  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
132  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
133  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
134  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
135  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
136  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
137  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
138  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
139  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
140  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
141  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
142  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
143  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
144  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
145  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
146  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
147  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
148  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
149 
150  // EB+06
151  if ( ism == 24 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
152 
153  // EB+07
154  if ( ism == 25 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
155  if ( ism == 25 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
156 
157  // EB+12
158  if ( ism == 30 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
159  if ( ism == 30 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
160 
161  // EB+15
162  if ( ism == 15 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
163  if ( ism == 15 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
164  if ( ism == 15 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
165 
166  } else if ( subdet == EcalEndcap ) {
167 
168  // EE-02
169  if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
170  if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
171  if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
172  if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
173 
174  // EE-03
175  if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
176  if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
177 
178  // EE-07
179  if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
180  if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
181  if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
182  if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
183 
184  // EE-08
185  if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
186  if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
187  if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
188  if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
189  if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
190  if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
191  if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
192 
193  } else {
194 
195  std::ostringstream s;
196  s << "Invalid subdetector: subdet = " << subdet;
197  throw( cms::Exception( s.str() ) );
198 
199  }
200 
201  return ( mask );
202 
203 }
204 
205 //-------------------------------------------------------------------------
206 
static const int LED_MEAN_ERROR
static bool validEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:829
static const int LASER_MEAN_ERROR
static bool maskChannel(int ism, int i1, int i2, uint32_t bits, const EcalSubdetector subdet)
Definition: Masks.cc:57
static bool init
Definition: Masks.h:38
Some &quot;id&quot; conversions.
static const EcalDQMTowerStatus * towerStatus
Definition: Masks.h:43
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:770
const_iterator find(uint32_t rawId) const
static bool maskPn(int ism, int i1, uint32_t bits, const EcalSubdetector subdet)
Definition: Masks.cc:109
static int iy0EE(const unsigned ism)
Definition: Numbers.cc:809
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:37
static void initMasking(const edm::EventSetup &setup, bool verbose=false)
Definition: Masks.cc:31
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:243
static const EcalDQMChannelStatus * channelStatus
Definition: Masks.h:42
const_iterator find(uint32_t rawId) const
tuple cout
Definition: gather_cfg.py:121
static const int TESTPULSE_HIGH_GAIN_MEAN_ERROR
bool isValid() const
Definition: ESHandle.h:37
static const int SMCRYSTALMODE
Definition: EBDetId.h:167
EcalSubdetector
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")