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.getParameter<edm::InputTag>("tagRPixDigi"));
168  tokenCluster = consumes<DetSetVector<CTPPSPixelCluster>>(ps.getParameter<edm::InputTag>("tagRPixCluster"));
169  tokenTrack = consumes<DetSetVector<CTPPSPixelLocalTrack>>(ps.getParameter<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.,
366  ROCSizeInX *ROCSizeInY,
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.,
413  ROCSizeInX * ROCSizeInY,
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 = 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(
443  st, st1 + ";pix col;pix row", nbins, 0, defaultDetSizeInX, nbins, 0, defaultDetSizeInX, 0., 512., "");
444  hp2xyADC[indexP][p]->getTProfile2D()->SetOption("colz");
445 
446  if (onlinePlots) {
447  st = "hits position";
448  h2xyHits[indexP][p] = ibooker.book2DD(st,
449  st1 + ";pix col;pix row",
450  defaultDetSizeInX,
451  0,
452  defaultDetSizeInX,
453  defaultDetSizeInX,
454  0,
455  defaultDetSizeInX);
456  h2xyHits[indexP][p]->getTH2D()->SetOption("colz");
457 
458  st = "hits multiplicity";
459  hHitsMult[indexP][p] =
460  ibooker.book1DD(st, st1 + ";number of hits;N / 1 hit", hitMultMAX + 1, -0.5, hitMultMAX + 0.5);
461  }
462 
463  if (offlinePlots) {
464  st = "plane efficiency";
465  h2Efficiency[indexP][p] = ibooker.bookProfile2D(
466  st, st1 + ";x0;y0", mapXbins, mapXmin, mapXmax, mapYbins, mapYmin, mapYmax, 0, 1, "");
467  h2Efficiency[indexP][p]->getTProfile2D()->SetOption("colz");
468  }
469  } // end of for(int p=0; p<NplaneMAX;..
470 
471  } // end for(int rp=0; rp<NRPotsMAX;...
472  } // end of for(int stn=0; stn<
473  } // end of for(int arm=0; arm<2;...
474 
475  return;
476 }
477 
478 //-------------------------------------------------------------------------------
479 
481  ++nEvents;
482  int lumiId = event.getLuminosityBlock().id().luminosityBlock();
483  if (lumiId < 0)
484  lumiId = 0;
485 
486  int RPactivity[RPotsTotalNumber], RPdigiSize[RPotsTotalNumber];
487  int pixRPTracks[RPotsTotalNumber];
488 
489  for (int rp = 0; rp < RPotsTotalNumber; rp++) {
490  RPactivity[rp] = RPdigiSize[rp] = pixRPTracks[rp] = 0;
491  }
492 
493  for (int ind = 0; ind < RPotsTotalNumber; ind++) {
494  for (int p = 0; p < NplaneMAX; p++) {
495  HitsMultPlane[ind][p] = 0;
496  }
497  }
498  for (int ind = 0; ind < RPotsTotalNumber * NplaneMAX; ind++) {
499  for (int roc = 0; roc < NROCsMAX; roc++) {
500  HitsMultROC[ind][roc] = 0;
501  }
502  }
504  event.getByToken(tokenDigi, pixDigi);
505 
507  event.getByToken(tokenCluster, pixClus);
508 
510  event.getByToken(tokenTrack, pixTrack);
511 
512  if (onlinePlots) {
513  hBX->Fill(event.bunchCrossing());
514  hBXshort->Fill(event.bunchCrossing());
515  }
516 
517  if (pixTrack.isValid()) {
518  for (const auto &ds_tr : *pixTrack) {
519  int idet = getDet(ds_tr.id);
520  if (idet != DetId::VeryForward) {
521  if (verbosity > 1)
522  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: ds_tr.id" << ds_tr.id;
523  continue;
524  }
525  CTPPSDetId theId(ds_tr.id);
526  int arm = theId.arm() & 0x1;
527  int station = theId.station() & 0x3;
528  int rpot = theId.rp() & 0x7;
529  int rpInd = getRPindex(arm, station, rpot);
530 
531  for (DetSet<CTPPSPixelLocalTrack>::const_iterator dit = ds_tr.begin(); dit != ds_tr.end(); ++dit) {
532  ++pixRPTracks[rpInd];
533  int nh_tr = (dit->ndf() + TrackFitDimension) / 2;
534  if (onlinePlots) {
535  for (int i = 0; i <= NplaneMAX; i++) {
536  if (i == nh_tr)
537  htrackHits[rpInd]->Fill(nh_tr, 1.);
538  else
539  htrackHits[rpInd]->Fill(i, 0.);
540  }
541  }
542  float x0 = dit->x0();
543  float y0 = dit->y0();
544  h2trackXY0[rpInd]->Fill(x0, y0);
545 
546  if (x0_MAX < x0)
547  x0_MAX = x0;
548  if (y0_MAX < y0)
549  y0_MAX = y0;
550  if (x0_MIN > x0)
551  x0_MIN = x0;
552  if (y0_MIN > y0)
553  y0_MIN = y0;
554 
555  if (offlinePlots) {
556  edm::DetSetVector<CTPPSPixelFittedRecHit> fittedHits = dit->hits();
557 
558  std::map<int, int> numberOfPointPerPlaneEff;
559  for (const auto &ds_frh : fittedHits) {
560  int plane = getPixPlane(ds_frh.id);
561  for (DetSet<CTPPSPixelFittedRecHit>::const_iterator frh_it = ds_frh.begin(); frh_it != ds_frh.end();
562  ++frh_it) { // there should always be only one hit in each
563  // vector
564  if (frh_it != ds_frh.begin())
565  if (verbosity > 1)
566  LogPrint("CTPPSPixelDQMSource") << "More than one FittedRecHit found in plane " << plane;
567  if (frh_it->isRealHit())
568  for (int p = 0; p < NplaneMAX; p++) {
569  if (p != plane)
570  numberOfPointPerPlaneEff[p]++;
571  }
572  }
573  }
574 
575  if (verbosity > 1)
576  for (auto planeAndHitsOnOthers : numberOfPointPerPlaneEff) {
577  LogPrint("CTPPSPixelDQMSource")
578  << "For plane " << planeAndHitsOnOthers.first << ", " << planeAndHitsOnOthers.second
579  << " hits on other planes were found" << endl;
580  }
581 
582  for (const auto &ds_frh : fittedHits) {
583  int plane = getPixPlane(ds_frh.id);
584  if (isPlanePlotsTurnedOff[arm][station][rpot][plane])
585  continue;
586  for (DetSet<CTPPSPixelFittedRecHit>::const_iterator frh_it = ds_frh.begin(); frh_it != ds_frh.end();
587  ++frh_it) {
588  float frhX0 = frh_it->globalCoordinates().x() + frh_it->xResidual();
589  float frhY0 = frh_it->globalCoordinates().y() + frh_it->yResidual();
590  if (numberOfPointPerPlaneEff[plane] >= 3) {
591  if (frh_it->isRealHit())
592  h2Efficiency[rpInd][plane]->Fill(frhX0, frhY0, 1);
593  else
594  h2Efficiency[rpInd][plane]->Fill(frhX0, frhY0, 0);
595  }
596  }
597  }
598  }
599  }
600  }
601  } // end if(pixTrack.isValid())
602 
603  bool valid = false;
604  valid |= pixDigi.isValid();
605  // valid |= Clus.isValid();
606 
607  if (!valid && verbosity)
608  LogPrint("CTPPSPixelDQMSource") << "No valid data in Event " << nEvents;
609 
610  if (pixDigi.isValid()) {
611  for (const auto &ds_digi : *pixDigi) {
612  int idet = getDet(ds_digi.id);
613  if (idet != DetId::VeryForward) {
614  if (verbosity > 1)
615  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: ds_digi.id" << ds_digi.id;
616  continue;
617  }
618  // int subdet = getSubdet(ds_digi.id);
619 
620  int plane = getPixPlane(ds_digi.id);
621 
622  CTPPSDetId theId(ds_digi.id);
623  int arm = theId.arm() & 0x1;
624  int station = theId.station() & 0x3;
625  int rpot = theId.rp() & 0x7;
626  int rpInd = getRPindex(arm, station, rpot);
627  RPactivity[rpInd] = 1;
628  ++RPdigiSize[rpInd];
629 
630  if (StationStatus[station] && RPstatus[station][rpot]) {
631  if (onlinePlots) {
632  h2HitsMultipl[arm][station]->Fill(prIndex(rpot, plane), ds_digi.data.size());
634  }
635  int index = getRPindex(arm, station, rpot);
636  HitsMultPlane[index][plane] += ds_digi.data.size();
637  if (RPindexValid[index]) {
638  int nh = ds_digi.data.size();
639  if (nh > hitMultMAX)
640  nh = hitMultMAX;
641  if (!isPlanePlotsTurnedOff[arm][station][rpot][plane])
642  if (onlinePlots)
643  hHitsMult[index][plane]->Fill(nh);
644  }
645  int rocHistIndex = getPlaneIndex(arm, station, rpot, plane);
646 
647  for (DetSet<CTPPSPixelDigi>::const_iterator dit = ds_digi.begin(); dit != ds_digi.end(); ++dit) {
648  int row = dit->row();
649  int col = dit->column();
650  int adc = dit->adc();
651 
652  if (RPindexValid[index]) {
653  if (!isPlanePlotsTurnedOff[arm][station][rpot][plane]) {
654  if (onlinePlots)
655  h2xyHits[index][plane]->Fill(col, row);
656  hp2xyADC[index][plane]->Fill(col, row, adc);
657  }
658  int colROC, rowROC;
659  int trocId;
660  if (!thePixIndices.transformToROC(col, row, trocId, colROC, rowROC)) {
661  if (trocId >= 0 && trocId < NROCsMAX) {
662  ++HitsMultROC[rocHistIndex][trocId];
663  }
664  }
665  } // end if(RPindexValid[index]) {
666  }
667  } // end if(StationStatus[station]) {
668  } // end for(const auto &ds_digi : *pixDigi)
669  } // if(pixDigi.isValid()) {
670 
671  if (pixClus.isValid() && onlinePlots)
672  for (const auto &ds : *pixClus) {
673  int idet = getDet(ds.id);
674  if (idet != DetId::VeryForward && verbosity > 1) {
675  LogPrint("CTPPSPixelDQMSource") << "not CTPPS: cluster.id" << ds.id;
676  continue;
677  }
678 
679  CTPPSDetId theId(ds.id);
680  int plane = getPixPlane(ds.id);
681  int arm = theId.arm() & 0x1;
682  int station = theId.station() & 0x3;
683  int rpot = theId.rp() & 0x7;
684 
685  if ((StationStatus[station] == 0) || (RPstatus[station][rpot] == 0))
686  continue;
687 
688  for (const auto &p : ds) {
689  int clusize = p.size();
690 
691  if (clusize > ClusterSizeMax)
692  clusize = ClusterSizeMax;
693 
694  h2CluSize[arm][station]->Fill(prIndex(rpot, plane), clusize);
695  }
696  } // end if(pixClus.isValid()) for(const auto &ds : *pixClus)
697 
698  bool allRPactivity = false;
699  for (int rp = 0; rp < RPotsTotalNumber; rp++)
700  if (RPactivity[rp] > 0)
701  allRPactivity = true;
702  for (int arm = 0; arm < 2; arm++) {
703  for (int stn = 0; stn < NStationMAX; stn++) {
704  for (int rp = 0; rp < NRPotsMAX; rp++) {
705  int index = getRPindex(arm, stn, rp);
706  if (RPindexValid[index] == 0)
707  continue;
708 
709  if (onlinePlots)
710  hpRPactive->Fill(getRPglobalBin(arm, stn), RPactivity[index]);
711  // if(RPactivity[index]==0) continue;
712  if (!allRPactivity)
713  continue;
714  if (onlinePlots)
715  hpixLTrack->Fill(getRPglobalBin(arm, stn), pixRPTracks[index]);
716  int ntr = pixRPTracks[index];
717  if (ntr > NLocalTracksMAX)
718  ntr = NLocalTracksMAX;
719  for (int i = 0; i <= NLocalTracksMAX; i++) {
720  if (i == ntr)
721  htrackMult[index]->Fill(ntr, 1.);
722  else
723  htrackMult[index]->Fill(i, 0.);
724  }
725 
726  int np = 0;
727  for (int p = 0; p < NplaneMAX; p++)
728  if (HitsMultPlane[index][p] > 0)
729  np++;
730  for (int p = 0; p <= NplaneMAX; p++) {
731  if (p == np)
732  hRPotActivPlanes[index]->Fill(p, 1.);
733  else
734  hRPotActivPlanes[index]->Fill(p, 0.);
735  }
736  if (onlinePlots) {
737  if (np >= 5)
738  hRPotActivBX[index]->Fill(event.bunchCrossing());
739  hRPotActivBXall[index]->Fill(event.bunchCrossing(), float(RPdigiSize[index]));
740  }
741 
742  int planesFiredAtROC[NROCsMAX]; // how many planes registered hits on ROC r
743  for (int r = 0; r < NROCsMAX; r++)
744  planesFiredAtROC[r] = 0;
745  for (int p = 0; p < NplaneMAX; p++) {
746  int indp = getPlaneIndex(arm, stn, rp, p);
747  for (int r = 0; r < NROCsMAX; r++)
748  if (HitsMultROC[indp][r] > 0)
749  ++planesFiredAtROC[r];
750  for (int r = 0; r < NROCsMAX; r++) {
751  if (onlinePlots)
752  h2HitsMultROC[index]->Fill(p, r, HitsMultROC[indp][r]);
753  hp2HitsMultROC_LS[index]->Fill(lumiId, p * NROCsMAX + r, HitsMultROC[indp][r]);
754  }
755  }
756  int max = 0;
757  for (int r = 0; r < NROCsMAX; r++)
758  if (max < planesFiredAtROC[r])
759  max = planesFiredAtROC[r];
760  if (max >= 4 && onlinePlots) // fill only if there are at least 4 aligned ROCs firing
761  hRPotActivBXroc[index]->Fill(event.bunchCrossing());
762  if (max >= 3 && onlinePlots) // fill only if there are at least 3 aligned ROCs firing
763  hRPotActivBXroc_3[index]->Fill(event.bunchCrossing());
764  if (max >= 2 && onlinePlots) // fill only if there are at least 2 aligned ROCs firing
765  hRPotActivBXroc_2[index]->Fill(event.bunchCrossing());
766  } // end for(int rp=0; rp<NRPotsMAX; rp++) {
767  }
768  } // end for(int arm=0; arm<2; arm++) {
769 
770  if ((nEvents % 100))
771  return;
772  if (verbosity)
773  LogPrint("CTPPSPixelDQMSource") << "analyze event " << nEvents;
774 }
775 
776 //---------------------------------------------------------------------------
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
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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:32
uint32_t arm() const
Definition: CTPPSDetId.h:51
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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
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:65
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:58
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
static constexpr float mapYmin
virtual TH2D * getTH2D() const