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