CMS 3D CMS Logo

CTPPSPixelDQMSource.cc
Go to the documentation of this file.
1 /******************************************
2  *
3  * This is a part of CTPPSDQM software.
4  * Authors:
5  * F.Ferro INFN Genova
6  * Vladimir Popov (vladimir.popov@cern.ch)
7  *
8  *******************************************/
9 
16 
19 
21 
29 
32 
33 #include <string>
34 
35 //-----------------------------------------------------------------------------
36 
38 public:
40  ~CTPPSPixelDQMSource() override;
41 
42 protected:
43  void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override;
44  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
45  void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override;
46 
47 private:
48  unsigned int verbosity;
49  long int nEvents = 0;
58 
59  static constexpr int NArms = 2;
60  static constexpr int NStationMAX = 3; // in an arm
61  static constexpr int NRPotsMAX = 6; // per station
62  static constexpr int NplaneMAX = 6; // per RPot
63  static constexpr int NROCsMAX = 6; // per plane
64  static constexpr int RPn_first = 3, RPn_last = 4;
65  static constexpr int ADCMax = 256;
66  static constexpr int StationIDMAX = 4; // possible range of ID
67  static constexpr int RPotsIDMAX = 8; // possible range of ID
68  static constexpr int NLocalTracksMAX = 20;
69  static constexpr int hitMultMAX = 50; // tuned
70  static constexpr int ClusMultMAX = 10; // tuned
71  static constexpr int ClusterSizeMax = 9;
72  static constexpr int errCodeSize = 15;
73  static constexpr int minFedNumber = 1462;
74  static constexpr int numberOfFeds = 2;
75  static constexpr int mapXbins = 200;
76  static constexpr int mapYbins = 240;
77  static constexpr float mapYmin = -16.;
78  static constexpr float mapYmax = 8.;
79  const float mapXmin = 0. * TMath::Cos(18.4 / 180. * TMath::Pi());
80  const float mapXmax = 30. * TMath::Cos(18.4 / 180. * TMath::Pi());
81 
83 
85 
88 
91 
94 
96 
106 
110 
130 
131  //--------------------------------------------------------
132  static constexpr int LINK_bits = 6;
133  static constexpr int ROC_bits = 5;
134  static constexpr int DCOL_bits = 5;
135  static constexpr int PXID_bits = 8;
136  static constexpr int ADC_bits = 8;
137  static constexpr int DataBit_bits = 1;
138 
139  static constexpr int ADC_shift = 0;
144  static constexpr int DB0_shift = 0;
152 
153  static constexpr uint32_t LINK_mask = ~(~uint32_t(0) << LINK_bits);
154  static constexpr uint32_t ROC_mask = ~(~uint32_t(0) << ROC_bits);
155  static constexpr uint32_t DCOL_mask = ~(~uint32_t(0) << DCOL_bits);
156  static constexpr uint32_t PXID_mask = ~(~uint32_t(0) << PXID_bits);
157  static constexpr uint32_t ADC_mask = ~(~uint32_t(0) << ADC_bits);
158  static constexpr uint32_t DataBit_mask = ~(~uint32_t(0) << DataBit_bits);
159  // Flags for disabling set of plots
160  bool offlinePlots = true;
161  bool onlinePlots = true;
162 
163  // Flags for disabling plots of a plane
165 
166  unsigned int rpStatusWord = 0x8008; // 220_fr_hr(stn2rp3)+ 210_fr_hr
167  int RPstatus[StationIDMAX][RPotsIDMAX]; // symmetric in both arms
168  int StationStatus[StationIDMAX]; // symmetric in both arms
169  const int IndexNotValid = 0;
170 
171  int getRPindex(int arm, int station, int rp) {
172  if (arm < 0 || station < 0 || rp < 0)
173  return (IndexNotValid);
174  if (arm > 1 || station >= NStationMAX || rp >= NRPotsMAX)
175  return (IndexNotValid);
176  int rc = (arm * NStationMAX + station) * NRPotsMAX + rp;
177  return (rc);
178  }
179 
180  int getPlaneIndex(int arm, int station, int rp, int plane) {
181  if (plane < 0 || plane >= NplaneMAX)
182  return (IndexNotValid);
183  int rc = getRPindex(arm, station, rp);
184  if (rc == IndexNotValid)
185  return (IndexNotValid);
186  return (rc * NplaneMAX + plane);
187  }
188 
189  int getRPInStationBin(int rp) { return (rp - RPn_first + 1); }
190 
191  static constexpr int NRPglobalBins = 4; // 2 arms w. 2 stations w. 1 RP
192 
193  int getRPglobalBin(int arm, int stn) {
194  static constexpr int stationBinOrder[NStationMAX] = {0, 4, 1};
195  return (arm * 2 + stationBinOrder[stn] + 1);
196  }
197 
198  int prIndex(int rp, int plane) // plane index in station
199 
200  {
201  return ((rp - RPn_first) * NplaneMAX + plane);
202  }
203  int getDet(int id) { return (id >> DetId::kDetOffset) & 0xF; }
204  int getPixPlane(int id) { return ((id >> 16) & 0x7); }
205  // int getSubdet(int id) { return ((id>>kSubdetOffset)&0x7); }
206 
208 };
209 
210 //----------------------------------------------------------------------------------
211 
212 using namespace std;
213 using namespace edm;
214 
215 //-------------------------------------------------------------------------------
216 
218  : verbosity(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
219  randomHLTPath(ps.getUntrackedParameter<std::string>("randomHLTPath", "")),
220  rpStatusWord(ps.getUntrackedParameter<unsigned int>("RPStatusWord", 0x8008)) {
221  tokenDigi = consumes<DetSetVector<CTPPSPixelDigi>>(ps.getUntrackedParameter<edm::InputTag>("tagRPixDigi"));
222  tokenError = consumes<DetSetVector<CTPPSPixelDataError>>(ps.getUntrackedParameter<edm::InputTag>("tagRPixError"));
223  tokenCluster = consumes<DetSetVector<CTPPSPixelCluster>>(ps.getUntrackedParameter<edm::InputTag>("tagRPixCluster"));
224  tokenTrack = consumes<DetSetVector<CTPPSPixelLocalTrack>>(ps.getUntrackedParameter<edm::InputTag>("tagRPixLTrack"));
225  tokenTrigResults = consumes<edm::TriggerResults>(ps.getUntrackedParameter<edm::InputTag>("tagTrigResults"));
226  tokenPixelDAQMapping = esConsumes<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd>();
227  mappingLabel = ps.getUntrackedParameter<std::string>("mappingLabel");
228  offlinePlots = ps.getUntrackedParameter<bool>("offlinePlots", true);
229  onlinePlots = ps.getUntrackedParameter<bool>("onlinePlots", true);
230 
231  vector<string> disabledPlanePlotsVec =
232  ps.getUntrackedParameter<vector<string>>("turnOffPlanePlots", vector<string>());
233  // Parse the strings in disabledPlanePlotsVec and set the flags in
234  // isPlanePlotsTurnedOff
235  for (auto s : disabledPlanePlotsVec) {
236  // Check that the format is <arm>_<station>_<RP>_<Plane>
237  if (count(s.begin(), s.end(), '_') != 3)
238  throw cms::Exception("RPixPlaneCombinatoryTracking") << "Invalid string in turnOffPlanePlots: " << s;
239  else {
240  vector<string> armStationRpPlane;
241  size_t pos = 0;
242  while ((pos = s.find('_')) != string::npos) {
243  armStationRpPlane.push_back(s.substr(0, pos));
244  s.erase(0, pos + 1);
245  }
246  armStationRpPlane.push_back(s);
247 
248  int arm = stoi(armStationRpPlane.at(0));
249  int station = stoi(armStationRpPlane.at(1));
250  int rp = stoi(armStationRpPlane.at(2));
251  int plane = stoi(armStationRpPlane.at(3));
252 
253  if (arm < NArms && station < NStationMAX && rp < NRPotsMAX && plane < NplaneMAX) {
254  if (verbosity)
255  LogPrint("CTPPSPixelDQMSource")
256  << "Shutting off plots for: Arm " << arm << " Station " << station << " Rp " << rp << " Plane " << plane;
257  isPlanePlotsTurnedOff[arm][station][rp][plane] = true;
258  } else {
259  throw cms::Exception("RPixPlaneCombinatoryTracking") << "Invalid string in turnOffPlanePlots: " << s;
260  }
261  }
262  }
263 }
264 
265 //----------------------------------------------------------------------------------
266 
268 
269 //--------------------------------------------------------------------------
270 
272  if (verbosity)
273  LogPrint("CTPPSPixelDQMSource") << "RPstatusWord= " << rpStatusWord;
274  nEvents = 0;
275 
276  CTPPSPixelLocalTrack thePixelLocalTrack;
277  TrackFitDimension = thePixelLocalTrack.dimension;
278 
279  for (int stn = 0; stn < StationIDMAX; stn++) {
280  StationStatus[stn] = 0;
281  for (int rp = 0; rp < RPotsIDMAX; rp++)
282  RPstatus[stn][rp] = 0;
283  }
284 
285  unsigned int rpSts = rpStatusWord << 1;
286  for (int stn = 0; stn < NStationMAX; stn++) {
287  int stns = 0;
288  for (int rp = 0; rp < NRPotsMAX; rp++) {
289  rpSts = (rpSts >> 1);
290  RPstatus[stn][rp] = rpSts & 1;
291  if (RPstatus[stn][rp] > 0)
292  stns = 1;
293  }
294  StationStatus[stn] = stns;
295  }
296 
297  for (int ind = 0; ind < 2 * 3 * NRPotsMAX; ind++)
298  RPindexValid[ind] = 0;
299 
300  x0_MIN = y0_MIN = 1.0e06;
301  x0_MAX = y0_MAX = -1.0e06;
302 }
303 
304 //-------------------------------------------------------------------------------------
305 
307  ibooker.cd();
308  ibooker.setCurrentFolder("CTPPS/TrackingPixel");
309  char s[50];
310  string armTitleShort, stnTitleShort;
311 
312  TAxis *yah1st = nullptr;
313  TAxis *xaRPact = nullptr;
314  TAxis *xah1trk = nullptr;
315  if (onlinePlots) {
316  hBX = ibooker.book1D("events per BX", "ctpps_pixel;Event.BX", 4002, -1.5, 4000. + 0.5);
317  hBXshort = ibooker.book1D("events per BX(short)", "ctpps_pixel;Event.BX", 102, -1.5, 100. + 0.5);
318 
319  string str1st = "Pixel planes activity";
320  h2AllPlanesActive = ibooker.book2DD(
321  str1st, str1st + "(digi task);Plane #", NplaneMAX, 0, NplaneMAX, NRPglobalBins, 0.5, NRPglobalBins + 0.5);
322  TH2D *h1st = h2AllPlanesActive->getTH2D();
323  h1st->SetOption("colz");
324  yah1st = h1st->GetYaxis();
325 
326  string str2 = "Pixel RP active";
327  hpRPactive = ibooker.bookProfile(
328  str2, str2 + " per event(digi task)", NRPglobalBins, 0.5, NRPglobalBins + 0.5, -0.1, 1.1, "");
329  xaRPact = hpRPactive->getTProfile()->GetXaxis();
330  hpRPactive->getTProfile()->SetOption("hist");
331  hpRPactive->getTProfile()->SetMinimum(0.);
332  hpRPactive->getTProfile()->SetMaximum(1.1);
333 
334  str2 = "Pixel Local Tracks";
335  hpixLTrack = ibooker.bookProfile(
336  str2, str2 + " per event", NRPglobalBins, 0.5, NRPglobalBins + 0.5, -0.1, NLocalTracksMAX, "");
337 
338  xah1trk = hpixLTrack->getTProfile()->GetXaxis();
339  hpixLTrack->getTProfile()->GetYaxis()->SetTitle("average number of tracks per event");
340  hpixLTrack->getTProfile()->SetOption("hist");
341  }
342  const float minErrCode = 25.;
343  const string errCode[errCodeSize] = {
344  "Masked channel ", // error 25
345  "Gap word", // error 26
346  "Dummy word", // error 27
347  "FIFO nearly full", // error 28
348  "Channel Timeout", // error 29
349  "TBM Trailer", // error 30
350  "Event number mismatch", // error 31
351  "Invalid/no FED header", // error 32
352  "Invalid/no FED trailer", // error 33
353  "Size mismatch", // error 34
354  "Conversion: inv. channel", // error 35
355  "Conversion: inv. ROC number", // error 36
356  "Conversion: inv. pixel address", // error 37
357  "-",
358  "CRC" //error 39
359  };
360 
361  const string tbmMessage[8] = {"Stack full ",
362  "Pre-cal issued ",
363  "Clear trigger counter",
364  "Synch trigger",
365  "Synch trigger error",
366  "Reset ROC",
367  "Reset TBM",
368  "No token pass"};
369 
370  const string tbmType[5] = {
371  "All bits 0", "bit 8 : Overflow", "bit 9 : PKAM", "bit 10 : Auto Reset", "bit 11 : Number of ROC Error"};
372 
373  h2ErrorCodeUnidDet = ibooker.book2D("Errors in Unidentified Det",
374  "Errors in Unidentified Det;;fed",
375  errCodeSize,
376  minErrCode - 0.5,
377  minErrCode + float(errCodeSize) - 0.5,
378  2,
379  1461.5,
380  1463.5);
381  for (unsigned int iBin = 1; iBin <= errCodeSize; iBin++)
382  h2ErrorCodeUnidDet->setBinLabel(iBin, errCode[iBin - 1]);
383  h2ErrorCodeUnidDet->setBinLabel(1, "1462", 2);
384  h2ErrorCodeUnidDet->setBinLabel(2, "1463", 2);
385  h2ErrorCodeUnidDet->getTH2F()->SetOption("colz");
387  ibooker.book2D("TBM Message Unid Det", "TBM Message Unid Det;;fed", 8, -0.5, 7.5, 2, 1461.5, 1463.5);
388  for (unsigned int iBin = 1; iBin <= 8; iBin++)
389  h2TBMMessageUnidDet->setBinLabel(iBin, tbmMessage[iBin - 1]);
390  h2TBMMessageUnidDet->getTH2F()->SetOption("colz");
391 
393  ibooker.book2D("TBM Type in Unid Det", "TBM Type in Unid Det;;fed", 5, -0.5, 4.5, 2, 1461.5, 1463.5);
394  for (unsigned int iBin = 1; iBin <= 5; iBin++)
395  h2TBMTypeUnidDet->setBinLabel(iBin, tbmType[iBin - 1]);
396  h2TBMTypeUnidDet->getTH2F()->SetOption("colz");
397 
398  h2FullType = ibooker.book2D("Full FIFO", "Full FIFO;;fed", 7, 0.5, 7.5, 2, 1461.5, 1463.5);
399  h2FullType->setBinLabel(1, "1462", 2);
400  h2FullType->setBinLabel(2, "1463", 2);
401  h2FullType->getTH2F()->SetOption("colz");
402 
403  for (int iFed = 0; iFed < numberOfFeds; iFed++) {
404  int fedId = minFedNumber + iFed;
405  auto s_fed = std::to_string(fedId);
406 
407  h2ErrorCodeFED[iFed] = ibooker.book2D("Errors in FED" + s_fed,
408  "Errors in FED" + s_fed + ";;channel",
409  errCodeSize,
410  minErrCode - 0.5,
411  minErrCode + float(errCodeSize) - 0.5,
412  37,
413  -0.5,
414  36.5);
415  for (unsigned int iBin = 1; iBin <= errCodeSize; iBin++)
416  h2ErrorCodeFED[iFed]->setBinLabel(iBin, errCode[iBin - 1]);
417  h2ErrorCodeFED[iFed]->getTH2F()->SetOption("colz");
418 
419  h2TBMMessageFED[iFed] = ibooker.book2D(
420  "TBM Message in FED" + s_fed, "TBM Message in FED" + s_fed + ";;channel", 8, -0.5, 7.5, 37, -0.5, 36.5);
421  for (unsigned int iBin = 1; iBin <= 8; iBin++)
422  h2TBMMessageFED[iFed]->setBinLabel(iBin, tbmMessage[iBin - 1]);
423  h2TBMMessageFED[iFed]->getTH2F()->SetOption("colz");
424 
425  h2TBMTypeFED[iFed] = ibooker.book2D(
426  "TBM Type in FED" + s_fed, "TBM Type in FED" + s_fed + ";;channel", 5, -0.5, 4.5, 37, -0.5, 36.5);
427  for (unsigned int iBin = 1; iBin <= 5; iBin++)
428  h2TBMTypeFED[iFed]->setBinLabel(iBin, tbmType[iBin - 1]);
429  h2TBMTypeFED[iFed]->getTH2F()->SetOption("colz");
430  }
431 
432  for (int arm = 0; arm < 2; arm++) {
434  string sd, armTitle;
435  ID.armName(sd, CTPPSDetId::nPath);
436  ID.armName(armTitle, CTPPSDetId::nFull);
437  ID.armName(armTitleShort, CTPPSDetId::nShort);
438 
439  ibooker.setCurrentFolder(sd);
440 
441  for (int stn = 0; stn < NStationMAX; stn++) {
442  if (StationStatus[stn] == 0)
443  continue;
444  ID.setStation(stn);
445  string stnd, stnTitle;
446 
447  CTPPSDetId(ID.stationId()).stationName(stnd, CTPPSDetId::nPath);
448  CTPPSDetId(ID.stationId()).stationName(stnTitle, CTPPSDetId::nFull);
449  CTPPSDetId(ID.stationId()).stationName(stnTitleShort, CTPPSDetId::nShort);
450 
451  ibooker.setCurrentFolder(stnd);
452  //--------- RPots ---
453  int pixBinW = 4;
454  for (int rp = RPn_first; rp < RPn_last; rp++) { // only installed pixel pots
455  ID.setRP(rp);
456  string rpd, rpTitle;
457  CTPPSDetId(ID.rpId()).rpName(rpTitle, CTPPSDetId::nShort);
458  string rpBinName = armTitleShort + "_" + stnTitleShort + "_" + rpTitle;
459  if (onlinePlots) {
460  yah1st->SetBinLabel(getRPglobalBin(arm, stn), rpBinName.c_str());
461  xah1trk->SetBinLabel(getRPglobalBin(arm, stn), rpBinName.c_str());
462  xaRPact->SetBinLabel(getRPglobalBin(arm, stn), rpBinName.c_str());
463  }
464  if (RPstatus[stn][rp] == 0)
465  continue;
466  int indexP = getRPindex(arm, stn, rp);
467  RPindexValid[indexP] = 1;
468 
469  CTPPSDetId(ID.rpId()).rpName(rpTitle, CTPPSDetId::nFull);
470  CTPPSDetId(ID.rpId()).rpName(rpd, CTPPSDetId::nPath);
471 
472  ibooker.setCurrentFolder(rpd);
473 
474  const float x0Maximum = 70.;
475  const float y0Maximum = 15.;
476  string st = "track intercept point";
477  string st2 = ": " + stnTitle;
478  h2trackXY0[indexP] = ibooker.book2D(
479  st, st + st2 + ";x0;y0", int(x0Maximum) * 2, 0., x0Maximum, int(y0Maximum) * 4, -y0Maximum, y0Maximum);
480  h2trackXY0[indexP]->getTH2F()->SetOption("colz");
481  st = "Error Code";
482  h2ErrorCodeRP[indexP] = ibooker.book2D(st,
483  st + st2 + ";;plane",
484  errCodeSize,
485  minErrCode - 0.5,
486  minErrCode + float(errCodeSize) - 0.5,
487  6,
488  -0.5,
489  5.5);
490  for (unsigned int iBin = 1; iBin <= errCodeSize; iBin++)
491  h2ErrorCodeRP[indexP]->setBinLabel(iBin, errCode[iBin - 1]);
492  h2ErrorCodeRP[indexP]->getTH2F()->SetOption("colz");
493 
494  h2TBMMessageRP[indexP] = ibooker.book2D("TBM Message", "TBM Message;;plane", 8, -0.5, 7.5, 6, -0.5, 5.5);
495  for (unsigned int iBin = 1; iBin <= 8; iBin++)
496  h2TBMMessageRP[indexP]->setBinLabel(iBin, tbmMessage[iBin - 1]);
497  h2TBMMessageRP[indexP]->getTH2F()->SetOption("colz");
498 
499  h2TBMTypeRP[indexP] = ibooker.book2D("TBM Type", "TBM Type;;plane", 5, -0.5, 4.5, 6, -0.5, 5.5);
500  for (unsigned int iBin = 1; iBin <= 5; iBin++)
501  h2TBMTypeRP[indexP]->setBinLabel(iBin, tbmType[iBin - 1]);
502  h2TBMTypeRP[indexP]->getTH2F()->SetOption("colz");
503 
504  st = "number of tracks per event";
505  htrackMult[indexP] = ibooker.bookProfile(st,
506  rpTitle + ";number of tracks",
507  NLocalTracksMAX + 1,
508  -0.5,
509  NLocalTracksMAX + 0.5,
510  -0.5,
511  NLocalTracksMAX + 0.5,
512  "");
513  htrackMult[indexP]->getTProfile()->SetOption("hist");
514 
515  hRPotActivPlanes[indexP] = ibooker.bookProfile("number of fired planes per event",
516  rpTitle + ";nPlanes;Probability",
517  NplaneMAX + 1,
518  -0.5,
519  NplaneMAX + 0.5,
520  -0.5,
521  NplaneMAX + 0.5,
522  "");
523  hRPotActivPlanes[indexP]->getTProfile()->SetOption("hist");
524 
525  hp2HitsMultROC_LS[indexP] = ibooker.bookProfile2D("ROCs hits multiplicity per event vs LS",
526  rpTitle + ";LumiSection;Plane#___ROC#",
527  1000,
528  0.,
529  1000.,
531  0.,
532  double(NplaneMAX * NROCsMAX),
533  0.,
535  "");
536  hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetOption("colz");
537  hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetMinimum(1.0e-10);
538  hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetCanExtend(TProfile2D::kXaxis);
539  TAxis *yahp2 = hp2HitsMultROC_LS[indexP]->getTProfile2D()->GetYaxis();
540  for (int p = 0; p < NplaneMAX; p++) {
541  sprintf(s, "plane%d_0", p);
542  yahp2->SetBinLabel(p * NplaneMAX + 1, s);
543  for (int r = 1; r < NROCsMAX; r++) {
544  sprintf(s, " %d_%d", p, r);
545  yahp2->SetBinLabel(p * NplaneMAX + r + 1, s);
546  }
547  }
548 
549  // Hits per plane per bx
550  h2HitsVsBXRandoms[indexP] = ibooker.book2D(
551  "Hits per plane per BX - random triggers", rpTitle + ";Event.BX;Plane", 4002, -1.5, 4000. + 0.5, 6, 0, 6);
552 
553  if (onlinePlots) {
554  string st3 = ";PlaneIndex(=pixelPot*PlaneMAX + plane)";
555 
556  st = "hit multiplicity in planes";
557  h2HitsMultipl[arm][stn] = ibooker.book2DD(
558  st, st + st2 + st3 + ";multiplicity", NPlaneBins, 0, NPlaneBins, hitMultMAX, 0, hitMultMAX);
559  h2HitsMultipl[arm][stn]->getTH2D()->SetOption("colz");
560 
561  st = "cluster size in planes";
562  h2CluSize[arm][stn] = ibooker.book2D(st,
563  st + st2 + st3 + ";Cluster size",
564  NPlaneBins,
565  0,
566  NPlaneBins,
567  ClusterSizeMax + 1,
568  0,
569  ClusterSizeMax + 1);
570  h2CluSize[arm][stn]->getTH2F()->SetOption("colz");
571 
572  st = "number of hits per track";
573  htrackHits[indexP] = ibooker.bookProfile(st, rpTitle + ";number of hits", 5, 1.5, 6.5, -0.1, 1.1, "");
574  htrackHits[indexP]->getTProfile()->SetOption("hist");
575 
576  h2HitsMultROC[indexP] = ibooker.bookProfile2D("ROCs hits multiplicity per event",
577  rpTitle + ";plane # ;ROC #",
578  NplaneMAX,
579  -0.5,
580  NplaneMAX - 0.5,
581  NROCsMAX,
582  -0.5,
583  NROCsMAX - 0.5,
584  0.,
586  "");
587  h2HitsMultROC[indexP]->getTProfile2D()->SetOption("colztext");
588  h2HitsMultROC[indexP]->getTProfile2D()->SetMinimum(1.e-10);
589 
590  ibooker.setCurrentFolder(rpd + "/latency");
591  hRPotActivBX[indexP] =
592  ibooker.book1D("5 fired planes per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
593 
594  hRPotActivBXroc[indexP] =
595  ibooker.book1D("4 fired ROCs per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
596  hRPotActivBXroc_3[indexP] =
597  ibooker.book1D("3 fired ROCs per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
598  hRPotActivBXroc_2[indexP] =
599  ibooker.book1D("2 fired ROCs per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
600 
601  hRPotActivBXall[indexP] = ibooker.book1D("hits per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
602  }
603  int nbins = rpixValues::defaultDetSizeInX / pixBinW;
604 
605  for (int p = 0; p < NplaneMAX; p++) {
606  if (isPlanePlotsTurnedOff[arm][stn][rp][p])
607  continue;
608  sprintf(s, "plane_%d", p);
609  string pd = rpd + "/" + string(s);
610  ibooker.setCurrentFolder(pd);
611  string st1 = ": " + rpTitle + "_" + string(s);
612 
613  st = "adc average value";
614  hp2xyADC[indexP][p] = ibooker.bookProfile2D(st,
615  st1 + ";pix col;pix row",
616  nbins,
617  0,
619  nbins,
620  0,
622  0.,
623  512.,
624  "");
625  hp2xyADC[indexP][p]->getTProfile2D()->SetOption("colz");
626 
627  if (onlinePlots) {
628  st = "hits position";
629  h2xyHits[indexP][p] = ibooker.book2DD(st,
630  st1 + ";pix col;pix row",
632  0,
635  0,
637  h2xyHits[indexP][p]->getTH2D()->SetOption("colz");
638 
639  st = "hits multiplicity";
640  hHitsMult[indexP][p] =
641  ibooker.book1DD(st, st1 + ";number of hits;N / 1 hit", hitMultMAX + 1, -0.5, hitMultMAX + 0.5);
642  }
643 
644  if (offlinePlots) {
645  st = "plane efficiency";
646  h2Efficiency[indexP][p] = ibooker.bookProfile2D(
647  st, st1 + ";x0;y0", mapXbins, mapXmin, mapXmax, mapYbins, mapYmin, mapYmax, 0, 1, "");
648  h2Efficiency[indexP][p]->getTProfile2D()->SetOption("colz");
649  }
650  } // end of for(int p=0; p<NplaneMAX;..
651 
652  } // end for(int rp=0; rp<NRPotsMAX;...
653  } // end of for(int stn=0; stn<
654  } // end of for(int arm=0; arm<2;...
655 
656  return;
657 }
658 
659 //-------------------------------------------------------------------------------
660 
662  ++nEvents;
663  int lumiId = event.getLuminosityBlock().id().luminosityBlock();
664  if (lumiId < 0)
665  lumiId = 0;
666 
667  int RPactivity[RPotsTotalNumber], RPdigiSize[RPotsTotalNumber];
668  int pixRPTracks[RPotsTotalNumber];
669 
670  for (int rp = 0; rp < RPotsTotalNumber; rp++) {
671  RPactivity[rp] = RPdigiSize[rp] = pixRPTracks[rp] = 0;
672  }
673 
674  for (int ind = 0; ind < RPotsTotalNumber; ind++) {
675  for (int p = 0; p < NplaneMAX; p++) {
676  HitsMultPlane[ind][p] = 0;
677  }
678  }
679  for (int ind = 0; ind < RPotsTotalNumber * NplaneMAX; ind++) {
680  for (int roc = 0; roc < NROCsMAX; roc++) {
681  HitsMultROC[ind][roc] = 0;
682  }
683  }
685  event.getByToken(tokenDigi, pixDigi);
686 
688  event.getByToken(tokenError, pixError);
689 
691  event.getByToken(tokenCluster, pixClus);
692 
694  event.getByToken(tokenTrack, pixTrack);
695 
697  event.getByToken(tokenTrigResults, hltResults);
698 
700 
701  if (onlinePlots) {
702  hBX->Fill(event.bunchCrossing());
703  hBXshort->Fill(event.bunchCrossing());
704  }
705 
706  if (pixTrack.isValid()) {
707  for (const auto &ds_tr : *pixTrack) {
708  int idet = getDet(ds_tr.id);
709  if (idet != DetId::VeryForward) {
710  if (verbosity > 1)
711  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: ds_tr.id" << ds_tr.id;
712  continue;
713  }
714  CTPPSDetId theId(ds_tr.id);
715  int arm = theId.arm() & 0x1;
716  int station = theId.station() & 0x3;
717  int rpot = theId.rp() & 0x7;
718  int rpInd = getRPindex(arm, station, rpot);
719 
720  for (DetSet<CTPPSPixelLocalTrack>::const_iterator dit = ds_tr.begin(); dit != ds_tr.end(); ++dit) {
721  ++pixRPTracks[rpInd];
722  int nh_tr = (dit->ndf() + TrackFitDimension) / 2;
723  if (onlinePlots) {
724  for (int i = 0; i <= NplaneMAX; i++) {
725  if (i == nh_tr)
726  htrackHits[rpInd]->Fill(nh_tr, 1.);
727  else
728  htrackHits[rpInd]->Fill(i, 0.);
729  }
730  }
731  float x0 = dit->x0();
732  float y0 = dit->y0();
733  h2trackXY0[rpInd]->Fill(x0, y0);
734 
735  if (x0_MAX < x0)
736  x0_MAX = x0;
737  if (y0_MAX < y0)
738  y0_MAX = y0;
739  if (x0_MIN > x0)
740  x0_MIN = x0;
741  if (y0_MIN > y0)
742  y0_MIN = y0;
743 
744  if (offlinePlots) {
745  edm::DetSetVector<CTPPSPixelFittedRecHit> fittedHits = dit->hits();
746 
747  std::map<int, int> numberOfPointPerPlaneEff;
748  for (const auto &ds_frh : fittedHits) {
749  int plane = getPixPlane(ds_frh.id);
750  for (DetSet<CTPPSPixelFittedRecHit>::const_iterator frh_it = ds_frh.begin(); frh_it != ds_frh.end();
751  ++frh_it) { // there should always be only one hit in each
752  // vector
753  if (frh_it != ds_frh.begin())
754  if (verbosity > 1)
755  LogPrint("CTPPSPixelDQMSource") << "More than one FittedRecHit found in plane " << plane;
756  if (frh_it->isRealHit())
757  for (int p = 0; p < NplaneMAX; p++) {
758  if (p != plane)
759  numberOfPointPerPlaneEff[p]++;
760  }
761  }
762  }
763 
764  if (verbosity > 1)
765  for (auto planeAndHitsOnOthers : numberOfPointPerPlaneEff) {
766  LogPrint("CTPPSPixelDQMSource")
767  << "For plane " << planeAndHitsOnOthers.first << ", " << planeAndHitsOnOthers.second
768  << " hits on other planes were found" << endl;
769  }
770 
771  for (const auto &ds_frh : fittedHits) {
772  int plane = getPixPlane(ds_frh.id);
773  if (isPlanePlotsTurnedOff[arm][station][rpot][plane])
774  continue;
775  for (DetSet<CTPPSPixelFittedRecHit>::const_iterator frh_it = ds_frh.begin(); frh_it != ds_frh.end();
776  ++frh_it) {
777  float frhX0 = frh_it->globalCoordinates().x() + frh_it->xResidual();
778  float frhY0 = frh_it->globalCoordinates().y() + frh_it->yResidual();
779  if (numberOfPointPerPlaneEff[plane] >= 3) {
780  if (frh_it->isRealHit())
781  h2Efficiency[rpInd][plane]->Fill(frhX0, frhY0, 1);
782  else
783  h2Efficiency[rpInd][plane]->Fill(frhX0, frhY0, 0);
784  }
785  }
786  }
787  }
788  }
789  }
790  } // end if(pixTrack.isValid())
791 
792  bool valid = false;
793  valid |= pixDigi.isValid();
794  // valid |= Clus.isValid();
795 
796  if (!valid && verbosity)
797  LogPrint("CTPPSPixelDQMSource") << "No valid data in Event " << nEvents;
798 
799  if (pixDigi.isValid()) {
800  for (const auto &ds_digi : *pixDigi) {
801  int idet = getDet(ds_digi.id);
802  if (idet != DetId::VeryForward) {
803  if (verbosity > 1)
804  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: ds_digi.id" << ds_digi.id;
805  continue;
806  }
807  // int subdet = getSubdet(ds_digi.id);
808 
809  int plane = getPixPlane(ds_digi.id);
810 
811  CTPPSDetId theId(ds_digi.id);
812  int arm = theId.arm() & 0x1;
813  int station = theId.station() & 0x3;
814  int rpot = theId.rp() & 0x7;
815  int rpInd = getRPindex(arm, station, rpot);
816  RPactivity[rpInd] = 1;
817  ++RPdigiSize[rpInd];
818 
819  if (StationStatus[station] && RPstatus[station][rpot]) {
820  if (onlinePlots) {
821  h2HitsMultipl[arm][station]->Fill(prIndex(rpot, plane), ds_digi.data.size());
823  }
824  int index = getRPindex(arm, station, rpot);
825  HitsMultPlane[index][plane] += ds_digi.data.size();
826  if (RPindexValid[index]) {
827  int nh = ds_digi.data.size();
828  if (nh > hitMultMAX)
829  nh = hitMultMAX;
830  if (!isPlanePlotsTurnedOff[arm][station][rpot][plane])
831  if (onlinePlots)
832  hHitsMult[index][plane]->Fill(nh);
833  }
834  int rocHistIndex = getPlaneIndex(arm, station, rpot, plane);
835 
836  for (DetSet<CTPPSPixelDigi>::const_iterator dit = ds_digi.begin(); dit != ds_digi.end(); ++dit) {
837  int row = dit->row();
838  int col = dit->column();
839  int adc = dit->adc();
840 
841  if (RPindexValid[index]) {
842  if (!isPlanePlotsTurnedOff[arm][station][rpot][plane]) {
843  if (onlinePlots)
844  h2xyHits[index][plane]->Fill(col, row);
845  hp2xyADC[index][plane]->Fill(col, row, adc);
846  }
847  int colROC, rowROC;
848  int trocId;
849  if (!thePixIndices.transformToROC(col, row, trocId, colROC, rowROC)) {
850  if (trocId >= 0 && trocId < NROCsMAX) {
851  ++HitsMultROC[rocHistIndex][trocId];
852  }
853  }
854  } // end if(RPindexValid[index]) {
855  }
856  } // end if(StationStatus[station]) {
857  } // end for(const auto &ds_digi : *pixDigi)
858  } // if(pixDigi.isValid()) {
859 
860  if (pixError.isValid()) {
861  std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo> rocMapping = mapping->ROCMapping;
862  for (const auto &ds_error : *pixError) {
863  int idet = getDet(ds_error.id);
864  if (idet != DetId::VeryForward) {
865  if (idet == 15) { //dummy det id: store in a plot with fed info
866 
867  for (DetSet<CTPPSPixelDataError>::const_iterator dit = ds_error.begin(); dit != ds_error.end(); ++dit) {
868  // recover fed channel number
869  int chanNmbr = -1;
870  if (dit->errorType() == 32 || dit->errorType() == 33 || dit->errorType() == 34) {
871  long long errorWord = dit->errorWord64(); // for 64-bit error words
872  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
873  } else {
874  uint32_t errorWord = dit->errorWord32();
875  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
876  }
877 
878  // recover detector Id from chanNmbr and fedId
879  CTPPSPixelFramePosition fPos(dit->fedId(), 0, chanNmbr, 0); // frame position for ROC 0
880  std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo>::const_iterator mit;
881  int index = -1;
882  int plane = -1;
883  bool goodRecovery = false;
884  mit = rocMapping.find(fPos);
885  if (mit != rocMapping.end()) {
886  CTPPSPixelROCInfo rocInfo = (*mit).second;
887  CTPPSPixelDetId recoveredDetId(rocInfo.iD);
888  plane = recoveredDetId.plane();
889  index = getRPindex(recoveredDetId.arm(), recoveredDetId.station(), recoveredDetId.rp());
890  if (RPindexValid[index] && !isPlanePlotsTurnedOff[recoveredDetId.arm()][recoveredDetId.station()]
891  [recoveredDetId.rp()][recoveredDetId.plane()])
892  goodRecovery = true;
893  } // if (mit != rocMapping.end())
894 
895  if (goodRecovery) {
896  h2ErrorCodeRP[index]->Fill(dit->errorType(), plane);
897  } else {
898  h2ErrorCodeUnidDet->Fill(dit->errorType(), dit->fedId());
899  }
900 
901  bool fillFED = false;
902  int iFed = dit->fedId() - minFedNumber;
903  if (iFed >= 0 && iFed < numberOfFeds)
904  fillFED = true;
905 
906  if (dit->errorType() == 28) { //error 28 = FIFO nearly full: identify FIFO and fill histogram
907  int fullType = -1;
908  uint32_t errorWord = dit->errorWord32();
909  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
910  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
911  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
912  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
913  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
914  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
915  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
916  if (NFa == 1) {
917  fullType = 1;
918  h2FullType->Fill((int)fullType, dit->fedId());
919  }
920  if (NFb == 1) {
921  fullType = 2;
922  h2FullType->Fill((int)fullType, dit->fedId());
923  }
924  if (NFc == 1) {
925  fullType = 3;
926  h2FullType->Fill((int)fullType, dit->fedId());
927  }
928  if (NFd == 1) {
929  fullType = 4;
930  h2FullType->Fill((int)fullType, dit->fedId());
931  }
932  if (NFe == 1) {
933  fullType = 5;
934  h2FullType->Fill((int)fullType, dit->fedId());
935  }
936  if (NF2 == 1) {
937  fullType = 6;
938  h2FullType->Fill((int)fullType, dit->fedId());
939  }
940  if (L1A == 1) {
941  fullType = 7;
942  h2FullType->Fill((int)fullType, dit->fedId());
943  }
944  }
945  if (dit->errorType() == 30) { //error 30 = TBM error trailer
946  uint32_t errorWord = dit->errorWord32();
947  int t0 = (errorWord >> DB0_shift) & DataBit_mask;
948  int t1 = (errorWord >> DB1_shift) & DataBit_mask;
949  int t2 = (errorWord >> DB2_shift) & DataBit_mask;
950  int t3 = (errorWord >> DB3_shift) & DataBit_mask;
951  int t4 = (errorWord >> DB4_shift) & DataBit_mask;
952  int t5 = (errorWord >> DB5_shift) & DataBit_mask;
953  int t6 = (errorWord >> DB6_shift) & DataBit_mask;
954  int t7 = (errorWord >> DB7_shift) & DataBit_mask;
955  if (t0 == 1) {
956  if (goodRecovery) {
957  h2TBMMessageRP[index]->Fill(0, plane);
958  } else {
959  h2TBMMessageUnidDet->Fill(0, dit->fedId());
960  }
961  if (fillFED)
962  h2TBMMessageFED[iFed]->Fill(0, chanNmbr);
963  }
964  if (t1 == 1) {
965  if (goodRecovery) {
966  h2TBMMessageRP[index]->Fill(1, plane);
967  } else {
968  h2TBMMessageUnidDet->Fill(1, dit->fedId());
969  }
970  if (fillFED)
971  h2TBMMessageFED[iFed]->Fill(1, chanNmbr);
972  }
973  if (t2 == 1) {
974  if (goodRecovery) {
975  h2TBMMessageRP[index]->Fill(2, plane);
976  } else {
977  h2TBMMessageUnidDet->Fill(2, dit->fedId());
978  }
979  if (fillFED)
980  h2TBMMessageFED[iFed]->Fill(2, chanNmbr);
981  }
982  if (t3 == 1) {
983  if (goodRecovery) {
984  h2TBMMessageRP[index]->Fill(3, plane);
985  } else {
986  h2TBMMessageUnidDet->Fill(3, dit->fedId());
987  }
988  if (fillFED)
989  h2TBMMessageFED[iFed]->Fill(3, chanNmbr);
990  }
991  if (t4 == 1) {
992  if (goodRecovery) {
993  h2TBMMessageRP[index]->Fill(4, plane);
994  } else {
995  h2TBMMessageUnidDet->Fill(4, dit->fedId());
996  }
997  if (fillFED)
998  h2TBMMessageFED[iFed]->Fill(4, chanNmbr);
999  }
1000  if (t5 == 1) {
1001  if (goodRecovery) {
1002  h2TBMMessageRP[index]->Fill(5, plane);
1003  } else {
1004  h2TBMMessageUnidDet->Fill(5, dit->fedId());
1005  }
1006  if (fillFED)
1007  h2TBMMessageFED[iFed]->Fill(5, chanNmbr);
1008  }
1009  if (t6 == 1) {
1010  if (goodRecovery) {
1011  h2TBMMessageRP[index]->Fill(6, plane);
1012  } else {
1013  h2TBMMessageUnidDet->Fill(6, dit->fedId());
1014  }
1015  if (fillFED)
1016  h2TBMMessageFED[iFed]->Fill(6, chanNmbr);
1017  }
1018  if (t7 == 1) {
1019  if (goodRecovery) {
1020  h2TBMMessageRP[index]->Fill(7, plane);
1021  } else {
1022  h2TBMMessageUnidDet->Fill(7, dit->fedId());
1023  }
1024  if (fillFED)
1025  h2TBMMessageFED[iFed]->Fill(7, chanNmbr);
1026  }
1027  int stateMach_bits = 4;
1028  int stateMach_shift = 8;
1029  uint32_t stateMach_mask = ~(~uint32_t(0) << stateMach_bits);
1030  uint32_t stateMach = (errorWord >> stateMach_shift) & stateMach_mask;
1031  if (stateMach == 0) {
1032  if (goodRecovery) {
1033  h2TBMTypeRP[index]->Fill(0, plane);
1034  } else {
1035  h2TBMTypeUnidDet->Fill(0, dit->fedId());
1036  }
1037  if (fillFED)
1038  h2TBMTypeFED[iFed]->Fill(0, chanNmbr);
1039  } else {
1040  if (((stateMach >> DB0_shift) & DataBit_mask) == 1) {
1041  if (goodRecovery) {
1042  h2TBMTypeRP[index]->Fill(1, plane);
1043  } else {
1044  h2TBMTypeUnidDet->Fill(1, dit->fedId());
1045  }
1046  if (fillFED)
1047  h2TBMTypeFED[iFed]->Fill(1, chanNmbr);
1048  }
1049  if (((stateMach >> DB1_shift) & DataBit_mask) == 1) {
1050  if (goodRecovery) {
1051  h2TBMTypeRP[index]->Fill(2, plane);
1052  } else {
1053  h2TBMTypeUnidDet->Fill(2, dit->fedId());
1054  }
1055  if (fillFED)
1056  h2TBMTypeFED[iFed]->Fill(2, chanNmbr);
1057  }
1058  if (((stateMach >> DB2_shift) & DataBit_mask) == 1) {
1059  if (goodRecovery) {
1060  h2TBMTypeRP[index]->Fill(3, plane);
1061  } else {
1062  h2TBMTypeUnidDet->Fill(3, dit->fedId());
1063  }
1064  if (fillFED)
1065  h2TBMTypeFED[iFed]->Fill(3, chanNmbr);
1066  }
1067  if (((stateMach >> DB3_shift) & DataBit_mask) == 1) {
1068  if (goodRecovery) {
1069  h2TBMTypeRP[index]->Fill(4, plane);
1070  } else {
1071  h2TBMTypeUnidDet->Fill(4, dit->fedId());
1072  }
1073  if (fillFED)
1074  h2TBMTypeFED[iFed]->Fill(4, chanNmbr);
1075  }
1076  }
1077  }
1078  if (fillFED)
1079  h2ErrorCodeFED[iFed]->Fill(dit->errorType(), chanNmbr);
1080  }
1081  continue;
1082  } // if idet == 15
1083  if (verbosity > 1)
1084  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: ds_error.id" << ds_error.id;
1085  continue;
1086  } // end of dummy detId block
1087 
1088  int plane = getPixPlane(ds_error.id);
1089  CTPPSDetId theId(ds_error.id);
1090  int arm = theId.arm() & 0x1;
1091  int station = theId.station() & 0x3;
1092  int rpot = theId.rp() & 0x7;
1093  int rpInd = getRPindex(arm, station, rpot);
1094  RPactivity[rpInd] = 1;
1095  CTPPSPixelDetId IDD(ds_error.id);
1096 
1097  if (StationStatus[station] && RPstatus[station][rpot]) {
1098  int index = getRPindex(arm, station, rpot);
1099  for (DetSet<CTPPSPixelDataError>::const_iterator dit = ds_error.begin(); dit != ds_error.end(); ++dit) {
1100  if (RPindexValid[index]) {
1101  if (!isPlanePlotsTurnedOff[arm][station][rpot][plane]) {
1102  h2ErrorCodeRP[index]->Fill(dit->errorType(), plane);
1103  // recover fed channel number
1104  int chanNmbr = -1;
1105  if (dit->errorType() == 32 || dit->errorType() == 33 || dit->errorType() == 34) {
1106  long long errorWord = dit->errorWord64(); // for 64-bit error words
1107  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
1108  } else {
1109  uint32_t errorWord = dit->errorWord32();
1110  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
1111  }
1112  bool fillFED = false;
1113  int iFed = dit->fedId() - minFedNumber;
1114  if (iFed >= 0 && iFed < numberOfFeds)
1115  fillFED = true;
1116  if (dit->errorType() == 28) { //error 28 = FIFO nearly full: identify FIFO and fill histogram
1117  int fullType = -1;
1118  uint32_t errorWord = dit->errorWord32();
1119  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
1120  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
1121  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
1122  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
1123  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
1124  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
1125  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
1126  if (NFa == 1) {
1127  fullType = 1;
1128  h2FullType->Fill((int)fullType, dit->fedId());
1129  }
1130  if (NFb == 1) {
1131  fullType = 2;
1132  h2FullType->Fill((int)fullType, dit->fedId());
1133  }
1134  if (NFc == 1) {
1135  fullType = 3;
1136  h2FullType->Fill((int)fullType, dit->fedId());
1137  }
1138  if (NFd == 1) {
1139  fullType = 4;
1140  h2FullType->Fill((int)fullType, dit->fedId());
1141  }
1142  if (NFe == 1) {
1143  fullType = 5;
1144  h2FullType->Fill((int)fullType, dit->fedId());
1145  }
1146  if (NF2 == 1) {
1147  fullType = 6;
1148  h2FullType->Fill((int)fullType, dit->fedId());
1149  }
1150  if (L1A == 1) {
1151  fullType = 7;
1152  h2FullType->Fill((int)fullType, dit->fedId());
1153  }
1154  }
1155 
1156  if (dit->errorType() == 30) { //error 30 = TBM error trailer
1157  uint32_t errorWord = dit->errorWord32();
1158  int t0 = (errorWord >> DB0_shift) & DataBit_mask;
1159  int t1 = (errorWord >> DB1_shift) & DataBit_mask;
1160  int t2 = (errorWord >> DB2_shift) & DataBit_mask;
1161  int t3 = (errorWord >> DB3_shift) & DataBit_mask;
1162  int t4 = (errorWord >> DB4_shift) & DataBit_mask;
1163  int t5 = (errorWord >> DB5_shift) & DataBit_mask;
1164  int t6 = (errorWord >> DB6_shift) & DataBit_mask;
1165  int t7 = (errorWord >> DB7_shift) & DataBit_mask;
1166  if (t0 == 1) {
1167  h2TBMMessageRP[index]->Fill(0, plane);
1168  if (fillFED)
1169  h2TBMMessageFED[iFed]->Fill(0, chanNmbr);
1170  }
1171  if (t1 == 1) {
1172  h2TBMMessageRP[index]->Fill(1, plane);
1173  if (fillFED)
1174  h2TBMMessageFED[iFed]->Fill(1, chanNmbr);
1175  }
1176  if (t2 == 1) {
1177  h2TBMMessageRP[index]->Fill(2, plane);
1178  if (fillFED)
1179  h2TBMMessageFED[iFed]->Fill(2, chanNmbr);
1180  }
1181  if (t3 == 1) {
1182  h2TBMMessageRP[index]->Fill(3, plane);
1183  if (fillFED)
1184  h2TBMMessageFED[iFed]->Fill(3, chanNmbr);
1185  }
1186  if (t4 == 1) {
1187  h2TBMMessageRP[index]->Fill(4, plane);
1188  if (fillFED)
1189  h2TBMMessageFED[iFed]->Fill(4, chanNmbr);
1190  }
1191  if (t5 == 1) {
1192  h2TBMMessageRP[index]->Fill(5, plane);
1193  if (fillFED)
1194  h2TBMMessageFED[iFed]->Fill(5, chanNmbr);
1195  }
1196  if (t6 == 1) {
1197  h2TBMMessageRP[index]->Fill(6, plane);
1198  if (fillFED)
1199  h2TBMMessageFED[iFed]->Fill(6, chanNmbr);
1200  }
1201  if (t7 == 1) {
1202  h2TBMMessageRP[index]->Fill(7, plane);
1203  if (fillFED)
1204  h2TBMMessageFED[iFed]->Fill(7, chanNmbr);
1205  }
1206  int stateMach_bits = 4;
1207  int stateMach_shift = 8;
1208  uint32_t stateMach_mask = ~(~uint32_t(0) << stateMach_bits);
1209  uint32_t stateMach = (errorWord >> stateMach_shift) & stateMach_mask;
1210  if (stateMach == 0) {
1211  h2TBMTypeRP[index]->Fill(0, plane);
1212  if (fillFED)
1213  h2TBMTypeFED[iFed]->Fill(0, chanNmbr);
1214  } else {
1215  if (((stateMach >> DB0_shift) & DataBit_mask) == 1) {
1216  h2TBMTypeRP[index]->Fill(1, plane);
1217  if (fillFED)
1218  h2TBMTypeFED[iFed]->Fill(1, chanNmbr);
1219  }
1220  if (((stateMach >> DB1_shift) & DataBit_mask) == 1) {
1221  h2TBMTypeRP[index]->Fill(2, plane);
1222  if (fillFED)
1223  h2TBMTypeFED[iFed]->Fill(2, chanNmbr);
1224  }
1225  if (((stateMach >> DB2_shift) & DataBit_mask) == 1) {
1226  h2TBMTypeRP[index]->Fill(3, plane);
1227  if (fillFED)
1228  h2TBMTypeFED[iFed]->Fill(3, chanNmbr);
1229  }
1230  if (((stateMach >> DB3_shift) & DataBit_mask) == 1) {
1231  h2TBMTypeRP[index]->Fill(4, plane);
1232  if (fillFED)
1233  h2TBMTypeFED[iFed]->Fill(4, chanNmbr);
1234  }
1235  }
1236  }
1237  if (fillFED)
1238  h2ErrorCodeFED[iFed]->Fill(dit->errorType(), chanNmbr);
1239  }
1240  } // end if(RPindexValid[index]) {
1241  }
1242  } // end if(StationStatus[station]) {
1243  } // end for(const auto &ds_error : *pixDigi)
1244  } // if(pixError.isValid())
1245 
1246  if (pixClus.isValid() && onlinePlots)
1247  for (const auto &ds : *pixClus) {
1248  int idet = getDet(ds.id);
1249  if (idet != DetId::VeryForward && verbosity > 1) {
1250  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: cluster.id" << ds.id;
1251  continue;
1252  }
1253 
1254  CTPPSDetId theId(ds.id);
1255  int plane = getPixPlane(ds.id);
1256  int arm = theId.arm() & 0x1;
1257  int station = theId.station() & 0x3;
1258  int rpot = theId.rp() & 0x7;
1259 
1260  if ((StationStatus[station] == 0) || (RPstatus[station][rpot] == 0))
1261  continue;
1262 
1263  for (const auto &p : ds) {
1264  int clusize = p.size();
1265 
1266  if (clusize > ClusterSizeMax)
1267  clusize = ClusterSizeMax;
1268 
1269  h2CluSize[arm][station]->Fill(prIndex(rpot, plane), clusize);
1270  }
1271  } // end if(pixClus.isValid()) for(const auto &ds : *pixClus)
1272 
1273  bool allRPactivity = false;
1274  for (int rp = 0; rp < RPotsTotalNumber; rp++)
1275  if (RPactivity[rp] > 0)
1276  allRPactivity = true;
1277  for (int arm = 0; arm < 2; arm++) {
1278  for (int stn = 0; stn < NStationMAX; stn++) {
1279  for (int rp = 0; rp < NRPotsMAX; rp++) {
1280  int index = getRPindex(arm, stn, rp);
1281  if (RPindexValid[index] == 0)
1282  continue;
1283 
1284  if (onlinePlots)
1285  hpRPactive->Fill(getRPglobalBin(arm, stn), RPactivity[index]);
1286  // if(RPactivity[index]==0) continue;
1287  if (!allRPactivity)
1288  continue;
1289  if (onlinePlots)
1290  hpixLTrack->Fill(getRPglobalBin(arm, stn), pixRPTracks[index]);
1291  int ntr = pixRPTracks[index];
1292  if (ntr > NLocalTracksMAX)
1293  ntr = NLocalTracksMAX;
1294  for (int i = 0; i <= NLocalTracksMAX; i++) {
1295  if (i == ntr)
1296  htrackMult[index]->Fill(ntr, 1.);
1297  else
1298  htrackMult[index]->Fill(i, 0.);
1299  }
1300 
1301  int np = 0;
1302  for (int p = 0; p < NplaneMAX; p++)
1303  if (HitsMultPlane[index][p] > 0)
1304  np++;
1305  for (int p = 0; p <= NplaneMAX; p++) {
1306  if (p == np)
1307  hRPotActivPlanes[index]->Fill(p, 1.);
1308  else
1309  hRPotActivPlanes[index]->Fill(p, 0.);
1310  }
1311  if (onlinePlots) {
1312  if (np >= 5)
1313  hRPotActivBX[index]->Fill(event.bunchCrossing());
1314  hRPotActivBXall[index]->Fill(event.bunchCrossing(), float(RPdigiSize[index]));
1315  }
1316 
1317  // Select only events from the desired random trigger and fill the histogram
1318  const edm::TriggerNames &trigNames = event.triggerNames(*hltResults);
1319  for (int p = 0; p < NplaneMAX; p++) {
1320  for (unsigned int i = 0; i < trigNames.size(); i++) {
1321  const std::string &triggerName = trigNames.triggerName(i);
1322  if ((hltResults->accept(i) > 0) && (triggerName == randomHLTPath))
1323  h2HitsVsBXRandoms[index]->Fill(event.bunchCrossing(), p, HitsMultPlane[index][p]);
1324  }
1325  }
1326 
1327  int planesFiredAtROC[NROCsMAX]; // how many planes registered hits on ROC r
1328  for (int r = 0; r < NROCsMAX; r++)
1329  planesFiredAtROC[r] = 0;
1330  for (int p = 0; p < NplaneMAX; p++) {
1331  int indp = getPlaneIndex(arm, stn, rp, p);
1332  for (int r = 0; r < NROCsMAX; r++)
1333  if (HitsMultROC[indp][r] > 0)
1334  ++planesFiredAtROC[r];
1335  for (int r = 0; r < NROCsMAX; r++) {
1336  if (onlinePlots)
1337  h2HitsMultROC[index]->Fill(p, r, HitsMultROC[indp][r]);
1338  hp2HitsMultROC_LS[index]->Fill(lumiId, p * NROCsMAX + r, HitsMultROC[indp][r]);
1339  }
1340  }
1341  int max = 0;
1342  for (int r = 0; r < NROCsMAX; r++)
1343  if (max < planesFiredAtROC[r])
1344  max = planesFiredAtROC[r];
1345  if (max >= 4 && onlinePlots) // fill only if there are at least 4 aligned ROCs firing
1346  hRPotActivBXroc[index]->Fill(event.bunchCrossing());
1347  if (max >= 3 && onlinePlots) // fill only if there are at least 3 aligned ROCs firing
1348  hRPotActivBXroc_3[index]->Fill(event.bunchCrossing());
1349  if (max >= 2 && onlinePlots) // fill only if there are at least 2 aligned ROCs firing
1350  hRPotActivBXroc_2[index]->Fill(event.bunchCrossing());
1351  } // end for(int rp=0; rp<NRPotsMAX; rp++) {
1352  }
1353  } // end for(int arm=0; arm<2; arm++) {
1354 
1355  if ((nEvents % 100))
1356  return;
1357  if (verbosity)
1358  LogPrint("CTPPSPixelDQMSource") << "analyze event " << nEvents;
1359 }
1360 
1361 //---------------------------------------------------------------------------
int StationStatus[StationIDMAX]
const double Pi
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelDataError > > tokenError
edm::ESGetToken< CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd > tokenPixelDAQMapping
MonitorElement * hHitsMult[RPotsTotalNumber][NplaneMAX]
int HitsMultPlane[RPotsTotalNumber][NplaneMAX]
MonitorElement * hp2xyADC[RPotsTotalNumber][NplaneMAX]
MonitorElement * hpRPactive
Contains mappind data related to a ROC.
MonitorElement * hp2HitsMultROC_LS[RPotsTotalNumber]
static constexpr int ClusMultMAX
static constexpr int mapYbins
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelCluster > > tokenCluster
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:476
virtual TProfile * getTProfile() const
MonitorElement * h2CluSize[NArms][NStationMAX]
static constexpr int ADCMax
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelDigi > > tokenDigi
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
static constexpr int RPotsIDMAX
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
static constexpr int DB2_shift
static constexpr int LINK_bits
uint32_t arm() const
Definition: CTPPSDetId.h:57
MonitorElement * htrackMult[RPotsTotalNumber]
MonitorElement * h2HitsMultROC[RPotsTotalNumber]
uint32_t ID
Definition: Definitions.h:24
MonitorElement * h2trackXY0[RPotsTotalNumber]
MonitorElement * hpixLTrack
static constexpr int NRPotBinsInStation
MonitorElement * hRPotActivBXroc_3[RPotsTotalNumber]
static constexpr int RPn_last
static constexpr int hitMultMAX
static constexpr int dimension
static constexpr int NRPotsMAX
static constexpr int NPlaneBins
static constexpr int DB3_shift
MonitorElement * h2TBMMessageFED[2]
static constexpr uint32_t DataBit_mask
static constexpr int DataBit_bits
CTPPSPixelIndices thePixIndices
MonitorElement * h2HitsVsBXRandoms[RPotsTotalNumber]
static constexpr int RPotsTotalNumber
static std::string to_string(const XMLCh *ch)
static constexpr int mapXbins
static constexpr float mapYmax
static constexpr int DCOL_shift
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
uint32_t iD
the symbolic id
MonitorElement * h2TBMMessageUnidDet
MonitorElement * htrackHits[RPotsTotalNumber]
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelLocalTrack > > tokenTrack
virtual TH2F * getTH2F() const
static constexpr int DB6_shift
MonitorElement * h2TBMTypeUnidDet
static constexpr int ROC_bits
int prIndex(int rp, int plane)
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:155
static constexpr int ROC_shift
int RPindexValid[RPotsTotalNumber]
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * h2Efficiency[RPotsTotalNumber][NplaneMAX]
MonitorElement * hROCadc[RPotsTotalNumber *NplaneMAX][NROCsMAX]
static constexpr int minFedNumber
int np
Definition: AMPTWrapper.h:43
CTPPSPixelDQMSource(const edm::ParameterSet &ps)
static constexpr int ADC_bits
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
static constexpr int errCodeSize
MonitorElement * hRPotActivBX[RPotsTotalNumber]
MonitorElement * h2ErrorCodeFED[2]
uint32_t plane() const
static constexpr int NLocalTracksMAX
static constexpr int PXID_shift
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static constexpr int numberOfFeds
static constexpr int DB0_shift
static constexpr int ClusterSizeMax
uint32_t nh
int transformToROC(const int col, const int row, int &rocId, int &colROC, int &rowROC) const
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
int getRPindex(int arm, int station, int rp)
Log< level::Warning, true > LogPrint
MonitorElement * hRPotActivBXroc_2[RPotsTotalNumber]
MonitorElement * hRPotActivBXroc[RPotsTotalNumber]
static constexpr int DB7_shift
const int verbosity
MonitorElement * h2xyROCHits[RPotsTotalNumber *NplaneMAX][NROCsMAX]
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
MonitorElement * hRPotActivBXall[RPotsTotalNumber]
uint32_t rp() const
Definition: CTPPSDetId.h:71
constexpr int defaultDetSizeInX
static constexpr int NRPglobalBins
static constexpr int StationIDMAX
MonitorElement * h2ErrorCodeRP[RPotsTotalNumber]
static constexpr int NStationMAX
static constexpr uint32_t DCOL_mask
static constexpr int DB5_shift
static constexpr int NROCsMAX
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
uint32_t station() const
Definition: CTPPSDetId.h:64
static constexpr uint32_t LINK_mask
static constexpr int PXID_bits
static constexpr uint32_t PXID_mask
MonitorElement * book2DD(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:338
bool isValid() const
Definition: HandleBase.h:70
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
static constexpr int DB1_shift
MonitorElement * h2FullType
HLT enums.
static const int kDetOffset
Definition: DetId.h:21
MonitorElement * h2ErrorCodeUnidDet
static constexpr int NArms
MonitorElement * h2TBMTypeFED[2]
col
Definition: cuy.py:1009
MonitorElement * h2AllPlanesActive
static constexpr int RPn_first
virtual TProfile2D * getTProfile2D() const
static constexpr int DB4_shift
int getRPglobalBin(int arm, int stn)
int HitsMultROC[RPotsTotalNumber *NplaneMAX][NROCsMAX]
MonitorElement * h2TBMMessageRP[RPotsTotalNumber]
static constexpr uint32_t ADC_mask
static constexpr int NplaneMAX
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
int getPlaneIndex(int arm, int station, int rp, int plane)
MonitorElement * h2xyHits[RPotsTotalNumber][NplaneMAX]
MonitorElement * hRPotActivPlanes[RPotsTotalNumber]
static constexpr int LINK_shift
int RPstatus[StationIDMAX][RPotsIDMAX]
static constexpr int ADC_shift
MonitorElement * hBXshort
static constexpr uint32_t ROC_mask
bool isPlanePlotsTurnedOff[NArms][NStationMAX][NRPotsMAX][NplaneMAX]
MonitorElement * h2HitsMultipl[NArms][NStationMAX]
Definition: event.py:1
Definition: Run.h:45
uint16_t *__restrict__ uint16_t const *__restrict__ adc
MonitorElement * h2TBMTypeRP[RPotsTotalNumber]
edm::EDGetTokenT< edm::TriggerResults > tokenTrigResults
constexpr int ROCSizeInX
The mapping between FramePosition and ROCInfo.
static constexpr float mapYmin
static constexpr int DCOL_bits
constexpr int ROCSizeInY
virtual TH2D * getTH2D() const