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