Go to the documentation of this file.00001
00002
00011 #include <sstream>
00012 #include <iomanip>
00013
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include "CondFormats/DataRecord/interface/EcalDQMChannelStatusRcd.h"
00016 #include "CondFormats/DataRecord/interface/EcalDQMTowerStatusRcd.h"
00017
00018 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00019 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00020
00021 #include "DQM/EcalCommon/interface/Numbers.h"
00022
00023 #include "DQM/EcalCommon/interface/Masks.h"
00024
00025
00026
00027 const EcalDQMChannelStatus* Masks::channelStatus = 0;
00028 const EcalDQMTowerStatus* Masks::towerStatus = 0;
00029
00030 bool Masks::init = false;
00031
00032
00033
00034 void Masks::initMasking( const edm::EventSetup& setup, bool verbose ) {
00035
00036 if ( Masks::init ) return;
00037
00038 if ( verbose ) std::cout << "Initializing EcalDQMChannelStatus and EcalDQMTowerStatus ..." << std::endl;
00039
00040 Masks::init = true;
00041
00042 if ( setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMChannelStatusRcd>() ) ) {
00043 edm::ESHandle<EcalDQMChannelStatus> handle;
00044 setup.get<EcalDQMChannelStatusRcd>().get(handle);
00045 if ( handle.isValid() ) Masks::channelStatus = handle.product();
00046 }
00047
00048 if ( setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMTowerStatusRcd>() ) ) {
00049 edm::ESHandle<EcalDQMTowerStatus> handle;
00050 setup.get<EcalDQMTowerStatusRcd>().get(handle);
00051 if ( handle.isValid() ) Masks::towerStatus = handle.product();
00052 }
00053
00054 if ( verbose ) std::cout << "done." << std::endl;
00055
00056 }
00057
00058
00059
00060 bool Masks::maskChannel( int ism, int i1, int i2, uint32_t bits, const EcalSubdetector subdet ) throw( cms::Exception ) {
00061
00062 bool mask = false;
00063
00064 if ( subdet == EcalBarrel ) {
00065
00066 int jsm = Numbers::iSM(ism, EcalBarrel);
00067 int ic = 20*(i1-1)+(i2-1)+1;
00068
00069 EBDetId id(jsm, ic, EBDetId::SMCRYSTALMODE);
00070 if ( Masks::channelStatus ) {
00071 EcalDQMChannelStatus::const_iterator it = Masks::channelStatus->find( id.rawId() );
00072 if ( it != Masks::channelStatus->end() ) mask |= it->getStatusCode() & bits;
00073 }
00074 if ( Masks::towerStatus ) {
00075 EcalDQMTowerStatus::const_iterator it = Masks::towerStatus->find( id.tower().rawId() );
00076 if ( it != Masks::towerStatus->end() ) mask |= it->getStatusCode() & bits;
00077 }
00078
00079 } else if ( subdet == EcalEndcap ) {
00080
00081 int jx = i1 + Numbers::ix0EE(ism);
00082 int jy = i2 + Numbers::iy0EE(ism);
00083
00084 if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00085
00086 if ( Numbers::validEE(ism, jx, jy) ) {
00087 EEDetId id(jx, jy, (ism>=1&&ism<=9)?-1:+1);
00088 if ( Masks::channelStatus ) {
00089 EcalDQMChannelStatus::const_iterator it = Masks::channelStatus->find( id.rawId() );
00090 if ( it != Masks::channelStatus->end() ) mask |= it->getStatusCode() & bits;
00091 }
00092 if ( Masks::towerStatus ) {
00093 EcalDQMTowerStatus::const_iterator it = Masks::towerStatus->find( id.sc().rawId() );
00094 if ( it != Masks::towerStatus->end() ) mask |= it->getStatusCode() & bits;
00095 }
00096 }
00097
00098 } else {
00099
00100 std::ostringstream s;
00101 s << "Invalid subdetector: subdet = " << subdet;
00102 throw( cms::Exception( s.str() ) );
00103
00104 }
00105
00106 return ( mask );
00107
00108 }
00109
00110
00111
00112 bool Masks::maskPn( int ism, int i1, uint32_t bits, const EcalSubdetector subdet ) throw( cms::Exception ) {
00113
00114 bool mask = false;
00115
00116 if ( subdet == EcalBarrel ) {
00117
00118
00119 if ( ism == 3 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00120 if ( ism == 3 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00121
00122
00123 if ( ism == 7 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00124 if ( ism == 7 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00125
00126
00127 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00128 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00129 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00130 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00131 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00132 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00133 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00134 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00135 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00136 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00137 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00138 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00139 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00140 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00141 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00142 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00143 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00144 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00145 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00146 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00147 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00148 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00149 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00150 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00151 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00152
00153
00154 if ( ism == 24 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00155
00156
00157 if ( ism == 25 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00158 if ( ism == 25 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00159
00160
00161 if ( ism == 30 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00162 if ( ism == 30 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00163
00164
00165 if ( ism == 15 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00166 if ( ism == 15 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00167 if ( ism == 15 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00168
00169 } else if ( subdet == EcalEndcap ) {
00170
00171
00172 if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00173 if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
00174 if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00175 if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
00176
00177
00178 if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00179 if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
00180
00181
00182 if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00183 if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
00184 if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00185 if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
00186
00187
00188 if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00189 if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
00190 if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00191 if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
00192 if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00193 if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00194 if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LED_MEAN_ERROR)) ) mask = true;
00195
00196 } else {
00197
00198 std::ostringstream s;
00199 s << "Invalid subdetector: subdet = " << subdet;
00200 throw( cms::Exception( s.str() ) );
00201
00202 }
00203
00204 return ( mask );
00205
00206 }
00207
00208
00209