CMS 3D CMS Logo

DiamondSampicDQMSource.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of CTPPSDQM software.
4  * Authors:
5  * Christopher Misan
6  * Nicola Minafra
7  * Laurent Forthomme
8  *
9  ****************************************************************************/
10 
17 
20 
27 
31 
36 
37 #include <string>
38 
39 //----------------------------------------------------------------------------------------------------
40 
41 namespace totemds {
42  struct Cache {
43  std::unordered_map<unsigned int, std::unique_ptr<TH2F>> hitDistribution2dMap;
44 
45  std::unordered_map<unsigned int, unsigned long> hitsCounterMap;
46  };
47 } // namespace totemds
48 
49 class DiamondSampicDQMSource : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<totemds::Cache>> {
50 public:
52  ~DiamondSampicDQMSource() override;
53 
54 protected:
55  void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
56  void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override;
57  void analyze(const edm::Event &, const edm::EventSetup &) override;
58  std::shared_ptr<totemds::Cache> globalBeginLuminosityBlock(const edm::LuminosityBlock &,
59  const edm::EventSetup &) const override;
60  void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override;
61 
62 private:
63  // Constants
64  static const double SEC_PER_LUMI_SECTION; // Number of seconds per
65  // lumisection: used to compute hit
66  // rates in Hz
67  static const double LHC_CLOCK_PERIOD_NS;
68  static const double DQM_FRACTION_OF_EVENTS; // approximate fraction of events
69  // sent to DQM stream
70  static const double HIT_RATE_FACTOR; // factor to have real rate in Hz
71  static const double DISPLAY_RESOLUTION_FOR_HITS_MM; // Bin width of histograms
72  // showing hits and tracks
73  // (in mm)
75  static const double SAMPIC_ADC_V;
76 
82 
84 
85  unsigned int samplesForNoise_;
86  unsigned int verbosity_;
88  bool perLSsaving_; //to avoid nanoDQMIO crashing, driven by DQMServices/Core/python/DQMStore_cfi.py
91 
92  std::unordered_map<unsigned int, double> horizontalShiftOfDiamond_;
93 
95  struct GlobalPlots {
97 
100  };
101 
103 
104  struct SectorPlots {
105  // Tracks
110  SectorPlots(DQMStore::IBooker &ibooker, unsigned int id, bool plotOnline);
111  };
112  std::unordered_map<unsigned int, SectorPlots> sectorPlots_;
113 
115  struct PotPlots {
116  // Digis
122 
126 
127  // RecHits
131 
138 
140 
143 
145 
146  std::set<unsigned int> planesWithDigisSet;
147  std::set<unsigned int> planesWithTimeSet;
148 
149  PotPlots(){};
150  PotPlots(DQMStore::IBooker &ibooker, unsigned int id, bool plotOnline);
151  };
152 
153  std::unordered_map<unsigned int, PotPlots> potPlots_;
154 
156  struct PlanePlots {
158 
162 
164  PlanePlots(DQMStore::IBooker &ibooker, unsigned int id);
165  };
166 
167  std::unordered_map<unsigned int, PlanePlots> planePlots_;
168 
170  struct ChannelPlots {
171  // Digis
176 
177  // RecHits
182 
183  //MonitorElement *hitTime = nullptr;
185 
187  ChannelPlots(DQMStore::IBooker &ibooker, unsigned int id);
188  };
189 
190  std::unordered_map<unsigned int, ChannelPlots> channelPlots_;
192 };
193 //----------------------------------------------------------------------------------------------------
195  std::string toReplace = "TimingDiamond";
196  path = path.substr(path.find(toReplace) + toReplace.length());
197  path = "CTPPS/DiamondSampic/" + path;
198  return path;
199 }
200 //----------------------------------------------------------------------------------------------------
201 
202 // Values for all constants
206 const double DiamondSampicDQMSource::HIT_RATE_FACTOR = DQM_FRACTION_OF_EVENTS / SEC_PER_LUMI_SECTION;
208 const double DiamondSampicDQMSource::INV_DISPLAY_RESOLUTION_FOR_HITS_MM = 1. / DISPLAY_RESOLUTION_FOR_HITS_MM;
209 const double DiamondSampicDQMSource::SAMPIC_ADC_V = 1. / 256;
210 //----------------------------------------------------------------------------------------------------
211 
213  ibooker.setCurrentFolder("CTPPS/DiamondSampic");
214  digiSentPercentage = ibooker.book2D(
215  "sent digis percentage", "sent digis percentage (sampic);board + 0.5 sampic;channel", 14, -0.5, 6.5, 16, 0, 16);
216 }
217 
218 //----------------------------------------------------------------------------------------------------
219 
224 
226 
227  trackCorrelation = ibooker.book2D("tracks correlation near-far",
228  title + " tracks correlation near-far;x (mm);x (mm)",
230  -1,
231  18,
233  -1,
234  18);
235  trackCorrelationLowMultiplicity =
236  ibooker.book2D("tracks correlation with low multiplicity near-far",
237  title + " tracks correlation with low multiplicity near-far;x (mm);x (mm)",
239  -1,
240  18,
242  -1,
243  18);
244  if (plotOnline)
245  digiSentPercentage = ibooker.book2D("sent digis percentage",
246  title + " sent digis percentage (sampic);board + 0.5 sampic;channel",
247  14,
248  -0.5,
249  6.5,
250  16,
251  0,
252  16);
253 }
254 
255 //----------------------------------------------------------------------------------------------------
256 
261 
263 
264  digiDistribution =
265  ibooker.book2D("digi distribution", title + " digi distribution;plane;channel", 10, -0.5, 4.5, 12, 0, 12);
266 
267  hitDistribution2d = ibooker.book2D("hits in planes",
268  title + " hits in planes;plane number;x (mm)",
269  10,
270  -0.5,
271  4.5,
273  -0.5,
274  18.5);
275  hitDistribution2dWithTime = ibooker.book2D("hits in planes with time",
276  title + " hits in planes with time;plane number;x (mm)",
277  10,
278  -0.5,
279  4.5,
281  -0.5,
282  18.5);
283 
284  recHitTime = ibooker.book1D("recHit time", title + " recHit time; t (ns)", 500, -25, 25);
285  trackDistribution = ibooker.book1D(
286  "tracks", title + " tracks;x (mm)", 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18); //TODO needs tracks
287 
288  if (plotOnline) {
289  hitDistribution2d_lumisection =
290  ibooker.book2D("hits in planes lumisection",
291  title + " hits in planes in the last lumisection;plane number;x (mm)",
292  18,
293  -0.5,
294  4,
296  0,
297  15);
298  triggerCellTime = ibooker.book1D("trigger cell time", title + " Trigger Cell Time; t (ns)", 390, -25, 25);
299  activityPerBX = ibooker.book1D("activity per BX CMS", title + " Activity per BX;Event.BX", 3600, -1.5, 3598. + 0.5);
300  amplitude = ibooker.book1D("amplitude", title + " amplitude above baseline; amplitude (V)", 50, 0, 1);
301  baselineRMS = ibooker.book2D("noise RMS", title + " noise RMS (V);plane;channel", 10, -0.5, 4.5, 12, 0, 12);
302  meanAmplitude =
303  ibooker.book2D("mean amplitude", title + " Mean Amplitude (V);plane;channel", 10, -0.5, 4.5, 12, 0, 12);
304  cellOfMax = ibooker.book2D("cell of max", title + " cell of max (0-23);plane;channel", 10, -0.5, 4.5, 12, 0, 12);
305 
306  //hitRate = ibooker.book2D("hit rate", title + " hit rate (Hz);plane;channel", 10, -0.5, 4.5, 12, 0, 12);
307 
308  planesWithDigis = ibooker.book1D("active planes digis",
309  title + " active planes with digis sent (per event);number of active planes",
310  6,
311  -0.5,
312  5.5);
313  planesWithTime = ibooker.book1D(
314  "active planes with time", title + " active planes with time (per event);number of active planes", 6, -0.5, 5.5);
315 
316  dataSamplesRaw = ibooker.book1D("raw Samples", title + " Raw Samples; ADC", 256, 0, 256);
317 
318  baseline = ibooker.book2D("baseline", title + " baseline (V);plane;channel", 10, -0.5, 4.5, 12, 0, 12);
319  noiseRMS = ibooker.book2D("noise RMS", title + " noise RMS (V);plane;channel", 10, -0.5, 4.5, 12, 0, 12);
320 
321  digiSent = ibooker.book2D(
322  "digis sent", title + " digi sent (sampic);board + 0.5 sampic;channel", 14, -0.5, 6.5, 16, 0, 16);
323  digiAll =
324  ibooker.book2D("all digis", title + " all digis(sampic);board + 0.5 sampic;channel", 14, -0.5, 6.5, 16, 0, 16);
325  digiSentPercentage = ibooker.book2D("sent digis percentage",
326  title + " sent digis percentage (sampic);board + 0.5 sampic;channel",
327  14,
328  -0.5,
329  6.5,
330  16,
331  0,
332  16);
333  }
334 }
335 
336 //----------------------------------------------------------------------------------------------------
337 
342 
344 
345  digiDistribution = ibooker.book1D("digi distribution", title + " digi distribution;channel", 12, 0, 12);
346 
347  hitProfile = ibooker.book1D("hit distribution with time",
348  title + " hit distribution (with time);x(mm)",
350  0,
351  30);
352 
353  hitMultiplicity = ibooker.book1D("channels per plane", title + " channels per plane; ch per plane", 13, -0.5, 12.5);
354 
355  hitMultiplicityWithTime = ibooker.book1D(
356  "channels per plane with time", title + " channels per plane with time; ch per plane", 13, -0.5, 12.5);
357 }
358 
359 //----------------------------------------------------------------------------------------------------
360 
365 
367 
368  activityPerBX = ibooker.book1D("activity per BX", title + " Activity per BX;Event.BX", 1000, -1.5, 998. + 0.5);
369  dataSamplesRaw = ibooker.book1D("raw samples", title + " Raw Samples; ADC", 256, 0, 256);
370  cellOfMax = ibooker.book1D("cell of max", title + " cell of max; cell", 24, 0, 24);
371 
372  triggerCellTime = ibooker.book1D("sampic trigger time", title + " Sampic Trigger Time; t (ns)", 100, -25, 25);
373  recHitTime = ibooker.book1D("recHit Time", title + " recHit Time; t (ns)", 500, -25, 25);
374  amplitude = ibooker.book1D("amplitude", title + " amplitude above baseline; amplitude (V)", 50, 0, 1);
375  noiseSamples = ibooker.book1D("noise samples", title + " noise samples; V", 50, 0, 1);
376 
377  //hitTime = ibooker.book1D("hit time", title + "hit time;t - t_previous (us)", 100, 0, 10000);
378  //hitRate = ibooker.book1D("hit rate", title + "hit rate;rate (Hz)", 100, 0, 10000);
379 }
380 
381 //----------------------------------------------------------------------------------------------------
382 
384  : tokenLocalTrack_(consumes<edm::DetSetVector<TotemRPLocalTrack>>(ps.getParameter<edm::InputTag>("tagLocalTrack"))),
385  tokenDigi_(consumes<edm::DetSetVector<TotemTimingDigi>>(ps.getParameter<edm::InputTag>("tagDigi"))),
386  tokenRecHit_(consumes<edm::DetSetVector<TotemTimingRecHit>>(ps.getParameter<edm::InputTag>("tagRecHits"))),
387  tokenTrack_(consumes<edm::DetSetVector<TotemTimingLocalTrack>>(ps.getParameter<edm::InputTag>("tagTracks"))),
388  tokenFEDInfo_(consumes<std::vector<TotemFEDInfo>>(ps.getParameter<edm::InputTag>("tagFEDInfo"))),
390  samplesForNoise_(ps.getUntrackedParameter<unsigned int>("samplesForNoise", 5)),
391  verbosity_(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
392  plotOnline_(ps.getUntrackedParameter<bool>("plotOnline", true)),
393  perLSsaving_(ps.getUntrackedParameter<bool>("perLSsaving", false)),
394  trackCorrelationThreshold_(ps.getUntrackedParameter<unsigned int>("trackCorrelationThreshold", 3)),
396 
397 //----------------------------------------------------------------------------------------------------
398 
400 
401 //----------------------------------------------------------------------------------------------------
402 
404  // Get detector shifts from the geometry (if present)
406  for (auto it = geom->beginSensor(); it != geom->endSensor(); it++) {
407  if (!CTPPSDiamondDetId::check(it->first))
408  continue;
409  const CTPPSDiamondDetId detid(it->first);
410 
411  const DetGeomDesc *det = geom->sensorNoThrow(detid);
412  if (det)
414  else
415  edm::LogProblem("DiamondSampicCalibrationDQMSource") << "ERROR: no descriptor for detId";
416  }
417  //horizontalShiftOfDiamond_=0;//unlock the shift
418 }
419 
420 //----------------------------------------------------------------------------------------------------
421 
423  const edm::Run &,
424  const edm::EventSetup &iSetup) {
425  ibooker.cd();
426  ibooker.setCurrentFolder("CTPPS/DiamondSampic");
427 
429  for (auto it = geom->beginSensor(); it != geom->endSensor(); ++it) {
430  if (!CTPPSDiamondDetId::check(it->first))
431  continue;
432  const CTPPSDiamondDetId detid(it->first);
433 
434  sectorPlots_[detid.armId()] = SectorPlots(ibooker, detid.armId(), plotOnline_);
435 
436  const CTPPSDiamondDetId rpId(detid.arm(), detid.station(), detid.rp());
437  potPlots_[rpId] = PotPlots(ibooker, rpId, plotOnline_);
438 
439  if (plotOnline_) {
440  globalPlot_ = GlobalPlots(ibooker);
441  const CTPPSDiamondDetId plId(detid.arm(), detid.station(), detid.rp(), detid.plane());
442  planePlots_[plId] = PlanePlots(ibooker, plId);
443 
444  const CTPPSDiamondDetId chId(detid.arm(), detid.station(), detid.rp(), detid.plane(), detid.channel());
445  channelPlots_[chId] = ChannelPlots(ibooker, chId);
446  }
447  }
448 }
449 
450 //----------------------------------------------------------------------------------------------------
451 
453  const edm::EventSetup &) const {
454  auto d = std::make_shared<totemds::Cache>();
455  d->hitDistribution2dMap.reserve(potPlots_.size());
456  if (!perLSsaving_ && plotOnline_)
457  for (auto &plot : potPlots_)
458  d->hitDistribution2dMap[plot.first] =
459  std::unique_ptr<TH2F>(static_cast<TH2F *>(plot.second.hitDistribution2d_lumisection->getTH2F()->Clone()));
460  return d;
461 }
462 
463 //----------------------------------------------------------------------------------------------------
464 
466  // get event data
468  event.getByToken(tokenDigi_, timingDigis);
469 
471  event.getByToken(tokenFEDInfo_, fedInfo);
472 
474  event.getByToken(tokenRecHit_, timingRecHits);
475 
477  event.getByToken(tokenTrack_, timingLocalTracks);
478 
479  // check validity
480  bool valid = true;
481  valid &= timingDigis.isValid();
482  //valid &= fedInfo.isValid();
483 
484  if (!valid) {
485  if (verbosity_) {
486  edm::LogProblem("DiamondSampicDQMSource")
487  << "ERROR in DiamondSampicDQMSource::analyze > some of the required inputs "
488  "are not valid. Skipping this event.\n"
489  << " timingDigis.isValid = " << timingDigis.isValid() << "\n"
490  << " fedInfo.isValid = " << fedInfo.isValid();
491  }
492 
493  return;
494  }
495 
496  // Using TotemTimingDigi
497  std::set<uint8_t> boardSet;
498  std::unordered_map<unsigned int, unsigned int> channelsPerPlane;
499  std::unordered_map<unsigned int, unsigned int> channelsPerPlaneWithTime;
500 
501  auto lumiCache = luminosityBlockCache(event.getLuminosityBlock().index());
502 
503  for (const auto &digis : *timingDigis) {
504  const CTPPSDiamondDetId detId(digis.detId());
505  CTPPSDiamondDetId detId_pot(digis.detId());
506  detId_pot.setPlane(0);
507  detId_pot.setChannel(0);
508  CTPPSDiamondDetId detId_plane(digis.detId());
509  detId_plane.setChannel(0);
510 
511  for (const auto &digi : digis) {
512  // Pot Plots
513  if (potPlots_.find(detId_pot) != potPlots_.end()) {
514  potPlots_[detId_pot].digiDistribution->Fill(detId.plane(), detId.channel());
515 
516  if (plotOnline_) {
517  potPlots_[detId_pot].activityPerBX->Fill(event.bunchCrossing());
518 
519  for (auto it = digi.samplesBegin(); it != digi.samplesEnd(); ++it) {
520  potPlots_[detId_pot].dataSamplesRaw->Fill(*it);
521  }
522 
523  float boardId = digi.eventInfo().hardwareBoardId() + 0.5 * digi.eventInfo().hardwareSampicId();
524  potPlots_[detId_pot].digiSent->Fill(boardId, digi.hardwareChannelId());
525 
526  if (boardSet.find(digi.eventInfo().hardwareId()) == boardSet.end()) {
527  // This guarantees that every board is counted only once
528  boardSet.insert(digi.eventInfo().hardwareId());
529  std::bitset<16> chMap(digi.eventInfo().channelMap());
530  for (int i = 0; i < 16; ++i) {
531  if (chMap.test(i)) {
532  potPlots_[detId_pot].digiAll->Fill(boardId, i);
533  }
534  }
535  }
536 
537  potPlots_[detId_pot].planesWithDigisSet.insert(detId.plane());
538  }
539  }
540 
541  if (plotOnline_) {
542  // Plane Plots
543  if (planePlots_.find(detId_plane) != planePlots_.end()) {
544  planePlots_[detId_plane].digiDistribution->Fill(detId.channel());
545 
546  if (channelsPerPlane.find(detId_plane) != channelsPerPlane.end())
547  channelsPerPlane[detId_plane]++;
548  else
549  //if it's the first channel, create new map element with the value of 1
550  channelsPerPlane[detId_plane] = 1;
551  }
552 
553  // Channel Plots
554  if (channelPlots_.find(detId) != channelPlots_.end()) {
555  channelPlots_[detId].activityPerBX->Fill(event.bunchCrossing());
556 
557  for (auto it = digi.samplesBegin(); it != digi.samplesEnd(); ++it)
558  channelPlots_[detId].dataSamplesRaw->Fill(*it);
559  for (unsigned short i = 0; i < samplesForNoise_; ++i)
560  channelPlots_[detId].noiseSamples->Fill(SAMPIC_ADC_V * digi.sampleAt(i));
561 
562  unsigned int cellOfMax = std::max_element(digi.samplesBegin(), digi.samplesEnd()) - digi.samplesBegin();
563  channelPlots_[detId].cellOfMax->Fill((int)cellOfMax);
564 
565  // if (timeOfPreviousEvent_ != 0)
566  // channelPlots_[detId].hitTime->Fill(1e-3 * LHC_CLOCK_PERIOD_NS *
567  // (event.time().value() - timeOfPreviousEvent_));
568  ++(lumiCache->hitsCounterMap[detId]);
569  }
570  }
571  }
572  }
573  // End digis
574 
575  for (const auto &rechits : *timingRecHits) {
576  const CTPPSDiamondDetId detId(rechits.detId());
577  CTPPSDiamondDetId detId_pot(rechits.detId());
578  detId_pot.setPlane(0);
579  detId_pot.setChannel(0);
580  CTPPSDiamondDetId detId_plane(rechits.detId());
581  detId_plane.setChannel(0);
582 
583  for (const auto &rechit : rechits) {
584  if (potPlots_.find(detId_pot) != potPlots_.end()) {
585  float UFSDShift = 0.0;
586  if (rechit.yWidth() < 3)
587  UFSDShift = 0.5;
588 
589  TH2F *hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F();
590  TAxis *hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
591  int startBin =
592  hitHistoTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] - 0.5 * rechit.xWidth());
593  const int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
594  for (int i = 0; i < numOfBins; ++i) {
595  potPlots_[detId_pot].hitDistribution2d->Fill(detId.plane() + UFSDShift,
596  hitHistoTmpYAxis->GetBinCenter(startBin + i));
597  if (!perLSsaving_ && plotOnline_)
598  potPlots_[detId_pot].hitDistribution2d_lumisection->Fill(detId.plane() + UFSDShift,
599  hitHistoTmpYAxis->GetBinCenter(startBin + i));
600  }
601 
602  //All plots with Time
603  if (rechit.time() != TotemTimingRecHit::NO_T_AVAILABLE) {
604  for (int i = 0; i < numOfBins; ++i)
605  potPlots_[detId_pot].hitDistribution2dWithTime->Fill(detId.plane() + UFSDShift,
606  hitHistoTmpYAxis->GetBinCenter(startBin + i));
607 
608  potPlots_[detId_pot].recHitTime->Fill(rechit.time());
609  if (plotOnline_) {
610  potPlots_[detId_pot].amplitude->Fill(rechit.amplitude());
611  potPlots_[detId_pot].planesWithTimeSet.insert(detId.plane());
612 
613  // Plane Plots
614  if (planePlots_.find(detId_plane) != planePlots_.end()) {
615  TH1F *hitProfileHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F();
616  const int startBin = hitProfileHistoTmp->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] -
617  0.5 * rechit.xWidth());
618  for (int i = 0; i < numOfBins; ++i)
619  hitProfileHistoTmp->Fill(hitProfileHistoTmp->GetBinCenter(startBin + i));
620 
621  if (channelsPerPlaneWithTime.find(detId_plane) != channelsPerPlaneWithTime.end())
622  channelsPerPlaneWithTime[detId_plane]++;
623  else
624  //if it's the first channel, create new map element with the value of 1
625  channelsPerPlaneWithTime[detId_plane] = 1;
626  }
627 
628  if (channelPlots_.find(detId) != channelPlots_.end()) {
629  potPlots_[detId_pot].triggerCellTime->Fill(rechit.sampicThresholdTime());
630  channelPlots_[detId].triggerCellTime->Fill(rechit.sampicThresholdTime());
631  channelPlots_[detId].recHitTime->Fill(rechit.time());
632  channelPlots_[detId].amplitude->Fill(rechit.amplitude());
633  }
634  }
635  }
636  }
637  }
638  }
639  // End RecHits
640 
641  // Using CTPPSDiamondLocalTrack
642  for (const auto &tracks : *timingLocalTracks) {
643  CTPPSDiamondDetId detId_pot(tracks.detId());
644  detId_pot.setPlane(0);
645  detId_pot.setChannel(0);
646  const CTPPSDiamondDetId detId_near(tracks.detId());
647 
648  for (const auto &track : tracks) {
649  if (!track.isValid())
650  continue;
651  if (potPlots_.find(detId_pot) == potPlots_.end())
652  continue;
653 
654  TH1F *trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution->getTH1F();
655  const int startBin =
656  trackHistoInTimeTmp->FindBin(track.x0() - horizontalShiftOfDiamond_[detId_pot] - track.x0Sigma());
657  const int numOfBins = 2 * track.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
658  for (int i = 0; i < numOfBins; ++i) {
659  trackHistoInTimeTmp->Fill(trackHistoInTimeTmp->GetBinCenter(startBin + i));
660  }
661 
662  //this plot was made with 2 stations per arm in mind
663  for (const auto &tracks_far : *timingLocalTracks) {
664  CTPPSDiamondDetId detId_far(tracks_far.detId());
665  detId_far.setPlane(0);
666  detId_far.setChannel(0);
667  if (detId_near.arm() != detId_far.arm() || detId_near.station() == detId_far.station())
668  continue;
669  for (const auto &track_far : tracks_far) {
670  if (!track.isValid())
671  continue;
672  if (sectorPlots_.find(detId_far.armId()) == sectorPlots_.end())
673  continue;
674  TH2F *trackHistoTmp = sectorPlots_[detId_far.armId()].trackCorrelation->getTH2F();
675  TAxis *trackHistoTmpXAxis = trackHistoTmp->GetXaxis();
676  TAxis *trackHistoTmpYAxis = trackHistoTmp->GetYaxis();
677  const int startBin_far =
678  trackHistoTmpYAxis->FindBin(track_far.x0() - horizontalShiftOfDiamond_[detId_far] - track_far.x0Sigma());
679  const int numOfBins_far = 2 * track_far.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
680  for (int i = 0; i < numOfBins; ++i) {
681  for (int y = 0; y < numOfBins_far; ++y) {
682  trackHistoTmp->Fill(trackHistoTmpXAxis->GetBinCenter(startBin + i),
683  trackHistoTmpYAxis->GetBinCenter(startBin_far + y));
684  if (tracks.size() < 3 && tracks_far.size() < trackCorrelationThreshold_)
685  sectorPlots_[detId_far.armId()].trackCorrelationLowMultiplicity->Fill(
686  trackHistoTmpXAxis->GetBinCenter(startBin + i), trackHistoTmpYAxis->GetBinCenter(startBin_far + y));
687  }
688  }
689  }
690  }
691  }
692  }
693  if (plotOnline_) {
694  for (auto &plt : potPlots_) {
695  plt.second.planesWithDigis->Fill(plt.second.planesWithDigisSet.size());
696  plt.second.planesWithDigisSet.clear();
697  plt.second.planesWithTime->Fill(plt.second.planesWithTimeSet.size());
698  plt.second.planesWithTimeSet.clear();
699  }
700 
701  for (const auto &plt : channelsPerPlane)
702  planePlots_[plt.first].hitMultiplicity->Fill(plt.second);
703 
704  for (const auto &plt : channelsPerPlaneWithTime)
705  planePlots_[plt.first].hitMultiplicityWithTime->Fill(plt.second);
706  }
707  timeOfPreviousEvent_ = event.time().value();
708 }
709 
710 //----------------------------------------------------------------------------------------------------
711 
713  auto lumiCache = luminosityBlockCache(iLumi.index());
714  if (!perLSsaving_ && plotOnline_) {
715  for (auto &plot : potPlots_)
716  *(plot.second.hitDistribution2d_lumisection->getTH2F()) = *(lumiCache->hitDistribution2dMap[plot.first]);
718  for (auto &plot : sectorPlots_)
719  plot.second.digiSentPercentage->Reset();
720  TH2F *hitHistoGlobalTmp = globalPlot_.digiSentPercentage->getTH2F();
721  for (auto &plot : potPlots_) {
722  TH2F *hitHistoTmp = plot.second.digiSentPercentage->getTH2F();
723  TH2F *histoSent = plot.second.digiSent->getTH2F();
724  TH2F *histoAll = plot.second.digiAll->getTH2F();
725 
726  hitHistoTmp->Divide(histoSent, histoAll);
727  hitHistoTmp->Scale(100);
728  hitHistoGlobalTmp->Add(hitHistoTmp, 1);
729 
730  plot.second.baseline->Reset();
731  plot.second.noiseRMS->Reset();
732  plot.second.meanAmplitude->Reset();
733  plot.second.cellOfMax->Reset();
734  //plot.second.hitRate->Reset();
735  CTPPSDiamondDetId rpId(plot.first);
736  TH2F *hitHistoSectorTmp = sectorPlots_[rpId.armId()].digiSentPercentage->getTH2F();
737  hitHistoSectorTmp->Add(hitHistoTmp, 1);
738 
739  for (auto &chPlot : channelPlots_) {
740  CTPPSDiamondDetId chId(chPlot.first);
741  if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) {
742  plot.second.baseline->Fill(chId.plane(), chId.channel(), chPlot.second.noiseSamples->getTH1F()->GetMean());
743  plot.second.noiseRMS->Fill(chId.plane(), chId.channel(), chPlot.second.noiseSamples->getTH1F()->GetRMS());
744  plot.second.meanAmplitude->Fill(chId.plane(), chId.channel(), chPlot.second.amplitude->getTH1F()->GetMean());
745  plot.second.cellOfMax->Fill(chId.plane(), chId.channel(), chPlot.second.cellOfMax->getTH1F()->GetMean());
746  //auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[chPlot.first];
747  //plot.second.hitRate->Fill(chId.plane(), chId.channel(), (double)hitsCounterPerLumisection * HIT_RATE_FACTOR);
748  }
749  }
750  }
751 
752  // for (auto &plot : channelPlots_) {
753  // auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[plot.first];
754  // if (hitsCounterPerLumisection != 0) {
755  // plot.second.hitRate->Fill((double)hitsCounterPerLumisection * HIT_RATE_FACTOR);
756  // }
757  // }
758  }
759 }
760 
OptoRx headers and footers.
Definition: TotemFEDInfo.h:17
const Translation & translation() const
Definition: DetGeomDesc.h:80
plots related to the whole system
static const double DISPLAY_RESOLUTION_FOR_HITS_MM
edm::TimeValue_t timeOfPreviousEvent_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
void setPlane(uint32_t channel)
uint32_t arm() const
Definition: CTPPSDetId.h:51
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setChannel(uint32_t channel)
std::unordered_map< unsigned int, std::unique_ptr< TH2F > > hitDistribution2dMap
std::unordered_map< unsigned int, PlanePlots > planePlots_
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > ctppsGeometryRunToken_
static const double INV_DISPLAY_RESOLUTION_FOR_HITS_MM
uint32_t plane() const
std::shared_ptr< totemds::Cache > globalBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const override
void planeName(std::string &name, NameFlag flag=nFull) const
plots related to one Diamond plane
A track fit through a single RP.
Event setup record containing the real (actual) geometry information.
plots related to one Diamond detector package
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static const double SEC_PER_LUMI_SECTION
static const double DQM_FRACTION_OF_EVENTS
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
edm::EDGetTokenT< std::vector< TotemFEDInfo > > tokenFEDInfo_
static const double HIT_RATE_FACTOR
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:128
static const double SAMPIC_ADC_V
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:78
uint32_t channel() const
Transition
Definition: Transition.h:12
void armName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:92
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:90
unsigned long long TimeValue_t
Definition: Timestamp.h:28
void channelName(std::string &name, NameFlag flag=nFull) const
std::unordered_map< unsigned int, ChannelPlots > channelPlots_
d
Definition: ztail.py:151
edm::EDGetTokenT< edm::DetSetVector< TotemTimingRecHit > > tokenRecHit_
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:30
std::set< unsigned int > planesWithTimeSet
uint32_t rp() const
Definition: CTPPSDetId.h:65
CTPPSDetId armId() const
Definition: CTPPSDetId.h:74
auto const & tracks
cannot be loose
std::unordered_map< unsigned int, double > horizontalShiftOfDiamond_
void analyze(const edm::Event &, const edm::EventSetup &) override
static std::string changePathToSampic(std::string path)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
uint32_t station() const
Definition: CTPPSDetId.h:58
plots related to one Diamond channel
DiamondSampicDQMSource(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:70
LuminosityBlockIndex index() const
std::set< unsigned int > planesWithDigisSet
HLT enums.
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
static const double LHC_CLOCK_PERIOD_NS
edm::EDGetTokenT< edm::DetSetVector< TotemTimingLocalTrack > > tokenTrack_
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
std::unordered_map< unsigned int, unsigned long > hitsCounterMap
edm::EDGetTokenT< edm::DetSetVector< TotemTimingDigi > > tokenDigi_
void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::unordered_map< unsigned int, PotPlots > potPlots_
edm::EDGetTokenT< edm::DetSetVector< TotemRPLocalTrack > > tokenLocalTrack_
Definition: event.py:1
Definition: Run.h:45
Log< level::Error, true > LogProblem
std::unordered_map< unsigned int, SectorPlots > sectorPlots_