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( std::runtime_error ) {
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( std::runtime_error( 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( std::runtime_error ) {
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
00121
00122 if ( ism == 7 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00123
00124
00125 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00126 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00127 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00128 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00129 if ( ism == 15 && i1 == 6 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00130 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00131 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00132 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00133 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00134 if ( ism == 15 && i1 == 7 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00135 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00136 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00137 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00138 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00139 if ( ism == 15 && i1 == 8 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00140 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00141 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00142 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00143 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00144 if ( ism == 15 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00145 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::TT_SIZE_ERROR)) ) mask = true;
00146 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR)) ) mask = true;
00147 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00148 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00149 if ( ism == 15 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00150
00151
00152 if ( ism == 25 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00153
00154
00155 if ( ism == 30 && i1 == 9 && (bits & (1 << EcalDQMStatusHelper::LASER_MEAN_ERROR)) ) mask = true;
00156
00157 } else if ( subdet == EcalEndcap ) {
00158
00159
00160 if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00161 if ( ism == 5 && i1 == 3 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00162 if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00163 if ( ism == 5 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00164
00165
00166 if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00167 if ( ism == 6 && i1 == 5 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00168
00169
00170 if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00171 if ( ism == 1 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00172 if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00173 if ( ism == 1 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00174
00175
00176 if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00177 if ( ism == 2 && i1 == 1 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00178 if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00179 if ( ism == 2 && i1 == 4 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00180 if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR)) ) mask = true;
00181 if ( ism == 2 && i1 == 10 && (bits & (1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR)) ) mask = true;
00182
00183 } else {
00184
00185 std::ostringstream s;
00186 s << "Invalid subdetector: subdet = " << subdet;
00187 throw( std::runtime_error( s.str() ) );
00188
00189 }
00190
00191 return ( mask );
00192
00193 }
00194
00195
00196