File indexing completed on 2024-04-06 12:11:01
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012
0013 #include "DataFormats/Common/interface/Handle.h"
0014
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0017 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0018
0019 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0020
0021 #include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h"
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include "FWCore/ServiceRegistry/interface/Service.h"
0037 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0038
0039
0040 #include <TROOT.h>
0041
0042 #include <TFile.h>
0043 #include <TF1.h>
0044 #include <TH2F.h>
0045 #include <TH1D.h>
0046 #include <TProfile.h>
0047 #include <TProfile2D.h>
0048
0049 #include <iostream>
0050 #include <fstream>
0051
0052 using namespace std;
0053
0054
0055
0056
0057 namespace {
0058 bool printErrors = true;
0059 bool printData = false;
0060 bool printHeaders = false;
0061 const bool CHECK_PIXELS = true;
0062 const bool PRINT_BASELINE = false;
0063
0064 int fed0 = -1, chan0 = -1, roc0 = -1, dcol0 = -1, pix0 = -1, count0 = -1;
0065 int countDecodeErrors1 = 0, countDecodeErrors2 = 0;
0066 }
0067
0068
0069
0070 class MyDecode {
0071 public:
0072 MyDecode() {}
0073 ~MyDecode() {}
0074 static int error(int error, int &fedChannel, int fed, int &stat1, int &stat2, bool print = false);
0075 static int data(int error, int &fedChannel, int fed, int &stat1, int &stat2, bool print = false);
0076 static int header(unsigned long long word64, int fed, bool print, unsigned int &bx);
0077 static int trailer(unsigned long long word64, int fed, bool print);
0078 static int convertToCol(int dcol, int pix);
0079 static int convertToRow(int pix);
0080 static int checkLayerLink(int fed, int chan);
0081
0082 private:
0083 };
0084
0085
0086
0087
0088 int MyDecode::checkLayerLink(int fed, int chan) {
0089 int layer = 0;
0090 if (fed < 0 || fed > 31)
0091 return layer;
0092
0093 if (chan > 24) {
0094
0095 if (fed == 0 || fed == 8) {
0096
0097 if (chan == 28 || chan == 34 || chan == 35 || chan == 36)
0098 layer = 13;
0099 else
0100 layer = 3;
0101
0102 } else if (fed == 23 || fed == 31) {
0103
0104 if (chan == 27 || chan == 31 || chan == 32 || chan == 33)
0105 layer = 13;
0106 else
0107 layer = 3;
0108
0109 } else if (fed == 7 || fed == 15 || fed == 16 || fed == 24) {
0110
0111 if (chan == 25 || chan == 26 || chan == 29 || chan == 30)
0112 layer = 13;
0113 else
0114 layer = 3;
0115
0116 } else {
0117 layer = 3;
0118 }
0119
0120 return layer;
0121
0122 } else if ((chan >= 13 && chan <= 19) || chan == 24) {
0123 return 2;
0124
0125 } else {
0126 if (fed == 0 || fed == 8 || fed == 16 || fed == 24) {
0127
0128 if (chan == 5 || chan == 6 || chan == 22 || chan == 23)
0129 layer = 12;
0130 else if (chan == 4 || chan == 10 || chan == 11 || chan == 12)
0131 layer = 11;
0132 else
0133 layer = 1;
0134
0135 } else if (fed == 7 || fed == 15 || fed == 23 || fed == 31) {
0136
0137 if (chan == 1 || chan == 2 || chan == 20 || chan == 21)
0138 layer = 12;
0139 else if (chan == 3 || chan == 7 || chan == 8 || chan == 9)
0140 layer = 11;
0141 else
0142 layer = 1;
0143
0144 } else if (fed == 1 || fed == 2 || fed == 3 || fed == 9 || fed == 10 || fed == 11 || fed == 17 || fed == 18 ||
0145 fed == 19 || fed == 25 || fed == 26 || fed == 27) {
0146
0147 if ((chan >= 4 && chan <= 6) || (chan >= 10 && chan <= 12) || (chan >= 22 && chan <= 23))
0148 layer = 2;
0149 else
0150 layer = 1;
0151
0152 } else if (fed == 4 || fed == 5 || fed == 6 || fed == 12 || fed == 13 || fed == 14 || fed == 20 || fed == 21 ||
0153 fed == 22 || fed == 28 || fed == 29 || fed == 30) {
0154
0155 if ((chan >= 1 && chan <= 3) || (chan >= 7 && chan <= 9) || (chan >= 20 && chan <= 21))
0156 layer = 2;
0157 else
0158 layer = 1;
0159
0160 } else {
0161 cout << "unknown fed " << fed << endl;
0162 }
0163
0164 return layer;
0165
0166 }
0167 }
0168
0169 int MyDecode::convertToCol(int dcol, int pix) {
0170
0171 int colEvenOdd = pix % 2;
0172
0173 return (dcol * 2 + colEvenOdd);
0174 }
0175 int MyDecode::convertToRow(int pix) {
0176 return abs(int(pix / 2) - 80);
0177 }
0178
0179 int MyDecode::header(unsigned long long word64, int fed, bool print, unsigned int &bx) {
0180 int fed_id = (word64 >> 8) & 0xfff;
0181 int event_id = (word64 >> 32) & 0xffffff;
0182 bx = (word64 >> 20) & 0xfff;
0183
0184
0185
0186
0187
0188
0189
0190 if (print)
0191 cout << "Header "
0192 << " for FED " << fed_id << " event " << event_id << " bx " << bx << endl;
0193 fed0 = -1;
0194 return event_id;
0195 }
0196
0197 int MyDecode::trailer(unsigned long long word64, int fed, bool print) {
0198 int slinkLength = int((word64 >> 32) & 0xffffff);
0199 int crc = int((word64 & 0xffff0000) >> 16);
0200 int tts = int((word64 & 0xf0) >> 4);
0201 int slinkError = int((word64 & 0xf00) >> 8);
0202 if (print)
0203 cout << "Trailer "
0204 << " len " << slinkLength << " tts " << tts << " error " << slinkError << " crc " << hex << crc << dec << endl;
0205 return slinkLength;
0206 }
0207
0208
0209
0210 int MyDecode::error(int word, int &fedChannel, int fed, int &stat1, int &stat2, bool print) {
0211 int status = -1;
0212 print = print || printErrors;
0213
0214 const unsigned int errorMask = 0x3e00000;
0215 const unsigned int dummyMask = 0x03600000;
0216 const unsigned int gapMask = 0x03400000;
0217 const unsigned int timeOut = 0x3a00000;
0218 const unsigned int eventNumError = 0x3e00000;
0219 const unsigned int trailError = 0x3c00000;
0220 const unsigned int fifoError = 0x3800000;
0221
0222
0223
0224 const unsigned int channelMask = 0xfc000000;
0225 const unsigned int tbmEventMask = 0xff;
0226 const unsigned int overflowMask = 0x100;
0227 const unsigned int tbmStatusMask = 0xff;
0228 const unsigned int BlkNumMask = 0x700;
0229 const unsigned int FsmErrMask = 0x600;
0230 const unsigned int RocErrMask = 0x800;
0231 const unsigned int ChnFifMask = 0x1f;
0232 const unsigned int Fif2NFMask = 0x40;
0233 const unsigned int TrigNFMask = 0x80;
0234
0235 const int offsets[8] = {0, 4, 9, 13, 18, 22, 27, 31};
0236 unsigned int channel = 0;
0237
0238
0239
0240 if ((word & errorMask) == dummyMask) {
0241
0242 return 0;
0243
0244 } else if ((word & errorMask) == gapMask) {
0245
0246 return 0;
0247
0248 } else if ((word & errorMask) == timeOut) {
0249
0250 unsigned int bit20 = (word & 0x100000) >> 20;
0251
0252 if (bit20 == 0) {
0253
0254 unsigned int timeoutCnt = (word & 0x7f800) >> 11;
0255
0256
0257
0258
0259 unsigned int index = (word & 0x1F);
0260 unsigned int chip = (word & BlkNumMask) >> 8;
0261 int offset = offsets[chip];
0262 if (print)
0263 cout << "Timeout Error- channel: ";
0264
0265 for (int i = 0; i < 5; i++) {
0266 if ((index & 0x1) != 0) {
0267 channel = offset + i + 1;
0268 if (print)
0269 cout << channel << " ";
0270
0271 }
0272 index = index >> 1;
0273 }
0274
0275 if (print)
0276 cout << " TimeoutCount: " << timeoutCnt;
0277
0278
0279
0280 status = -10;
0281 fedChannel = channel;
0282
0283
0284 } else {
0285
0286 int baselineCorr = 0;
0287 if (word & 0x200) {
0288 baselineCorr = -(((~word) & 0x1ff) + 1);
0289 } else {
0290 baselineCorr = (word & 0x1ff);
0291 }
0292
0293 if (PRINT_BASELINE && print)
0294 cout << "Timeout BaselineCorr: " << baselineCorr << endl;
0295
0296 status = 0;
0297 }
0298
0299 } else if ((word & errorMask) == eventNumError) {
0300 channel = (word & channelMask) >> 26;
0301 unsigned int tbm_event = (word & tbmEventMask);
0302
0303 if (print)
0304 cout << " Event Number Error- channel: " << channel << " tbm event nr. " << tbm_event << " ";
0305 status = -11;
0306 fedChannel = channel;
0307
0308 } else if (((word & errorMask) == trailError)) {
0309 channel = (word & channelMask) >> 26;
0310 unsigned int tbm_status = (word & tbmStatusMask);
0311
0312 if (tbm_status != 0) {
0313 if (print)
0314 cout << " Trailer Error- "
0315 << "channel: " << channel << " TBM status:0x" << hex << tbm_status << dec << " ";
0316 status = -15;
0317
0318 }
0319
0320 if (word & RocErrMask) {
0321 if (print)
0322 cout << "Number of Rocs Error- "
0323 << "channel: " << channel << " ";
0324 status = -12;
0325 }
0326
0327 if (word & overflowMask) {
0328 if (print)
0329 cout << "Overflow Error- "
0330 << "channel: " << channel << " ";
0331 status = -14;
0332 }
0333
0334 if (word & FsmErrMask) {
0335 if (print)
0336 cout << "Finite State Machine Error- "
0337 << "channel: " << channel << " Error status:0x" << hex << ((word & FsmErrMask) >> 9) << dec
0338 << " ";
0339 status = -13;
0340 }
0341
0342 fedChannel = channel;
0343
0344 } else if ((word & errorMask) == fifoError) {
0345 if (print) {
0346 if (word & Fif2NFMask)
0347 cout << "A fifo 2 is Nearly full- ";
0348 if (word & TrigNFMask)
0349 cout << "The trigger fifo is nearly Full - ";
0350 if (word & ChnFifMask)
0351 cout << "fifo-1 is nearly full for channel" << (word & ChnFifMask);
0352
0353 status = -16;
0354 }
0355
0356 } else {
0357 cout << " Unknown error?"
0358 << " : ";
0359 cout << " for FED " << fed << " Word " << hex << word << dec << endl;
0360 }
0361
0362 if (print && status < 0)
0363 cout << " FED " << fed << " status " << status << endl;
0364 return status;
0365 }
0366
0367 int MyDecode::data(int word, int &fedChannel, int fed, int &stat1, int &stat2, bool print) {
0368
0369 const unsigned int plsmsk = 0xff;
0370 const unsigned int pxlmsk = 0xff00;
0371 const unsigned int dclmsk = 0x1f0000;
0372 const unsigned int rocmsk = 0x3e00000;
0373 const unsigned int chnlmsk = 0xfc000000;
0374 int status = 0;
0375
0376 int roc = ((word & rocmsk) >> 21);
0377
0378 if (roc > 0 && roc < 25) {
0379
0380 int channel = ((word & chnlmsk) >> 26);
0381
0382 if (channel > 0 && channel < 37) {
0383
0384 int dcol = (word & dclmsk) >> 16;
0385 int pix = (word & pxlmsk) >> 8;
0386 int adc = (word & plsmsk);
0387 fedChannel = channel;
0388
0389 int col = convertToCol(dcol, pix);
0390 int row = convertToRow(pix);
0391
0392
0393 if (print)
0394 cout << " Fed " << fed << " Channel- " << channel << " ROC- " << (roc - 1) << " DCOL- " << dcol << " Pixel- "
0395 << pix << " (" << col << "," << row << ") ADC- " << adc << endl;
0396 status++;
0397
0398 if (CHECK_PIXELS) {
0399
0400 if ((fed > 31 && roc > 24) || (fed <= 31 && roc > 16)) {
0401
0402 cout << " Fed " << fed << " wrong roc number chan/roc/dcol/pix/adc = " << channel << "/" << roc - 1 << "/"
0403 << dcol << "/" << pix << "/" << adc << endl;
0404 status = -4;
0405
0406 } else if (fed <= 31 && channel <= 24 && roc > 8) {
0407
0408
0409
0410 if (!((fed == 13 && channel == 17) || (fed == 15 && channel == 5) || (fed == 31 && channel == 10) ||
0411 (fed == 27 && channel == 15))) {
0412
0413 cout << " Fed " << fed << " wrong roc number, chan/roc/dcol/pix/adc = " << channel << "/" << roc - 1 << "/"
0414 << dcol << "/" << pix << "/" << adc << endl;
0415 status = -4;
0416 }
0417 }
0418
0419
0420 if (pix == 0) {
0421
0422 if (printErrors)
0423 cout << " Fed " << fed << " pix=0 chan/roc/dcol/pix/adc = " << channel << "/" << roc - 1 << "/" << dcol
0424 << "/" << pix << "/" << adc << " (" << col << "," << row << ")" << endl;
0425 count0++;
0426 stat1 = roc - 1;
0427 stat2 = count0;
0428 status = -5;
0429
0430 } else if (fed == fed0 && channel == chan0 && roc == roc0 && dcol == dcol0 && pix == pix0) {
0431
0432
0433 count0++;
0434 if (printErrors)
0435 cout << " Fed "
0436 << fed
0437
0438 << " double pixel chan/roc/dcol/pix/adc = " << channel << "/" << roc - 1 << "/" << dcol << "/" << pix
0439 << "/" << adc << " (" << col << "," << row << ") " << count0 << endl;
0440 stat1 = roc - 1;
0441 stat2 = count0;
0442 status = -6;
0443
0444 } else {
0445
0446 count0 = 0;
0447
0448 fed0 = fed;
0449 chan0 = channel;
0450 roc0 = roc;
0451 dcol0 = dcol;
0452 pix0 = pix;
0453
0454
0455 if (pix < 2 || pix > 161) {
0456 if (printErrors)
0457 cout << " Fed " << fed << " wrong pix number chan/roc/dcol/pix/adc = " << channel << "/" << roc - 1 << "/"
0458 << dcol << "/" << pix << "/" << adc << " (" << col << "," << row << ")" << endl;
0459 status = -3;
0460 }
0461
0462 if (dcol < 0 || dcol > 25) {
0463 if (printErrors)
0464 cout << " Fed " << fed << " wrong dcol number chan/roc/dcol/pix/adc = " << channel << "/" << roc - 1
0465 << "/" << dcol << "/" << pix << "/" << adc << " (" << col << "," << row << ")" << endl;
0466 status = -3;
0467 }
0468
0469 }
0470
0471
0472 if (pix < 2 || pix > 161 || dcol < 0 || dcol > 25) {
0473 countDecodeErrors2++;
0474 if (pix < 2 || pix > 161)
0475 countDecodeErrors1++;
0476 if (dcol < 0 || dcol > 25)
0477 countDecodeErrors1++;
0478
0479
0480 }
0481
0482 }
0483
0484 } else {
0485
0486 cout << " Wrong channel " << channel << " : ";
0487 cout << " for FED " << fed << " Word " << hex << word << dec << endl;
0488 return -2;
0489 }
0490
0491 } else if (roc == 25) {
0492 unsigned int channel = ((word & chnlmsk) >> 26);
0493 cout << "Wrong roc 25 "
0494 << " in fed/chan " << fed << "/" << channel << endl;
0495 status = -4;
0496
0497 } else {
0498
0499
0500 status = error(word, fedChannel, fed, stat1, stat2, print);
0501 }
0502
0503 return status;
0504 }
0505
0506
0507 class SiPixelRawDumper : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0508 public:
0509
0510 explicit SiPixelRawDumper(const edm::ParameterSet &cfg);
0511
0512
0513
0514
0515
0516 virtual ~SiPixelRawDumper() = default;
0517
0518 void beginJob();
0519
0520
0521 void endJob();
0522
0523
0524 virtual void analyze(const edm::Event &, const edm::EventSetup &);
0525
0526 private:
0527 edm::ParameterSet theConfig;
0528 edm::EDGetTokenT<FEDRawDataCollection> rawData;
0529
0530 int printLocal;
0531 double printThreshold;
0532 int countEvents, countAllEvents;
0533 int countTotErrors;
0534 float sumPixels, sumFedSize, sumFedPixels[40];
0535 int fedErrors[40][36];
0536 int fedErrorsENE[40][36];
0537 int fedErrorsTime[40][36];
0538 int fedErrorsOver[40][36];
0539 int decodeErrors[40][36];
0540 int decodeErrors000[40][36];
0541 int decodeErrorsDouble[40][36];
0542 int errorType[20];
0543
0544 #ifdef OUTFILE
0545 ofstream outfile;
0546 #endif
0547
0548 TH1D *hsize, *hsize0, *hsize1, *hsize2, *hsize3;
0549 #ifdef IND_FEDS
0550 TH1D *hsizeFeds[40];
0551 #endif
0552 TH1D *hpixels, *hpixels0, *hpixels1, *hpixels2, *hpixels3, *hpixels4;
0553 TH1D *htotPixels, *htotPixels0, *htotPixels1;
0554 TH1D *herrors, *htotErrors;
0555 TH1D *herrorType1, *herrorType1Fed, *herrorType1Chan, *herrorType2, *herrorType2Fed, *herrorType2Chan;
0556 TH1D *hcountDouble, *hcount000, *hrocDouble, *hroc000;
0557
0558 TH2F *hfed2DErrorsType1, *hfed2DErrorsType2;
0559 TH2F *hfed2DErrors1, *hfed2DErrors2, *hfed2DErrors3, *hfed2DErrors4, *hfed2DErrors5, *hfed2DErrors6, *hfed2DErrors7,
0560 *hfed2DErrors8, *hfed2DErrors9, *hfed2DErrors10, *hfed2DErrors11, *hfed2DErrors12, *hfed2DErrors13,
0561 *hfed2DErrors14, *hfed2DErrors15, *hfed2DErrors16;
0562 TH2F *hfed2d, *hsize2d, *hfedErrorType1ls, *hfedErrorType2ls, *hcountDouble2, *hcount0002;
0563 TH2F *hfed2DErrors1ls, *hfed2DErrors2ls, *hfed2DErrors3ls, *hfed2DErrors4ls, *hfed2DErrors5ls, *hfed2DErrors6ls,
0564 *hfed2DErrors7ls, *hfed2DErrors8ls, *hfed2DErrors9ls, *hfed2DErrors10ls, *hfed2DErrors11ls, *hfed2DErrors12ls,
0565 *hfed2DErrors13ls, *hfed2DErrors14ls, *hfed2DErrors15ls, *hfed2DErrors16ls;
0566
0567 TH1D *hevent, *hlumi, *horbit, *hbx, *hlumi0, *hbx0;
0568
0569 TProfile *htotPixelsls, *hsizels, *herrorType1ls, *herrorType2ls, *havsizels, *htotPixelsbx, *herrorType1bx,
0570 *herrorType2bx, *havsizebx, *hsizep;
0571 TProfile *herror1ls, *herror2ls, *herror3ls, *herror4ls, *herror5ls, *herror6ls, *herror7ls, *herror8ls, *herror9ls,
0572 *herror10ls, *herror11ls, *herror12ls, *herror13ls, *herror14ls, *herror15ls, *herror16ls;
0573 TProfile2D *hfedchannelsize;
0574 TH1D *herrorTimels, *herrorOverls, *herrorTimels1, *herrorOverls1, *herrorTimels2, *herrorOverls2, *herrorTimels3,
0575 *herrorOverls3, *herrorTimels0, *herrorOverls0;
0576 TH1D *hfedchannelsizeb, *hfedchannelsizeb1, *hfedchannelsizeb2, *hfedchannelsizeb3, *hfedchannelsizef;
0577 };
0578
0579 SiPixelRawDumper::SiPixelRawDumper(const edm::ParameterSet &cfg) : theConfig(cfg) {
0580 string label = theConfig.getUntrackedParameter<std::string>("InputLabel", "source");
0581
0582 rawData = consumes<FEDRawDataCollection>(label);
0583 usesResource(TFileService::kSharedResource);
0584 }
0585
0586 void SiPixelRawDumper::endJob() {
0587 string errorName[18] = {" ",
0588 " ",
0589 "wrong channel",
0590 "wrong pix or dcol",
0591 "wrong roc",
0592 "pix=0",
0593 " double-pix",
0594 " ",
0595 " ",
0596 " ",
0597 "timeout",
0598 "ENE",
0599 "NOR",
0600 "FSM",
0601 "overflow",
0602 "trailer",
0603 "fifo",
0604 "reset/resync"};
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620 if (countEvents > 0) {
0621 sumPixels /= float(countEvents);
0622 sumFedSize /= float(countAllEvents);
0623 for (int i = 0; i < 40; ++i) {
0624 sumFedPixels[i] /= float(countEvents);
0625 hpixels4->Fill(float(i), sumFedPixels[i]);
0626 }
0627 }
0628
0629 cout << " Total/non-empty events " << countAllEvents << " / " << countEvents << " average number of pixels "
0630 << sumPixels << endl;
0631
0632 cout << " Average Fed size per event for all events (in 4-words) " << (sumFedSize * 2. / 40.)
0633 << " total for all feds " << (sumFedSize * 2.) << endl;
0634
0635 cout << " Size for ech FED per event in units of hit pixels:" << endl;
0636
0637 for (int i = 0; i < 40; ++i)
0638 cout << sumFedPixels[i] << " ";
0639 cout << endl;
0640
0641 cout << " Total number of errors " << countTotErrors << " print threshold " << int(countEvents * printThreshold)
0642 << " total errors per fed channel" << endl;
0643 cout << " FED errors " << endl << "Fed Channel Tot-Errors ENE-Errors Time-Errors Over-Errors" << endl;
0644
0645 for (int i = 0; i < 40; ++i) {
0646 for (int j = 0; j < 36; ++j)
0647 if ((fedErrors[i][j]) > int(countEvents * printThreshold) || (fedErrorsENE[i][j] > 0)) {
0648 cout << " " << i << " - " << (j + 1) << " - " << fedErrors[i][j] << " - " << fedErrorsENE[i][j] << " - "
0649 << fedErrorsTime[i][j] << " - " << fedErrorsOver[i][j] << endl;
0650 }
0651 }
0652 cout << " Decode errors " << endl << "Fed Channel Errors Pix_000 Double_Pix" << endl;
0653 for (int i = 0; i < 40; ++i) {
0654 for (int j = 0; j < 36; ++j) {
0655 int tmp = decodeErrors[i][j] + decodeErrors000[i][j] + decodeErrorsDouble[i][j];
0656 if (tmp > 10)
0657 cout << " " << i << " - " << (j + 1) << " - " << decodeErrors[i][j] << " - " << decodeErrors000[i][j]
0658 << " - " << decodeErrorsDouble[i][j] << endl;
0659 }
0660 }
0661
0662 cout << " Total errors for all feds " << endl << " Type Name Num-Of-Errors" << endl;
0663 for (int i = 0; i < 20; ++i) {
0664 if (errorType[i] > 0)
0665 cout << " " << i << " - " << errorName[i] << " - " << errorType[i] << endl;
0666 }
0667
0668 cout << " Test decode errors " << countDecodeErrors1 << " " << countDecodeErrors2 << endl;
0669
0670 #ifdef OUTFILE
0671 outfile.close();
0672 #endif
0673 }
0674
0675 void SiPixelRawDumper::beginJob() {
0676 printLocal = theConfig.getUntrackedParameter<int>("Verbosity", 1);
0677
0678 printThreshold = theConfig.getUntrackedParameter<double>("PrintThreshold", 0.001);
0679 cout << " beginjob " << printLocal << " " << printThreshold << endl;
0680
0681 if (printLocal > 0)
0682 printErrors = true;
0683 else
0684 printErrors = false;
0685 if (printLocal > 1)
0686 printData = true;
0687 else
0688 printData = false;
0689 if (printLocal > 2)
0690 printHeaders = true;
0691 else
0692 printHeaders = false;
0693
0694 countEvents = 0;
0695 countAllEvents = 0;
0696 countTotErrors = 0;
0697 sumPixels = 0.;
0698 sumFedSize = 0;
0699 for (int i = 0; i < 40; ++i) {
0700 sumFedPixels[i] = 0;
0701 for (int j = 0; j < 36; ++j) {
0702 fedErrors[i][j] = 0;
0703 fedErrorsENE[i][j] = 0;
0704 fedErrorsTime[i][j] = 0;
0705 fedErrorsOver[i][j] = 0;
0706 }
0707 for (int j = 0; j < 36; ++j) {
0708 decodeErrors[i][j] = 0;
0709 decodeErrors000[i][j] = 0;
0710 decodeErrorsDouble[i][j] = 0;
0711 }
0712 }
0713 for (int i = 0; i < 20; ++i)
0714 errorType[i] = 0;
0715
0716 edm::Service<TFileService> fs;
0717
0718
0719
0720
0721
0722 const float pixMax = 19999.5;
0723 const float totMax = 399999.5;
0724 const float maxLink = 1000.;
0725
0726 hsize = fs->make<TH1D>("hsize", "FED event size in words-4", 6000, -0.5, pixMax);
0727 hsize0 = fs->make<TH1D>("hsize0", "FED event size in words-4", 2000, -0.5, 19999.5);
0728 hsize1 = fs->make<TH1D>("hsize1", "bpix FED event size in words-4", 6000, -0.5, pixMax);
0729 hsize2 = fs->make<TH1D>("hsize2", "fpix FED event size in words-4", 6000, -0.5, pixMax);
0730 hsize3 = fs->make<TH1D>("hsize3", "ave bpix FED event size in words-4", 6000, -0.5, pixMax);
0731
0732 hpixels = fs->make<TH1D>("hpixels", "pixels per FED", 2000, -0.5, 19999.5);
0733 hpixels0 = fs->make<TH1D>("hpixels0", "pixels per FED", 6000, -0.5, pixMax);
0734 hpixels1 = fs->make<TH1D>("hpixels1", "pixels >0 per FED", 6000, -0.5, pixMax);
0735 hpixels2 = fs->make<TH1D>("hpixels2", "pixels >0 per BPix FED", 6000, -0.5, pixMax);
0736 hpixels3 = fs->make<TH1D>("hpixels3", "pixels >0 per Fpix FED", 6000, -0.5, pixMax);
0737 hpixels4 = fs->make<TH1D>("hpixels4", "pixels per each FED", 40, -0.5, 39.5);
0738
0739 htotPixels = fs->make<TH1D>("htotPixels", "pixels per event", 10000, -0.5, totMax);
0740 htotPixels0 = fs->make<TH1D>("htotPixels0", "pixels per event, zoom low region", 20000, -0.5, 19999.5);
0741 htotPixels1 = fs->make<TH1D>("htotPixels1", "pixels >0 per event", 10000, -0.5, totMax);
0742
0743 herrors = fs->make<TH1D>("herrors", "errors per FED", 100, -0.5, 99.5);
0744 htotErrors = fs->make<TH1D>("htotErrors", "errors per event", 1000, -0.5, 999.5);
0745
0746 herrorType1 = fs->make<TH1D>("herrorType1", "errors 1 per type", 20, -0.5, 19.5);
0747 herrorType1Fed = fs->make<TH1D>("herrorType1Fed", "errors 1 per FED", 40, -0.5, 39.5);
0748 herrorType1Chan = fs->make<TH1D>("herrorType1Chan", "errors 1 per chan", 37, -0.5, 36.5);
0749 herrorType2 = fs->make<TH1D>("herrorType2", "readout errors 2 per type", 20, -0.5, 19.5);
0750 herrorType2Fed = fs->make<TH1D>("herrorType2Fed", "readout errors 2 per FED", 40, -0.5, 39.5);
0751 herrorType2Chan = fs->make<TH1D>("herrorType2Chan", "readout errors 2 per chan", 37, -0.5, 36.5);
0752
0753 hcountDouble = fs->make<TH1D>("hcountDouble", "count double pixels", 100, -0.5, 99.5);
0754 hcountDouble2 = fs->make<TH2F>("hcountDouble2", "count double pixels", 40, -0.5, 39.5, 10, 0., 10.);
0755 hcount000 = fs->make<TH1D>("hcount000", "count 000 pixels", 100, -0.5, 99.5);
0756 hcount0002 = fs->make<TH2F>("hcount0002", "count 000 pixels", 40, -0.5, 39.5, 10, 0., 10.);
0757 hrocDouble = fs->make<TH1D>("hrocDouble", "double pixels rocs", 25, -0.5, 24.5);
0758 hroc000 = fs->make<TH1D>("hroc000", "000 pixels rocs", 25, -0.5, 24.5);
0759
0760 hfed2d = fs->make<TH2F>("hfed2d", "errors", 40, -0.5, 39.5, 21, -0.5, 20.5);
0761
0762 hsize2d = fs->make<TH2F>("hsize2d", "size vs fed", 40, -0.5, 39.5, 50, 0, 500);
0763 hsizep = fs->make<TProfile>("hsizep", "size vs fed", 40, -0.5, 39.5, 0, 100000);
0764
0765
0766 #ifdef IND_FEDS
0767 hsizeFeds[0] = fs->make<TH1D>("hsizeFed0", "FED 0 event size ", 1000, -0.5, pixMax);
0768 hsizeFeds[1] = fs->make<TH1D>("hsizeFed1", "FED 1 event size ", 1000, -0.5, pixMax);
0769 hsizeFeds[2] = fs->make<TH1D>("hsizeFed2", "FED 2 event size ", 1000, -0.5, pixMax);
0770 hsizeFeds[3] = fs->make<TH1D>("hsizeFed3", "FED 3 event size ", 1000, -0.5, pixMax);
0771 hsizeFeds[4] = fs->make<TH1D>("hsizeFed4", "FED 4 event size ", 1000, -0.5, pixMax);
0772 hsizeFeds[5] = fs->make<TH1D>("hsizeFed5", "FED 5 event size ", 1000, -0.5, pixMax);
0773 hsizeFeds[6] = fs->make<TH1D>("hsizeFed6", "FED 6 event size ", 1000, -0.5, pixMax);
0774 hsizeFeds[7] = fs->make<TH1D>("hsizeFed7", "FED 7 event size ", 1000, -0.5, pixMax);
0775 hsizeFeds[8] = fs->make<TH1D>("hsizeFed8", "FED 8 event size ", 1000, -0.5, pixMax);
0776 hsizeFeds[9] = fs->make<TH1D>("hsizeFed9", "FED 9 event size ", 1000, -0.5, pixMax);
0777 hsizeFeds[10] = fs->make<TH1D>("hsizeFed10", "FED 10 event size ", 1000, -0.5, pixMax);
0778 hsizeFeds[11] = fs->make<TH1D>("hsizeFed11", "FED 11 event size ", 1000, -0.5, pixMax);
0779 hsizeFeds[12] = fs->make<TH1D>("hsizeFed12", "FED 12 event size ", 1000, -0.5, pixMax);
0780 hsizeFeds[13] = fs->make<TH1D>("hsizeFed13", "FED 13 event size ", 1000, -0.5, pixMax);
0781 hsizeFeds[14] = fs->make<TH1D>("hsizeFed14", "FED 14 event size ", 1000, -0.5, pixMax);
0782 hsizeFeds[15] = fs->make<TH1D>("hsizeFed15", "FED 15 event size ", 1000, -0.5, pixMax);
0783 hsizeFeds[16] = fs->make<TH1D>("hsizeFed16", "FED 16 event size ", 1000, -0.5, pixMax);
0784 hsizeFeds[17] = fs->make<TH1D>("hsizeFed17", "FED 17 event size ", 1000, -0.5, pixMax);
0785 hsizeFeds[18] = fs->make<TH1D>("hsizeFed18", "FED 18 event size ", 1000, -0.5, pixMax);
0786 hsizeFeds[19] = fs->make<TH1D>("hsizeFed19", "FED 19 event size ", 1000, -0.5, pixMax);
0787 hsizeFeds[20] = fs->make<TH1D>("hsizeFed20", "FED 20 event size ", 1000, -0.5, pixMax);
0788 hsizeFeds[21] = fs->make<TH1D>("hsizeFed21", "FED 21 event size ", 1000, -0.5, pixMax);
0789 hsizeFeds[22] = fs->make<TH1D>("hsizeFed22", "FED 22 event size ", 1000, -0.5, pixMax);
0790 hsizeFeds[23] = fs->make<TH1D>("hsizeFed23", "FED 23 event size ", 1000, -0.5, pixMax);
0791 hsizeFeds[24] = fs->make<TH1D>("hsizeFed24", "FED 24 event size ", 1000, -0.5, pixMax);
0792 hsizeFeds[25] = fs->make<TH1D>("hsizeFed25", "FED 25 event size ", 1000, -0.5, pixMax);
0793 hsizeFeds[26] = fs->make<TH1D>("hsizeFed26", "FED 26 event size ", 1000, -0.5, pixMax);
0794 hsizeFeds[27] = fs->make<TH1D>("hsizeFed27", "FED 27 event size ", 1000, -0.5, pixMax);
0795 hsizeFeds[28] = fs->make<TH1D>("hsizeFed28", "FED 28 event size ", 1000, -0.5, pixMax);
0796 hsizeFeds[29] = fs->make<TH1D>("hsizeFed29", "FED 29 event size ", 1000, -0.5, pixMax);
0797 hsizeFeds[30] = fs->make<TH1D>("hsizeFed30", "FED 30 event size ", 1000, -0.5, pixMax);
0798 hsizeFeds[31] = fs->make<TH1D>("hsizeFed31", "FED 31 event size ", 1000, -0.5, pixMax);
0799 hsizeFeds[32] = fs->make<TH1D>("hsizeFed32", "FED 32 event size ", 1000, -0.5, pixMax);
0800 hsizeFeds[33] = fs->make<TH1D>("hsizeFed33", "FED 33 event size ", 1000, -0.5, pixMax);
0801 hsizeFeds[34] = fs->make<TH1D>("hsizeFed34", "FED 34 event size ", 1000, -0.5, pixMax);
0802 hsizeFeds[35] = fs->make<TH1D>("hsizeFed35", "FED 35 event size ", 1000, -0.5, pixMax);
0803 hsizeFeds[36] = fs->make<TH1D>("hsizeFed36", "FED 36 event size ", 1000, -0.5, pixMax);
0804 hsizeFeds[37] = fs->make<TH1D>("hsizeFed37", "FED 37 event size ", 1000, -0.5, pixMax);
0805 hsizeFeds[38] = fs->make<TH1D>("hsizeFed38", "FED 38 event size ", 1000, -0.5, pixMax);
0806 hsizeFeds[39] = fs->make<TH1D>("hsizeFed39", "FED 39 event size ", 1000, -0.5, pixMax);
0807 #endif
0808
0809 hevent = fs->make<TH1D>("hevent", "event", 1000, 0, 10000000.);
0810
0811 hlumi = fs->make<TH1D>("hlumi", "lumi", 3000, 0, 3000.);
0812 hlumi0 = fs->make<TH1D>("hlumi0", "lumi", 3000, 0, 3000.);
0813
0814 hbx = fs->make<TH1D>("hbx", "bx", 4000, 0, 4000.);
0815 hbx0 = fs->make<TH1D>("hbx0", "bx", 4000, 0, 4000.);
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830 herrorTimels = fs->make<TH1D>("herrorTimels", "timeouts vs ls", 1000, 0, 3000);
0831 herrorOverls = fs->make<TH1D>("herrorOverls", "overflows vs ls", 1000, 0, 3000);
0832 herrorTimels1 = fs->make<TH1D>("herrorTimels1", "timeouts vs ls", 1000, 0, 3000);
0833 herrorOverls1 = fs->make<TH1D>("herrorOverls1", "overflows vs ls", 1000, 0, 3000);
0834 herrorTimels2 = fs->make<TH1D>("herrorTimels2", "timeouts vs ls", 1000, 0, 3000);
0835 herrorOverls2 = fs->make<TH1D>("herrorOverls2", "overflows vs ls", 1000, 0, 3000);
0836 herrorTimels3 = fs->make<TH1D>("herrorTimels3", "timeouts vs ls", 1000, 0, 3000);
0837 herrorOverls3 = fs->make<TH1D>("herrorOverls3", "overflows vs ls", 1000, 0, 3000);
0838 herrorTimels0 = fs->make<TH1D>("herrorTimels0", "timeouts vs ls", 1000, 0, 3000);
0839 herrorOverls0 = fs->make<TH1D>("herrorOverls0", "overflows vs ls", 1000, 0, 3000);
0840
0841 hfed2DErrorsType1 = fs->make<TH2F>("hfed2DErrorsType1", "errors type 1 per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0842 hfed2DErrorsType2 = fs->make<TH2F>("hfed2DErrorsType2", "errors type 2 per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0843
0844 hfed2DErrors1 = fs->make<TH2F>("hfed2DErrors1", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0845
0846 hfed2DErrors3 = fs->make<TH2F>("hfed2DErrors3", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0847 hfed2DErrors4 = fs->make<TH2F>("hfed2DErrors4", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0848 hfed2DErrors5 = fs->make<TH2F>("hfed2DErrors5", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0849 hfed2DErrors6 = fs->make<TH2F>("hfed2DErrors6", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0850
0851
0852
0853 hfed2DErrors10 = fs->make<TH2F>("hfed2DErrors10", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0854 hfed2DErrors11 = fs->make<TH2F>("hfed2DErrors11", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0855 hfed2DErrors12 = fs->make<TH2F>("hfed2DErrors12", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0856 hfed2DErrors13 = fs->make<TH2F>("hfed2DErrors13", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0857 hfed2DErrors14 = fs->make<TH2F>("hfed2DErrors14", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0858 hfed2DErrors15 = fs->make<TH2F>("hfed2DErrors15", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0859 hfed2DErrors16 = fs->make<TH2F>("hfed2DErrors16", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0860
0861 hfedErrorType1ls = fs->make<TH2F>("hfedErrorType1ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0862 hfedErrorType2ls = fs->make<TH2F>("hfedErrorType2ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0863
0864 hfed2DErrors1ls = fs->make<TH2F>("hfed2DErrors1ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0865
0866 hfed2DErrors3ls = fs->make<TH2F>("hfed2DErrors3ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0867 hfed2DErrors4ls = fs->make<TH2F>("hfed2DErrors4ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0868 hfed2DErrors5ls = fs->make<TH2F>("hfed2DErrors5ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0869 hfed2DErrors6ls = fs->make<TH2F>("hfed2DErrors6ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0870
0871
0872
0873 hfed2DErrors10ls = fs->make<TH2F>("hfed2DErrors10ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0874 hfed2DErrors11ls = fs->make<TH2F>("hfed2DErrors11ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0875 hfed2DErrors12ls = fs->make<TH2F>("hfed2DErrors12ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0876 hfed2DErrors13ls = fs->make<TH2F>("hfed2DErrors13ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0877 hfed2DErrors14ls = fs->make<TH2F>("hfed2DErrors14ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0878 hfed2DErrors15ls = fs->make<TH2F>("hfed2DErrors15ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0879 hfed2DErrors16ls = fs->make<TH2F>("hfed2DErrors16ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0880
0881 herrorTimels = fs->make<TH1D>("herrorTimels", "timeouts vs ls", 1000, 0, 3000);
0882 herrorOverls = fs->make<TH1D>("herrorOverls", "overflows vs ls", 1000, 0, 3000);
0883 herrorTimels1 = fs->make<TH1D>("herrorTimels1", "timeouts vs ls", 1000, 0, 3000);
0884 herrorOverls1 = fs->make<TH1D>("herrorOverls1", "overflows vs ls", 1000, 0, 3000);
0885 herrorTimels2 = fs->make<TH1D>("herrorTimels2", "timeouts vs ls", 1000, 0, 3000);
0886 herrorOverls2 = fs->make<TH1D>("herrorOverls2", "overflows vs ls", 1000, 0, 3000);
0887 herrorTimels3 = fs->make<TH1D>("herrorTimels3", "timeouts vs ls", 1000, 0, 3000);
0888 herrorOverls3 = fs->make<TH1D>("herrorOverls3", "overflows vs ls", 1000, 0, 3000);
0889 herrorTimels0 = fs->make<TH1D>("herrorTimels0", "timeouts vs ls", 1000, 0, 3000);
0890 herrorOverls0 = fs->make<TH1D>("herrorOverls0", "overflows vs ls", 1000, 0, 3000);
0891
0892 hfed2DErrorsType1 = fs->make<TH2F>("hfed2DErrorsType1", "errors type 1 per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0893 hfed2DErrorsType2 = fs->make<TH2F>("hfed2DErrorsType2", "errors type 2 per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0894
0895 hfed2DErrors1 = fs->make<TH2F>("hfed2DErrors1", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0896
0897 hfed2DErrors3 = fs->make<TH2F>("hfed2DErrors3", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0898 hfed2DErrors4 = fs->make<TH2F>("hfed2DErrors4", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0899 hfed2DErrors5 = fs->make<TH2F>("hfed2DErrors5", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0900 hfed2DErrors6 = fs->make<TH2F>("hfed2DErrors6", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0901
0902
0903
0904 hfed2DErrors10 = fs->make<TH2F>("hfed2DErrors10", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0905 hfed2DErrors11 = fs->make<TH2F>("hfed2DErrors11", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0906 hfed2DErrors12 = fs->make<TH2F>("hfed2DErrors12", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0907 hfed2DErrors13 = fs->make<TH2F>("hfed2DErrors13", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0908 hfed2DErrors14 = fs->make<TH2F>("hfed2DErrors14", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0909 hfed2DErrors15 = fs->make<TH2F>("hfed2DErrors15", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0910 hfed2DErrors16 = fs->make<TH2F>("hfed2DErrors16", "errors per FED", 40, -0.5, 39.5, 37, -0.5, 36.5);
0911
0912 hfedErrorType1ls = fs->make<TH2F>("hfedErrorType1ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0913 hfedErrorType2ls = fs->make<TH2F>("hfedErrorType2ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0914
0915 hfed2DErrors1ls = fs->make<TH2F>("hfed2DErrors1ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0916
0917 hfed2DErrors3ls = fs->make<TH2F>("hfed2DErrors3ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0918 hfed2DErrors4ls = fs->make<TH2F>("hfed2DErrors4ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0919 hfed2DErrors5ls = fs->make<TH2F>("hfed2DErrors5ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0920 hfed2DErrors6ls = fs->make<TH2F>("hfed2DErrors6ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0921
0922
0923
0924 hfed2DErrors10ls = fs->make<TH2F>("hfed2DErrors10ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0925 hfed2DErrors11ls = fs->make<TH2F>("hfed2DErrors11ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0926 hfed2DErrors12ls = fs->make<TH2F>("hfed2DErrors12ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0927 hfed2DErrors13ls = fs->make<TH2F>("hfed2DErrors13ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0928 hfed2DErrors14ls = fs->make<TH2F>("hfed2DErrors14ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0929 hfed2DErrors15ls = fs->make<TH2F>("hfed2DErrors15ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0930 hfed2DErrors16ls = fs->make<TH2F>("hfed2DErrors16ls", "errors vs lumi", 300, 0, 3000, 40, -0.5, 39.5);
0931
0932 hsizels = fs->make<TProfile>("hsizels", " bpix fed size vs ls", 300, 0, 3000, 0, 200000.);
0933 htotPixelsls = fs->make<TProfile>("htotPixelsls", " tot pixels vs ls", 300, 0, 3000, 0, 300000.);
0934 havsizels = fs->make<TProfile>("havsizels", "av. bpix fed size vs ls", 300, 0, 3000, 0, 300000.);
0935
0936 herrorType1ls = fs->make<TProfile>("herrorType1ls", "error type 1 vs ls", 300, 0, 3000, 0, 1000.);
0937 herrorType2ls = fs->make<TProfile>("herrorType2ls", "error type 2 vs ls", 300, 0, 3000, 0, 1000.);
0938
0939 herror1ls = fs->make<TProfile>("herror1ls", "error 1 vs ls", 300, 0, 3000, 0, 1000.);
0940
0941 herror3ls = fs->make<TProfile>("herror3ls", "error 3 vs ls", 300, 0, 3000, 0, 1000.);
0942 herror4ls = fs->make<TProfile>("herror4ls", "error 4 vs ls", 300, 0, 3000, 0, 1000.);
0943 herror5ls = fs->make<TProfile>("herror5ls", "error 5 vs ls", 300, 0, 3000, 0, 1000.);
0944 herror6ls = fs->make<TProfile>("herror6ls", "error 6 vs ls", 300, 0, 3000, 0, 1000.);
0945
0946
0947
0948 herror10ls = fs->make<TProfile>("herror10ls", "error 10 vs ls", 300, 0, 3000, 0, 1000.);
0949 herror11ls = fs->make<TProfile>("herror11ls", "error 11 vs ls", 300, 0, 3000, 0, 1000.);
0950 herror12ls = fs->make<TProfile>("herror12ls", "error 12 vs ls", 300, 0, 3000, 0, 1000.);
0951 herror13ls = fs->make<TProfile>("herror13ls", "error 13 vs ls", 300, 0, 3000, 0, 1000.);
0952 herror14ls = fs->make<TProfile>("herror14ls", "error 14 vs ls", 300, 0, 3000, 0, 1000.);
0953 herror15ls = fs->make<TProfile>("herror15ls", "error 15 vs ls", 300, 0, 3000, 0, 1000.);
0954 herror16ls = fs->make<TProfile>("herror16ls", "error 16 vs ls", 300, 0, 3000, 0, 1000.);
0955
0956 htotPixelsbx = fs->make<TProfile>("htotPixelsbx", " tot pixels vs bx", 4000, -0.5, 3999.5, 0, 300000.);
0957 havsizebx = fs->make<TProfile>("havsizebx", " ave bpix fed size vs bx", 4000, -0.5, 3999.5, 0, 300000.);
0958 herrorType1bx = fs->make<TProfile>("herrorType1bx", " error type 1 vs bx", 4000, -0.5, 3999.5, 0, 300000.);
0959 herrorType2bx = fs->make<TProfile>("herrorType2bx", " error type 2 vs bx", 4000, -0.5, 3999.5, 0, 300000.);
0960
0961
0962
0963
0964 hfedchannelsize =
0965 fs->make<TProfile2D>("hfedchannelsize", "pixels per fed/channel", 40, -0.5, 39.5, 37, -0.5, 36.5, 0.0, 10000.);
0966
0967 hfedchannelsizeb = fs->make<TH1D>("hfedchannelsizeb", "pixels per bpix channel", 200, 0.0, maxLink);
0968 hfedchannelsizeb1 = fs->make<TH1D>("hfedchannelsizeb1", "pixels per bpix1 channel", 200, 0.0, maxLink);
0969 hfedchannelsizeb2 = fs->make<TH1D>("hfedchannelsizeb2", "pixels per bpix2 channel", 200, 0.0, maxLink);
0970 hfedchannelsizeb3 = fs->make<TH1D>("hfedchannelsizeb3", "pixels per bpix3 channel", 200, 0.0, maxLink);
0971 hfedchannelsizef = fs->make<TH1D>("hfedchannelsizef", "pixels per fpix channel", 200, 0.0, maxLink);
0972
0973 #ifdef OUTFILE
0974 outfile.open("pixfed.csv");
0975 for (int i = 0; i < 40; ++i) {
0976 if (i < 39)
0977 outfile << i << ",";
0978 else
0979 outfile << i << endl;
0980 }
0981 #endif
0982 }
0983
0984 void SiPixelRawDumper::analyze(const edm::Event &ev, const edm::EventSetup &es) {
0985
0986 int run = ev.id().run();
0987 int event = ev.id().event();
0988 int lumiBlock = ev.luminosityBlock();
0989 int bx = ev.bunchCrossing();
0990
0991
0992 hevent->Fill(float(event));
0993 hlumi0->Fill(float(lumiBlock));
0994 hbx0->Fill(float(bx));
0995
0996
0997 #ifdef L1
0998
0999 edm::Handle<L1GlobalTriggerReadoutRecord> L1GTRR;
1000 ev.getByLabel("gtDigis", L1GTRR);
1001
1002 if (L1GTRR.isValid()) {
1003 bool l1a = L1GTRR->decision();
1004 cout << " L1 status :" << l1a << endl;
1005 } else {
1006 cout << " NO L1 status " << endl;
1007 }
1008 #endif
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035 edm::Handle<FEDRawDataCollection> buffers;
1036
1037
1038
1039 ev.getByToken(rawData, buffers);
1040
1041 std::pair<int, int> fedIds(FEDNumbering::MINSiPixelFEDID, FEDNumbering::MAXSiPixelFEDID);
1042
1043
1044
1045
1046
1047
1048 typedef uint32_t Word32;
1049 typedef uint64_t Word64;
1050 int status = 0;
1051 int countPixels = 0;
1052 int eventId = -1;
1053 int countErrorsPerEvent = 0;
1054 int countErrorsPerEvent1 = 0;
1055 int countErrorsPerEvent2 = 0;
1056 double aveFedSize = 0.;
1057 int stat1 = -1, stat2 = -1;
1058 int fedchannelsize[36];
1059
1060 int countErrors[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1061
1062 countAllEvents++;
1063
1064 if (printHeaders || printLocal > 0)
1065 cout << "Event = " << countEvents << " Event number " << event << " Run " << run << " LS " << lumiBlock << endl;
1066
1067
1068 for (int fedId = fedIds.first; fedId <= fedIds.second; fedId++) {
1069
1070 PixelDataFormatter::Errors errors;
1071
1072
1073 const FEDRawData &rawData = buffers->FEDData(fedId);
1074
1075 if (printHeaders)
1076 cout << "Get data For FED = " << fedId << " size in bytes " << rawData.size() << endl;
1077 if (rawData.size() == 0)
1078 continue;
1079
1080 for (int i = 0; i < 36; ++i)
1081 fedchannelsize[i] = 0;
1082
1083 int nWords = rawData.size() / sizeof(Word64);
1084
1085
1086 sumFedSize += float(nWords);
1087 if (fedId < 32)
1088 aveFedSize += double(2. * nWords);
1089
1090 hsize->Fill(float(2 * nWords));
1091 hsize0->Fill(float(2 * nWords));
1092 if (fedId < 32)
1093 hsize1->Fill(float(2 * nWords));
1094 else
1095 hsize2->Fill(float(2 * nWords));
1096
1097 #ifdef IND_FEDS
1098 hsizeFeds[fedId]->Fill(float(2 * nWords));
1099 #endif
1100 hsize2d->Fill(float(fedId), float(2 * nWords));
1101 hsizep->Fill(float(fedId), float(2 * nWords));
1102 if (fedId < 32)
1103 hsizels->Fill(float(lumiBlock), float(2 * nWords));
1104
1105
1106 const Word64 *header = reinterpret_cast<const Word64 *>(rawData.data());
1107
1108
1109 unsigned int bxid = 0;
1110 eventId = MyDecode::header(*header, fedId, printHeaders, bxid);
1111
1112 if (bx != int(bxid))
1113 cout << " Inconsistent BX: from event " << bx << " from FED " << bxid << endl;
1114
1115 const Word64 *trailer = reinterpret_cast<const Word64 *>(rawData.data()) + (nWords - 1);
1116
1117 status = MyDecode::trailer(*trailer, fedId, printHeaders);
1118
1119 int countPixelsInFed = 0;
1120 int countErrorsInFed = 0;
1121 int countErrorsInFed1 = 0;
1122 int countErrorsInFed2 = 0;
1123 int fedChannel = 0;
1124 int num = 0;
1125
1126
1127 for (const Word64 *word = header + 1; word != trailer; word++) {
1128 static const Word64 WORD32_mask = 0xffffffff;
1129
1130 for (int ipart = 0; ipart < 2; ++ipart) {
1131 Word32 w = 0;
1132 if (ipart == 0) {
1133 w = *word & WORD32_mask;
1134
1135 } else if (ipart == 1) {
1136 w = *word >> 32 & WORD32_mask;
1137 }
1138
1139 num++;
1140 if (printLocal > 3)
1141 cout << " " << num << " " << hex << w << dec << endl;
1142
1143 status = MyDecode::data(w, fedChannel, fedId, stat1, stat2, printData);
1144 int layer = MyDecode::checkLayerLink(fedId, fedChannel);
1145 if (layer > 10)
1146 layer = layer - 10;
1147 if (status > 0) {
1148 countPixels++;
1149 countPixelsInFed++;
1150 fedchannelsize[fedChannel - 1]++;
1151
1152 } else if (status < 0) {
1153 countErrorsInFed++;
1154
1155 if (printErrors)
1156 cout << " Bad stats for FED " << fedId << " Event " << eventId << "/" << countAllEvents << " chan "
1157 << fedChannel << " status " << status << endl;
1158 status = abs(status);
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173 switch (status) {
1174 case (10): {
1175
1176 countErrors[10]++;
1177 fedErrorsTime[fedId][(fedChannel - 1)]++;
1178 hfed2DErrors10->Fill(float(fedId), float(fedChannel));
1179 hfed2DErrors10ls->Fill(float(lumiBlock), float(fedId));
1180
1181 herrorTimels->Fill(float(lumiBlock));
1182 if (layer == 1)
1183 herrorTimels1->Fill(float(lumiBlock));
1184 else if (layer == 2)
1185 herrorTimels2->Fill(float(lumiBlock));
1186 else if (layer == 3)
1187 herrorTimels3->Fill(float(lumiBlock));
1188 else if (layer == 0)
1189 herrorTimels0->Fill(float(lumiBlock));
1190
1191
1192 break;
1193 }
1194
1195 case (14): {
1196
1197 countErrors[14]++;
1198 fedErrorsOver[fedId][(fedChannel - 1)]++;
1199 hfed2DErrors14->Fill(float(fedId), float(fedChannel));
1200 hfed2DErrors14ls->Fill(float(lumiBlock), float(fedId));
1201
1202 herrorOverls->Fill(float(lumiBlock));
1203 if (layer == 1)
1204 herrorOverls1->Fill(float(lumiBlock));
1205 else if (layer == 2)
1206 herrorOverls2->Fill(float(lumiBlock));
1207 else if (layer == 3)
1208 herrorOverls3->Fill(float(lumiBlock));
1209 else if (layer == 0)
1210 herrorOverls0->Fill(float(lumiBlock));
1211
1212 break;
1213 }
1214
1215 case (11): {
1216
1217 countErrors[11]++;
1218 hfed2DErrors11->Fill(float(fedId), float(fedChannel));
1219 hfed2DErrors11ls->Fill(float(lumiBlock), float(fedId));
1220
1221 fedErrorsENE[fedId][(fedChannel - 1)]++;
1222 break;
1223 }
1224
1225 case (16): {
1226
1227 countErrors[16]++;
1228 hfed2DErrors16->Fill(float(fedId), float(fedChannel));
1229 hfed2DErrors16ls->Fill(float(lumiBlock), float(fedId));
1230 break;
1231 }
1232
1233 case (12): {
1234
1235 countErrors[12]++;
1236 hfed2DErrors12->Fill(float(fedId), float(fedChannel));
1237 hfed2DErrors12ls->Fill(float(lumiBlock), float(fedId));
1238
1239 break;
1240 }
1241
1242 case (15): {
1243
1244 countErrors[15]++;
1245 hfed2DErrors15->Fill(float(fedId), float(fedChannel));
1246 hfed2DErrors15ls->Fill(float(lumiBlock), float(fedId));
1247 break;
1248 }
1249
1250 case (13): {
1251
1252 countErrors[13]++;
1253 hfed2DErrors13->Fill(float(fedId), float(fedChannel));
1254 hfed2DErrors13ls->Fill(float(lumiBlock), float(fedId));
1255 break;
1256 }
1257
1258 case (3): {
1259
1260 countErrors[3]++;
1261 hfed2DErrors3->Fill(float(fedId), float(fedChannel));
1262 hfed2DErrors3ls->Fill(float(lumiBlock), float(fedId));
1263
1264 break;
1265 }
1266
1267 case (4): {
1268 countErrors[4]++;
1269 hfed2DErrors4->Fill(float(fedId), float(fedChannel));
1270 hfed2DErrors4ls->Fill(float(lumiBlock), float(fedId));
1271
1272 break;
1273 }
1274
1275 case (5): {
1276 countErrors[5]++;
1277 hfed2DErrors5->Fill(float(fedId), float(fedChannel));
1278 hfed2DErrors5ls->Fill(float(lumiBlock), float(fedId));
1279
1280
1281 hroc000->Fill(float(stat1));
1282 hcount000->Fill(float(stat2));
1283 hcount0002->Fill(float(fedId), float(stat2));
1284 break;
1285 }
1286
1287 case (6): {
1288
1289 countErrors[6]++;
1290 hfed2DErrors6->Fill(float(fedId), float(fedChannel));
1291 hfed2DErrors6ls->Fill(float(lumiBlock), float(fedId));
1292
1293
1294 hrocDouble->Fill(float(stat1));
1295 hcountDouble->Fill(float(stat2));
1296 hcountDouble2->Fill(float(fedId), float(stat2));
1297 break;
1298 }
1299
1300 case (1): {
1301 countErrors[1]++;
1302 hfed2DErrors1->Fill(float(fedId), float(fedChannel));
1303 hfed2DErrors1ls->Fill(float(lumiBlock), float(fedId));
1304 break;
1305 }
1306
1307 }
1308
1309 if (status < 20)
1310 errorType[status]++;
1311
1312
1313
1314
1315
1316 hfed2d->Fill(float(fedId), float(status));
1317
1318 if (status >= 10) {
1319
1320
1321 countErrorsInFed1++;
1322 hfedErrorType1ls->Fill(float(lumiBlock), float(fedId));
1323 hfed2DErrorsType1->Fill(float(fedId), float(fedChannel));
1324
1325 herrorType1->Fill(float(status));
1326 herrorType1Fed->Fill(float(fedId));
1327 herrorType1Chan->Fill(float(fedChannel));
1328
1329 fedErrors[fedId][(fedChannel - 1)]++;
1330
1331 } else if (status > 0) {
1332
1333
1334 countErrorsInFed2++;
1335 hfedErrorType2ls->Fill(float(lumiBlock), float(fedId));
1336 hfed2DErrorsType2->Fill(float(fedId), float(fedChannel));
1337
1338 herrorType2->Fill(float(status));
1339 herrorType2Fed->Fill(float(fedId));
1340 herrorType2Chan->Fill(float(fedChannel));
1341
1342 if (status == 5)
1343 decodeErrors000[fedId][(fedChannel - 1)]++;
1344 else if (status == 6)
1345 decodeErrorsDouble[fedId][(fedChannel - 1)]++;
1346 else
1347 decodeErrors[fedId][(fedChannel - 1)]++;
1348 }
1349 }
1350 }
1351
1352 }
1353
1354 countTotErrors += countErrorsInFed;
1355 countErrorsPerEvent += countErrorsInFed;
1356 countErrorsPerEvent1 += countErrorsInFed1;
1357 countErrorsPerEvent2 += countErrorsInFed2;
1358
1359
1360
1361
1362
1363 if (countPixelsInFed > 0) {
1364 sumFedPixels[fedId] += countPixelsInFed;
1365 }
1366
1367 hpixels->Fill(float(countPixelsInFed));
1368 hpixels0->Fill(float(countPixelsInFed));
1369 if (countPixelsInFed > 0)
1370 hpixels1->Fill(float(countPixelsInFed));
1371 if (countPixelsInFed > 0 && fedId < 32)
1372 hpixels2->Fill(float(countPixelsInFed));
1373 if (countPixelsInFed > 0 && fedId >= 32)
1374 hpixels3->Fill(float(countPixelsInFed));
1375 herrors->Fill(float(countErrorsInFed));
1376
1377 for (int i = 0; i < 36; ++i) {
1378 hfedchannelsize->Fill(float(fedId), float(i + 1), float(fedchannelsize[i]));
1379 if (fedId < 32) {
1380 hfedchannelsizeb->Fill(float(fedchannelsize[i]));
1381 int layer = MyDecode::checkLayerLink(fedId, i);
1382 if (layer > 10)
1383 layer = layer - 10;
1384 if (layer == 3)
1385 hfedchannelsizeb3->Fill(float(fedchannelsize[i]));
1386 else if (layer == 2)
1387 hfedchannelsizeb2->Fill(float(fedchannelsize[i]));
1388 else if (layer == 1)
1389 hfedchannelsizeb1->Fill(float(fedchannelsize[i]));
1390 else
1391 cout << " Cannot be " << layer << " " << fedId << " " << i << endl;
1392 } else
1393 hfedchannelsizef->Fill(float(fedchannelsize[i]));
1394 }
1395
1396
1397
1398
1399
1400
1401 #ifdef OUTFILE
1402
1403 if (fedId == fedIds.second)
1404 outfile << (nWords * 8) << endl;
1405 else
1406 outfile << (nWords * 8) << ",";
1407 #endif
1408
1409 }
1410
1411 htotPixels->Fill(float(countPixels));
1412 htotPixels0->Fill(float(countPixels));
1413 htotErrors->Fill(float(countErrorsPerEvent));
1414
1415 htotPixelsls->Fill(float(lumiBlock), float(countPixels));
1416 htotPixelsbx->Fill(float(bx), float(countPixels));
1417
1418 herrorType1ls->Fill(float(lumiBlock), float(countErrorsPerEvent1));
1419 herrorType2ls->Fill(float(lumiBlock), float(countErrorsPerEvent2));
1420
1421 herror1ls->Fill(float(lumiBlock), float(countErrors[1]));
1422 herror3ls->Fill(float(lumiBlock), float(countErrors[3]));
1423 herror4ls->Fill(float(lumiBlock), float(countErrors[4]));
1424 herror5ls->Fill(float(lumiBlock), float(countErrors[5]));
1425 herror6ls->Fill(float(lumiBlock), float(countErrors[6]));
1426 herror10ls->Fill(float(lumiBlock), float(countErrors[10]));
1427 herror11ls->Fill(float(lumiBlock), float(countErrors[11]));
1428 herror12ls->Fill(float(lumiBlock), float(countErrors[12]));
1429 herror13ls->Fill(float(lumiBlock), float(countErrors[13]));
1430 herror14ls->Fill(float(lumiBlock), float(countErrors[14]));
1431 herror15ls->Fill(float(lumiBlock), float(countErrors[15]));
1432 herror16ls->Fill(float(lumiBlock), float(countErrors[16]));
1433
1434 herrorType1bx->Fill(float(bx), float(countErrorsPerEvent1));
1435 herrorType2bx->Fill(float(bx), float(countErrorsPerEvent2));
1436
1437 aveFedSize /= 32.;
1438 hsize3->Fill(aveFedSize);
1439
1440
1441 havsizels->Fill(float(lumiBlock), aveFedSize);
1442 havsizebx->Fill(float(bx), aveFedSize);
1443
1444 if (countPixels > 0) {
1445 hlumi->Fill(float(lumiBlock));
1446 hbx->Fill(float(bx));
1447 htotPixels1->Fill(float(countPixels));
1448
1449
1450 sumPixels += countPixels;
1451 countEvents++;
1452
1453
1454
1455 }
1456
1457 }
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473 #include "FWCore/Framework/interface/MakerMacros.h"
1474 DEFINE_FWK_MODULE(SiPixelRawDumper);