CMS 3D CMS Logo

CTPPSDiamondDQMSource.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of CTPPS offline software.
4 * Authors:
5 * Jan Kašpar (jan.kaspar@gmail.com)
6 * Nicola Minafra
7 * Laurent Forthomme
8 *
9 ****************************************************************************/
10 
18 
22 
27 
30 
33 
38 
39 #include <string>
40 
41 //----------------------------------------------------------------------------------------------------
42 
43 // Utility for efficiency computations
45  const CTPPSDiamondDetId& detid,
46  const CTPPSDiamondLocalTrack& localTrack,
47  const float tolerance = 1) {
48  const DetGeomDesc* det = geom->getSensor(detid);
49  const float x_pos = det->translation().x(),
50  x_width = 2.0 * det->params().at(0); // parameters stand for half the size
51  return ((x_pos + 0.5 * x_width > localTrack.getX0() - localTrack.getX0Sigma() - tolerance &&
52  x_pos + 0.5 * x_width < localTrack.getX0() + localTrack.getX0Sigma() + tolerance) ||
53  (x_pos - 0.5 * x_width > localTrack.getX0() - localTrack.getX0Sigma() - tolerance &&
54  x_pos - 0.5 * x_width < localTrack.getX0() + localTrack.getX0Sigma() + tolerance) ||
55  (x_pos - 0.5 * x_width < localTrack.getX0() - localTrack.getX0Sigma() - tolerance &&
56  x_pos + 0.5 * x_width > localTrack.getX0() + localTrack.getX0Sigma() + tolerance));
57 }
58 
59 namespace dds {
60  struct Cache {
61  std::unordered_map<unsigned int, std::unique_ptr<TH2F>> hitDistribution2dMap;
62 
63  std::unordered_map<unsigned int, unsigned long> hitsCounterMap;
64  };
65 } // namespace dds
66 
67 class CTPPSDiamondDQMSource : public one::DQMEDAnalyzer<edm::LuminosityBlockCache<dds::Cache>> {
68 public:
70  ~CTPPSDiamondDQMSource() override;
71 
72 protected:
73  void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
74  void bookHistograms(DQMStore::IBooker&, const edm::Run&, const edm::EventSetup&) override;
75  void analyze(const edm::Event&, const edm::EventSetup&) override;
76  std::shared_ptr<dds::Cache> globalBeginLuminosityBlock(const edm::LuminosityBlock&,
77  const edm::EventSetup&) const override;
78  void globalEndLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
79  void endRun(const edm::Run&, const edm::EventSetup&) override;
80 
81 private:
82  // Constants
83  static const double SEC_PER_LUMI_SECTION; // Number of seconds per lumisection: used to compute hit rates in Hz
84  static const int CHANNEL_OF_VFAT_CLOCK; // Channel ID of the VFAT that contains clock data
85  static const double DISPLAY_RESOLUTION_FOR_HITS_MM; // Bin width of histograms showing hits and tracks (in mm)
87  static const double HPTDC_BIN_WIDTH_NS; // ns per HPTDC bin
88  static const int CTPPS_NUM_OF_ARMS;
89  static const int CTPPS_DIAMOND_STATION_ID;
90  static const int CTPPS_DIAMOND_RP_ID;
91  static const int CTPPS_PIXEL_STATION_ID;
92  static const int CTPPS_NEAR_RP_ID;
93  static const int CTPPS_FAR_RP_ID;
94  static const int CTPPS_DIAMOND_NUM_OF_PLANES;
96  static const int CTPPS_FED_ID_45;
97  static const int CTPPS_FED_ID_56;
98 
105 
109  std::vector<std::pair<edm::EventRange, int>> runParameters_;
111  unsigned int verbosity_;
112 
114  struct GlobalPlots {
116  GlobalPlots(DQMStore::IBooker& ibooker);
117  };
118 
120 
122  struct PotPlots {
123  std::unordered_map<unsigned int, MonitorElement*> activity_per_bx;
124 
125  MonitorElement* hitDistribution2d = nullptr;
126  MonitorElement* hitDistribution2d_lumisection = nullptr;
127  MonitorElement* hitDistribution2dOOT = nullptr;
128  MonitorElement* hitDistribution2dOOT_le = nullptr;
129  MonitorElement *activePlanes = nullptr, *activePlanesInclusive = nullptr;
130 
131  MonitorElement* trackDistribution = nullptr;
132  MonitorElement* trackDistributionOOT = nullptr;
133 
134  std::unordered_map<unsigned int, MonitorElement*> pixelTomographyAll;
135 
136  MonitorElement *leadingEdgeCumulative_both = nullptr, *leadingEdgeCumulative_all = nullptr,
137  *leadingEdgeCumulative_le = nullptr, *trailingEdgeCumulative_te = nullptr;
138  MonitorElement *timeOverThresholdCumulativePot = nullptr, *leadingTrailingCorrelationPot = nullptr;
139  MonitorElement* leadingWithoutTrailingCumulativePot = nullptr;
140 
141  MonitorElement* ECCheck = nullptr;
142 
143  MonitorElement* HPTDCErrorFlags_2D = nullptr;
144  MonitorElement* MHComprensive = nullptr;
145 
146  // MonitorElement* clock_Digi1_le = nullptr;
147  // MonitorElement* clock_Digi1_te = nullptr;
148  // MonitorElement* clock_Digi3_le = nullptr;
149  // MonitorElement* clock_Digi3_te = nullptr;
150 
151  unsigned int HitCounter, MHCounter, LeadingOnlyCounter, TrailingOnlyCounter, CompleteCounter;
152 
153  std::map<int, int> effTriplecountingChMap;
154  std::map<int, int> effDoublecountingChMap;
155  MonitorElement* EfficiencyOfChannelsInPot = nullptr;
157 
158  PotPlots() {}
159  PotPlots(DQMStore::IBooker& ibooker, unsigned int id);
160  };
161 
162  std::unordered_map<unsigned int, PotPlots> potPlots_;
163  int EC_difference_56_, EC_difference_45_;
164 
166  struct PlanePlots {
167  MonitorElement* digiProfileCumulativePerPlane = nullptr;
168  MonitorElement* hitProfile = nullptr;
169  MonitorElement* hit_multiplicity = nullptr;
170 
171  MonitorElement* pixelTomography_far = nullptr;
172  MonitorElement* EfficiencyWRTPixelsInPlane = nullptr;
173 
175 
177  PlanePlots(DQMStore::IBooker& ibooker, unsigned int id);
178  };
179 
180  std::unordered_map<unsigned int, PlanePlots> planePlots_;
181 
183  struct ChannelPlots {
184  std::unordered_map<unsigned int, MonitorElement*> activity_per_bx;
185 
187  MonitorElement *leadingEdgeCumulative_both = nullptr, *leadingEdgeCumulative_le = nullptr,
188  *trailingEdgeCumulative_te = nullptr;
189  MonitorElement* TimeOverThresholdCumulativePerChannel = nullptr;
190  MonitorElement* LeadingTrailingCorrelationPerChannel = nullptr;
191  MonitorElement* leadingWithoutTrailing = nullptr;
192  MonitorElement* pixelTomography_far = nullptr;
193  MonitorElement* hit_rate = nullptr;
194 
195  unsigned int HitCounter, MHCounter, LeadingOnlyCounter, TrailingOnlyCounter, CompleteCounter;
196 
198  ChannelPlots(DQMStore::IBooker& ibooker, unsigned int id);
199  };
200 
201  std::unordered_map<unsigned int, ChannelPlots> channelPlots_;
202 };
203 
204 //----------------------------------------------------------------------------------------------------
205 
206 // Values for all constants
210 const double CTPPSDiamondDQMSource::INV_DISPLAY_RESOLUTION_FOR_HITS_MM = 1. / DISPLAY_RESOLUTION_FOR_HITS_MM;
211 const double CTPPSDiamondDQMSource::HPTDC_BIN_WIDTH_NS = 25. / 1024;
222 
223 //----------------------------------------------------------------------------------------------------
224 
226 
227 //----------------------------------------------------------------------------------------------------
228 
230  : HitCounter(0),
231  MHCounter(0),
232  LeadingOnlyCounter(0),
233  TrailingOnlyCounter(0),
234  CompleteCounter(0),
235  pixelTracksMap("Pixel track maps for efficiency", "Pixel track maps for efficiency", 25, 0, 25, 12, -2, 10) {
238  ibooker.setCurrentFolder(path);
239 
241 
242  activity_per_bx[0] =
243  ibooker.book1D("activity per BX 0 25", title + " Activity per BX 0 - 25 ns;Event.BX", 3600, -1.5, 3598. + 0.5);
244  activity_per_bx[1] =
245  ibooker.book1D("activity per BX 25 50", title + " Activity per BX 25 - 50 ns;Event.BX", 3600, -1.5, 3598. + 0.5);
246  activity_per_bx[2] =
247  ibooker.book1D("activity per BX 50 75", title + " Activity per BX 50 - 75 ns;Event.BX", 3600, -1.5, 3598. + 0.5);
248 
249  hitDistribution2d = ibooker.book2D("hits in planes",
250  title + " hits in planes;plane number;x (mm)",
251  10,
252  -0.5,
253  4.5,
255  -0.5,
256  18.5);
257  hitDistribution2d_lumisection = ibooker.book2D("hits in planes lumisection",
258  title + " hits in planes in the last lumisection;plane number;x (mm)",
259  10,
260  -0.5,
261  4.5,
263  -0.5,
264  18.5);
265  hitDistribution2dOOT = ibooker.book2D("hits with OOT in planes",
266  title + " hits with OOT in planes;plane number + 0.25 OOT;x (mm)",
267  17,
268  -0.25,
269  4,
271  -0.5,
272  18.5);
273  hitDistribution2dOOT_le = ibooker.book2D("hits with OOT in planes (le only)",
274  title + " hits with OOT in planes (le only);plane number + 0.25 OOT;x (mm)",
275  17,
276  -0.25,
277  4,
279  -0.5,
280  18.5);
281  activePlanes =
282  ibooker.book1D("active planes", title + " active planes (per event);number of active planes", 6, -0.5, 5.5);
284  ibooker.book1D("active planes inclusive",
285  title + " active planes, MH and le only included (per event);number of active planes",
286  6,
287  -0.5,
288  5.5);
289 
291  ibooker.book1D("tracks", title + " tracks;x (mm)", 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -0.5, 18.5);
292  trackDistributionOOT = ibooker.book2D("tracks with OOT",
293  title + " tracks with OOT;plane number;x (mm)",
294  9,
295  -0.5,
296  4,
298  -0.5,
299  18.5);
300 
301  pixelTomographyAll[0] =
302  ibooker.book2D("tomography pixel 0 25",
303  title + " tomography with pixel 0 - 25 ns (all planes);x + 25*plane(mm);y (mm)",
304  100,
305  0,
306  100,
307  8,
308  0,
309  8);
310  pixelTomographyAll[1] =
311  ibooker.book2D("tomography pixel 25 50",
312  title + " tomography with pixel 25 - 50 ns (all planes);x + 25*plane(mm);y (mm)",
313  100,
314  0,
315  100,
316  8,
317  0,
318  8);
319  pixelTomographyAll[2] =
320  ibooker.book2D("tomography pixel 50 75",
321  title + " tomography with pixel 50 - 75 ns (all planes);x + 25*plane(mm);y (mm)",
322  100,
323  0,
324  100,
325  8,
326  0,
327  8);
328 
330  "leading edge (le and te)", title + " leading edge (le and te) (recHits); leading edge (ns)", 75, 0, 75);
332  "leading edge (all)", title + " leading edge (with or without te) (DIGIs); leading edge (ns)", 75, 0, 75);
334  ibooker.book1D("leading edge (le only)", title + " leading edge (le only) (DIGIs); leading edge (ns)", 75, 0, 75);
336  "trailing edge (te only)", title + " trailing edge (te only) (DIGIs); trailing edge (ns)", 75, 0, 75);
338  ibooker.book1D("time over threshold", title + " time over threshold;time over threshold (ns)", 250, -25, 100);
340  ibooker.book2D("leading trailing correlation",
341  title + " leading trailing correlation;leading edge (ns);trailing edge (ns)",
342  75,
343  0,
344  75,
345  75,
346  0,
347  75);
348 
350  ibooker.book1D("event category", title + " leading edges without trailing;;%", 3, 0.5, 3.5);
351  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel(1, "Leading only");
352  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel(2, "Trailing only");
353  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel(3, "Both");
354 
355  ECCheck = ibooker.book1D("optorxEC(8bit) - vfatEC", title + " EC Error;optorxEC-vfatEC", 50, -25, 25);
356 
357  HPTDCErrorFlags_2D = ibooker.book2D("HPTDC Errors", title + " HPTDC Errors", 16, -0.5, 16.5, 9, -0.5, 8.5);
358  for (unsigned short error_index = 1; error_index < 16; ++error_index)
359  HPTDCErrorFlags_2D->getTH2F()->GetXaxis()->SetBinLabel(error_index,
360  HPTDCErrorFlags::getHPTDCErrorName(error_index - 1).c_str());
361  HPTDCErrorFlags_2D->getTH2F()->GetXaxis()->SetBinLabel(16, "Wrong EC");
362 
363  int tmpIndex = 0;
364  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel(++tmpIndex, "DB 0 TDC 18");
365  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel(++tmpIndex, "DB 0 TDC 17");
366  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel(++tmpIndex, "DB 0 TDC 16");
367  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel(++tmpIndex, "DB 0 TDC 15");
368  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel(++tmpIndex, "DB 1 TDC 18");
369  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel(++tmpIndex, "DB 1 TDC 17");
370  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel(++tmpIndex, "DB 1 TDC 16");
371  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel(++tmpIndex, "DB 1 TDC 15");
372 
373  MHComprensive =
374  ibooker.book2D("MH in channels", title + " MH (%) in channels;plane number;ch number", 10, -0.5, 4.5, 14, -1, 13);
375 
377  ibooker.book2D("Efficiency in channels",
378  title + " Efficiency (%) in channels (diamonds only);plane number;ch number",
379  10,
380  -0.5,
381  4.5,
382  14,
383  -1,
384  13);
385 
386  // ibooker.setCurrentFolder( path+"/clock/" );
387  // clock_Digi1_le = ibooker.book1D( "clock1 leading edge", title+" clock1;leading edge (ns)", 250, 0, 25 );
388  // clock_Digi1_te = ibooker.book1D( "clock1 trailing edge", title+" clock1;trailing edge (ns)", 75, 0, 75 );
389  // clock_Digi3_le = ibooker.book1D( "clock3 leading edge", title+" clock3;leading edge (ns)", 250, 0, 25 );
390  // clock_Digi3_te = ibooker.book1D( "clock3 trailing edge", title+" clock3;trailing edge (ns)", 75, 0, 75 );
391 }
392 
393 //----------------------------------------------------------------------------------------------------
394 
396  : pixelTracksMapWithDiamonds("Pixel track maps for efficiency with coincidence",
397  "Pixel track maps for efficiency with coincidence",
398  25,
399  0,
400  25,
401  12,
402  -2,
403  10) {
406  ibooker.setCurrentFolder(path);
407 
409 
410  digiProfileCumulativePerPlane = ibooker.book1D("digi profile", title + " digi profile; ch number", 12, -0.5, 11.5);
411  hitProfile = ibooker.book1D(
412  "hit profile", title + " hit profile;x (mm)", 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -0.5, 18.5);
413  hit_multiplicity = ibooker.book1D("channels per plane", title + " channels per plane; ch per plane", 13, -0.5, 12.5);
414 
416  ibooker.book2D("tomography pixel", title + " tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, 0, 8);
418  ibooker.book2D("Efficiency wrt pixels", title + " Efficiency wrt pixels;x (mm);y (mm)", 25, 0, 25, 12, -2, 10);
419 }
420 
421 //----------------------------------------------------------------------------------------------------
422 
424  : HitCounter(0), MHCounter(0), LeadingOnlyCounter(0), TrailingOnlyCounter(0), CompleteCounter(0) {
427  ibooker.setCurrentFolder(path);
428 
430 
431  leadingWithoutTrailing = ibooker.book1D("event category", title + " Event Category;;%", 3, 0.5, 3.5);
432  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel(1, "Leading only");
433  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel(2, "Trailing only");
434  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel(3, "Full");
435 
436  activity_per_bx[0] =
437  ibooker.book1D("activity per BX 0 25", title + " Activity per BX 0 - 25 ns;Event.BX", 500, -1.5, 498. + 0.5);
438  activity_per_bx[1] =
439  ibooker.book1D("activity per BX 25 50", title + " Activity per BX 25 - 50 ns;Event.BX", 500, -1.5, 498. + 0.5);
440  activity_per_bx[2] =
441  ibooker.book1D("activity per BX 50 75", title + " Activity per BX 50 - 75 ns;Event.BX", 500, -1.5, 498. + 0.5);
442 
443  HPTDCErrorFlags = ibooker.book1D("hptdc_Errors", title + " HPTDC Errors", 16, -0.5, 16.5);
444  for (unsigned short error_index = 1; error_index < 16; ++error_index)
445  HPTDCErrorFlags->getTH1F()->GetXaxis()->SetBinLabel(error_index,
446  HPTDCErrorFlags::getHPTDCErrorName(error_index - 1).c_str());
447  HPTDCErrorFlags->getTH1F()->GetXaxis()->SetBinLabel(16, "MH (%)");
448 
450  ibooker.book1D("leading edge (le and te)", title + " leading edge (recHits); leading edge (ns)", 75, 0, 75);
452  ibooker.book1D("leading edge (le only)", title + " leading edge (DIGIs); leading edge (ns)", 75, 0, 75);
454  "trailing edge (te only)", title + " trailing edge (te only) (DIGIs); trailing edge (ns)", 75, 0, 75);
456  ibooker.book1D("time over threshold", title + " time over threshold;time over threshold (ns)", 75, -25, 50);
458  ibooker.book2D("leading trailing correlation",
459  title + " leading trailing correlation;leading edge (ns);trailing edge (ns)",
460  75,
461  0,
462  75,
463  75,
464  0,
465  75);
466 
468  ibooker.book2D("tomography pixel", "tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, 0, 8);
469 
470  hit_rate = ibooker.book1D("hit rate", title + "hit rate;rate (Hz)", 40, 0, 20);
471 }
472 
473 //----------------------------------------------------------------------------------------------------
474 
476  : tokenStatus_(consumes<edm::DetSetVector<TotemVFATStatus>>(ps.getParameter<edm::InputTag>("tagStatus"))),
478  consumes<edm::DetSetVector<CTPPSPixelLocalTrack>>(ps.getParameter<edm::InputTag>("tagPixelLocalTracks"))),
479  tokenDigi_(consumes<edm::DetSetVector<CTPPSDiamondDigi>>(ps.getParameter<edm::InputTag>("tagDigi"))),
481  consumes<edm::DetSetVector<CTPPSDiamondRecHit>>(ps.getParameter<edm::InputTag>("tagDiamondRecHits"))),
483  consumes<edm::DetSetVector<CTPPSDiamondLocalTrack>>(ps.getParameter<edm::InputTag>("tagDiamondLocalTracks"))),
484  tokenFEDInfo_(consumes<std::vector<TotemFEDInfo>>(ps.getParameter<edm::InputTag>("tagFEDInfo"))),
485  excludeMultipleHits_(ps.getParameter<bool>("excludeMultipleHits")),
486  centralOOT_(-999),
487  verbosity_(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
488  EC_difference_56_(-500),
489  EC_difference_45_(-500) {
490  for (const auto& pset : ps.getParameter<std::vector<edm::ParameterSet>>("offsetsOOT")) {
491  runParameters_.emplace_back(
492  std::make_pair(pset.getParameter<edm::EventRange>("validityRange"), pset.getParameter<int>("centralOOT")));
493  }
494 }
495 
496 //----------------------------------------------------------------------------------------------------
497 
499 
500 //----------------------------------------------------------------------------------------------------
501 
503  centralOOT_ = -999;
504  for (const auto& oot : runParameters_) {
505  if (edm::contains(oot.first, edm::EventID(iRun.run(), 0, 1))) {
506  centralOOT_ = oot.second;
507  break;
508  }
509  }
510 
511  // Get detector shifts from the geometry
513  iSetup.get<VeryForwardRealGeometryRecord>().get(geometry_);
514  const CTPPSGeometry* geom = geometry_.product();
516  const DetGeomDesc* det = geom->getSensor(detid);
517  horizontalShiftOfDiamond_ = det->translation().x() - det->params().at(0);
518 
519  // Rough alignement of pixel detector for diamond thomography
521  if (iRun.run() > 300000) { //Pixel installed
522  det = geom->getSensor(pixid);
524  }
525 }
526 
527 //----------------------------------------------------------------------------------------------------
528 
530  ibooker.cd();
531  ibooker.setCurrentFolder("CTPPS");
532 
533  globalPlot_ = GlobalPlots(ibooker);
534 
535  for (unsigned short arm = 0; arm < CTPPS_NUM_OF_ARMS; ++arm) {
537  potPlots_[rpId] = PotPlots(ibooker, rpId);
538  for (unsigned short pl = 0; pl < CTPPS_DIAMOND_NUM_OF_PLANES; ++pl) {
540  planePlots_[plId] = PlanePlots(ibooker, plId);
541  for (unsigned short ch = 0; ch < CTPPS_DIAMOND_NUM_OF_CHANNELS; ++ch) {
543  channelPlots_[chId] = ChannelPlots(ibooker, chId);
544  }
545  }
546  }
547 }
548 
549 //----------------------------------------------------------------------------------------------------
550 
552  const edm::EventSetup&) const {
553  auto d = std::make_shared<dds::Cache>();
554  d->hitDistribution2dMap.reserve(potPlots_.size());
555  for (auto& plot : potPlots_)
556  d->hitDistribution2dMap[plot.first] =
557  std::unique_ptr<TH2F>(static_cast<TH2F*>(plot.second.hitDistribution2d_lumisection->getTH2F()->Clone()));
558  return d;
559 }
560 
561 //----------------------------------------------------------------------------------------------------
562 
564  // get event data
566  event.getByToken(tokenStatus_, diamondVFATStatus);
567 
569  event.getByToken(tokenPixelTrack_, pixelTracks);
570 
572  event.getByToken(tokenDigi_, diamondDigis);
573 
575  event.getByToken(tokenFEDInfo_, fedInfo);
576 
578  event.getByToken(tokenDiamondHit_, diamondRecHits);
579 
581  event.getByToken(tokenDiamondTrack_, diamondLocalTracks);
582 
584  iSetup.get<VeryForwardRealGeometryRecord>().get(geometry_);
585 
586  // check validity
587  bool valid = true;
588  valid &= diamondVFATStatus.isValid();
589  valid &= pixelTracks.isValid();
590  valid &= diamondDigis.isValid();
591  valid &= fedInfo.isValid();
592  valid &= diamondRecHits.isValid();
593  valid &= diamondLocalTracks.isValid();
594 
595  if (!valid) {
596  if (verbosity_) {
597  edm::LogProblem("CTPPSDiamondDQMSource")
598  << "ERROR in CTPPSDiamondDQMSource::analyze > some of the required inputs are not valid. Skipping this "
599  "event.\n"
600  << " diamondVFATStatus.isValid = " << diamondVFATStatus.isValid() << "\n"
601  << " pixelTracks.isValid = " << pixelTracks.isValid() << "\n"
602  << " diamondDigis.isValid = " << diamondDigis.isValid() << "\n"
603  << " fedInfo.isValid = " << fedInfo.isValid() << "\n"
604  << " diamondRecHits.isValid = " << diamondRecHits.isValid() << "\n"
605  << " diamondLocalTracks.isValid = " << diamondLocalTracks.isValid();
606  }
607 
608  return;
609  }
610 
611  //------------------------------
612  // RP Plots
613  //------------------------------
614 
615  //------------------------------
616  // Correlation Plots
617  //------------------------------
618 
619  // Using CTPPSDiamondDigi
620  for (const auto& digis : *diamondDigis) {
621  const CTPPSDiamondDetId detId(digis.detId());
622  CTPPSDiamondDetId detId_pot(digis.detId());
623 
624  for (const auto& digi : digis) {
625  detId_pot.setPlane(0);
626  detId_pot.setChannel(0);
627  if (detId.channel() == CHANNEL_OF_VFAT_CLOCK)
628  continue;
629  if (potPlots_.find(detId_pot) == potPlots_.end())
630  continue;
631  //Leading without trailing investigation
632  if (digi.getLeadingEdge() != 0 || digi.getTrailingEdge() != 0) {
633  ++(potPlots_[detId_pot].HitCounter);
634  if (digi.getLeadingEdge() != 0) {
635  potPlots_[detId_pot].leadingEdgeCumulative_all->Fill(HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge());
636  }
637  if (digi.getLeadingEdge() != 0 && digi.getTrailingEdge() == 0) {
638  ++(potPlots_[detId_pot].LeadingOnlyCounter);
639  potPlots_[detId_pot].leadingEdgeCumulative_le->Fill(HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge());
640  }
641  if (digi.getLeadingEdge() == 0 && digi.getTrailingEdge() != 0) {
642  ++(potPlots_[detId_pot].TrailingOnlyCounter);
643  potPlots_[detId_pot].trailingEdgeCumulative_te->Fill(HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge());
644  }
645  if (digi.getLeadingEdge() != 0 && digi.getTrailingEdge() != 0) {
646  ++(potPlots_[detId_pot].CompleteCounter);
647  potPlots_[detId_pot].leadingTrailingCorrelationPot->Fill(HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge(),
648  HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge());
649  }
650  }
651 
652  // HPTDC Errors
653  const HPTDCErrorFlags hptdcErrors = digi.getHPTDCErrorFlags();
654  if (detId.channel() == 6 || detId.channel() == 7) // ch6 for HPTDC 0 and ch7 for HPTDC 1
655  {
656  int verticalIndex = 2 * detId.plane() + (detId.channel() - 6);
657  for (unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex)
658  if (hptdcErrors.getErrorId(hptdcErrorIndex - 1))
659  potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill(hptdcErrorIndex, verticalIndex);
660  }
661  if (digi.getMultipleHit())
662  ++(potPlots_[detId_pot].MHCounter);
663  }
664  }
665 
666  // EC Errors
667  for (const auto& vfat_status : *diamondVFATStatus) {
668  const CTPPSDiamondDetId detId(vfat_status.detId());
669  CTPPSDiamondDetId detId_pot(vfat_status.detId());
670  detId_pot.setPlane(0);
671  detId_pot.setChannel(0);
672  for (const auto& status : vfat_status) {
673  if (!status.isOK())
674  continue;
675  if (potPlots_.find(detId_pot) == potPlots_.end())
676  continue;
677  if (channelPlots_.find(detId) == channelPlots_.end())
678  continue;
679 
680  // Check Event Number
681  for (const auto& optorx : *fedInfo) {
682  if (detId.arm() == 1 && optorx.getFEDId() == CTPPS_FED_ID_56) {
683  potPlots_[detId_pot].ECCheck->Fill((int)((optorx.getLV1() & 0xFF) - ((unsigned int)status.getEC() & 0xFF)) &
684  0xFF);
685  if ((static_cast<int>((optorx.getLV1() & 0xFF) - status.getEC()) != EC_difference_56_) &&
686  (static_cast<uint8_t>((optorx.getLV1() & 0xFF) - status.getEC()) < 128))
688  static_cast<int>(optorx.getLV1() & 0xFF) - (static_cast<unsigned int>(status.getEC()) & 0xFF);
689  if (EC_difference_56_ != 1 && EC_difference_56_ != -500 && std::abs(EC_difference_56_) < 127) {
690  if (detId.channel() == 6 || detId.channel() == 7)
691  potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill(16, 2 * detId.plane() + (detId.channel() - 6));
692  if (verbosity_)
693  edm::LogProblem("CTPPSDiamondDQMSource")
694  << "FED " << CTPPS_FED_ID_56 << ": ECError at EV: 0x" << std::hex << optorx.getLV1()
695  << "\t\tVFAT EC: 0x" << static_cast<unsigned int>(status.getEC()) << "\twith ID: " << std::dec
696  << detId << "\tdiff: " << EC_difference_56_;
697  }
698  } else if (detId.arm() == 0 && optorx.getFEDId() == CTPPS_FED_ID_45) {
699  potPlots_[detId_pot].ECCheck->Fill((int)((optorx.getLV1() & 0xFF) - status.getEC()) & 0xFF);
700  if ((static_cast<int>((optorx.getLV1() & 0xFF) - status.getEC()) != EC_difference_45_) &&
701  (static_cast<uint8_t>((optorx.getLV1() & 0xFF) - status.getEC()) < 128))
703  static_cast<int>(optorx.getLV1() & 0xFF) - (static_cast<unsigned int>(status.getEC()) & 0xFF);
704  if (EC_difference_45_ != 1 && EC_difference_45_ != -500 && std::abs(EC_difference_45_) < 127) {
705  if (detId.channel() == 6 || detId.channel() == 7)
706  potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill(16, 2 * detId.plane() + (detId.channel() - 6));
707  if (verbosity_)
708  edm::LogProblem("CTPPSDiamondDQMSource")
709  << "FED " << CTPPS_FED_ID_45 << ": ECError at EV: 0x" << std::hex << optorx.getLV1()
710  << "\t\tVFAT EC: 0x" << static_cast<unsigned int>(status.getEC()) << "\twith ID: " << std::dec
711  << detId << "\tdiff: " << EC_difference_45_;
712  }
713  }
714  }
715  }
716  }
717 
718  // Using CTPPSDiamondRecHit
719  std::unordered_map<unsigned int, std::set<unsigned int>> planes;
720  std::unordered_map<unsigned int, std::set<unsigned int>> planes_inclusive;
721 
722  auto lumiCache = luminosityBlockCache(event.getLuminosityBlock().index());
723  for (const auto& rechits : *diamondRecHits) {
724  CTPPSDiamondDetId detId_pot(rechits.detId());
725  detId_pot.setPlane(0);
726  detId_pot.setChannel(0);
727  const CTPPSDiamondDetId detId(rechits.detId());
728 
729  for (const auto& rechit : rechits) {
730  planes_inclusive[detId_pot].insert(detId.plane());
731  if (excludeMultipleHits_ && rechit.getMultipleHits() > 0)
732  continue;
733  if (rechit.getToT() != 0 && centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_)
734  planes[detId_pot].insert(detId.plane());
735 
736  if (potPlots_.find(detId_pot) == potPlots_.end())
737  continue;
738 
739  float UFSDShift = 0.0;
740  if (rechit.getYWidth() < 3)
741  UFSDShift = 0.5; // Display trick for UFSD that have 2 pixels with same X
742 
743  if (rechit.getToT() != 0 && centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_) {
744  TH2F* hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F();
745  TAxis* hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
746  int startBin = hitHistoTmpYAxis->FindBin(rechit.getX() - horizontalShiftOfDiamond_ - 0.5 * rechit.getXWidth());
747  int numOfBins = rechit.getXWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
748  for (int i = 0; i < numOfBins; ++i) {
749  hitHistoTmp->Fill(detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin + i));
750  }
751 
752  hitHistoTmp = lumiCache->hitDistribution2dMap[detId_pot].get();
753  hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
754  startBin = hitHistoTmpYAxis->FindBin(rechit.getX() - horizontalShiftOfDiamond_ - 0.5 * rechit.getXWidth());
755  numOfBins = rechit.getXWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
756  for (int i = 0; i < numOfBins; ++i) {
757  hitHistoTmp->Fill(detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin + i));
758  }
759  }
760 
761  if (rechit.getToT() != 0) {
762  // Both
763  potPlots_[detId_pot].leadingEdgeCumulative_both->Fill(rechit.getT() + 25 * rechit.getOOTIndex());
764  potPlots_[detId_pot].timeOverThresholdCumulativePot->Fill(rechit.getToT());
765 
766  TH2F* hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT->getTH2F();
767  TAxis* hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis();
768  int startBin =
769  hitHistoOOTTmpYAxis->FindBin(rechit.getX() - horizontalShiftOfDiamond_ - 0.5 * rechit.getXWidth());
770  int numOfBins = rechit.getXWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
771  for (int i = 0; i < numOfBins; ++i) {
772  hitHistoOOTTmp->Fill(detId.plane() + 0.25 * rechit.getOOTIndex(),
773  hitHistoOOTTmpYAxis->GetBinCenter(startBin + i));
774  }
775  } else {
776  if (rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING) {
777  // Only leading
778  TH2F* hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT_le->getTH2F();
779  TAxis* hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis();
780  int startBin =
781  hitHistoOOTTmpYAxis->FindBin(rechit.getX() - horizontalShiftOfDiamond_ - 0.5 * rechit.getXWidth());
782  int numOfBins = rechit.getXWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
783  for (int i = 0; i < numOfBins; ++i) {
784  hitHistoOOTTmp->Fill(detId.plane() + 0.25 * rechit.getOOTIndex(),
785  hitHistoOOTTmpYAxis->GetBinCenter(startBin + i));
786  }
787  }
788  }
789  if (rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING &&
790  potPlots_[detId_pot].activity_per_bx.count(rechit.getOOTIndex()) > 0)
791  potPlots_[detId_pot].activity_per_bx.at(rechit.getOOTIndex())->Fill(event.bunchCrossing());
792  }
793  }
794 
795  for (const auto& plt : potPlots_) {
796  plt.second.activePlanes->Fill(planes[plt.first].size());
797  plt.second.activePlanesInclusive->Fill(planes_inclusive[plt.first].size());
798  }
799 
800  // Using CTPPSDiamondLocalTrack
801  for (const auto& tracks : *diamondLocalTracks) {
802  CTPPSDiamondDetId detId_pot(tracks.detId());
803  detId_pot.setPlane(0);
804  detId_pot.setChannel(0);
805  const CTPPSDiamondDetId detId(tracks.detId());
806 
807  for (const auto& track : tracks) {
808  if (!track.isValid())
809  continue;
811  continue;
812  if (excludeMultipleHits_ && track.getMultipleHits() > 0)
813  continue;
814  if (potPlots_.find(detId_pot) == potPlots_.end())
815  continue;
816 
817  TH2F* trackHistoOOTTmp = potPlots_[detId_pot].trackDistributionOOT->getTH2F();
818  TAxis* trackHistoOOTTmpYAxis = trackHistoOOTTmp->GetYaxis();
819  int startBin = trackHistoOOTTmpYAxis->FindBin(track.getX0() - horizontalShiftOfDiamond_ - track.getX0Sigma());
820  int numOfBins = 2 * track.getX0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
821  for (int i = 0; i < numOfBins; ++i) {
822  trackHistoOOTTmp->Fill(track.getOOTIndex(), trackHistoOOTTmpYAxis->GetBinCenter(startBin + i));
823  }
824 
825  if (centralOOT_ != -999 && track.getOOTIndex() == centralOOT_) {
826  TH1F* trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution->getTH1F();
827  int startBin = trackHistoInTimeTmp->FindBin(track.getX0() - horizontalShiftOfDiamond_ - track.getX0Sigma());
828  int numOfBins = 2 * track.getX0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
829  for (int i = 0; i < numOfBins; ++i) {
830  trackHistoInTimeTmp->Fill(trackHistoInTimeTmp->GetBinCenter(startBin + i));
831  }
832  }
833  }
834  }
835 
836  // Channel efficiency using CTPPSDiamondLocalTrack
837  for (const auto& tracks : *diamondLocalTracks) {
838  CTPPSDiamondDetId detId_pot(tracks.detId());
839  detId_pot.setPlane(0);
840  detId_pot.setChannel(0);
841  for (const auto& track : tracks) {
842  // Find hits and planes in the track
843  int numOfHits = 0;
844  std::set<int> planesInTrackSet;
845  for (const auto& vec : *diamondRecHits) {
846  const CTPPSDiamondDetId detid(vec.detId());
847  if (detid.arm() != detId_pot.arm())
848  continue;
849 
850  for (const auto& hit : vec) {
851  // first check if the hit contributes to the track
852  if (track.containsHit(hit)) {
853  ++numOfHits;
854  planesInTrackSet.insert(detid.plane());
855  }
856  }
857  }
858 
859  if (numOfHits > 0 && numOfHits <= 10 && planesInTrackSet.size() > 2) {
860  for (int plane = 0; plane < 4; ++plane) {
861  for (int channel = 0; channel < 12; ++channel) {
862  int map_index = plane * 100 + channel;
863  if (potPlots_[detId_pot].effDoublecountingChMap.find(map_index) ==
864  potPlots_[detId_pot].effDoublecountingChMap.end()) {
865  potPlots_[detId_pot].effTriplecountingChMap[map_index] = 0;
866  potPlots_[detId_pot].effDoublecountingChMap[map_index] = 0;
867  }
868  CTPPSDiamondDetId detId(detId_pot.arm(), CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, plane, channel);
869  if (channelAlignedWithTrack(geometry_.product(), detId, track, 0.2)) {
870  // Channel should fire
871  ++(potPlots_[detId_pot].effDoublecountingChMap[map_index]);
872  for (const auto& rechits : *diamondRecHits) {
873  CTPPSDiamondDetId detId_hit(rechits.detId());
874  if (detId_hit == detId) {
875  for (const auto& rechit : rechits) {
876  if (track.containsHit(rechit, 1)) {
877  // Channel fired
878  ++(potPlots_[detId_pot].effTriplecountingChMap[map_index]);
879  }
880  }
881  }
882  }
883  }
884  }
885  }
886  }
887  }
888  }
889 
890  // Tomography of diamonds using pixel
891  for (const auto& rechits : *diamondRecHits) {
892  CTPPSDiamondDetId detId_pot(rechits.detId());
893  detId_pot.setPlane(0);
894  detId_pot.setChannel(0);
895  const CTPPSDiamondDetId detId(rechits.detId());
896  for (const auto& rechit : rechits) {
897  if (excludeMultipleHits_ && rechit.getMultipleHits() > 0)
898  continue;
899  if (rechit.getToT() == 0)
900  continue;
901  if (!pixelTracks.isValid())
902  continue;
903  if (potPlots_.find(detId_pot) == potPlots_.end())
904  continue;
905 
906  for (const auto& ds : *pixelTracks) {
907  if (ds.size() > 1)
908  continue;
909  const CTPPSPixelDetId pixId(ds.detId());
910  if (pixId.station() != CTPPS_PIXEL_STATION_ID || pixId.rp() != CTPPS_FAR_RP_ID)
911  continue;
912  for (const auto& lt : ds) {
913  if (lt.isValid() && pixId.arm() == detId_pot.arm()) {
914  if (rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && rechit.getOOTIndex() >= 0 &&
915  potPlots_[detId_pot].pixelTomographyAll.count(rechit.getOOTIndex()) > 0 &&
916  lt.getX0() - horizontalShiftBwDiamondPixels_ < 24)
917  potPlots_[detId_pot]
918  .pixelTomographyAll.at(rechit.getOOTIndex())
919  ->Fill(lt.getX0() - horizontalShiftBwDiamondPixels_ + 25 * detId.plane(), lt.getY0());
920  }
921  }
922  }
923  }
924  }
925 
926  //------------------------------
927  // Clock Plots
928  //------------------------------
929  // Commented out to save space in the DQM files, but code should be kept
930  // for ( const auto& digis : *diamondDigis ) {
931  // const CTPPSDiamondDetId detId( digis.detId() );
932  // CTPPSDiamondDetId detId_pot( digis.detId() );
933  // if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) {
934  // detId_pot.setPlane( 0 );
935  // detId_pot.setChannel( 0 );
936  // for ( const auto& digi : digis ) {
937  // if ( digi.getLeadingEdge() != 0 ) {
938  // if ( detId.plane() == 1 ) {
939  // potPlots_[detId_pot].clock_Digi1_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
940  // potPlots_[detId_pot].clock_Digi1_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
941  // }
942  // if ( detId.plane() == 3 ) {
943  // potPlots_[detId_pot].clock_Digi3_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
944  // potPlots_[detId_pot].clock_Digi3_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
945  // }
946  // }
947  // }
948  // }
949  // }
950 
951  //------------------------------
952  // Plane Plots
953  //------------------------------
954 
955  // Using CTPPSDiamondDigi
956  std::unordered_map<unsigned int, unsigned int> channelsPerPlane;
957  for (const auto& digis : *diamondDigis) {
958  const CTPPSDiamondDetId detId(digis.detId());
959  CTPPSDiamondDetId detId_plane(digis.detId());
960  for (const auto& digi : digis) {
961  detId_plane.setChannel(0);
962  if (detId.channel() == CHANNEL_OF_VFAT_CLOCK)
963  continue;
964  if (planePlots_.find(detId_plane) == planePlots_.end())
965  continue;
966 
967  if (digi.getLeadingEdge() != 0) {
968  planePlots_[detId_plane].digiProfileCumulativePerPlane->Fill(detId.channel());
969  if (channelsPerPlane.find(detId_plane) != channelsPerPlane.end())
970  channelsPerPlane[detId_plane]++;
971  else
972  channelsPerPlane[detId_plane] = 0;
973  }
974  }
975  }
976 
977  for (const auto& plt : channelsPerPlane) {
978  planePlots_[plt.first].hit_multiplicity->Fill(plt.second);
979  }
980 
981  // Using CTPPSDiamondRecHit
982  for (const auto& rechits : *diamondRecHits) {
983  CTPPSDiamondDetId detId_plane(rechits.detId());
984  detId_plane.setChannel(0);
985  for (const auto& rechit : rechits) {
986  if (excludeMultipleHits_ && rechit.getMultipleHits() > 0)
987  continue;
988  if (rechit.getToT() == 0)
989  continue;
990  if (planePlots_.find(detId_plane) != planePlots_.end()) {
991  if (centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_) {
992  TH1F* hitHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F();
993  int startBin = hitHistoTmp->FindBin(rechit.getX() - horizontalShiftOfDiamond_ - 0.5 * rechit.getXWidth());
994  int numOfBins = rechit.getXWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
995  for (int i = 0; i < numOfBins; ++i) {
996  hitHistoTmp->Fill(hitHistoTmp->GetBinCenter(startBin + i));
997  }
998  }
999  }
1000  }
1001  }
1002 
1003  //Tomography of diamonds using pixel and Efficiency WRT Pixels
1004  for (const auto& ds : *pixelTracks) {
1005  const CTPPSPixelDetId pixId(ds.detId());
1006  if (pixId.station() != CTPPS_PIXEL_STATION_ID || pixId.rp() != CTPPS_FAR_RP_ID)
1007  continue;
1008  if (ds.size() > 1)
1009  continue;
1010  for (const auto& lt : ds) {
1011  if (lt.isValid()) {
1012  // For efficieny
1014  potPlots_[detId_pot].pixelTracksMap.Fill(lt.getX0() - horizontalShiftBwDiamondPixels_, lt.getY0());
1015 
1016  std::set<CTPPSDiamondDetId> planesWitHits_set;
1017  for (const auto& rechits : *diamondRecHits) {
1018  CTPPSDiamondDetId detId_plane(rechits.detId());
1019  detId_plane.setChannel(0);
1020  for (const auto& rechit : rechits) {
1021  if (excludeMultipleHits_ && rechit.getMultipleHits() > 0)
1022  continue;
1023  if (rechit.getOOTIndex() == CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING || rechit.getToT() == 0)
1024  continue;
1025  if (planePlots_.find(detId_plane) == planePlots_.end())
1026  continue;
1027  if (pixId.arm() == detId_plane.arm() && lt.getX0() - horizontalShiftBwDiamondPixels_ < 24) {
1028  planePlots_[detId_plane].pixelTomography_far->Fill(
1029  lt.getX0() - horizontalShiftBwDiamondPixels_ + 25 * rechit.getOOTIndex(), lt.getY0());
1030  if (centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_)
1031  planesWitHits_set.insert(detId_plane);
1032  }
1033  }
1034  }
1035 
1036  for (auto& planeId : planesWitHits_set)
1037  planePlots_[planeId].pixelTracksMapWithDiamonds.Fill(lt.getX0() - horizontalShiftBwDiamondPixels_,
1038  lt.getY0());
1039  }
1040  }
1041  }
1042 
1043  //------------------------------
1044  // Channel Plots
1045  //------------------------------
1046 
1047  // digi profile cumulative
1048  for (const auto& digis : *diamondDigis) {
1049  const CTPPSDiamondDetId detId(digis.detId());
1050  for (const auto& digi : digis) {
1051  if (detId.channel() == CHANNEL_OF_VFAT_CLOCK)
1052  continue;
1053  if (channelPlots_.find(detId) != channelPlots_.end()) {
1054  // HPTDC Errors
1055  const HPTDCErrorFlags hptdcErrors = digi.getHPTDCErrorFlags();
1056  for (unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex)
1057  if (hptdcErrors.getErrorId(hptdcErrorIndex - 1))
1058  channelPlots_[detId].HPTDCErrorFlags->Fill(hptdcErrorIndex);
1059  if (digi.getMultipleHit())
1060  ++(channelPlots_[detId].MHCounter);
1061 
1062  // Check dropped trailing edges
1063  if (digi.getLeadingEdge() != 0 || digi.getTrailingEdge() != 0) {
1064  ++(channelPlots_[detId].HitCounter);
1065  if (digi.getLeadingEdge() != 0 && digi.getTrailingEdge() == 0) {
1066  ++(channelPlots_[detId].LeadingOnlyCounter);
1067  channelPlots_[detId].leadingEdgeCumulative_le->Fill(HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge());
1068  }
1069  if (digi.getLeadingEdge() == 0 && digi.getTrailingEdge() != 0) {
1070  ++(channelPlots_[detId].TrailingOnlyCounter);
1071  channelPlots_[detId].trailingEdgeCumulative_te->Fill(HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge());
1072  }
1073  if (digi.getLeadingEdge() != 0 && digi.getTrailingEdge() != 0) {
1074  ++(channelPlots_[detId].CompleteCounter);
1075  channelPlots_[detId].LeadingTrailingCorrelationPerChannel->Fill(
1076  HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge(), HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge());
1077  }
1078  }
1079  }
1080  }
1081  }
1082 
1083  // Using CTPPSDiamondRecHit
1084 
1085  for (const auto& rechits : *diamondRecHits) {
1086  CTPPSDiamondDetId detId(rechits.detId());
1087  for (const auto& rechit : rechits) {
1088  if (excludeMultipleHits_ && rechit.getMultipleHits() > 0)
1089  continue;
1090  if (channelPlots_.find(detId) != channelPlots_.end()) {
1091  if (rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && rechit.getToT() != 0) {
1092  channelPlots_[detId].leadingEdgeCumulative_both->Fill(rechit.getT() + 25 * rechit.getOOTIndex());
1093  channelPlots_[detId].TimeOverThresholdCumulativePerChannel->Fill(rechit.getToT());
1094  }
1095  ++(lumiCache->hitsCounterMap[detId]);
1096  }
1097 
1098  if (rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING &&
1099  channelPlots_[detId].activity_per_bx.count(rechit.getOOTIndex()) > 0)
1100  channelPlots_[detId].activity_per_bx.at(rechit.getOOTIndex())->Fill(event.bunchCrossing());
1101  }
1102  }
1103 
1104  // Tomography of diamonds using pixel
1105  for (const auto& rechits : *diamondRecHits) {
1106  const CTPPSDiamondDetId detId(rechits.detId());
1107  for (const auto& rechit : rechits) {
1108  if (excludeMultipleHits_ && rechit.getMultipleHits() > 0)
1109  continue;
1110  if (rechit.getOOTIndex() == CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING || rechit.getToT() == 0)
1111  continue;
1112  if (!pixelTracks.isValid())
1113  continue;
1114  if (channelPlots_.find(detId) == channelPlots_.end())
1115  continue;
1116 
1117  for (const auto& ds : *pixelTracks) {
1118  const CTPPSPixelDetId pixId(ds.detId());
1119  if (pixId.station() != CTPPS_PIXEL_STATION_ID || pixId.rp() != CTPPS_FAR_RP_ID)
1120  continue;
1121  if (ds.size() > 1)
1122  continue;
1123  for (const auto& lt : ds) {
1124  if (lt.isValid() && pixId.arm() == detId.arm() && lt.getX0() - horizontalShiftBwDiamondPixels_ < 24)
1125  channelPlots_[detId].pixelTomography_far->Fill(
1126  lt.getX0() - horizontalShiftBwDiamondPixels_ + 25 * rechit.getOOTIndex(), lt.getY0());
1127  }
1128  }
1129  }
1130  }
1131 }
1132 
1133 //----------------------------------------------------------------------------------------------------
1134 
1136  auto lumiCache = luminosityBlockCache(iLumi.index());
1137  for (auto& plot : potPlots_) {
1138  *(plot.second.hitDistribution2d_lumisection->getTH2F()) = *(lumiCache->hitDistribution2dMap[plot.first]);
1139  }
1140  for (auto& plot : channelPlots_) {
1141  auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[plot.first];
1142  if (hitsCounterPerLumisection != 0) {
1143  plot.second.hit_rate->Fill((double)hitsCounterPerLumisection / SEC_PER_LUMI_SECTION);
1144  }
1145 
1146  double HundredOverHitCounter = .0;
1147  if (plot.second.HitCounter != 0)
1148  HundredOverHitCounter = 100. / plot.second.HitCounter;
1149  plot.second.HPTDCErrorFlags->setBinContent(16, HundredOverHitCounter * plot.second.MHCounter);
1150  plot.second.leadingWithoutTrailing->setBinContent(1, HundredOverHitCounter * plot.second.LeadingOnlyCounter);
1151  plot.second.leadingWithoutTrailing->setBinContent(2, HundredOverHitCounter * plot.second.TrailingOnlyCounter);
1152  plot.second.leadingWithoutTrailing->setBinContent(3, HundredOverHitCounter * plot.second.CompleteCounter);
1153  }
1154 
1155  for (auto& plot : potPlots_) {
1156  double HundredOverHitCounterPot = 0.;
1157  if (plot.second.HitCounter != 0)
1158  HundredOverHitCounterPot = 100. / plot.second.HitCounter;
1159  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
1160  1, HundredOverHitCounterPot * plot.second.LeadingOnlyCounter);
1161  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
1162  2, HundredOverHitCounterPot * plot.second.TrailingOnlyCounter);
1163  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
1164  3, HundredOverHitCounterPot * plot.second.CompleteCounter);
1165 
1166  plot.second.MHComprensive->Reset();
1167  CTPPSDiamondDetId rpId(plot.first);
1168  for (auto& chPlot : channelPlots_) {
1169  CTPPSDiamondDetId chId(chPlot.first);
1170  if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) {
1171  plot.second.MHComprensive->Fill(chId.plane(), chId.channel(), chPlot.second.HPTDCErrorFlags->getBinContent(16));
1172  }
1173  }
1174  }
1175 
1176  // Efficiencies of single channels
1177  for (auto& plot : potPlots_) {
1178  plot.second.EfficiencyOfChannelsInPot->Reset();
1179  for (auto& element : plot.second.effTriplecountingChMap) {
1180  if (plot.second.effDoublecountingChMap[element.first] > 0) {
1181  int plane = element.first / 100;
1182  int channel = element.first % 100;
1183  double counted = element.second;
1184  double total = plot.second.effDoublecountingChMap[element.first];
1185  double efficiency = counted / total;
1186  // double error = std::sqrt( efficiency * ( 1 - efficiency ) / total );
1187 
1188  plot.second.EfficiencyOfChannelsInPot->Fill(plane, channel, 100 * efficiency);
1189  }
1190  }
1191  }
1192 
1193  // Efficeincy wrt pixels //TODO
1194  for (auto& plot : planePlots_) {
1195  TH2F* hitHistoTmp = plot.second.EfficiencyWRTPixelsInPlane->getTH2F();
1196 
1197  CTPPSDiamondDetId detId_pot(plot.first);
1198  detId_pot.setPlane(0);
1199 
1200  hitHistoTmp->Divide(&(plot.second.pixelTracksMapWithDiamonds), &(potPlots_[detId_pot].pixelTracksMap));
1201  }
1202 }
1203 
1204 //----------------------------------------------------------------------------------------------------
1205 
1207 
1208 //----------------------------------------------------------------------------------------------------
1209 
static const int CTPPS_FED_ID_56
void analyze(const edm::Event &, const edm::EventSetup &) override
OptoRx headers and footers.
Definition: TotemFEDInfo.h:17
plots related to one Diamond plane
T getParameter(std::string const &) const
plots related to one Diamond detector package
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondRecHit > > tokenDiamondHit_
Translation translation() const
Definition: DetGeomDesc.h:66
edm::EDGetTokenT< std::vector< TotemFEDInfo > > tokenFEDInfo_
static const int CHANNEL_OF_VFAT_CLOCK
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
RunNumber_t run() const
Definition: RunBase.h:40
static const double DISPLAY_RESOLUTION_FOR_HITS_MM
LuminosityBlockIndex index() const
static const int CTPPS_DIAMOND_NUM_OF_PLANES
TH1F * getTH1F() const
void setPlane(uint32_t channel)
Reconstructed hit in diamond detectors.
const double tolerance
void endRun(const edm::Run &, const edm::EventSetup &) override
void setChannel(uint32_t channel)
void channelName(std::string &name, NameFlag flag=nFull) const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
CTPPSDiamondDQMSource(const edm::ParameterSet &)
bool getErrorId(unsigned short id) const
static const int CTPPS_NUM_OF_ARMS
plots related to the whole system
int bunchCrossing() const
Definition: EventBase.h:64
static const int CTPPS_DIAMOND_NUM_OF_CHANNELS
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondLocalTrack > > tokenDiamondTrack_
Event setup record containing the real (actual) geometry information.
MonitorElement * leadingWithoutTrailingCumulativePot
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelLocalTrack > > tokenPixelTrack_
static const int CTPPS_PIXEL_STATION_ID
void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
std::unordered_map< unsigned int, MonitorElement * > pixelTomographyAll
static const int CTPPS_DIAMOND_STATION_ID
const DetGeomDesc * getSensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
std::vector< std::pair< edm::EventRange, int > > runParameters_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondDigi > > tokenDigi_
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
static const int CTPPS_NEAR_RP_ID
std::unordered_map< unsigned int, ChannelPlots > channelPlots_
edm::EDGetTokenT< edm::DetSetVector< TotemVFATStatus > > tokenStatus_
Geometrical description of a sensor.
Definition: DetGeomDesc.h:35
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:128
std::unordered_map< unsigned int, std::unique_ptr< TH2F > > hitDistribution2dMap
plots related to one Diamond channel
uint32_t plane() const
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:97
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
uint32_t arm() const
Definition: CTPPSDetId.h:51
bool isValid() const
Definition: HandleBase.h:74
TH2F * getTH2F() const
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:33
static const double HPTDC_BIN_WIDTH_NS
uint32_t channel() const
static const double INV_DISPLAY_RESOLUTION_FOR_HITS_MM
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
void planeName(std::string &name, NameFlag flag=nFull) const
std::unordered_map< unsigned int, MonitorElement * > activity_per_bx
std::shared_ptr< dds::Cache > globalBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const override
bool channelAlignedWithTrack(const CTPPSGeometry *geom, const CTPPSDiamondDetId &detid, const CTPPSDiamondLocalTrack &localTrack, const float tolerance=1)
std::unordered_map< unsigned int, PotPlots > potPlots_
static constexpr int TIMESLICE_WITHOUT_LEADING
HLT enums.
static const int CTPPS_FAR_RP_ID
T get() const
Definition: EventSetup.h:71
static const double SEC_PER_LUMI_SECTION
std::vector< double > params() const
Definition: DetGeomDesc.h:68
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
std::unordered_map< unsigned int, PlanePlots > planePlots_
std::unordered_map< unsigned int, MonitorElement * > activity_per_bx
static const int CTPPS_DIAMOND_RP_ID
static std::string getHPTDCErrorName(const unsigned short id)
static const int CTPPS_FED_ID_45
T const * product() const
Definition: ESHandle.h:86
std::unordered_map< unsigned int, unsigned long > hitsCounterMap
Definition: event.py:1
Definition: Run.h:45
uint32_t rp() const
Definition: CTPPSDetId.h:65