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.13 2010/08/09 09:00:15 dellaric 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( std::runtime_error ) {
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( std::runtime_error( 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( std::runtime_error ) {
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 
121  // EB-07
122  if ( ism == 7 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
123 
124  // EB-15
125  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
126  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
127  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
128  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
129  if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
130  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
131  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
132  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
133  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
134  if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
135  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
136  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
137  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
138  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
139  if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
140  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
141  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
142  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
143  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
144  if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
145  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
146  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
147  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
148  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
149  if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
150 
151  // EB+07
152  if ( ism == 25 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
153 
154  // EB+12
155  if ( ism == 30 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
156 
157  } else if ( subdet == EcalEndcap ) {
158 
159  // EE-02
160  if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
161  if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
162  if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
163  if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
164 
165  // EE-03
166  if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
167  if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
168 
169  // EE-07
170  if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
171  if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
172  if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
173  if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
174 
175  // EE-08
176  if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
177  if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
178  if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
179  if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
180  if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
181  if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
182 
183  } else {
184 
185  std::ostringstream s;
186  s << "Invalid subdetector: subdet = " << subdet;
187  throw( std::runtime_error( s.str() ) );
188 
189  }
190 
191  return ( mask );
192 
193 }
194 
195 //-------------------------------------------------------------------------
196 
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:38
static int iy0EE(const int ism)
Definition: Numbers.cc:987
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
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 const int STATUS_FLAG_ERROR
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
static int iSM(const int ism, const EcalSubdetector subdet)
Definition: Numbers.cc:222
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 int ix0EE(const int ism)
Definition: Numbers.cc:952
static const EcalDQMChannelStatus * channelStatus
Definition: Masks.h:42
const_iterator find(uint32_t rawId) const
tuple cout
Definition: gather_cfg.py:41
std::vector< Item >::const_iterator const_iterator
string s
Definition: asciidump.py:422
static bool validEE(const int ism, const int ix, const int iy)
Definition: Numbers.cc:1005
bool isValid() const
Definition: ESHandle.h:37
static const int SMCRYSTALMODE
Definition: EBDetId.h:146
EcalSubdetector
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")