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