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