CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
220 DiamondSampicDQMSource::SectorPlots::SectorPlots(DQMStore::IBooker &ibooker, unsigned int id, bool plotOnline) {
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 
257 DiamondSampicDQMSource::PotPlots::PotPlots(DQMStore::IBooker &ibooker, unsigned int id, bool plotOnline) {
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  channelsPerPlane[detId_plane] = 0;
550  }
551 
552  // Channel Plots
553  if (channelPlots_.find(detId) != channelPlots_.end()) {
554  channelPlots_[detId].activityPerBX->Fill(event.bunchCrossing());
555 
556  for (auto it = digi.samplesBegin(); it != digi.samplesEnd(); ++it)
557  channelPlots_[detId].dataSamplesRaw->Fill(*it);
558  for (unsigned short i = 0; i < samplesForNoise_; ++i)
559  channelPlots_[detId].noiseSamples->Fill(SAMPIC_ADC_V * digi.sampleAt(i));
560 
561  unsigned int cellOfMax = std::max_element(digi.samplesBegin(), digi.samplesEnd()) - digi.samplesBegin();
562  channelPlots_[detId].cellOfMax->Fill((int)cellOfMax);
563 
564  // if (timeOfPreviousEvent_ != 0)
565  // channelPlots_[detId].hitTime->Fill(1e-3 * LHC_CLOCK_PERIOD_NS *
566  // (event.time().value() - timeOfPreviousEvent_));
567  ++(lumiCache->hitsCounterMap[detId]);
568  }
569  }
570  }
571  }
572  // End digis
573 
574  for (const auto &rechits : *timingRecHits) {
575  const CTPPSDiamondDetId detId(rechits.detId());
576  CTPPSDiamondDetId detId_pot(rechits.detId());
577  detId_pot.setPlane(0);
578  detId_pot.setChannel(0);
579  CTPPSDiamondDetId detId_plane(rechits.detId());
580  detId_plane.setChannel(0);
581 
582  for (const auto &rechit : rechits) {
583  if (potPlots_.find(detId_pot) != potPlots_.end()) {
584  float UFSDShift = 0.0;
585  if (rechit.yWidth() < 3)
586  UFSDShift = 0.5;
587 
588  TH2F *hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F();
589  TAxis *hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
590  int startBin =
591  hitHistoTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] - 0.5 * rechit.xWidth());
592  const int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
593  for (int i = 0; i < numOfBins; ++i) {
594  potPlots_[detId_pot].hitDistribution2d->Fill(detId.plane() + UFSDShift,
595  hitHistoTmpYAxis->GetBinCenter(startBin + i));
596  if (!perLSsaving_ && plotOnline_)
597  potPlots_[detId_pot].hitDistribution2d_lumisection->Fill(detId.plane() + UFSDShift,
598  hitHistoTmpYAxis->GetBinCenter(startBin + i));
599  }
600 
601  //All plots with Time
602  if (rechit.time() != TotemTimingRecHit::NO_T_AVAILABLE) {
603  for (int i = 0; i < numOfBins; ++i)
604  potPlots_[detId_pot].hitDistribution2dWithTime->Fill(detId.plane() + UFSDShift,
605  hitHistoTmpYAxis->GetBinCenter(startBin + i));
606 
607  potPlots_[detId_pot].recHitTime->Fill(rechit.time());
608  if (plotOnline_) {
609  potPlots_[detId_pot].amplitude->Fill(rechit.amplitude());
610  potPlots_[detId_pot].planesWithTimeSet.insert(detId.plane());
611 
612  // Plane Plots
613  if (planePlots_.find(detId_plane) != planePlots_.end()) {
614  TH1F *hitProfileHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F();
615  const int startBin = hitProfileHistoTmp->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] -
616  0.5 * rechit.xWidth());
617  for (int i = 0; i < numOfBins; ++i)
618  hitProfileHistoTmp->Fill(hitProfileHistoTmp->GetBinCenter(startBin + i));
619 
620  if (channelsPerPlaneWithTime.find(detId_plane) != channelsPerPlaneWithTime.end())
621  channelsPerPlaneWithTime[detId_plane]++;
622  else
623  channelsPerPlaneWithTime[detId_plane] = 0;
624  }
625 
626  if (channelPlots_.find(detId) != channelPlots_.end()) {
627  potPlots_[detId_pot].triggerCellTime->Fill(rechit.sampicThresholdTime());
628  channelPlots_[detId].triggerCellTime->Fill(rechit.sampicThresholdTime());
629  channelPlots_[detId].recHitTime->Fill(rechit.time());
630  channelPlots_[detId].amplitude->Fill(rechit.amplitude());
631  }
632  }
633  }
634  }
635  }
636  }
637  // End RecHits
638 
639  // Using CTPPSDiamondLocalTrack
640  for (const auto &tracks : *timingLocalTracks) {
641  CTPPSDiamondDetId detId_pot(tracks.detId());
642  detId_pot.setPlane(0);
643  detId_pot.setChannel(0);
644  const CTPPSDiamondDetId detId_near(tracks.detId());
645 
646  for (const auto &track : tracks) {
647  if (!track.isValid())
648  continue;
649  if (potPlots_.find(detId_pot) == potPlots_.end())
650  continue;
651 
652  TH1F *trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution->getTH1F();
653  const int startBin =
654  trackHistoInTimeTmp->FindBin(track.x0() - horizontalShiftOfDiamond_[detId_pot] - track.x0Sigma());
655  const int numOfBins = 2 * track.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
656  for (int i = 0; i < numOfBins; ++i) {
657  trackHistoInTimeTmp->Fill(trackHistoInTimeTmp->GetBinCenter(startBin + i));
658  }
659 
660  //this plot was made with 2 stations per arm in mind
661  for (const auto &tracks_far : *timingLocalTracks) {
662  CTPPSDiamondDetId detId_far(tracks_far.detId());
663  detId_far.setPlane(0);
664  detId_far.setChannel(0);
665  if (detId_near.arm() != detId_far.arm() || detId_near.station() == detId_far.station())
666  continue;
667  for (const auto &track_far : tracks_far) {
668  if (!track.isValid())
669  continue;
670  if (sectorPlots_.find(detId_far.armId()) == sectorPlots_.end())
671  continue;
672  TH2F *trackHistoTmp = sectorPlots_[detId_far.armId()].trackCorrelation->getTH2F();
673  TAxis *trackHistoTmpXAxis = trackHistoTmp->GetXaxis();
674  TAxis *trackHistoTmpYAxis = trackHistoTmp->GetYaxis();
675  const int startBin_far =
676  trackHistoTmpYAxis->FindBin(track_far.x0() - horizontalShiftOfDiamond_[detId_far] - track_far.x0Sigma());
677  const int numOfBins_far = 2 * track_far.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
678  for (int i = 0; i < numOfBins; ++i) {
679  for (int y = 0; y < numOfBins_far; ++y) {
680  trackHistoTmp->Fill(trackHistoTmpXAxis->GetBinCenter(startBin + i),
681  trackHistoTmpYAxis->GetBinCenter(startBin_far + y));
682  if (tracks.size() < 3 && tracks_far.size() < trackCorrelationThreshold_)
683  sectorPlots_[detId_far.armId()].trackCorrelationLowMultiplicity->Fill(
684  trackHistoTmpXAxis->GetBinCenter(startBin + i), trackHistoTmpYAxis->GetBinCenter(startBin_far + y));
685  }
686  }
687  }
688  }
689  }
690  }
691  if (plotOnline_) {
692  for (auto &plt : potPlots_) {
693  plt.second.planesWithDigis->Fill(plt.second.planesWithDigisSet.size());
694  plt.second.planesWithDigisSet.clear();
695  plt.second.planesWithTime->Fill(plt.second.planesWithTimeSet.size());
696  plt.second.planesWithTimeSet.clear();
697  }
698 
699  for (const auto &plt : channelsPerPlane)
700  planePlots_[plt.first].hitMultiplicity->Fill(plt.second);
701 
702  for (const auto &plt : channelsPerPlaneWithTime)
703  planePlots_[plt.first].hitMultiplicityWithTime->Fill(plt.second);
704  }
705  timeOfPreviousEvent_ = event.time().value();
706 }
707 
708 //----------------------------------------------------------------------------------------------------
709 
711  auto lumiCache = luminosityBlockCache(iLumi.index());
712  if (!perLSsaving_ && plotOnline_) {
713  for (auto &plot : potPlots_)
714  *(plot.second.hitDistribution2d_lumisection->getTH2F()) = *(lumiCache->hitDistribution2dMap[plot.first]);
716  for (auto &plot : sectorPlots_)
717  plot.second.digiSentPercentage->Reset();
718  TH2F *hitHistoGlobalTmp = globalPlot_.digiSentPercentage->getTH2F();
719  for (auto &plot : potPlots_) {
720  TH2F *hitHistoTmp = plot.second.digiSentPercentage->getTH2F();
721  TH2F *histoSent = plot.second.digiSent->getTH2F();
722  TH2F *histoAll = plot.second.digiAll->getTH2F();
723 
724  hitHistoTmp->Divide(histoSent, histoAll);
725  hitHistoTmp->Scale(100);
726  hitHistoGlobalTmp->Add(hitHistoTmp, 1);
727 
728  plot.second.baseline->Reset();
729  plot.second.noiseRMS->Reset();
730  plot.second.meanAmplitude->Reset();
731  plot.second.cellOfMax->Reset();
732  //plot.second.hitRate->Reset();
733  CTPPSDiamondDetId rpId(plot.first);
734  TH2F *hitHistoSectorTmp = sectorPlots_[rpId.armId()].digiSentPercentage->getTH2F();
735  hitHistoSectorTmp->Add(hitHistoTmp, 1);
736 
737  for (auto &chPlot : channelPlots_) {
738  CTPPSDiamondDetId chId(chPlot.first);
739  if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) {
740  plot.second.baseline->Fill(chId.plane(), chId.channel(), chPlot.second.noiseSamples->getTH1F()->GetMean());
741  plot.second.noiseRMS->Fill(chId.plane(), chId.channel(), chPlot.second.noiseSamples->getTH1F()->GetRMS());
742  plot.second.meanAmplitude->Fill(chId.plane(), chId.channel(), chPlot.second.amplitude->getTH1F()->GetMean());
743  plot.second.cellOfMax->Fill(chId.plane(), chId.channel(), chPlot.second.cellOfMax->getTH1F()->GetMean());
744  //auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[chPlot.first];
745  //plot.second.hitRate->Fill(chId.plane(), chId.channel(), (double)hitsCounterPerLumisection * HIT_RATE_FACTOR);
746  }
747  }
748  }
749 
750  // for (auto &plot : channelPlots_) {
751  // auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[plot.first];
752  // if (hitsCounterPerLumisection != 0) {
753  // plot.second.hitRate->Fill((double)hitsCounterPerLumisection * HIT_RATE_FACTOR);
754  // }
755  // }
756  }
757 }
758 
OptoRx headers and footers.
Definition: TotemFEDInfo.h:17
uint32_t station() const
Definition: CTPPSDetId.h:58
plots related to the whole system
static const double DISPLAY_RESOLUTION_FOR_HITS_MM
LuminosityBlockIndex index() const
edm::TimeValue_t timeOfPreviousEvent_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
const Translation & translation() const
Definition: DetGeomDesc.h:80
void setPlane(uint32_t channel)
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
void channelName(std::string &name, NameFlag flag=nFull) const
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:90
std::unordered_map< unsigned int, PlanePlots > planePlots_
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > ctppsGeometryRunToken_
int bunchCrossing() const
Definition: EventBase.h:64
static const double INV_DISPLAY_RESOLUTION_FOR_HITS_MM
std::shared_ptr< totemds::Cache > globalBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const override
auto const & tracks
cannot be loose
mapType::const_iterator beginSensor() const
begin iterator over sensors
Definition: CTPPSGeometry.h:67
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
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:78
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static const double SEC_PER_LUMI_SECTION
bool getData(T &iHolder) const
Definition: EventSetup.h:128
static const double DQM_FRACTION_OF_EVENTS
tuple d
Definition: ztail.py:151
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
const DetGeomDesc * sensorNoThrow(unsigned int id) const noexcept
edm::EDGetTokenT< std::vector< TotemFEDInfo > > tokenFEDInfo_
static const double HIT_RATE_FACTOR
static const double SAMPIC_ADC_V
def plot
Definition: bigModule.py:18
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:128
Transition
Definition: Transition.h:12
uint32_t plane() const
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:100
uint32_t arm() const
Definition: CTPPSDetId.h:51
bool isValid() const
Definition: HandleBase.h:70
void armName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:92
unsigned long long TimeValue_t
Definition: Timestamp.h:28
std::unordered_map< unsigned int, ChannelPlots > channelPlots_
CTPPSDetId armId() const
Definition: CTPPSDetId.h:74
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 channel() const
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:177
mapType::const_iterator endSensor() const
end iterator over sensors
Definition: CTPPSGeometry.h:69
void planeName(std::string &name, NameFlag flag=nFull) const
plots related to one Diamond channel
DiamondSampicDQMSource(const edm::ParameterSet &)
std::set< unsigned int > planesWithDigisSet
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: Run.h:45
Log< level::Error, true > LogProblem
std::unordered_map< unsigned int, SectorPlots > sectorPlots_
uint32_t rp() const
Definition: CTPPSDetId.h:65