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 
28 
29 #include <string>
30 
31 //-----------------------------------------------------------------------------
32 
34 public:
36  ~CTPPSPixelDQMSource() override;
37 
38 protected:
39  void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override;
40  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
41  void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override;
42 
43 private:
44  unsigned int verbosity;
45  long int nEvents = 0;
50 
51  static constexpr int NArms = 2;
52  static constexpr int NStationMAX = 3; // in an arm
53  static constexpr int NRPotsMAX = 6; // per station
54  static constexpr int NplaneMAX = 6; // per RPot
55  static constexpr int NROCsMAX = 6; // per plane
56  static constexpr int RPn_first = 3, RPn_last = 4;
57  static constexpr int ADCMax = 256;
58  static constexpr int StationIDMAX = 4; // possible range of ID
59  static constexpr int RPotsIDMAX = 8; // possible range of ID
60  static constexpr int NLocalTracksMAX = 20;
61  static constexpr int hitMultMAX = 50; // tuned
62  static constexpr int ClusMultMAX = 10; // tuned
63  static constexpr int ClusterSizeMax = 9;
64  static constexpr int errCodeSize = 15;
65 
66  static constexpr int mapXbins = 200;
67  static constexpr int mapYbins = 240;
68  static constexpr float mapYmin = -16.;
69  static constexpr float mapYmax = 8.;
70  const float mapXmin = 0. * TMath::Cos(18.4 / 180. * TMath::Pi());
71  const float mapXmax = 30. * TMath::Cos(18.4 / 180. * TMath::Pi());
72 
74 
76 
77  static constexpr int NRPotBinsInStation = RPn_last - RPn_first;
78  static constexpr int NPlaneBins = NplaneMAX * NRPotBinsInStation;
79 
82 
85 
86  static constexpr int RPotsTotalNumber = NArms * NStationMAX * NRPotsMAX;
87 
92 
111 
112  // Flags for disabling set of plots
113  bool offlinePlots = true;
114  bool onlinePlots = true;
115 
116  // Flags for disabling plots of a plane
118 
119  unsigned int rpStatusWord = 0x8008; // 220_fr_hr(stn2rp3)+ 210_fr_hr
120  int RPstatus[StationIDMAX][RPotsIDMAX]; // symmetric in both arms
121  int StationStatus[StationIDMAX]; // symmetric in both arms
122  const int IndexNotValid = 0;
123 
124  int getRPindex(int arm, int station, int rp) {
125  if (arm < 0 || station < 0 || rp < 0)
126  return (IndexNotValid);
127  if (arm > 1 || station >= NStationMAX || rp >= NRPotsMAX)
128  return (IndexNotValid);
129  int rc = (arm * NStationMAX + station) * NRPotsMAX + rp;
130  return (rc);
131  }
132 
133  int getPlaneIndex(int arm, int station, int rp, int plane) {
134  if (plane < 0 || plane >= NplaneMAX)
135  return (IndexNotValid);
136  int rc = getRPindex(arm, station, rp);
137  if (rc == IndexNotValid)
138  return (IndexNotValid);
139  return (rc * NplaneMAX + plane);
140  }
141 
142  int getRPInStationBin(int rp) { return (rp - RPn_first + 1); }
143 
144  static constexpr int NRPglobalBins = 4; // 2 arms w. 2 stations w. 1 RP
145 
146  int getRPglobalBin(int arm, int stn) {
147  static constexpr int stationBinOrder[NStationMAX] = {0, 4, 1};
148  return (arm * 2 + stationBinOrder[stn] + 1);
149  }
150 
151  int prIndex(int rp, int plane) // plane index in station
152 
153  {
154  return ((rp - RPn_first) * NplaneMAX + plane);
155  }
156  int getDet(int id) { return (id >> DetId::kDetOffset) & 0xF; }
157  int getPixPlane(int id) { return ((id >> 16) & 0x7); }
158  // int getSubdet(int id) { return ((id>>kSubdetOffset)&0x7); }
159 
161 };
162 
163 //----------------------------------------------------------------------------------
164 
165 using namespace std;
166 using namespace edm;
167 
168 //-------------------------------------------------------------------------------
169 
171  : verbosity(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
172  rpStatusWord(ps.getUntrackedParameter<unsigned int>("RPStatusWord", 0x8008)) {
173  tokenDigi = consumes<DetSetVector<CTPPSPixelDigi>>(ps.getUntrackedParameter<edm::InputTag>("tagRPixDigi"));
174  tokenError = consumes<DetSetVector<CTPPSPixelDataError>>(ps.getUntrackedParameter<edm::InputTag>("tagRPixError"));
175  tokenCluster = consumes<DetSetVector<CTPPSPixelCluster>>(ps.getUntrackedParameter<edm::InputTag>("tagRPixCluster"));
176  tokenTrack = consumes<DetSetVector<CTPPSPixelLocalTrack>>(ps.getUntrackedParameter<edm::InputTag>("tagRPixLTrack"));
177  offlinePlots = ps.getUntrackedParameter<bool>("offlinePlots", true);
178  onlinePlots = ps.getUntrackedParameter<bool>("onlinePlots", true);
179 
180  vector<string> disabledPlanePlotsVec =
181  ps.getUntrackedParameter<vector<string>>("turnOffPlanePlots", vector<string>());
182 
183  // Parse the strings in disabledPlanePlotsVec and set the flags in
184  // isPlanePlotsTurnedOff
185  for (auto s : disabledPlanePlotsVec) {
186  // Check that the format is <arm>_<station>_<RP>_<Plane>
187  if (count(s.begin(), s.end(), '_') != 3)
188  throw cms::Exception("RPixPlaneCombinatoryTracking") << "Invalid string in turnOffPlanePlots: " << s;
189  else {
190  vector<string> armStationRpPlane;
191  size_t pos = 0;
192  while ((pos = s.find('_')) != string::npos) {
193  armStationRpPlane.push_back(s.substr(0, pos));
194  s.erase(0, pos + 1);
195  }
196  armStationRpPlane.push_back(s);
197 
198  int arm = stoi(armStationRpPlane.at(0));
199  int station = stoi(armStationRpPlane.at(1));
200  int rp = stoi(armStationRpPlane.at(2));
201  int plane = stoi(armStationRpPlane.at(3));
202 
203  if (arm < NArms && station < NStationMAX && rp < NRPotsMAX && plane < NplaneMAX) {
204  if (verbosity)
205  LogPrint("CTPPSPixelDQMSource")
206  << "Shutting off plots for: Arm " << arm << " Station " << station << " Rp " << rp << " Plane " << plane;
207  isPlanePlotsTurnedOff[arm][station][rp][plane] = true;
208  } else {
209  throw cms::Exception("RPixPlaneCombinatoryTracking") << "Invalid string in turnOffPlanePlots: " << s;
210  }
211  }
212  }
213 }
214 
215 //----------------------------------------------------------------------------------
216 
218 
219 //--------------------------------------------------------------------------
220 
222  if (verbosity)
223  LogPrint("CTPPSPixelDQMSource") << "RPstatusWord= " << rpStatusWord;
224  nEvents = 0;
225 
226  CTPPSPixelLocalTrack thePixelLocalTrack;
227  TrackFitDimension = thePixelLocalTrack.dimension;
228 
229  for (int stn = 0; stn < StationIDMAX; stn++) {
230  StationStatus[stn] = 0;
231  for (int rp = 0; rp < RPotsIDMAX; rp++)
232  RPstatus[stn][rp] = 0;
233  }
234 
235  unsigned int rpSts = rpStatusWord << 1;
236  for (int stn = 0; stn < NStationMAX; stn++) {
237  int stns = 0;
238  for (int rp = 0; rp < NRPotsMAX; rp++) {
239  rpSts = (rpSts >> 1);
240  RPstatus[stn][rp] = rpSts & 1;
241  if (RPstatus[stn][rp] > 0)
242  stns = 1;
243  }
244  StationStatus[stn] = stns;
245  }
246 
247  for (int ind = 0; ind < 2 * 3 * NRPotsMAX; ind++)
248  RPindexValid[ind] = 0;
249 
250  x0_MIN = y0_MIN = 1.0e06;
251  x0_MAX = y0_MAX = -1.0e06;
252 }
253 
254 //-------------------------------------------------------------------------------------
255 
257  ibooker.cd();
258  ibooker.setCurrentFolder("CTPPS/TrackingPixel");
259  char s[50];
260  string armTitleShort, stnTitleShort;
261 
262  TAxis *yah1st = nullptr;
263  TAxis *xaRPact = nullptr;
264  TAxis *xah1trk = nullptr;
265  if (onlinePlots) {
266  hBX = ibooker.book1D("events per BX", "ctpps_pixel;Event.BX", 4002, -1.5, 4000. + 0.5);
267  hBXshort = ibooker.book1D("events per BX(short)", "ctpps_pixel;Event.BX", 102, -1.5, 100. + 0.5);
268 
269  string str1st = "Pixel planes activity";
270  h2AllPlanesActive = ibooker.book2DD(
271  str1st, str1st + "(digi task);Plane #", NplaneMAX, 0, NplaneMAX, NRPglobalBins, 0.5, NRPglobalBins + 0.5);
272  TH2D *h1st = h2AllPlanesActive->getTH2D();
273  h1st->SetOption("colz");
274  yah1st = h1st->GetYaxis();
275 
276  string str2 = "Pixel RP active";
277  hpRPactive = ibooker.bookProfile(
278  str2, str2 + " per event(digi task)", NRPglobalBins, 0.5, NRPglobalBins + 0.5, -0.1, 1.1, "");
279  xaRPact = hpRPactive->getTProfile()->GetXaxis();
280  hpRPactive->getTProfile()->SetOption("hist");
281  hpRPactive->getTProfile()->SetMinimum(0.);
282  hpRPactive->getTProfile()->SetMaximum(1.1);
283 
284  str2 = "Pixel Local Tracks";
285  hpixLTrack = ibooker.bookProfile(
286  str2, str2 + " per event", NRPglobalBins, 0.5, NRPglobalBins + 0.5, -0.1, NLocalTracksMAX, "");
287 
288  xah1trk = hpixLTrack->getTProfile()->GetXaxis();
289  hpixLTrack->getTProfile()->GetYaxis()->SetTitle("average number of tracks per event");
290  hpixLTrack->getTProfile()->SetOption("hist");
291  }
292  const float minErrCode = 25.;
293  const string errCode[errCodeSize] = {
294  "Invalid ROC ", // error 25
295  "Gap word", // error 26
296  "Dummy word", // error 27
297  "FIFO nearly full", // error 28
298  "Channel Timeout", // error 29
299  "TBM Trailer", // error 30
300  "Event number mismatch", // error 31
301  "Invalid/no FED header", // error 32
302  "Invalid/no FED trailer", // error 33
303  "Size mismatch", // error 34
304  "Conversion: inv. channel", // error 35
305  "Conversion: inv. ROC number", // error 36
306  "Conversion: inv. pixel address", // error 37
307  "-",
308  "CRC" //error 39
309  };
310  h2ErrorCode = ibooker.book2D("Errors in Unidentified Det",
311  "Errors in Unidentified Det;;fed",
312  errCodeSize,
313  minErrCode - 0.5,
314  minErrCode + float(errCodeSize) - 0.5,
315  2,
316  1461.5,
317  1463.5);
318  for (unsigned int iBin = 1; iBin <= errCodeSize; iBin++)
319  h2ErrorCode->setBinLabel(iBin, errCode[iBin - 1]);
320  h2ErrorCode->setBinLabel(1, "1462", 2);
321  h2ErrorCode->setBinLabel(2, "1463", 2);
322  h2ErrorCode->getTH2F()->SetOption("colz");
323 
324  for (int arm = 0; arm < 2; arm++) {
326  string sd, armTitle;
327  ID.armName(sd, CTPPSDetId::nPath);
328  ID.armName(armTitle, CTPPSDetId::nFull);
329  ID.armName(armTitleShort, CTPPSDetId::nShort);
330 
331  ibooker.setCurrentFolder(sd);
332 
333  for (int stn = 0; stn < NStationMAX; stn++) {
334  if (StationStatus[stn] == 0)
335  continue;
336  ID.setStation(stn);
337  string stnd, stnTitle;
338 
339  CTPPSDetId(ID.stationId()).stationName(stnd, CTPPSDetId::nPath);
340  CTPPSDetId(ID.stationId()).stationName(stnTitle, CTPPSDetId::nFull);
341  CTPPSDetId(ID.stationId()).stationName(stnTitleShort, CTPPSDetId::nShort);
342 
343  ibooker.setCurrentFolder(stnd);
344  //--------- RPots ---
345  int pixBinW = 4;
346  for (int rp = RPn_first; rp < RPn_last; rp++) { // only installed pixel pots
347  ID.setRP(rp);
348  string rpd, rpTitle;
349  CTPPSDetId(ID.rpId()).rpName(rpTitle, CTPPSDetId::nShort);
350  string rpBinName = armTitleShort + "_" + stnTitleShort + "_" + rpTitle;
351  if (onlinePlots) {
352  yah1st->SetBinLabel(getRPglobalBin(arm, stn), rpBinName.c_str());
353  xah1trk->SetBinLabel(getRPglobalBin(arm, stn), rpBinName.c_str());
354  xaRPact->SetBinLabel(getRPglobalBin(arm, stn), rpBinName.c_str());
355  }
356  if (RPstatus[stn][rp] == 0)
357  continue;
358  int indexP = getRPindex(arm, stn, rp);
359  RPindexValid[indexP] = 1;
360 
361  CTPPSDetId(ID.rpId()).rpName(rpTitle, CTPPSDetId::nFull);
362  CTPPSDetId(ID.rpId()).rpName(rpd, CTPPSDetId::nPath);
363 
364  ibooker.setCurrentFolder(rpd);
365 
366  const float x0Maximum = 70.;
367  const float y0Maximum = 15.;
368  string st = "track intercept point";
369  string st2 = ": " + stnTitle;
370  h2trackXY0[indexP] = ibooker.book2D(
371  st, st + st2 + ";x0;y0", int(x0Maximum) * 2, 0., x0Maximum, int(y0Maximum) * 4, -y0Maximum, y0Maximum);
372  h2trackXY0[indexP]->getTH2F()->SetOption("colz");
373  st = "Error Code";
374  h2ErrorCodeRP[indexP] = ibooker.book2D(st,
375  st + st2 + ";;plane",
376  errCodeSize,
377  minErrCode - 0.5,
378  minErrCode + float(errCodeSize) - 0.5,
379  6,
380  -0.5,
381  5.5);
382  for (unsigned int iBin = 1; iBin <= errCodeSize; iBin++)
383  h2ErrorCodeRP[indexP]->setBinLabel(iBin, errCode[iBin - 1]);
384  h2ErrorCodeRP[indexP]->getTH2F()->SetOption("colz");
385 
386  st = "number of tracks per event";
387  htrackMult[indexP] = ibooker.bookProfile(st,
388  rpTitle + ";number of tracks",
389  NLocalTracksMAX + 1,
390  -0.5,
391  NLocalTracksMAX + 0.5,
392  -0.5,
393  NLocalTracksMAX + 0.5,
394  "");
395  htrackMult[indexP]->getTProfile()->SetOption("hist");
396 
397  hRPotActivPlanes[indexP] = ibooker.bookProfile("number of fired planes per event",
398  rpTitle + ";nPlanes;Probability",
399  NplaneMAX + 1,
400  -0.5,
401  NplaneMAX + 0.5,
402  -0.5,
403  NplaneMAX + 0.5,
404  "");
405  hRPotActivPlanes[indexP]->getTProfile()->SetOption("hist");
406 
407  hp2HitsMultROC_LS[indexP] = ibooker.bookProfile2D("ROCs hits multiplicity per event vs LS",
408  rpTitle + ";LumiSection;Plane#___ROC#",
409  1000,
410  0.,
411  1000.,
413  0.,
414  double(NplaneMAX * NROCsMAX),
415  0.,
417  "");
418  hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetOption("colz");
419  hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetMinimum(1.0e-10);
420  hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetCanExtend(TProfile2D::kXaxis);
421  TAxis *yahp2 = hp2HitsMultROC_LS[indexP]->getTProfile2D()->GetYaxis();
422  for (int p = 0; p < NplaneMAX; p++) {
423  sprintf(s, "plane%d_0", p);
424  yahp2->SetBinLabel(p * NplaneMAX + 1, s);
425  for (int r = 1; r < NROCsMAX; r++) {
426  sprintf(s, " %d_%d", p, r);
427  yahp2->SetBinLabel(p * NplaneMAX + r + 1, s);
428  }
429  }
430 
431  if (onlinePlots) {
432  string st3 = ";PlaneIndex(=pixelPot*PlaneMAX + plane)";
433 
434  st = "hit multiplicity in planes";
435  h2HitsMultipl[arm][stn] = ibooker.book2DD(
436  st, st + st2 + st3 + ";multiplicity", NPlaneBins, 0, NPlaneBins, hitMultMAX, 0, hitMultMAX);
437  h2HitsMultipl[arm][stn]->getTH2D()->SetOption("colz");
438 
439  st = "cluster size in planes";
440  h2CluSize[arm][stn] = ibooker.book2D(st,
441  st + st2 + st3 + ";Cluster size",
442  NPlaneBins,
443  0,
444  NPlaneBins,
445  ClusterSizeMax + 1,
446  0,
447  ClusterSizeMax + 1);
448  h2CluSize[arm][stn]->getTH2F()->SetOption("colz");
449 
450  st = "number of hits per track";
451  htrackHits[indexP] = ibooker.bookProfile(st, rpTitle + ";number of hits", 5, 1.5, 6.5, -0.1, 1.1, "");
452  htrackHits[indexP]->getTProfile()->SetOption("hist");
453 
454  h2HitsMultROC[indexP] = ibooker.bookProfile2D("ROCs hits multiplicity per event",
455  rpTitle + ";plane # ;ROC #",
456  NplaneMAX,
457  -0.5,
458  NplaneMAX - 0.5,
459  NROCsMAX,
460  -0.5,
461  NROCsMAX - 0.5,
462  0.,
464  "");
465  h2HitsMultROC[indexP]->getTProfile2D()->SetOption("colztext");
466  h2HitsMultROC[indexP]->getTProfile2D()->SetMinimum(1.e-10);
467 
468  ibooker.setCurrentFolder(rpd + "/latency");
469  hRPotActivBX[indexP] =
470  ibooker.book1D("5 fired planes per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
471 
472  hRPotActivBXroc[indexP] =
473  ibooker.book1D("4 fired ROCs per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
474  hRPotActivBXroc_3[indexP] =
475  ibooker.book1D("3 fired ROCs per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
476  hRPotActivBXroc_2[indexP] =
477  ibooker.book1D("2 fired ROCs per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
478 
479  hRPotActivBXall[indexP] = ibooker.book1D("hits per BX", rpTitle + ";Event.BX", 4002, -1.5, 4000. + 0.5);
480  }
481  int nbins = rpixValues::defaultDetSizeInX / pixBinW;
482 
483  for (int p = 0; p < NplaneMAX; p++) {
484  if (isPlanePlotsTurnedOff[arm][stn][rp][p])
485  continue;
486  sprintf(s, "plane_%d", p);
487  string pd = rpd + "/" + string(s);
488  ibooker.setCurrentFolder(pd);
489  string st1 = ": " + rpTitle + "_" + string(s);
490 
491  st = "adc average value";
492  hp2xyADC[indexP][p] = ibooker.bookProfile2D(st,
493  st1 + ";pix col;pix row",
494  nbins,
495  0,
497  nbins,
498  0,
500  0.,
501  512.,
502  "");
503  hp2xyADC[indexP][p]->getTProfile2D()->SetOption("colz");
504 
505  if (onlinePlots) {
506  st = "hits position";
507  h2xyHits[indexP][p] = ibooker.book2DD(st,
508  st1 + ";pix col;pix row",
510  0,
513  0,
515  h2xyHits[indexP][p]->getTH2D()->SetOption("colz");
516 
517  st = "hits multiplicity";
518  hHitsMult[indexP][p] =
519  ibooker.book1DD(st, st1 + ";number of hits;N / 1 hit", hitMultMAX + 1, -0.5, hitMultMAX + 0.5);
520  }
521 
522  if (offlinePlots) {
523  st = "plane efficiency";
524  h2Efficiency[indexP][p] = ibooker.bookProfile2D(
525  st, st1 + ";x0;y0", mapXbins, mapXmin, mapXmax, mapYbins, mapYmin, mapYmax, 0, 1, "");
526  h2Efficiency[indexP][p]->getTProfile2D()->SetOption("colz");
527  }
528  } // end of for(int p=0; p<NplaneMAX;..
529 
530  } // end for(int rp=0; rp<NRPotsMAX;...
531  } // end of for(int stn=0; stn<
532  } // end of for(int arm=0; arm<2;...
533 
534  return;
535 }
536 
537 //-------------------------------------------------------------------------------
538 
540  ++nEvents;
541  int lumiId = event.getLuminosityBlock().id().luminosityBlock();
542  if (lumiId < 0)
543  lumiId = 0;
544 
545  int RPactivity[RPotsTotalNumber], RPdigiSize[RPotsTotalNumber];
546  int pixRPTracks[RPotsTotalNumber];
547 
548  for (int rp = 0; rp < RPotsTotalNumber; rp++) {
549  RPactivity[rp] = RPdigiSize[rp] = pixRPTracks[rp] = 0;
550  }
551 
552  for (int ind = 0; ind < RPotsTotalNumber; ind++) {
553  for (int p = 0; p < NplaneMAX; p++) {
554  HitsMultPlane[ind][p] = 0;
555  }
556  }
557  for (int ind = 0; ind < RPotsTotalNumber * NplaneMAX; ind++) {
558  for (int roc = 0; roc < NROCsMAX; roc++) {
559  HitsMultROC[ind][roc] = 0;
560  }
561  }
563  event.getByToken(tokenDigi, pixDigi);
564 
566  event.getByToken(tokenError, pixError);
567 
569  event.getByToken(tokenCluster, pixClus);
570 
572  event.getByToken(tokenTrack, pixTrack);
573 
574  if (onlinePlots) {
575  hBX->Fill(event.bunchCrossing());
576  hBXshort->Fill(event.bunchCrossing());
577  }
578 
579  if (pixTrack.isValid()) {
580  for (const auto &ds_tr : *pixTrack) {
581  int idet = getDet(ds_tr.id);
582  if (idet != DetId::VeryForward) {
583  if (verbosity > 1)
584  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: ds_tr.id" << ds_tr.id;
585  continue;
586  }
587  CTPPSDetId theId(ds_tr.id);
588  int arm = theId.arm() & 0x1;
589  int station = theId.station() & 0x3;
590  int rpot = theId.rp() & 0x7;
591  int rpInd = getRPindex(arm, station, rpot);
592 
593  for (DetSet<CTPPSPixelLocalTrack>::const_iterator dit = ds_tr.begin(); dit != ds_tr.end(); ++dit) {
594  ++pixRPTracks[rpInd];
595  int nh_tr = (dit->ndf() + TrackFitDimension) / 2;
596  if (onlinePlots) {
597  for (int i = 0; i <= NplaneMAX; i++) {
598  if (i == nh_tr)
599  htrackHits[rpInd]->Fill(nh_tr, 1.);
600  else
601  htrackHits[rpInd]->Fill(i, 0.);
602  }
603  }
604  float x0 = dit->x0();
605  float y0 = dit->y0();
606  h2trackXY0[rpInd]->Fill(x0, y0);
607 
608  if (x0_MAX < x0)
609  x0_MAX = x0;
610  if (y0_MAX < y0)
611  y0_MAX = y0;
612  if (x0_MIN > x0)
613  x0_MIN = x0;
614  if (y0_MIN > y0)
615  y0_MIN = y0;
616 
617  if (offlinePlots) {
618  edm::DetSetVector<CTPPSPixelFittedRecHit> fittedHits = dit->hits();
619 
620  std::map<int, int> numberOfPointPerPlaneEff;
621  for (const auto &ds_frh : fittedHits) {
622  int plane = getPixPlane(ds_frh.id);
623  for (DetSet<CTPPSPixelFittedRecHit>::const_iterator frh_it = ds_frh.begin(); frh_it != ds_frh.end();
624  ++frh_it) { // there should always be only one hit in each
625  // vector
626  if (frh_it != ds_frh.begin())
627  if (verbosity > 1)
628  LogPrint("CTPPSPixelDQMSource") << "More than one FittedRecHit found in plane " << plane;
629  if (frh_it->isRealHit())
630  for (int p = 0; p < NplaneMAX; p++) {
631  if (p != plane)
632  numberOfPointPerPlaneEff[p]++;
633  }
634  }
635  }
636 
637  if (verbosity > 1)
638  for (auto planeAndHitsOnOthers : numberOfPointPerPlaneEff) {
639  LogPrint("CTPPSPixelDQMSource")
640  << "For plane " << planeAndHitsOnOthers.first << ", " << planeAndHitsOnOthers.second
641  << " hits on other planes were found" << endl;
642  }
643 
644  for (const auto &ds_frh : fittedHits) {
645  int plane = getPixPlane(ds_frh.id);
646  if (isPlanePlotsTurnedOff[arm][station][rpot][plane])
647  continue;
648  for (DetSet<CTPPSPixelFittedRecHit>::const_iterator frh_it = ds_frh.begin(); frh_it != ds_frh.end();
649  ++frh_it) {
650  float frhX0 = frh_it->globalCoordinates().x() + frh_it->xResidual();
651  float frhY0 = frh_it->globalCoordinates().y() + frh_it->yResidual();
652  if (numberOfPointPerPlaneEff[plane] >= 3) {
653  if (frh_it->isRealHit())
654  h2Efficiency[rpInd][plane]->Fill(frhX0, frhY0, 1);
655  else
656  h2Efficiency[rpInd][plane]->Fill(frhX0, frhY0, 0);
657  }
658  }
659  }
660  }
661  }
662  }
663  } // end if(pixTrack.isValid())
664 
665  bool valid = false;
666  valid |= pixDigi.isValid();
667  // valid |= Clus.isValid();
668 
669  if (!valid && verbosity)
670  LogPrint("CTPPSPixelDQMSource") << "No valid data in Event " << nEvents;
671 
672  if (pixDigi.isValid()) {
673  for (const auto &ds_digi : *pixDigi) {
674  int idet = getDet(ds_digi.id);
675  if (idet != DetId::VeryForward) {
676  if (verbosity > 1)
677  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: ds_digi.id" << ds_digi.id;
678  continue;
679  }
680  // int subdet = getSubdet(ds_digi.id);
681 
682  int plane = getPixPlane(ds_digi.id);
683 
684  CTPPSDetId theId(ds_digi.id);
685  int arm = theId.arm() & 0x1;
686  int station = theId.station() & 0x3;
687  int rpot = theId.rp() & 0x7;
688  int rpInd = getRPindex(arm, station, rpot);
689  RPactivity[rpInd] = 1;
690  ++RPdigiSize[rpInd];
691 
692  if (StationStatus[station] && RPstatus[station][rpot]) {
693  if (onlinePlots) {
694  h2HitsMultipl[arm][station]->Fill(prIndex(rpot, plane), ds_digi.data.size());
696  }
697  int index = getRPindex(arm, station, rpot);
698  HitsMultPlane[index][plane] += ds_digi.data.size();
699  if (RPindexValid[index]) {
700  int nh = ds_digi.data.size();
701  if (nh > hitMultMAX)
702  nh = hitMultMAX;
703  if (!isPlanePlotsTurnedOff[arm][station][rpot][plane])
704  if (onlinePlots)
705  hHitsMult[index][plane]->Fill(nh);
706  }
707  int rocHistIndex = getPlaneIndex(arm, station, rpot, plane);
708 
709  for (DetSet<CTPPSPixelDigi>::const_iterator dit = ds_digi.begin(); dit != ds_digi.end(); ++dit) {
710  int row = dit->row();
711  int col = dit->column();
712  int adc = dit->adc();
713 
714  if (RPindexValid[index]) {
715  if (!isPlanePlotsTurnedOff[arm][station][rpot][plane]) {
716  if (onlinePlots)
717  h2xyHits[index][plane]->Fill(col, row);
718  hp2xyADC[index][plane]->Fill(col, row, adc);
719  }
720  int colROC, rowROC;
721  int trocId;
722  if (!thePixIndices.transformToROC(col, row, trocId, colROC, rowROC)) {
723  if (trocId >= 0 && trocId < NROCsMAX) {
724  ++HitsMultROC[rocHistIndex][trocId];
725  }
726  }
727  } // end if(RPindexValid[index]) {
728  }
729  } // end if(StationStatus[station]) {
730  } // end for(const auto &ds_digi : *pixDigi)
731  } // if(pixDigi.isValid()) {
732 
733  if (pixError.isValid()) {
734  for (const auto &ds_error : *pixError) {
735  int idet = getDet(ds_error.id);
736  if (idet != DetId::VeryForward) {
737  if (idet == 15) { //dummy det id: store in a plot with fed info
738 
739  for (DetSet<CTPPSPixelDataError>::const_iterator dit = ds_error.begin(); dit != ds_error.end(); ++dit) {
740  h2ErrorCode->Fill(dit->errorType(), dit->fedId());
741  }
742  continue;
743  }
744  if (verbosity > 1)
745  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: ds_error.id" << ds_error.id;
746  continue;
747  }
748 
749  int plane = getPixPlane(ds_error.id);
750  CTPPSDetId theId(ds_error.id);
751  int arm = theId.arm() & 0x1;
752  int station = theId.station() & 0x3;
753  int rpot = theId.rp() & 0x7;
754  int rpInd = getRPindex(arm, station, rpot);
755  RPactivity[rpInd] = 1;
756 
757  if (StationStatus[station] && RPstatus[station][rpot]) {
758  int index = getRPindex(arm, station, rpot);
759  for (DetSet<CTPPSPixelDataError>::const_iterator dit = ds_error.begin(); dit != ds_error.end(); ++dit) {
760  if (RPindexValid[index]) {
761  if (!isPlanePlotsTurnedOff[arm][station][rpot][plane]) {
762  h2ErrorCodeRP[index]->Fill(dit->errorType(), plane);
763  }
764  } // end if(RPindexValid[index]) {
765  }
766  } // end if(StationStatus[station]) {
767  } // end for(const auto &ds_error : *pixDigi)
768  } // if(pixError.isValid())
769 
770  if (pixClus.isValid() && onlinePlots)
771  for (const auto &ds : *pixClus) {
772  int idet = getDet(ds.id);
773  if (idet != DetId::VeryForward && verbosity > 1) {
774  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: cluster.id" << ds.id;
775  continue;
776  }
777 
778  CTPPSDetId theId(ds.id);
779  int plane = getPixPlane(ds.id);
780  int arm = theId.arm() & 0x1;
781  int station = theId.station() & 0x3;
782  int rpot = theId.rp() & 0x7;
783 
784  if ((StationStatus[station] == 0) || (RPstatus[station][rpot] == 0))
785  continue;
786 
787  for (const auto &p : ds) {
788  int clusize = p.size();
789 
790  if (clusize > ClusterSizeMax)
791  clusize = ClusterSizeMax;
792 
793  h2CluSize[arm][station]->Fill(prIndex(rpot, plane), clusize);
794  }
795  } // end if(pixClus.isValid()) for(const auto &ds : *pixClus)
796 
797  bool allRPactivity = false;
798  for (int rp = 0; rp < RPotsTotalNumber; rp++)
799  if (RPactivity[rp] > 0)
800  allRPactivity = true;
801  for (int arm = 0; arm < 2; arm++) {
802  for (int stn = 0; stn < NStationMAX; stn++) {
803  for (int rp = 0; rp < NRPotsMAX; rp++) {
804  int index = getRPindex(arm, stn, rp);
805  if (RPindexValid[index] == 0)
806  continue;
807 
808  if (onlinePlots)
809  hpRPactive->Fill(getRPglobalBin(arm, stn), RPactivity[index]);
810  // if(RPactivity[index]==0) continue;
811  if (!allRPactivity)
812  continue;
813  if (onlinePlots)
814  hpixLTrack->Fill(getRPglobalBin(arm, stn), pixRPTracks[index]);
815  int ntr = pixRPTracks[index];
816  if (ntr > NLocalTracksMAX)
817  ntr = NLocalTracksMAX;
818  for (int i = 0; i <= NLocalTracksMAX; i++) {
819  if (i == ntr)
820  htrackMult[index]->Fill(ntr, 1.);
821  else
822  htrackMult[index]->Fill(i, 0.);
823  }
824 
825  int np = 0;
826  for (int p = 0; p < NplaneMAX; p++)
827  if (HitsMultPlane[index][p] > 0)
828  np++;
829  for (int p = 0; p <= NplaneMAX; p++) {
830  if (p == np)
831  hRPotActivPlanes[index]->Fill(p, 1.);
832  else
833  hRPotActivPlanes[index]->Fill(p, 0.);
834  }
835  if (onlinePlots) {
836  if (np >= 5)
837  hRPotActivBX[index]->Fill(event.bunchCrossing());
838  hRPotActivBXall[index]->Fill(event.bunchCrossing(), float(RPdigiSize[index]));
839  }
840 
841  int planesFiredAtROC[NROCsMAX]; // how many planes registered hits on ROC r
842  for (int r = 0; r < NROCsMAX; r++)
843  planesFiredAtROC[r] = 0;
844  for (int p = 0; p < NplaneMAX; p++) {
845  int indp = getPlaneIndex(arm, stn, rp, p);
846  for (int r = 0; r < NROCsMAX; r++)
847  if (HitsMultROC[indp][r] > 0)
848  ++planesFiredAtROC[r];
849  for (int r = 0; r < NROCsMAX; r++) {
850  if (onlinePlots)
851  h2HitsMultROC[index]->Fill(p, r, HitsMultROC[indp][r]);
852  hp2HitsMultROC_LS[index]->Fill(lumiId, p * NROCsMAX + r, HitsMultROC[indp][r]);
853  }
854  }
855  int max = 0;
856  for (int r = 0; r < NROCsMAX; r++)
857  if (max < planesFiredAtROC[r])
858  max = planesFiredAtROC[r];
859  if (max >= 4 && onlinePlots) // fill only if there are at least 4 aligned ROCs firing
860  hRPotActivBXroc[index]->Fill(event.bunchCrossing());
861  if (max >= 3 && onlinePlots) // fill only if there are at least 3 aligned ROCs firing
862  hRPotActivBXroc_3[index]->Fill(event.bunchCrossing());
863  if (max >= 2 && onlinePlots) // fill only if there are at least 2 aligned ROCs firing
864  hRPotActivBXroc_2[index]->Fill(event.bunchCrossing());
865  } // end for(int rp=0; rp<NRPotsMAX; rp++) {
866  }
867  } // end for(int arm=0; arm<2; arm++) {
868 
869  if ((nEvents % 100))
870  return;
871  if (verbosity)
872  LogPrint("CTPPSPixelDQMSource") << "analyze event " << nEvents;
873 }
874 
875 //---------------------------------------------------------------------------
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
uint32_t arm() const
Definition: CTPPSDetId.h:57
MonitorElement * htrackMult[RPotsTotalNumber]
MonitorElement * h2HitsMultROC[RPotsTotalNumber]
uint32_t ID
Definition: Definitions.h:24
MonitorElement * h2trackXY0[RPotsTotalNumber]
MonitorElement * hpixLTrack
static constexpr int NRPotBinsInStation
MonitorElement * hRPotActivBXroc_3[RPotsTotalNumber]
static constexpr int RPn_last
static constexpr int hitMultMAX
static constexpr int dimension
static constexpr int NRPotsMAX
static constexpr int NPlaneBins
CTPPSPixelIndices thePixIndices
static constexpr int RPotsTotalNumber
static constexpr int mapXbins
static constexpr float mapYmax
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
MonitorElement * htrackHits[RPotsTotalNumber]
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelLocalTrack > > tokenTrack
virtual TH2F * getTH2F() const
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
int RPindexValid[RPotsTotalNumber]
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * h2Efficiency[RPotsTotalNumber][NplaneMAX]
MonitorElement * hROCadc[RPotsTotalNumber *NplaneMAX][NROCsMAX]
int np
Definition: AMPTWrapper.h:43
CTPPSPixelDQMSource(const edm::ParameterSet &ps)
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 * h2ErrorCode
MonitorElement * hRPotActivBX[RPotsTotalNumber]
static constexpr int NLocalTracksMAX
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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]
const int verbosity
MonitorElement * h2xyROCHits[RPotsTotalNumber *NplaneMAX][NROCsMAX]
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 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
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
HLT enums.
static const int kDetOffset
Definition: DetId.h:21
static constexpr int NArms
col
Definition: cuy.py:1009
MonitorElement * h2AllPlanesActive
static constexpr int RPn_first
virtual TProfile2D * getTProfile2D() const
int getRPglobalBin(int arm, int stn)
int HitsMultROC[RPotsTotalNumber *NplaneMAX][NROCsMAX]
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]
int RPstatus[StationIDMAX][RPotsIDMAX]
MonitorElement * hBXshort
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
constexpr int ROCSizeInX
static constexpr float mapYmin
constexpr int ROCSizeInY
virtual TH2D * getTH2D() const