00001 #include "DQM/SiPixelMonitorRawData/interface/SiPixelRawDataErrorModule.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DQM/SiPixelCommon/interface/SiPixelHistogramId.h"
00004
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006
00007 #include <vector>
00008 #include <memory>
00009 #include <string>
00010 #include <iostream>
00011 #include <stdlib.h>
00012 #include <sstream>
00013
00014
00015 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00016 #include "DataFormats/SiPixelDetId/interface/PixelBarrelNameUpgrade.h"
00017 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00018 #include "DataFormats/SiPixelDetId/interface/PixelEndcapNameUpgrade.h"
00019 #include "DataFormats/DetId/interface/DetId.h"
00020 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00021
00022 using namespace std;
00023
00024 const int SiPixelRawDataErrorModule::LINK_bits = 6;
00025 const int SiPixelRawDataErrorModule::ROC_bits = 5;
00026 const int SiPixelRawDataErrorModule::DCOL_bits = 5;
00027 const int SiPixelRawDataErrorModule::PXID_bits = 8;
00028 const int SiPixelRawDataErrorModule::ADC_bits = 8;
00029 const int SiPixelRawDataErrorModule::DataBit_bits = 1;
00030
00031 const int SiPixelRawDataErrorModule::ADC_shift = 0;
00032 const int SiPixelRawDataErrorModule::PXID_shift = ADC_shift + ADC_bits;
00033 const int SiPixelRawDataErrorModule::DCOL_shift = PXID_shift + PXID_bits;
00034 const int SiPixelRawDataErrorModule::ROC_shift = DCOL_shift + DCOL_bits;
00035 const int SiPixelRawDataErrorModule::LINK_shift = ROC_shift + ROC_bits;
00036 const int SiPixelRawDataErrorModule::DB0_shift = 0;
00037 const int SiPixelRawDataErrorModule::DB1_shift = DB0_shift + DataBit_bits;
00038 const int SiPixelRawDataErrorModule::DB2_shift = DB1_shift + DataBit_bits;
00039 const int SiPixelRawDataErrorModule::DB3_shift = DB2_shift + DataBit_bits;
00040 const int SiPixelRawDataErrorModule::DB4_shift = DB3_shift + DataBit_bits;
00041 const int SiPixelRawDataErrorModule::DB5_shift = DB4_shift + DataBit_bits;
00042 const int SiPixelRawDataErrorModule::DB6_shift = DB5_shift + DataBit_bits;
00043 const int SiPixelRawDataErrorModule::DB7_shift = DB6_shift + DataBit_bits;
00044
00045 const uint32_t SiPixelRawDataErrorModule::LINK_mask = ~(~uint32_t(0) << LINK_bits);
00046 const uint32_t SiPixelRawDataErrorModule::ROC_mask = ~(~uint32_t(0) << ROC_bits);
00047 const uint32_t SiPixelRawDataErrorModule::DCOL_mask = ~(~uint32_t(0) << DCOL_bits);
00048 const uint32_t SiPixelRawDataErrorModule::PXID_mask = ~(~uint32_t(0) << PXID_bits);
00049 const uint32_t SiPixelRawDataErrorModule::ADC_mask = ~(~uint32_t(0) << ADC_bits);
00050 const uint32_t SiPixelRawDataErrorModule::DataBit_mask = ~(~uint32_t(0) << DataBit_bits);
00051
00052 const int SiPixelRawDataErrorModule::TRLRBGN_bits = 32;
00053 const int SiPixelRawDataErrorModule::EVTLGT_bits = 24;
00054 const int SiPixelRawDataErrorModule::TRLREND_bits = 8;
00055
00056 const int SiPixelRawDataErrorModule::TRLRBGN_shift = 0;
00057 const int SiPixelRawDataErrorModule::EVTLGT_shift = TRLRBGN_shift + TRLRBGN_bits;
00058 const int SiPixelRawDataErrorModule::TRLREND_shift = EVTLGT_shift + EVTLGT_bits;
00059
00060 const long long SiPixelRawDataErrorModule::TRLREND_mask = ~(~(long long)(0) << TRLREND_bits);
00061 const long long SiPixelRawDataErrorModule::EVTLGT_mask = ~(~(long long)(0) << EVTLGT_bits);
00062 const long long SiPixelRawDataErrorModule::TRLRBGN_mask = ~(~(long long)(0) << TRLRBGN_bits);
00063
00064
00065
00066 SiPixelRawDataErrorModule::SiPixelRawDataErrorModule() :
00067 id_(0),
00068 ncols_(416),
00069 nrows_(160)
00070 {
00071 _debug_ = false;
00072 }
00073
00074 SiPixelRawDataErrorModule::SiPixelRawDataErrorModule(const uint32_t& id) :
00075 id_(id),
00076 ncols_(416),
00077 nrows_(160)
00078 {
00079 _debug_ = false;
00080 }
00081
00082 SiPixelRawDataErrorModule::SiPixelRawDataErrorModule(const uint32_t& id, const int& ncols, const int& nrows) :
00083 id_(id),
00084 ncols_(ncols),
00085 nrows_(nrows)
00086 {
00087 _debug_ = false;
00088 }
00089
00090
00091
00092 SiPixelRawDataErrorModule::~SiPixelRawDataErrorModule() {}
00093
00094
00095
00096 void SiPixelRawDataErrorModule::book(const edm::ParameterSet& iConfig, int type, bool isUpgrade) {
00097 }
00098
00099
00100
00101 void SiPixelRawDataErrorModule::bookFED(const edm::ParameterSet& iConfig) {
00102
00103 std::string hid;
00104
00105 edm::InputTag src = iConfig.getParameter<edm::InputTag>( "src" );
00106 SiPixelHistogramId* theHistogramId = new SiPixelHistogramId( src.label() );
00107
00108 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00109
00110 hid = theHistogramId->setHistoId("errorType",id_);
00111 meErrorType_ = theDMBE->book1D(hid,"Type of errors",15,24.5,39.5);
00112 meErrorType_->setAxisTitle("Type of errors",1);
00113
00114 hid = theHistogramId->setHistoId("NErrors",id_);
00115 meNErrors_ = theDMBE->book1D(hid,"Number of errors",36,0.,36.);
00116 meNErrors_->setAxisTitle("Number of errors",1);
00117
00118
00119
00120 hid = theHistogramId->setHistoId("fullType",id_);
00121 meFullType_ = theDMBE->book1D(hid,"Type of FIFO full",7,0.5,7.5);
00122 meFullType_->setAxisTitle("FIFO type",1);
00123
00124
00125
00126 hid = theHistogramId->setHistoId("TBMMessage",id_);
00127 meTBMMessage_ = theDMBE->book1D(hid,"TBM trailer message",8,-0.5,7.5);
00128 meTBMMessage_->setAxisTitle("TBM message",1);
00129
00130
00131 hid = theHistogramId->setHistoId("TBMType",id_);
00132 meTBMType_ = theDMBE->book1D(hid,"Type of TBM trailer",5,-0.5,4.5);
00133 meTBMType_->setAxisTitle("TBM Type",1);
00134
00135 hid = theHistogramId->setHistoId("EvtNbr",id_);
00136 meEvtNbr_ = theDMBE->bookInt(hid);
00137
00138 hid = theHistogramId->setHistoId("evtSize",id_);
00139 meEvtSize_ = theDMBE->bookInt(hid);
00140
00141 for(int j=0; j!=37; j++){
00142 std::stringstream temp; temp << j;
00143 hid = "FedChNErrArray_" + temp.str();
00144 meFedChNErrArray_[j] = theDMBE->bookInt(hid);
00145 hid = "FedChLErrArray_" + temp.str();
00146 meFedChLErrArray_[j] = theDMBE->bookInt(hid);
00147 hid = "FedETypeNErrArray_" + temp.str();
00148 if(j<21) meFedETypeNErrArray_[j] = theDMBE->bookInt(hid);
00149 }
00150 delete theHistogramId;
00151
00152 }
00153
00154
00155
00156 int SiPixelRawDataErrorModule::fill(const edm::DetSetVector<SiPixelRawDataError>& input, bool modon, bool ladon, bool bladeon) {
00157
00158 bool barrel = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00159 bool endcap = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00160
00161
00162 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00163
00164 unsigned int numberOfSeriousErrors = 0;
00165
00166 edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(id_);
00167
00168 if( isearch != input.end() ) {
00169
00170 edm::DetSet<SiPixelRawDataError>::const_iterator di;
00171 for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
00172 int FedId = di->getFedId();
00173 int chanNmbr = 0;
00174 int errorType = di->getType();
00175 int TBMType=-1; int TBMMessage=-1; int evtSize=-1; int evtNbr=-1; int fullType=-1;
00176
00177 const int LINK_bits = 6;
00178 const int LINK_shift = 26;
00179 const uint32_t LINK_mask = ~(~(uint32_t)(0) << LINK_bits);
00180
00181 if(modon){
00182 if(errorType == 32 || errorType == 33 || errorType == 34) {
00183 long long errorWord = di->getWord64();
00184 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00185 if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00186 } else {
00187 uint32_t errorWord = di->getWord32();
00188 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00189 switch(errorType) {
00190 case(28) : {
00191 int NFa = (errorWord >> DB0_shift) & DataBit_mask;
00192 int NFb = (errorWord >> DB1_shift) & DataBit_mask;
00193 int NFc = (errorWord >> DB2_shift) & DataBit_mask;
00194 int NFd = (errorWord >> DB3_shift) & DataBit_mask;
00195 int NFe = (errorWord >> DB4_shift) & DataBit_mask;
00196 int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
00197 int L1A = (errorWord >> DB7_shift) & DataBit_mask;
00198 if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
00199 if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
00200 if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
00201 if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
00202 if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
00203 if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
00204 if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
00205 chanNmbr = 0;
00206 break; }
00207 case(29) : {
00208 int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
00209 int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
00210 int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
00211 int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
00212 int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
00213 int BLOCK_bits = 3;
00214 int BLOCK_shift = 8;
00215 uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
00216 int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
00217 int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
00218 if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
00219 else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
00220 if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;
00221 break; }
00222 case(30) : {
00223 int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00224 int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00225 int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00226 int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00227 int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00228 int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00229 int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00230 int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00231 if (T0==1) TBMMessage=0;
00232 if (T1==1) TBMMessage=1;
00233 if (T2==1) TBMMessage=2;
00234 if (T3==1) TBMMessage=3;
00235 if (T4==1) TBMMessage=4;
00236 if (T5==1) TBMMessage=5;
00237 if (T6==1) TBMMessage=6;
00238 if (T7==1) TBMMessage=7;
00239
00240 int StateMach_bits = 4;
00241 int StateMach_shift = 8;
00242 uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00243 int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00244 switch(StateMach) {
00245 case(0) : {
00246 TBMType = 0;
00247 break; }
00248 case(1) : case(9) : {
00249 TBMType = 1;
00250 break; }
00251 case(2) : case(4) : case(6) : {
00252 TBMType = 2;
00253 break; }
00254 case(8) : {
00255 TBMType = 3;
00256 break; }
00257 default : TBMType = 4;
00258 };
00259 break; }
00260 case(31) : {
00261 evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00262 break; }
00263 case(36) : {
00264
00265 break; }
00266 case(37) : {
00267
00268
00269 break; }
00270 case(38) : {
00271
00272 break; }
00273 default : break;
00274 };
00275 }
00276 }
00277
00278 if(ladon && barrel){
00279 if(errorType == 32 || errorType == 33 || errorType == 34){
00280 long long errorWord = di->getWord64();
00281 if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00282 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00283 } else {
00284 uint32_t errorWord = di->getWord32();
00285 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00286 switch(errorType) {
00287 case(28) : {
00288 int NFa = (errorWord >> DB0_shift) & DataBit_mask;
00289 int NFb = (errorWord >> DB1_shift) & DataBit_mask;
00290 int NFc = (errorWord >> DB2_shift) & DataBit_mask;
00291 int NFd = (errorWord >> DB3_shift) & DataBit_mask;
00292 int NFe = (errorWord >> DB4_shift) & DataBit_mask;
00293 int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
00294 int L1A = (errorWord >> DB7_shift) & DataBit_mask;
00295 if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
00296 if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
00297 if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
00298 if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
00299 if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
00300 if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
00301 if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
00302 chanNmbr = 0;
00303 break; }
00304 case(29) : {
00305 int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
00306 int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
00307 int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
00308 int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
00309 int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
00310 int BLOCK_bits = 3;
00311 int BLOCK_shift = 8;
00312 uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
00313 int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
00314 int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
00315 if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
00316 else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
00317 if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;
00318 break; }
00319 case(30) : {
00320 int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00321 int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00322 int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00323 int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00324 int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00325 int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00326 int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00327 int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00328 if (T0==1) TBMMessage=0;
00329 if (T1==1) TBMMessage=1;
00330 if (T2==1) TBMMessage=2;
00331 if (T3==1) TBMMessage=3;
00332 if (T4==1) TBMMessage=4;
00333 if (T5==1) TBMMessage=5;
00334 if (T6==1) TBMMessage=6;
00335 if (T7==1) TBMMessage=7;
00336 int StateMach_bits = 4;
00337 int StateMach_shift = 8;
00338 uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00339 int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00340 switch(StateMach) {
00341 case(0) : {
00342 TBMType = 0;
00343 break; }
00344 case(1) : case(9) : {
00345 TBMType = 1;
00346 break; }
00347 case(2) : case(4) : case(6) : {
00348 TBMType = 2;
00349 break; }
00350 case(8) : {
00351 TBMType = 3;
00352 break; }
00353 default : TBMType = 4;
00354 };
00355 break; }
00356 case(31) : {
00357 evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00358 break; }
00359 case(36) : {
00360
00361 break; }
00362 case(37) : {
00363
00364
00365 break; }
00366 case(38) : {
00367
00368 break; }
00369 default : break;
00370 };
00371 }
00372 }
00373
00374 if(bladeon && endcap){
00375 if(errorType == 32 || errorType == 33 || errorType == 34){
00376 long long errorWord = di->getWord64();
00377 if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00378 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00379 } else {
00380 uint32_t errorWord = di->getWord32();
00381 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00382 switch(errorType) {
00383 case(28) : {
00384 int NFa = (errorWord >> DB0_shift) & DataBit_mask;
00385 int NFb = (errorWord >> DB1_shift) & DataBit_mask;
00386 int NFc = (errorWord >> DB2_shift) & DataBit_mask;
00387 int NFd = (errorWord >> DB3_shift) & DataBit_mask;
00388 int NFe = (errorWord >> DB4_shift) & DataBit_mask;
00389 int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
00390 int L1A = (errorWord >> DB7_shift) & DataBit_mask;
00391 if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
00392 if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
00393 if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
00394 if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
00395 if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
00396 if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
00397 if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
00398 chanNmbr = 0;
00399 break; }
00400 case(29) : {
00401 int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
00402 int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
00403 int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
00404 int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
00405 int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
00406 int BLOCK_bits = 3;
00407 int BLOCK_shift = 8;
00408 uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
00409 int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
00410 int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
00411 if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
00412 else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
00413 if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;
00414 break; }
00415 case(30) : {
00416 int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00417 int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00418 int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00419 int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00420 int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00421 int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00422 int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00423 int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00424 if (T0==1) TBMMessage=0;
00425 if (T1==1) TBMMessage=1;
00426 if (T2==1) TBMMessage=2;
00427 if (T3==1) TBMMessage=3;
00428 if (T4==1) TBMMessage=4;
00429 if (T5==1) TBMMessage=5;
00430 if (T6==1) TBMMessage=6;
00431 if (T7==1) TBMMessage=7;
00432 int StateMach_bits = 4;
00433 int StateMach_shift = 8;
00434 uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00435 int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00436 switch(StateMach) {
00437 case(0) : {
00438 TBMType = 0;
00439 break; }
00440 case(1) : case(9) : {
00441 TBMType = 1;
00442 break; }
00443 case(2) : case(4) : case(6) : {
00444 TBMType = 2;
00445 break; }
00446 case(8) : {
00447 TBMType = 3;
00448 break; }
00449 default : TBMType = 4;
00450 };
00451 break; }
00452 case(31) : {
00453 evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00454 break; }
00455 case(36) : {
00456
00457 break; }
00458 case(37) : {
00459
00460
00461 break; }
00462 case(38) : {
00463
00464 break; }
00465 default : break;
00466 };
00467 }
00468 }
00469
00470 if(!(FedId==38&&chanNmbr==7)){
00471 if(errorType==29 || (errorType==30 && TBMType==1)){
00472
00473
00474 std::string hid;
00475 static const char chNfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
00476 char chNbuf[sizeof(chNfmt) + 2*32];
00477 sprintf(chNbuf, chNfmt, FedId, chanNmbr);
00478 hid = chNbuf;
00479 meFedChNErrArray_[chanNmbr] = theDMBE->get(hid);
00480 if(meFedChNErrArray_[chanNmbr]) meFedChNErrArray_[chanNmbr]->Fill(meFedChNErrArray_[chanNmbr]->getIntValue()+1);
00481
00482 static const char chLfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChLErrArray_%d";
00483 char chLbuf[sizeof(chLfmt) + 2*32];
00484 sprintf(chLbuf, chLfmt, FedId, chanNmbr);
00485 hid = chLbuf;
00486 meFedChLErrArray_[chanNmbr] = theDMBE->get(hid);
00487 if(meFedChLErrArray_[chanNmbr]) meFedChLErrArray_[chanNmbr]->Fill(errorType);
00488
00489 numberOfSeriousErrors++;
00490 int messageType = 99;
00491 if(errorType<30) messageType = errorType-25;
00492 else if(errorType>30) messageType = errorType-19;
00493 else if(errorType==30 && TBMMessage==0) messageType = errorType-25;
00494 else if(errorType==30 && TBMMessage==1) messageType = errorType-24;
00495 else if(errorType==30 && (TBMMessage==2 || TBMMessage==3 || TBMMessage==4)) messageType = errorType-23;
00496 else if(errorType==30 && TBMMessage==7) messageType = errorType-22;
00497 else if(errorType==30 && TBMType==1) messageType = errorType-21;
00498 else if(errorType==30 && TBMType==2) messageType = errorType-20;
00499 else if(errorType==30 && TBMType==3) messageType = errorType-19;
00500 if(messageType<=20){
00501 static const char fmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedETypeNErrArray_%d";
00502 char buf[sizeof(fmt) + 2*32];
00503 sprintf(buf, fmt, FedId, messageType);
00504 hid = buf;
00505 meFedETypeNErrArray_[messageType] = theDMBE->get(hid);
00506 if(meFedETypeNErrArray_[messageType]) meFedETypeNErrArray_[messageType]->Fill(meFedETypeNErrArray_[messageType]->getIntValue()+1);
00507 }
00508 }
00509
00510 std::string currDir = theDMBE->pwd();
00511 static const char buf[] = "Pixel/AdditionalPixelErrors/FED_%d";
00512 char feddir[sizeof(buf)+2];
00513 sprintf(feddir,buf,FedId);
00514 theDMBE->cd(feddir);
00515 MonitorElement* me;
00516 static const char buf1[] = "Pixel/AdditionalPixelErrors/FED_%d/NErrors_siPixelDigis_%d";
00517 char hname1[sizeof(buf1)+4];
00518 sprintf(hname1,buf1,FedId,FedId);
00519 me = theDMBE->get(hname1);
00520 if(me) me->Fill((int)numberOfSeriousErrors);
00521 static const char buf2[] = "Pixel/AdditionalPixelErrors/FED_%d/TBMMessage_siPixelDigis_%d";
00522 char hname2[sizeof(buf2)+4];
00523 sprintf(hname2,buf2,FedId,FedId);
00524 me = theDMBE->get(hname2);
00525 if(me) me->Fill((int)TBMMessage);
00526 static const char buf3[] = "Pixel/AdditionalPixelErrors/FED_%d/TBMType_siPixelDigis_%d";
00527 char hname3[sizeof(buf3)+4];
00528 sprintf(hname3,buf3,FedId,FedId);
00529 me = theDMBE->get(hname3);
00530 if(me) me->Fill((int)TBMType);
00531 static const char buf4[] = "Pixel/AdditionalPixelErrors/FED_%d/errorType_siPixelDigis_%d";
00532 char hname4[sizeof(buf4)+4];
00533 sprintf(hname4,buf4,FedId,FedId);
00534 me = theDMBE->get(hname4);
00535 if(me) me->Fill((int)errorType);
00536 static const char buf5[] = "Pixel/AdditionalPixelErrors/FED_%d/fullType_siPixelDigis_%d";
00537 char hname5[sizeof(buf5)+4];
00538 sprintf(hname5,buf5,FedId,FedId);
00539 me = theDMBE->get(hname5);
00540 if(me) me->Fill((int)fullType);
00541 static const char buf6[] = "Pixel/AdditionalPixelErrors/FED_%d/EvtNbr_siPixelDigis_%d";
00542 char hname6[sizeof(buf6)+4];
00543 sprintf(hname6,buf6,FedId,FedId);
00544 me = theDMBE->get(hname6);
00545 if(me) me->Fill((int)evtNbr);
00546 static const char buf7[] = "Pixel/AdditionalPixelErrors/FED_%d/evtSize_siPixelDigis_%d";
00547 char hname7[sizeof(buf7)+4];
00548 sprintf(hname7,buf7,FedId,FedId);
00549 me = theDMBE->get(hname7);
00550 if(me) me->Fill((int)evtSize);
00551 theDMBE->cd(currDir);
00552 }
00553 }
00554 }
00555
00556 return numberOfSeriousErrors;
00557 }
00558
00559 int SiPixelRawDataErrorModule::fillFED(const edm::DetSetVector<SiPixelRawDataError>& input) {
00560
00561 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00562 unsigned int numberOfSeriousErrors = 0;
00563
00564 edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(0xffffffff);
00565 if( isearch != input.end() ) {
00566
00567 edm::DetSet<SiPixelRawDataError>::const_iterator di;
00568 for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
00569 int FedId = di->getFedId();
00570 int chanNmbr = -1;
00571 int errorType = 0;
00572 if(FedId==static_cast<int>(id_)) {
00573 errorType = di->getType();
00574 (meErrorType_)->Fill((int)errorType);
00575
00576 int TBMType=-1; int TBMMessage=-1; int evtSize=-1; int fullType=-1;
00577 const int LINK_bits = 6;
00578 const int LINK_shift = 26;
00579 const uint32_t LINK_mask = ~(~(uint32_t)(0) << LINK_bits);
00580 if((errorType == 32)||(errorType == 33)||(errorType == 34)) {
00581 long long errorWord = di->getWord64();
00582 chanNmbr = 0;
00583 switch(errorType) {
00584 case(32) : {
00585 break; }
00586 case(33) : {
00587 break; }
00588 case(34) : {
00589 evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00590 if(!(FedId==38&&chanNmbr==7)) (meEvtSize_)->Fill((int)evtSize);
00591 break; }
00592 default : break;
00593 };
00594 } else {
00595 uint32_t errorWord = di->getWord32();
00596 switch(errorType) {
00597 case(25) : case(39) : {
00598 chanNmbr = 0;
00599 break; }
00600 case(28) : {
00601 int NFa = (errorWord >> DB0_shift) & DataBit_mask;
00602 int NFb = (errorWord >> DB1_shift) & DataBit_mask;
00603 int NFc = (errorWord >> DB2_shift) & DataBit_mask;
00604 int NFd = (errorWord >> DB3_shift) & DataBit_mask;
00605 int NFe = (errorWord >> DB4_shift) & DataBit_mask;
00606 int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
00607 int L1A = (errorWord >> DB7_shift) & DataBit_mask;
00608 if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
00609 if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
00610 if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
00611 if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
00612 if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
00613 if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
00614 if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
00615 chanNmbr = 0;
00616 break; }
00617 case(29) : {
00618 int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
00619 int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
00620 int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
00621 int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
00622 int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
00623 int BLOCK_bits = 3;
00624 int BLOCK_shift = 8;
00625 uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
00626 int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
00627 int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
00628 if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
00629 else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
00630 if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;
00631 break; }
00632 case(30) : {
00633 int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00634 int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00635 int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00636 int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00637 int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00638 int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00639 int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00640 int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00641 if(!(FedId==38&&chanNmbr==7)){
00642 if (T0==1) { TBMMessage=0; (meTBMMessage_)->Fill((int)TBMMessage); }
00643 if (T1==1) { TBMMessage=1; (meTBMMessage_)->Fill((int)TBMMessage); }
00644 if (T2==1) { TBMMessage=2; (meTBMMessage_)->Fill((int)TBMMessage); }
00645 if (T3==1) { TBMMessage=3; (meTBMMessage_)->Fill((int)TBMMessage); }
00646 if (T4==1) { TBMMessage=4; (meTBMMessage_)->Fill((int)TBMMessage); }
00647 if (T5==1) { TBMMessage=5; (meTBMMessage_)->Fill((int)TBMMessage); }
00648 if (T6==1) { TBMMessage=6; (meTBMMessage_)->Fill((int)TBMMessage); }
00649 if (T7==1) { TBMMessage=7; (meTBMMessage_)->Fill((int)TBMMessage); }
00650 }
00651
00652 int StateMach_bits = 4;
00653 int StateMach_shift = 8;
00654 uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00655 int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00656 switch(StateMach) {
00657 case(0) : {
00658 TBMType = 0;
00659 break; }
00660 case(1) : case(9) : {
00661 TBMType = 1;
00662 break; }
00663 case(2) : case(4) : case(6) : {
00664 TBMType = 2;
00665 break; }
00666 case(8) : {
00667 TBMType = 3;
00668 break; }
00669 default : TBMType = 4;
00670 };
00671 if(!(FedId==38&&chanNmbr==7)) (meTBMType_)->Fill((int)TBMType);
00672 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00673 break; }
00674 case(31) : {
00675 int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00676 if(!(FedId==38&&chanNmbr==7))(meEvtNbr_)->Fill((int)evtNbr);
00677 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00678 break; }
00679 case(35) : case(36) : case(37) : case(38) : {
00680 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00681 break; }
00682 default : break;
00683 };
00684 }
00685
00686
00687 if(errorType==29 || (errorType==30 && TBMType==1)){
00688 if(!(FedId==38&&chanNmbr==7)){
00689 std::string hid;
00690
00691 static const char chNfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
00692 char chNbuf[sizeof(chNfmt) + 2*32];
00693 sprintf(chNbuf, chNfmt, FedId, chanNmbr);
00694 hid = chNbuf;
00695 meFedChNErrArray_[chanNmbr] = theDMBE->get(hid);
00696 if(meFedChNErrArray_[chanNmbr]) meFedChNErrArray_[chanNmbr]->Fill(meFedChNErrArray_[chanNmbr]->getIntValue()+1);
00697
00698 static const char chLfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChLErrArray_%d";
00699 char chLbuf[sizeof(chLfmt) + 2*32];
00700 sprintf(chLbuf, chLfmt, FedId, chanNmbr);
00701 hid = chLbuf;
00702 meFedChLErrArray_[chanNmbr] = theDMBE->get(hid);
00703 if(meFedChLErrArray_[chanNmbr]) meFedChLErrArray_[chanNmbr]->Fill(errorType);
00704
00705 numberOfSeriousErrors++;
00706 int messageType = 99;
00707 if(errorType<30) messageType = errorType-25;
00708 else if(errorType>30) messageType = errorType-19;
00709 else if(errorType==30 && TBMMessage==0) messageType = errorType-25;
00710 else if(errorType==30 && TBMMessage==1) messageType = errorType-24;
00711 else if(errorType==30 && (TBMMessage==2 || TBMMessage==3 || TBMMessage==4)) messageType = errorType-23;
00712 else if(errorType==30 && TBMMessage==7) messageType = errorType-22;
00713 else if(errorType==30 && TBMType==1) messageType = errorType-21;
00714 else if(errorType==30 && TBMType==2) messageType = errorType-20;
00715 else if(errorType==30 && TBMType==3) messageType = errorType-19;
00716 if(messageType<=20){
00717 static const char fmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedETypeNErrArray_%d";
00718 char buf[sizeof(fmt) + 2*32];
00719 sprintf(buf, fmt, FedId, messageType);
00720 hid = buf;
00721 meFedETypeNErrArray_[messageType] = theDMBE->get(hid);
00722 if(meFedETypeNErrArray_[messageType]) meFedETypeNErrArray_[messageType]->Fill(meFedETypeNErrArray_[messageType]->getIntValue()+1);
00723 }
00724 }
00725 }
00726 }
00727 }
00728 if(numberOfSeriousErrors>0) (meNErrors_)->Fill((float)numberOfSeriousErrors);
00729
00730 }
00731
00732
00733 return numberOfSeriousErrors;
00734 }