File indexing completed on 2024-04-06 12:11:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013
0014 #include "DataFormats/Common/interface/Handle.h"
0015
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0018 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0019
0020 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0021
0022 #include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h"
0023
0024
0025 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0026 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
0027 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
0028 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
0029 #include "DataFormats/DetId/interface/DetId.h"
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #include "FWCore/ServiceRegistry/interface/Service.h"
0040 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0041
0042
0043 #include <TROOT.h>
0044
0045 #include <TFile.h>
0046 #include <TF1.h>
0047 #include <TH2F.h>
0048 #include <TH1F.h>
0049
0050 #include <iostream>
0051 using namespace std;
0052
0053
0054
0055 class MyDecode {
0056 public:
0057 MyDecode() {}
0058 ~MyDecode() {}
0059 static int error(int error, int &fedChannel, int fed, bool print = false);
0060 static int data(int error, int &fedChannel, int fed, bool print = false);
0061 static int header(unsigned long long word64, int fed, bool print);
0062 static int trailer(unsigned long long word64, int fed, bool print);
0063
0064 private:
0065 };
0066
0067 int MyDecode::header(unsigned long long word64, int fed, bool print) {
0068 int fed_id = (word64 >> 8) & 0xfff;
0069 int event_id = (word64 >> 32) & 0xffffff;
0070 unsigned int bx_id = (word64 >> 20) & 0xfff;
0071
0072
0073
0074
0075
0076
0077
0078 if (print)
0079 cout << " Header "
0080 << " for FED " << fed_id << " event " << event_id << " bx " << bx_id << endl;
0081
0082 return event_id;
0083 }
0084
0085 int MyDecode::trailer(unsigned long long word64, int fed, bool print) {
0086 int slinkLength = int((word64 >> 32) & 0xffffff);
0087 int crc = int((word64 & 0xffff0000) >> 16);
0088 int tts = int((word64 & 0xf0) >> 4);
0089 int slinkError = int((word64 & 0xf00) >> 8);
0090 if (print)
0091 cout << " Trailer "
0092 << " len " << slinkLength << " tts " << tts << " error " << slinkError << " crc " << hex << crc << dec << endl;
0093 return slinkLength;
0094 }
0095
0096
0097
0098 int MyDecode::error(int word, int &fedChannel, int fed, bool print) {
0099 int status = -1;
0100
0101 const unsigned int errorMask = 0x3e00000;
0102 const unsigned int dummyMask = 0x03600000;
0103 const unsigned int gapMask = 0x03400000;
0104 const unsigned int timeOut = 0x3a00000;
0105 const unsigned int eventNumError = 0x3e00000;
0106 const unsigned int trailError = 0x3c00000;
0107 const unsigned int fifoError = 0x3800000;
0108
0109
0110
0111 const unsigned int channelMask = 0xfc000000;
0112 const unsigned int tbmEventMask = 0xff;
0113 const unsigned int overflowMask = 0x100;
0114 const unsigned int tbmStatusMask = 0xff;
0115 const unsigned int BlkNumMask = 0x700;
0116 const unsigned int FsmErrMask = 0x600;
0117 const unsigned int RocErrMask = 0x800;
0118 const unsigned int ChnFifMask = 0x1f;
0119 const unsigned int Fif2NFMask = 0x40;
0120 const unsigned int TrigNFMask = 0x80;
0121
0122 const int offsets[8] = {0, 4, 9, 13, 18, 22, 27, 31};
0123 unsigned int channel = 0;
0124
0125
0126
0127 if ((word & errorMask) == dummyMask) {
0128
0129 return 0;
0130 } else if ((word & errorMask) == gapMask) {
0131
0132 return 0;
0133
0134 } else if ((word & errorMask) == timeOut) {
0135
0136 unsigned int index = (word & 0x1F);
0137 unsigned int chip = (word & BlkNumMask) >> 8;
0138 int offset = offsets[chip];
0139 if (print)
0140 cout << "Timeout Error- channel: ";
0141 for (int i = 0; i < 5; i++) {
0142 if ((index & 0x1) != 0) {
0143 channel = offset + i + 1;
0144 if (print)
0145 cout << channel << " ";
0146 }
0147 index = index >> 1;
0148 }
0149
0150 status = -10;
0151 fedChannel = channel;
0152
0153
0154 } else if ((word & errorMask) == eventNumError) {
0155 channel = (word & channelMask) >> 26;
0156 unsigned int tbm_event = (word & tbmEventMask);
0157
0158 if (print)
0159 cout << "Event Number Error- channel: " << channel << " tbm event nr. " << tbm_event << " ";
0160 status = -11;
0161 fedChannel = channel;
0162
0163 } else if (((word & errorMask) == trailError)) {
0164 channel = (word & channelMask) >> 26;
0165 unsigned int tbm_status = (word & tbmStatusMask);
0166
0167 if (tbm_status != 0) {
0168 if (print)
0169 cout << "Trailer Error- "
0170 << "channel: " << channel << " TBM status:0x" << hex << tbm_status << dec << " ";
0171 status = -15;
0172
0173 }
0174
0175 if (word & RocErrMask) {
0176 if (print)
0177 cout << "Number of Rocs Error- "
0178 << "channel: " << channel << " ";
0179 status = -12;
0180 }
0181
0182 if (word & overflowMask) {
0183 if (print)
0184 cout << "Overflow Error- "
0185 << "channel: " << channel << " ";
0186 status = -14;
0187 }
0188
0189 if (word & FsmErrMask) {
0190 if (print)
0191 cout << "Finite State Machine Error- "
0192 << "channel: " << channel << " Error status:0x" << hex << ((word & FsmErrMask) >> 9) << dec
0193 << " ";
0194 status = -13;
0195 }
0196
0197 fedChannel = channel;
0198
0199 } else if ((word & errorMask) == fifoError) {
0200 if (print) {
0201 if (word & Fif2NFMask)
0202 cout << "A fifo 2 is Nearly full- ";
0203 if (word & TrigNFMask)
0204 cout << "The trigger fifo is nearly Full - ";
0205 if (word & ChnFifMask)
0206 cout << "fifo-1 is nearly full for channel" << (word & ChnFifMask);
0207
0208 status = -16;
0209 }
0210
0211 } else {
0212 cout << " Unknown error?, error word " << hex << word << dec << endl;
0213 status = -19;
0214 }
0215
0216 if (print && status < -1)
0217 cout << " For FED " << fed << endl;
0218 return status;
0219 }
0220
0221 int MyDecode::data(int word, int &fedChannel, int fed, bool print) {
0222 const bool CHECK_PIXELS = true;
0223
0224 const unsigned int plsmsk = 0xff;
0225 const unsigned int pxlmsk = 0xff00;
0226 const unsigned int dclmsk = 0x1f0000;
0227 const unsigned int rocmsk = 0x3e00000;
0228 const unsigned int chnlmsk = 0xfc000000;
0229 int status = 0;
0230
0231 int roc = ((word & rocmsk) >> 21);
0232
0233 if (roc > 0 && roc < 25) {
0234
0235 unsigned int channel = ((word & chnlmsk) >> 26);
0236 if (channel > 0 && channel < 37) {
0237
0238 int dcol = (word & dclmsk) >> 16;
0239 int pix = (word & pxlmsk) >> 8;
0240 int adc = (word & plsmsk);
0241 fedChannel = channel;
0242
0243 if (print) {
0244 int dcol1 = dcol / 6;
0245 int dcol2 = dcol % 6;
0246 int pix1 = pix / 36;
0247 int pix2 = (pix % 36) / 6;
0248 int pix3 = pix % 6;
0249 cout << " Fed " << fed << " Channel- " << channel << " ROC- " << (roc - 1) << " DCOL- " << dcol << " Pixel- "
0250 << pix << " ADC- " << adc << " : " << dcol1 << dcol2 << "-" << pix1 << pix2 << pix3 << endl;
0251 }
0252 status++;
0253 if (CHECK_PIXELS) {
0254 if (dcol < 0 || dcol > 25) {
0255 if (print)
0256 cout << " Fed " << fed << " wrong dcol number chan/roc/dcol/pix/adc = " << channel << "/" << roc << "/"
0257 << dcol << "/" << pix << "/" << adc << endl;
0258 status = -3;
0259 }
0260
0261 if (pix < 2 || pix > 181) {
0262 if (print)
0263 cout << " Fed " << fed << " wrong pix number chan/roc/dcol/pix/adc = " << channel << "/" << roc << "/"
0264 << dcol << "/" << pix << "/" << adc << endl;
0265 status = -3;
0266 }
0267
0268 if ((fed > 31 && roc > 24) || (fed <= 31 && roc > 16)) {
0269 if (print)
0270 cout << " Fed " << fed << " wrong roc number chan/roc/dcol/pix/adc = " << channel << "/" << roc << "/"
0271 << dcol << "/" << pix << "/" << adc << endl;
0272 status = -4;
0273 } else if (fed <= 31 && channel <= 24 && roc > 8) {
0274
0275 if (!((fed == 13 && channel == 17) || (fed == 15 && channel == 5) || (fed == 31 && channel == 10) ||
0276 (fed == 27 && channel == 15))) {
0277 if (print)
0278 cout << " Fed " << fed << " wrong roc number, chan/roc/dcol/pix/adc = " << channel << "/" << roc << "/"
0279 << dcol << "/" << pix << "/" << adc << endl;
0280 status = -4;
0281 }
0282 }
0283
0284 if (pix == 0) {
0285 if (print)
0286 cout << " Fed " << fed << " pix=0 chan/roc/dcol/pix/adc = " << channel << "/" << roc << "/" << dcol << "/"
0287 << pix << "/" << adc << endl;
0288 status = -5;
0289 }
0290 }
0291
0292 } else {
0293 cout << "Wrong channel " << channel << endl;
0294 return -2;
0295 }
0296
0297 } else if (roc == 25) {
0298
0299 unsigned int channel = ((word & chnlmsk) >> 26);
0300 cout << "Wrong roc 25-" << roc << " in fed/chan " << fed << "/" << channel << endl;
0301 status = -4;
0302
0303 } else {
0304
0305
0306 status = error(word, fedChannel, fed, print);
0307
0308 }
0309
0310 return status;
0311 }
0312
0313
0314
0315 class FedErrorDumper : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0316 public:
0317
0318 explicit FedErrorDumper(const edm::ParameterSet &cfg);
0319
0320
0321 virtual ~FedErrorDumper() = default;
0322
0323 void beginJob();
0324
0325
0326 void endJob();
0327
0328
0329 virtual void analyze(const edm::Event &, const edm::EventSetup &);
0330
0331 private:
0332 edm::ParameterSet theConfig;
0333 edm::EDGetTokenT<edm::DetSetVector<SiPixelRawDataError> > fedErrorContainer;
0334 bool PRINT;
0335
0336 int fedErrors, moduleErrors, spareCounts;
0337
0338
0339
0340
0341 int countErrors[40], countErrors2[40];
0342
0343 TH1F *hfeds, *hfedsF, *hfedsSlink, *hfedsCRC, *hfedsUnknown;
0344 TH1F *herrors, *herrorsF, *htype;
0345 TH1F *hmode, *hmodeF;
0346 TH1F *htbm, *htbmF;
0347 TH2F *hfedErrors0, *hfedErrors1, *hfedErrors2, *hfedErrors3, *hfedErrors4, *hfedErrors5, *hfedErrors6, *hfedErrors7,
0348 *hfedErrors8, *hfedErrors9;
0349 TH2F *hfedErrors0F, *hfed2d, *hfed2d0;
0350
0351 TH1F *hlumi, *hbx;
0352 };
0353
0354 FedErrorDumper::FedErrorDumper(const edm::ParameterSet &cfg) : theConfig(cfg) {
0355
0356 std::string src = theConfig.getUntrackedParameter<std::string>("InputLabel", "siPixelDigis");
0357
0358
0359 fedErrorContainer = consumes<edm::DetSetVector<SiPixelRawDataError> >(src);
0360 usesResource(TFileService::kSharedResource);
0361 }
0362
0363
0364 void FedErrorDumper::endJob() {
0365 cout << " fed-errors " << fedErrors << " module-Errors " << moduleErrors << " " << spareCounts << endl;
0366 for (int i = 0; i < 40; ++i) {
0367 if (countErrors[i] > 0 || countErrors2[i] > 0)
0368 cout << i << " " << countErrors[i] << " " << countErrors2[i] << endl;
0369 }
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404 }
0405
0406 void FedErrorDumper::beginJob() {
0407
0408
0409
0410 fedErrors = 0;
0411 moduleErrors = 0;
0412 spareCounts = 0.;
0413
0414
0415 PRINT = theConfig.getUntrackedParameter<bool>("Verbosity", false);
0416 for (int i = 0; i < 40; ++i) {
0417 countErrors[i] = 0;
0418 countErrors2[i] = 0;
0419 }
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429 edm::Service<TFileService> fs;
0430
0431 htbm = fs->make<TH1F>("htbm", "tbm errors ", 256, -0.5, 255.5);
0432 htbmF = fs->make<TH1F>("htbmF", "tbm errors ", 256, -0.5, 255.5);
0433
0434 hmode = fs->make<TH1F>("hmode", "mode", 16, -0.5, 15.5);
0435 hmodeF = fs->make<TH1F>("hmodeF", "mode", 16, -0.5, 15.5);
0436
0437 hfeds = fs->make<TH1F>("hfeds", "errors per FED", 40, -0.5, 39.5);
0438 hfedsF = fs->make<TH1F>("hfedsF", "errors per FED", 40, -0.5, 39.5);
0439 hfedsSlink = fs->make<TH1F>("hfedsSlink", "errors per FED", 40, -0.5, 39.5);
0440 hfedsCRC = fs->make<TH1F>("hfedsCRC", "errors per FED", 40, -0.5, 39.5);
0441 hfedsUnknown = fs->make<TH1F>("hfedsUnknown", "errors per FED", 40, -0.5, 39.5);
0442
0443 htype = fs->make<TH1F>("htype", "error type ", 50, -0.5, 49.5);
0444 herrors = fs->make<TH1F>("herrors", "error type ", 50, -0.5, 49.5);
0445 herrorsF = fs->make<TH1F>("herrorsF", "error type", 50, -0.5, 49.5);
0446
0447 hfedErrors0 = fs->make<TH2F>("hfedErrors0", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0448 hfedErrors0F = fs->make<TH2F>("hfedErrors0F", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0449 hfedErrors1 = fs->make<TH2F>("hfedErrors1", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0450 hfedErrors2 = fs->make<TH2F>("hfedErrors2", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0451 hfedErrors3 = fs->make<TH2F>("hfedErrors3", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0452 hfedErrors4 = fs->make<TH2F>("hfedErrors4", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0453 hfedErrors5 = fs->make<TH2F>("hfedErrors5", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0454 hfedErrors6 = fs->make<TH2F>("hfedErrors6", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0455 hfedErrors7 = fs->make<TH2F>("hfedErrors7", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0456 hfedErrors8 = fs->make<TH2F>("hfedErrors8", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0457 hfedErrors9 = fs->make<TH2F>("hfedErrors9", "errors", 40, -0.5, 39.5, 37, -0.5, 36.5);
0458
0459 hfed2d = fs->make<TH2F>("hfed2d", "errors", 40, -0.5, 39.5, 20, 19.5, 39.5);
0460 hfed2d0 = fs->make<TH2F>("hfed2d0", "errors", 40, -0.5, 39.5, 20, 19.5, 39.5);
0461
0462 hlumi = fs->make<TH1F>("hlumi", "lumi", 4000, 0, 4000.);
0463 hbx = fs->make<TH1F>("hbx", "bx", 4000, 0, 4000.);
0464 }
0465
0466 void FedErrorDumper::analyze(const edm::Event &ev, const edm::EventSetup &es) {
0467
0468
0469
0470 int run = ev.id().run();
0471 int event = ev.id().event();
0472 int lumiBlock = ev.luminosityBlock();
0473 int bx = ev.bunchCrossing();
0474
0475
0476 hlumi->Fill(float(lumiBlock));
0477 hbx->Fill(float(bx));
0478
0479
0480
0481
0482
0483
0484 edm::Handle<edm::DetSetVector<SiPixelRawDataError> > input;
0485
0486
0487
0488
0489 ev.getByToken(fedErrorContainer, input);
0490
0491 if (!input.isValid()) {
0492 cout << " Container not found " << endl;
0493 return;
0494 }
0495
0496 if (PRINT)
0497 cout << " Container found " << run << " " << event << " " << lumiBlock << " " << bx << endl;
0498
0499
0500 edm::DetSetVector<SiPixelRawDataError>::const_iterator DSViter;
0501 for (DSViter = input->begin(); DSViter != input->end(); DSViter++) {
0502
0503 unsigned int detid = DSViter->id;
0504
0505
0506 if (detid == 0xffffffff) {
0507
0508 if (PRINT)
0509 cout << " FED errors " << DSViter->data.size() << endl;
0510
0511 edm::DetSet<SiPixelRawDataError>::const_iterator di;
0512
0513 for (di = DSViter->data.begin(); di != DSViter->data.end(); di++) {
0514 int FedId = di->getFedId();
0515 int errorType = di->getType();
0516 uint32_t word32 = di->getWord32();
0517 uint64_t word64 = di->getWord64();
0518
0519 fedErrors++;
0520
0521 herrors->Fill(float(errorType));
0522 herrorsF->Fill(float(errorType));
0523 hfedsF->Fill(float(FedId));
0524 hfeds->Fill(float(FedId));
0525 int errorTypeMod = errorType;
0526
0527 if (PRINT)
0528 cout << " fed " << FedId << " type " << errorType << " " << hex << word32 << " " << word64 << dec << " "
0529 << di->getMessage() << endl;
0530
0531 int status = 0;
0532 int fedChannel = -1;
0533
0534 if (errorType >= 26 && errorType <= 31) {
0535 status = MyDecode::error(word32, fedChannel, FedId, PRINT);
0536 if (PRINT)
0537 cout << " status " << status << endl;
0538
0539 if (fedChannel < 1 || fedChannel > 36) {
0540 cout << " Cannot get a valid fed channel number of a -fed- error " << fedChannel << endl;
0541 continue;
0542 }
0543
0544 hfedErrors0->Fill(float(FedId), float(fedChannel));
0545 hfedErrors0F->Fill(float(FedId), float(fedChannel));
0546
0547 switch (errorType) {
0548 case (28): {
0549 hfedErrors4->Fill(float(FedId), float(fedChannel));
0550 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0551 htype->Fill(float(errorTypeMod));
0552 break;
0553 }
0554
0555 case (29): {
0556 hfedErrors1->Fill(float(FedId), float(fedChannel));
0557 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0558 htype->Fill(float(errorTypeMod));
0559 break;
0560 }
0561
0562 case (30): {
0563
0564 int tbm = (word32 & 0xff);
0565 int mode = (word32 >> 8) & 0xf;
0566 hmodeF->Fill(float(mode));
0567 hmode->Fill(float(mode));
0568
0569 countErrors[30]++;
0570
0571 if (tbm != 0) {
0572 hfedErrors6->Fill(float(FedId), float(fedChannel));
0573 htbmF->Fill(float(tbm));
0574 errorTypeMod = 20;
0575 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0576 htype->Fill(float(errorTypeMod));
0577 }
0578
0579 if ((mode & 0x8) != 0) {
0580
0581 hfedErrors5->Fill(float(FedId), float(fedChannel));
0582 errorTypeMod = 21;
0583 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0584 htype->Fill(float(errorTypeMod));
0585 }
0586
0587 if ((mode & 0x1) != 0) {
0588 hfedErrors2->Fill(float(FedId), float(fedChannel));
0589 errorTypeMod = 22;
0590 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0591 htype->Fill(float(errorTypeMod));
0592 }
0593
0594 if ((mode & 0x6) != 0) {
0595 hfedErrors7->Fill(float(FedId), float(fedChannel));
0596 errorTypeMod = 23;
0597 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0598 htype->Fill(float(errorTypeMod));
0599 }
0600
0601 break;
0602 }
0603
0604 case (31): {
0605 hfedErrors3->Fill(float(FedId), float(fedChannel));
0606 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0607 htype->Fill(float(errorTypeMod));
0608 break;
0609 }
0610 }
0611
0612 } else if (errorType >= 32 && errorType <= 34) {
0613 cout << " Slink error " << endl;
0614
0615 hfedsSlink->Fill(float(FedId));
0616 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0617 htype->Fill(float(errorTypeMod));
0618
0619 } else if (errorType == 25 || (errorType >= 35 && errorType <= 38)) {
0620 cout << " Should never happen, a -fed- conversion error? " << endl;
0621 status = MyDecode::data(word32, fedChannel, FedId, PRINT);
0622 if (PRINT)
0623 cout << " status " << status << endl;
0624
0625 hfedErrors0->Fill(float(FedId), float(fedChannel));
0626 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0627 htype->Fill(float(errorTypeMod));
0628
0629 switch (errorType) {
0630 case (25): {
0631 hfedErrors8->Fill(float(FedId), float(fedChannel));
0632 break;
0633 }
0634 case (36): {
0635 hfedErrors8->Fill(float(FedId), float(fedChannel));
0636 break;
0637 }
0638 case (37): {
0639 hfedErrors9->Fill(float(FedId), float(fedChannel));
0640
0641 cout << " does it ever happen " << endl;
0642 break;
0643 }
0644 }
0645
0646 } else if (errorType == 39) {
0647 cout << " CRC error " << endl;
0648 hfedsCRC->Fill(float(FedId));
0649 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0650 htype->Fill(float(errorTypeMod));
0651
0652 } else {
0653 cout << " unknown error " << errorType << endl;
0654 hfedsUnknown->Fill(float(FedId));
0655 errorTypeMod = 24;
0656 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0657 htype->Fill(float(errorTypeMod));
0658 }
0659
0660 hfed2d->Fill(float(FedId), float(errorTypeMod));
0661
0662 if (errorTypeMod >= 0 && errorTypeMod < 40)
0663 countErrors[errorTypeMod]++;
0664
0665 }
0666
0667 } else {
0668
0669 DetId detId(detid);
0670
0671
0672 unsigned int detType = detId.det();
0673 unsigned int subid = detId.subdetId();
0674
0675 if (PRINT) {
0676 cout << " Module errors " << DSViter->data.size() << endl;
0677 cout << "Det: " << detId.rawId() << ":";
0678
0679 }
0680
0681 int layer = 0, ladder = 0, module = 0, disk = 0, blade = 0, zindex = 0;
0682 if (subid == 1) {
0683 PXBDetId pdetId = PXBDetId(detid);
0684
0685 int layerC = pdetId.layer();
0686
0687 int ladderC = pdetId.ladder();
0688
0689 int zindex = pdetId.module();
0690
0691 PixelBarrelName pbn(pdetId);
0692 int sector = pbn.sectorName();
0693 ladder = pbn.ladderName();
0694 layer = pbn.layerName();
0695 module = pbn.moduleName();
0696 int half = pbn.isHalfModule();
0697 PixelBarrelName::Shell shell = pbn.shell();
0698
0699 if (PRINT)
0700 cout << " BPix: layer " << layer << " ladder " << ladder << " module " << module << " shell " << shell
0701 << " sector " << sector << " " << layerC << " " << ladderC << " " << zindex << " " << half << " "
0702 << detType << endl;
0703
0704 } else if (subid == 2) {
0705
0706 PXFDetId pdetId = PXFDetId(detid);
0707 disk = pdetId.disk();
0708 blade = pdetId.blade();
0709 zindex = pdetId.module();
0710 int side = pdetId.side();
0711 int panel = pdetId.panel();
0712
0713 if (PRINT)
0714 cout << " FPix: disk " << disk << " " << blade << " " << side << " " << panel << endl;
0715 }
0716
0717
0718 edm::DetSet<SiPixelRawDataError>::const_iterator di;
0719 for (di = DSViter->data.begin(); di != DSViter->data.end(); di++) {
0720 int FedId = di->getFedId();
0721 int errorType = di->getType();
0722 uint32_t word32 = di->getWord32();
0723
0724
0725 herrors->Fill(float(errorType));
0726 moduleErrors++;
0727 int errorTypeMod = errorType;
0728
0729
0730 if (PRINT)
0731 cout << " fed " << FedId << " type " << errorType << endl;
0732
0733 int status = 0;
0734 int fedChannel = 0;
0735
0736
0737 if (errorType >= 26 && errorType <= 31) {
0738 status = MyDecode::error(word32, fedChannel, FedId, PRINT);
0739 if (PRINT)
0740 cout << " fed " << FedId << " "
0741 << "Channel " << fedChannel << " " << status << endl;
0742
0743 hfedErrors0->Fill(float(FedId), float(fedChannel));
0744
0745 switch (errorType) {
0746 case (28): {
0747 hfedErrors4->Fill(float(FedId), float(fedChannel));
0748 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0749 htype->Fill(float(errorTypeMod));
0750 break;
0751 }
0752
0753 case (29): {
0754 hfedErrors1->Fill(float(FedId), float(fedChannel));
0755 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0756 htype->Fill(float(errorTypeMod));
0757 break;
0758 }
0759
0760 case (30): {
0761
0762 int tbm = (word32 & 0xff);
0763 int mode = (word32 >> 8) & 0xf;
0764 hmode->Fill(float(mode));
0765
0766
0767 if (tbm != 0) {
0768 htbm->Fill(float(tbm));
0769 hfedErrors6->Fill(float(FedId), float(fedChannel));
0770 errorTypeMod = 20;
0771 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0772 htype->Fill(float(errorTypeMod));
0773 }
0774
0775 if ((mode & 0x8) != 0) {
0776
0777 hfedErrors5->Fill(float(FedId), float(fedChannel));
0778 errorTypeMod = 21;
0779 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0780 htype->Fill(float(errorTypeMod));
0781 }
0782
0783 if ((mode & 0x1) != 0) {
0784 hfedErrors2->Fill(float(FedId), float(fedChannel));
0785 errorTypeMod = 22;
0786 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0787 htype->Fill(float(errorTypeMod));
0788 }
0789
0790 if ((mode & 0x6) != 0) {
0791 hfedErrors7->Fill(float(FedId), float(fedChannel));
0792 errorTypeMod = 23;
0793 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0794 htype->Fill(float(errorTypeMod));
0795 }
0796
0797 break;
0798 }
0799
0800 case (31): {
0801 hfedErrors3->Fill(float(FedId), float(fedChannel));
0802 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0803 htype->Fill(float(errorTypeMod));
0804 break;
0805 }
0806 }
0807
0808 } else if (errorType >= 32 && errorType <= 34) {
0809 cout << " Slink error " << endl;
0810 hfedsSlink->Fill(float(FedId));
0811 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0812 htype->Fill(float(errorTypeMod));
0813
0814 } else if (errorType == 25 || (errorType >= 35 && errorType <= 38)) {
0815
0816 status = MyDecode::data(word32, fedChannel, FedId, PRINT);
0817 if (PRINT)
0818 cout << " fed " << FedId << " "
0819 << "Channel " << fedChannel << " " << status << endl;
0820
0821 hfedErrors0->Fill(float(FedId), float(fedChannel));
0822 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0823 htype->Fill(float(errorTypeMod));
0824
0825 switch (errorType) {
0826 case (25): {
0827 hfedErrors8->Fill(float(FedId), float(fedChannel));
0828 break;
0829 }
0830 case (36): {
0831 hfedErrors8->Fill(float(FedId), float(fedChannel));
0832 break;
0833 }
0834 case (37): {
0835 hfedErrors9->Fill(float(FedId), float(fedChannel));
0836 if (FedId == 6 && fedChannel == 35) {
0837 spareCounts++;
0838 cout << errorType << " " << FedId << " " << fedChannel;
0839 if (subid == 1)
0840 cout << " BPix: layer " << layer << " ladder " << ladder << " module " << module << endl;
0841 else
0842 cout << " FPix: disk " << disk << " " << blade << " " << zindex << endl;
0843 }
0844 break;
0845 }
0846 }
0847
0848 } else if (errorType == 39) {
0849 cout << " CRC error " << endl;
0850 hfedsCRC->Fill(float(FedId));
0851 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0852 htype->Fill(float(errorTypeMod));
0853
0854 } else {
0855 cout << " unknown error " << errorType << endl;
0856 hfedsUnknown->Fill(float(FedId));
0857 errorTypeMod = 24;
0858 hfed2d0->Fill(float(FedId), float(errorTypeMod));
0859 htype->Fill(float(errorTypeMod));
0860 }
0861
0862 hfed2d->Fill(float(FedId), float(errorTypeMod));
0863
0864 if (errorTypeMod >= 0 && errorTypeMod < 40)
0865 countErrors2[errorTypeMod]++;
0866
0867 }
0868
0869 }
0870
0871 }
0872 }
0873
0874 #include "FWCore/Framework/interface/MakerMacros.h"
0875 DEFINE_FWK_MODULE(FedErrorDumper);