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 bool isHalfModule = false;
00159 uint32_t DBladder = 0;
00160 if(barrel){
00161 isHalfModule = PixelBarrelName(DetId(id_)).isHalfModule();
00162 DBladder = PixelBarrelName(DetId(id_)).ladderName();
00163
00164
00165 }
00166
00167
00168 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00169
00170 unsigned int numberOfSeriousErrors = 0;
00171
00172 edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(id_);
00173
00174 if( isearch != input.end() ) {
00175
00176 edm::DetSet<SiPixelRawDataError>::const_iterator di;
00177 for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
00178 int FedId = di->getFedId();
00179 int chanNmbr = -1;
00180 int errorType = di->getType();
00181 int TBMType=-1; int TBMMessage=-1; int evtSize=-1; int evtNbr=-1; int fullType=-1;
00182 bool notReset = true;
00183 const int LINK_bits = 6;
00184 const int LINK_shift = 26;
00185 const uint32_t LINK_mask = ~(~(uint32_t)(0) << LINK_bits);
00186
00187 if(modon){
00188 if(errorType == 32 || errorType == 33 || errorType == 34) {
00189 long long errorWord = di->getWord64();
00190 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00191 if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00192 } else {
00193 uint32_t errorWord = di->getWord32();
00194 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00195 switch(errorType) {
00196 case(28) : {
00197 int NFa = (errorWord >> DB0_shift) & DataBit_mask;
00198 int NFb = (errorWord >> DB1_shift) & DataBit_mask;
00199 int NFc = (errorWord >> DB2_shift) & DataBit_mask;
00200 int NFd = (errorWord >> DB3_shift) & DataBit_mask;
00201 int NFe = (errorWord >> DB4_shift) & DataBit_mask;
00202 int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
00203 int L1A = (errorWord >> DB7_shift) & DataBit_mask;
00204 if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
00205 if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
00206 if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
00207 if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
00208 if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
00209 if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
00210 if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
00211 chanNmbr = 0;
00212 break; }
00213 case(29) : {
00214 int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
00215 int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
00216 int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
00217 int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
00218 int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
00219 int BLOCK_bits = 3;
00220 int BLOCK_shift = 8;
00221 uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
00222 int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
00223 int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
00224 if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
00225 else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
00226 if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;
00227 break; }
00228 case(30) : {
00229 int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00230 int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00231 int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00232 int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00233 int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00234 int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00235 int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00236 int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00237 if (T0==1) TBMMessage=0;
00238 if (T1==1) TBMMessage=1;
00239 if (T2==1) TBMMessage=2;
00240 if (T3==1) TBMMessage=3;
00241 if (T4==1) TBMMessage=4;
00242 if (T5==1) TBMMessage=5;
00243 if (T6==1) TBMMessage=6;
00244 if (T7==1) TBMMessage=7;
00245 if(TBMMessage==5 || TBMMessage==6) notReset=false;
00246 int StateMach_bits = 4;
00247 int StateMach_shift = 8;
00248 uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00249 int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00250 switch(StateMach) {
00251 case(0) : {
00252 TBMType = 0;
00253 break; }
00254 case(1) : case(9) : {
00255 TBMType = 1;
00256 break; }
00257 case(2) : case(4) : case(6) : {
00258 TBMType = 2;
00259 break; }
00260 case(8) : {
00261 TBMType = 3;
00262 break; }
00263 default : TBMType = 4;
00264 };
00265 break; }
00266 case(31) : {
00267 evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00268 break; }
00269 case(36) : {
00270
00271 break; }
00272 case(37) : {
00273
00274
00275 break; }
00276 case(38) : {
00277
00278 break; }
00279 default : break;
00280 };
00281 }
00282 }
00283
00284 if(ladon && barrel){
00285 if(errorType == 32 || errorType == 33 || errorType == 34){
00286 long long errorWord = di->getWord64();
00287 if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00288 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00289 } else {
00290 uint32_t errorWord = di->getWord32();
00291 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00292 switch(errorType) {
00293 case(28) : {
00294 int NFa = (errorWord >> DB0_shift) & DataBit_mask;
00295 int NFb = (errorWord >> DB1_shift) & DataBit_mask;
00296 int NFc = (errorWord >> DB2_shift) & DataBit_mask;
00297 int NFd = (errorWord >> DB3_shift) & DataBit_mask;
00298 int NFe = (errorWord >> DB4_shift) & DataBit_mask;
00299 int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
00300 int L1A = (errorWord >> DB7_shift) & DataBit_mask;
00301 if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
00302 if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
00303 if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
00304 if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
00305 if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
00306 if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
00307 if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
00308 chanNmbr = 0;
00309 break; }
00310 case(29) : {
00311 int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
00312 int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
00313 int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
00314 int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
00315 int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
00316 int BLOCK_bits = 3;
00317 int BLOCK_shift = 8;
00318 uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
00319 int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
00320 int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
00321 if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
00322 else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
00323 if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;
00324 break; }
00325 case(30) : {
00326 int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00327 int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00328 int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00329 int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00330 int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00331 int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00332 int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00333 int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00334 if (T0==1) TBMMessage=0;
00335 if (T1==1) TBMMessage=1;
00336 if (T2==1) TBMMessage=2;
00337 if (T3==1) TBMMessage=3;
00338 if (T4==1) TBMMessage=4;
00339 if (T5==1) TBMMessage=5;
00340 if (T6==1) TBMMessage=6;
00341 if (T7==1) TBMMessage=7;
00342 int StateMach_bits = 4;
00343 int StateMach_shift = 8;
00344 uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00345 int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00346 switch(StateMach) {
00347 case(0) : {
00348 TBMType = 0;
00349 break; }
00350 case(1) : case(9) : {
00351 TBMType = 1;
00352 break; }
00353 case(2) : case(4) : case(6) : {
00354 TBMType = 2;
00355 break; }
00356 case(8) : {
00357 TBMType = 3;
00358 break; }
00359 default : TBMType = 4;
00360 };
00361 break; }
00362 case(31) : {
00363 evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00364 break; }
00365 case(36) : {
00366
00367 break; }
00368 case(37) : {
00369
00370
00371 break; }
00372 case(38) : {
00373
00374 break; }
00375 default : break;
00376 };
00377 }
00378 }
00379
00380 if(bladeon && endcap){
00381 if(errorType == 32 || errorType == 33 || errorType == 34){
00382 long long errorWord = di->getWord64();
00383 if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00384 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00385 } else {
00386 uint32_t errorWord = di->getWord32();
00387 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00388 switch(errorType) {
00389 case(28) : {
00390 int NFa = (errorWord >> DB0_shift) & DataBit_mask;
00391 int NFb = (errorWord >> DB1_shift) & DataBit_mask;
00392 int NFc = (errorWord >> DB2_shift) & DataBit_mask;
00393 int NFd = (errorWord >> DB3_shift) & DataBit_mask;
00394 int NFe = (errorWord >> DB4_shift) & DataBit_mask;
00395 int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
00396 int L1A = (errorWord >> DB7_shift) & DataBit_mask;
00397 if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
00398 if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
00399 if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
00400 if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
00401 if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
00402 if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
00403 if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
00404 chanNmbr = 0;
00405 break; }
00406 case(29) : {
00407 int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
00408 int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
00409 int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
00410 int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
00411 int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
00412 int BLOCK_bits = 3;
00413 int BLOCK_shift = 8;
00414 uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
00415 int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
00416 int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
00417 if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
00418 else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
00419 if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;
00420 break; }
00421 case(30) : {
00422 int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00423 int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00424 int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00425 int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00426 int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00427 int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00428 int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00429 int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00430 if (T0==1) TBMMessage=0;
00431 if (T1==1) TBMMessage=1;
00432 if (T2==1) TBMMessage=2;
00433 if (T3==1) TBMMessage=3;
00434 if (T4==1) TBMMessage=4;
00435 if (T5==1) TBMMessage=5;
00436 if (T6==1) TBMMessage=6;
00437 if (T7==1) TBMMessage=7;
00438 int StateMach_bits = 4;
00439 int StateMach_shift = 8;
00440 uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00441 int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00442 switch(StateMach) {
00443 case(0) : {
00444 TBMType = 0;
00445 break; }
00446 case(1) : case(9) : {
00447 TBMType = 1;
00448 break; }
00449 case(2) : case(4) : case(6) : {
00450 TBMType = 2;
00451 break; }
00452 case(8) : {
00453 TBMType = 3;
00454 break; }
00455 default : TBMType = 4;
00456 };
00457 break; }
00458 case(31) : {
00459 evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00460 break; }
00461 case(36) : {
00462
00463 break; }
00464 case(37) : {
00465
00466
00467 break; }
00468 case(38) : {
00469
00470 break; }
00471 default : break;
00472 };
00473 }
00474 }
00475
00476 if(!(FedId==38&&chanNmbr==7)){
00477 if(!(errorType==30) || notReset){
00478 std::string hid;
00479 static const char chNfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
00480 char chNbuf[sizeof(chNfmt) + 2*32];
00481 sprintf(chNbuf, chNfmt, FedId, chanNmbr);
00482 hid = chNbuf;
00483 meFedChNErrArray_[chanNmbr] = theDMBE->get(hid);
00484 if(meFedChNErrArray_[chanNmbr]) meFedChNErrArray_[chanNmbr]->Fill(meFedChNErrArray_[chanNmbr]->getIntValue()+1);
00485
00486 static const char chLfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChLErrArray_%d";
00487 char chLbuf[sizeof(chLfmt) + 2*32];
00488 sprintf(chLbuf, chLfmt, FedId, chanNmbr);
00489 hid = chLbuf;
00490 meFedChLErrArray_[chanNmbr] = theDMBE->get(hid);
00491 if(meFedChLErrArray_[chanNmbr]) meFedChLErrArray_[chanNmbr]->Fill(errorType);
00492
00493 numberOfSeriousErrors++;
00494 int messageType = 99;
00495 if(errorType<30) messageType = errorType-25;
00496 else if(errorType>30) messageType = errorType-19;
00497 else if(errorType==30 && TBMMessage==0) messageType = errorType-25;
00498 else if(errorType==30 && TBMMessage==1) messageType = errorType-24;
00499 else if(errorType==30 && (TBMMessage==2 || TBMMessage==3 || TBMMessage==4)) messageType = errorType-23;
00500 else if(errorType==30 && TBMMessage==7) messageType = errorType-22;
00501 else if(errorType==30 && TBMType==1) messageType = errorType-21;
00502 else if(errorType==30 && TBMType==2) messageType = errorType-20;
00503 else if(errorType==30 && TBMType==3) messageType = errorType-19;
00504 if(messageType<=20){
00505 static const char fmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedETypeNErrArray_%d";
00506 char buf[sizeof(fmt) + 2*32];
00507 sprintf(buf, fmt, FedId, messageType);
00508 hid = buf;
00509 meFedETypeNErrArray_[messageType] = theDMBE->get(hid);
00510 if(meFedETypeNErrArray_[messageType]) meFedETypeNErrArray_[messageType]->Fill(meFedETypeNErrArray_[messageType]->getIntValue()+1);
00511 }
00512 }
00513
00514 std::string currDir = theDMBE->pwd();
00515 static const char buf[] = "Pixel/AdditionalPixelErrors/FED_%d";
00516 char feddir[sizeof(buf)+2];
00517 sprintf(feddir,buf,FedId);
00518 theDMBE->cd(feddir);
00519 MonitorElement* me;
00520 static const char buf1[] = "Pixel/AdditionalPixelErrors/FED_%d/NErrors_siPixelDigis_%d";
00521 char hname1[sizeof(buf1)+4];
00522 sprintf(hname1,buf1,FedId,FedId);
00523 me = theDMBE->get(hname1);
00524 if(me) me->Fill((int)numberOfSeriousErrors);
00525 static const char buf2[] = "Pixel/AdditionalPixelErrors/FED_%d/TBMMessage_siPixelDigis_%d";
00526 char hname2[sizeof(buf2)+4];
00527 sprintf(hname2,buf2,FedId,FedId);
00528 me = theDMBE->get(hname2);
00529 if(me) me->Fill((int)TBMMessage);
00530 static const char buf3[] = "Pixel/AdditionalPixelErrors/FED_%d/TBMType_siPixelDigis_%d";
00531 char hname3[sizeof(buf3)+4];
00532 sprintf(hname3,buf3,FedId,FedId);
00533 me = theDMBE->get(hname3);
00534 if(me) me->Fill((int)TBMType);
00535 static const char buf4[] = "Pixel/AdditionalPixelErrors/FED_%d/errorType_siPixelDigis_%d";
00536 char hname4[sizeof(buf4)+4];
00537 sprintf(hname4,buf4,FedId,FedId);
00538 me = theDMBE->get(hname4);
00539 if(me) me->Fill((int)errorType);
00540 static const char buf5[] = "Pixel/AdditionalPixelErrors/FED_%d/fullType_siPixelDigis_%d";
00541 char hname5[sizeof(buf5)+4];
00542 sprintf(hname5,buf5,FedId,FedId);
00543 me = theDMBE->get(hname5);
00544 if(me) me->Fill((int)fullType);
00545 static const char buf6[] = "Pixel/AdditionalPixelErrors/FED_%d/EvtNbr_siPixelDigis_%d";
00546 char hname6[sizeof(buf6)+4];
00547 sprintf(hname6,buf6,FedId,FedId);
00548 me = theDMBE->get(hname6);
00549 if(me) me->Fill((int)evtNbr);
00550 static const char buf7[] = "Pixel/AdditionalPixelErrors/FED_%d/evtSize_siPixelDigis_%d";
00551 char hname7[sizeof(buf7)+4];
00552 sprintf(hname7,buf7,FedId,FedId);
00553 me = theDMBE->get(hname7);
00554 if(me) me->Fill((int)evtSize);
00555 theDMBE->cd(currDir);
00556 }
00557 }
00558 }
00559
00560 return numberOfSeriousErrors;
00561 }
00562
00563 int SiPixelRawDataErrorModule::fillFED(const edm::DetSetVector<SiPixelRawDataError>& input) {
00564
00565 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00566 unsigned int numberOfSeriousErrors = 0;
00567
00568 edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(0xffffffff);
00569 if( isearch != input.end() ) {
00570
00571 edm::DetSet<SiPixelRawDataError>::const_iterator di;
00572 for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
00573 int FedId = di->getFedId();
00574 int chanNmbr = -1;
00575 int errorType = 0;
00576 if(FedId==static_cast<int>(id_)) {
00577 errorType = di->getType();
00578 (meErrorType_)->Fill((int)errorType);
00579 bool notReset=true;
00580 int TBMType=-1; int TBMMessage=-1; int evtSize=-1; int fullType=-1;
00581 const int LINK_bits = 6;
00582 const int LINK_shift = 26;
00583 const uint32_t LINK_mask = ~(~(uint32_t)(0) << LINK_bits);
00584 if((errorType == 32)||(errorType == 33)||(errorType == 34)) {
00585 long long errorWord = di->getWord64();
00586 chanNmbr = 0;
00587 switch(errorType) {
00588 case(32) : {
00589 break; }
00590 case(33) : {
00591 break; }
00592 case(34) : {
00593 evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00594 if(!(FedId==38&&chanNmbr==7)) (meEvtSize_)->Fill((int)evtSize);
00595 break; }
00596 default : break;
00597 };
00598 } else {
00599 uint32_t errorWord = di->getWord32();
00600 switch(errorType) {
00601 case(25) : case(39) : {
00602 chanNmbr = 0;
00603 break; }
00604 case(28) : {
00605 int NFa = (errorWord >> DB0_shift) & DataBit_mask;
00606 int NFb = (errorWord >> DB1_shift) & DataBit_mask;
00607 int NFc = (errorWord >> DB2_shift) & DataBit_mask;
00608 int NFd = (errorWord >> DB3_shift) & DataBit_mask;
00609 int NFe = (errorWord >> DB4_shift) & DataBit_mask;
00610 int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
00611 int L1A = (errorWord >> DB7_shift) & DataBit_mask;
00612 if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
00613 if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
00614 if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
00615 if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
00616 if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
00617 if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
00618 if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
00619 chanNmbr = 0;
00620 break; }
00621 case(29) : {
00622 int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
00623 int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
00624 int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
00625 int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
00626 int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
00627 int BLOCK_bits = 3;
00628 int BLOCK_shift = 8;
00629 uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
00630 int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
00631 int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
00632 if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
00633 else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
00634 if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;
00635 break; }
00636 case(30) : {
00637 int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00638 int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00639 int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00640 int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00641 int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00642 int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00643 int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00644 int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00645 if(!(FedId==38&&chanNmbr==7)){
00646 if (T0==1) { TBMMessage=0; (meTBMMessage_)->Fill((int)TBMMessage); }
00647 if (T1==1) { TBMMessage=1; (meTBMMessage_)->Fill((int)TBMMessage); }
00648 if (T2==1) { TBMMessage=2; (meTBMMessage_)->Fill((int)TBMMessage); }
00649 if (T3==1) { TBMMessage=3; (meTBMMessage_)->Fill((int)TBMMessage); }
00650 if (T4==1) { TBMMessage=4; (meTBMMessage_)->Fill((int)TBMMessage); }
00651 if (T5==1) { TBMMessage=5; (meTBMMessage_)->Fill((int)TBMMessage); }
00652 if (T6==1) { TBMMessage=6; (meTBMMessage_)->Fill((int)TBMMessage); }
00653 if (T7==1) { TBMMessage=7; (meTBMMessage_)->Fill((int)TBMMessage); }
00654 }
00655 if(TBMMessage==5 || TBMMessage==6) notReset=false;
00656 int StateMach_bits = 4;
00657 int StateMach_shift = 8;
00658 uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00659 int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00660 switch(StateMach) {
00661 case(0) : {
00662 TBMType = 0;
00663 break; }
00664 case(1) : case(9) : {
00665 TBMType = 1;
00666 break; }
00667 case(2) : case(4) : case(6) : {
00668 TBMType = 2;
00669 break; }
00670 case(8) : {
00671 TBMType = 3;
00672 break; }
00673 default : TBMType = 4;
00674 };
00675 if(!(FedId==38&&chanNmbr==7)) (meTBMType_)->Fill((int)TBMType);
00676 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00677 break; }
00678 case(31) : {
00679 int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00680 if(!(FedId==38&&chanNmbr==7))(meEvtNbr_)->Fill((int)evtNbr);
00681 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00682 break; }
00683 case(35) : case(36) : case(37) : case(38) : {
00684 chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
00685 break; }
00686 default : break;
00687 };
00688 }
00689
00690 if(!(errorType==30) || notReset){
00691 if(!(FedId==38&&chanNmbr==7)){
00692 std::string hid;
00693
00694 static const char chNfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
00695 char chNbuf[sizeof(chNfmt) + 2*32];
00696 sprintf(chNbuf, chNfmt, FedId, chanNmbr);
00697 hid = chNbuf;
00698 meFedChNErrArray_[chanNmbr] = theDMBE->get(hid);
00699 if(meFedChNErrArray_[chanNmbr]) meFedChNErrArray_[chanNmbr]->Fill(meFedChNErrArray_[chanNmbr]->getIntValue()+1);
00700
00701 static const char chLfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChLErrArray_%d";
00702 char chLbuf[sizeof(chLfmt) + 2*32];
00703 sprintf(chLbuf, chLfmt, FedId, chanNmbr);
00704 hid = chLbuf;
00705 meFedChLErrArray_[chanNmbr] = theDMBE->get(hid);
00706 if(meFedChLErrArray_[chanNmbr]) meFedChLErrArray_[chanNmbr]->Fill(errorType);
00707
00708 numberOfSeriousErrors++;
00709 int messageType = 99;
00710 if(errorType<30) messageType = errorType-25;
00711 else if(errorType>30) messageType = errorType-19;
00712 else if(errorType==30 && TBMMessage==0) messageType = errorType-25;
00713 else if(errorType==30 && TBMMessage==1) messageType = errorType-24;
00714 else if(errorType==30 && (TBMMessage==2 || TBMMessage==3 || TBMMessage==4)) messageType = errorType-23;
00715 else if(errorType==30 && TBMMessage==7) messageType = errorType-22;
00716 else if(errorType==30 && TBMType==1) messageType = errorType-21;
00717 else if(errorType==30 && TBMType==2) messageType = errorType-20;
00718 else if(errorType==30 && TBMType==3) messageType = errorType-19;
00719 if(messageType<=20){
00720 static const char fmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedETypeNErrArray_%d";
00721 char buf[sizeof(fmt) + 2*32];
00722 sprintf(buf, fmt, FedId, messageType);
00723 hid = buf;
00724 meFedETypeNErrArray_[messageType] = theDMBE->get(hid);
00725 if(meFedETypeNErrArray_[messageType]) meFedETypeNErrArray_[messageType]->Fill(meFedETypeNErrArray_[messageType]->getIntValue()+1);
00726 }
00727 }
00728 }
00729 }
00730 }
00731 if(numberOfSeriousErrors>0) (meNErrors_)->Fill((float)numberOfSeriousErrors);
00732
00733 }
00734
00735
00736 return numberOfSeriousErrors;
00737 }