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