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 
385  consumes<edm::DetSetVector<TotemRPLocalTrack>>(ps.getUntrackedParameter<edm::InputTag>("tagLocalTrack"))),
386  tokenDigi_(consumes<edm::DetSetVector<TotemTimingDigi>>(ps.getUntrackedParameter<edm::InputTag>("tagDigi"))),
387  tokenRecHit_(
388  consumes<edm::DetSetVector<TotemTimingRecHit>>(ps.getUntrackedParameter<edm::InputTag>("tagRecHits"))),
389  tokenTrack_(
390  consumes<edm::DetSetVector<TotemTimingLocalTrack>>(ps.getUntrackedParameter<edm::InputTag>("tagTracks"))),
391  tokenFEDInfo_(consumes<std::vector<TotemFEDInfo>>(ps.getUntrackedParameter<edm::InputTag>("tagFEDInfo"))),
393  samplesForNoise_(ps.getUntrackedParameter<unsigned int>("samplesForNoise", 5)),
394  verbosity_(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
395  plotOnline_(ps.getUntrackedParameter<bool>("plotOnline", true)),
396  perLSsaving_(ps.getUntrackedParameter<bool>("perLSsaving", false)),
397  trackCorrelationThreshold_(ps.getUntrackedParameter<unsigned int>("trackCorrelationThreshold", 3)),
399 
400 //----------------------------------------------------------------------------------------------------
401 
403 
404 //----------------------------------------------------------------------------------------------------
405 
407  // Get detector shifts from the geometry (if present)
409  for (auto it = geom->beginSensor(); it != geom->endSensor(); it++) {
410  if (!CTPPSDiamondDetId::check(it->first))
411  continue;
412  const CTPPSDiamondDetId detid(it->first);
413 
414  const DetGeomDesc *det = geom->sensorNoThrow(detid);
415  if (det)
417  else
418  edm::LogProblem("DiamondSampicCalibrationDQMSource") << "ERROR: no descriptor for detId";
419  }
420  //horizontalShiftOfDiamond_=0;//unlock the shift
421 }
422 
423 //----------------------------------------------------------------------------------------------------
424 
426  const edm::Run &,
427  const edm::EventSetup &iSetup) {
428  ibooker.cd();
429  ibooker.setCurrentFolder("CTPPS/DiamondSampic");
430 
432  for (auto it = geom->beginSensor(); it != geom->endSensor(); ++it) {
433  if (!CTPPSDiamondDetId::check(it->first))
434  continue;
435  const CTPPSDiamondDetId detid(it->first);
436 
437  sectorPlots_[detid.armId()] = SectorPlots(ibooker, detid.armId(), plotOnline_);
438 
439  const CTPPSDiamondDetId rpId(detid.arm(), detid.station(), detid.rp());
440  potPlots_[rpId] = PotPlots(ibooker, rpId, plotOnline_);
441 
442  if (plotOnline_) {
443  globalPlot_ = GlobalPlots(ibooker);
444  const CTPPSDiamondDetId plId(detid.arm(), detid.station(), detid.rp(), detid.plane());
445  planePlots_[plId] = PlanePlots(ibooker, plId);
446 
447  const CTPPSDiamondDetId chId(detid.arm(), detid.station(), detid.rp(), detid.plane(), detid.channel());
448  channelPlots_[chId] = ChannelPlots(ibooker, chId);
449  }
450  }
451 }
452 
453 //----------------------------------------------------------------------------------------------------
454 
456  const edm::EventSetup &) const {
457  auto d = std::make_shared<totemds::Cache>();
458  d->hitDistribution2dMap.reserve(potPlots_.size());
459  if (!perLSsaving_ && plotOnline_)
460  for (auto &plot : potPlots_)
461  d->hitDistribution2dMap[plot.first] =
462  std::unique_ptr<TH2F>(static_cast<TH2F *>(plot.second.hitDistribution2d_lumisection->getTH2F()->Clone()));
463  return d;
464 }
465 
466 //----------------------------------------------------------------------------------------------------
467 
469  // get event data
471  event.getByToken(tokenDigi_, timingDigis);
472 
474  event.getByToken(tokenFEDInfo_, fedInfo);
475 
477  event.getByToken(tokenRecHit_, timingRecHits);
478 
480  event.getByToken(tokenTrack_, timingLocalTracks);
481 
482  // check validity
483  bool valid = true;
484  valid &= timingDigis.isValid();
485  //valid &= fedInfo.isValid();
486 
487  if (!valid) {
488  if (verbosity_) {
489  edm::LogProblem("DiamondSampicDQMSource")
490  << "ERROR in DiamondSampicDQMSource::analyze > some of the required inputs "
491  "are not valid. Skipping this event.\n"
492  << " timingDigis.isValid = " << timingDigis.isValid() << "\n"
493  << " fedInfo.isValid = " << fedInfo.isValid();
494  }
495 
496  return;
497  }
498 
499  // Using TotemTimingDigi
500  std::set<uint8_t> boardSet;
501  std::unordered_map<unsigned int, unsigned int> channelsPerPlane;
502  std::unordered_map<unsigned int, unsigned int> channelsPerPlaneWithTime;
503 
504  auto lumiCache = luminosityBlockCache(event.getLuminosityBlock().index());
505 
506  for (const auto &digis : *timingDigis) {
507  const CTPPSDiamondDetId detId(digis.detId());
508  CTPPSDiamondDetId detId_pot(digis.detId());
509  detId_pot.setPlane(0);
510  detId_pot.setChannel(0);
511  CTPPSDiamondDetId detId_plane(digis.detId());
512  detId_plane.setChannel(0);
513 
514  for (const auto &digi : digis) {
515  // Pot Plots
516  if (potPlots_.find(detId_pot) != potPlots_.end()) {
517  potPlots_[detId_pot].digiDistribution->Fill(detId.plane(), detId.channel());
518 
519  if (plotOnline_) {
520  potPlots_[detId_pot].activityPerBX->Fill(event.bunchCrossing());
521 
522  for (auto it = digi.samplesBegin(); it != digi.samplesEnd(); ++it) {
523  potPlots_[detId_pot].dataSamplesRaw->Fill(*it);
524  }
525 
526  float boardId = digi.eventInfo().hardwareBoardId() + 0.5 * digi.eventInfo().hardwareSampicId();
527  potPlots_[detId_pot].digiSent->Fill(boardId, digi.hardwareChannelId());
528 
529  if (boardSet.find(digi.eventInfo().hardwareId()) == boardSet.end()) {
530  // This guarantees that every board is counted only once
531  boardSet.insert(digi.eventInfo().hardwareId());
532  std::bitset<16> chMap(digi.eventInfo().channelMap());
533  for (int i = 0; i < 16; ++i) {
534  if (chMap.test(i)) {
535  potPlots_[detId_pot].digiAll->Fill(boardId, i);
536  }
537  }
538  }
539 
540  potPlots_[detId_pot].planesWithDigisSet.insert(detId.plane());
541  }
542  }
543 
544  if (plotOnline_) {
545  // Plane Plots
546  if (planePlots_.find(detId_plane) != planePlots_.end()) {
547  planePlots_[detId_plane].digiDistribution->Fill(detId.channel());
548 
549  if (channelsPerPlane.find(detId_plane) != channelsPerPlane.end())
550  channelsPerPlane[detId_plane]++;
551  else
552  //if it's the first channel, create new map element with the value of 1
553  channelsPerPlane[detId_plane] = 1;
554  }
555 
556  // Channel Plots
557  if (channelPlots_.find(detId) != channelPlots_.end()) {
558  channelPlots_[detId].activityPerBX->Fill(event.bunchCrossing());
559 
560  for (auto it = digi.samplesBegin(); it != digi.samplesEnd(); ++it)
561  channelPlots_[detId].dataSamplesRaw->Fill(*it);
562  for (unsigned short i = 0; i < samplesForNoise_; ++i)
563  channelPlots_[detId].noiseSamples->Fill(SAMPIC_ADC_V * digi.sampleAt(i));
564 
565  unsigned int cellOfMax = std::max_element(digi.samplesBegin(), digi.samplesEnd()) - digi.samplesBegin();
566  channelPlots_[detId].cellOfMax->Fill((int)cellOfMax);
567 
568  // if (timeOfPreviousEvent_ != 0)
569  // channelPlots_[detId].hitTime->Fill(1e-3 * LHC_CLOCK_PERIOD_NS *
570  // (event.time().value() - timeOfPreviousEvent_));
571  ++(lumiCache->hitsCounterMap[detId]);
572  }
573  }
574  }
575  }
576  // End digis
577 
578  for (const auto &rechits : *timingRecHits) {
579  const CTPPSDiamondDetId detId(rechits.detId());
580  CTPPSDiamondDetId detId_pot(rechits.detId());
581  detId_pot.setPlane(0);
582  detId_pot.setChannel(0);
583  CTPPSDiamondDetId detId_plane(rechits.detId());
584  detId_plane.setChannel(0);
585 
586  for (const auto &rechit : rechits) {
587  if (potPlots_.find(detId_pot) != potPlots_.end()) {
588  float UFSDShift = 0.0;
589  if (rechit.yWidth() < 3)
590  UFSDShift = 0.5;
591 
592  TH2F *hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F();
593  TAxis *hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
594  int startBin =
595  hitHistoTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] - 0.5 * rechit.xWidth());
596  const int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
597  for (int i = 0; i < numOfBins; ++i) {
598  potPlots_[detId_pot].hitDistribution2d->Fill(detId.plane() + UFSDShift,
599  hitHistoTmpYAxis->GetBinCenter(startBin + i));
600  if (!perLSsaving_ && plotOnline_)
601  potPlots_[detId_pot].hitDistribution2d_lumisection->Fill(detId.plane() + UFSDShift,
602  hitHistoTmpYAxis->GetBinCenter(startBin + i));
603  }
604 
605  //All plots with Time
606  if (rechit.time() != TotemTimingRecHit::NO_T_AVAILABLE) {
607  for (int i = 0; i < numOfBins; ++i)
608  potPlots_[detId_pot].hitDistribution2dWithTime->Fill(detId.plane() + UFSDShift,
609  hitHistoTmpYAxis->GetBinCenter(startBin + i));
610 
611  potPlots_[detId_pot].recHitTime->Fill(rechit.time());
612  if (plotOnline_) {
613  potPlots_[detId_pot].amplitude->Fill(rechit.amplitude());
614  potPlots_[detId_pot].planesWithTimeSet.insert(detId.plane());
615 
616  // Plane Plots
617  if (planePlots_.find(detId_plane) != planePlots_.end()) {
618  TH1F *hitProfileHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F();
619  const int startBin = hitProfileHistoTmp->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] -
620  0.5 * rechit.xWidth());
621  for (int i = 0; i < numOfBins; ++i)
622  hitProfileHistoTmp->Fill(hitProfileHistoTmp->GetBinCenter(startBin + i));
623 
624  if (channelsPerPlaneWithTime.find(detId_plane) != channelsPerPlaneWithTime.end())
625  channelsPerPlaneWithTime[detId_plane]++;
626  else
627  //if it's the first channel, create new map element with the value of 1
628  channelsPerPlaneWithTime[detId_plane] = 1;
629  }
630 
631  if (channelPlots_.find(detId) != channelPlots_.end()) {
632  potPlots_[detId_pot].triggerCellTime->Fill(rechit.sampicThresholdTime());
633  channelPlots_[detId].triggerCellTime->Fill(rechit.sampicThresholdTime());
634  channelPlots_[detId].recHitTime->Fill(rechit.time());
635  channelPlots_[detId].amplitude->Fill(rechit.amplitude());
636  }
637  }
638  }
639  }
640  }
641  }
642  // End RecHits
643 
644  // Using CTPPSDiamondLocalTrack
645  for (const auto &tracks : *timingLocalTracks) {
646  CTPPSDiamondDetId detId_pot(tracks.detId());
647  detId_pot.setPlane(0);
648  detId_pot.setChannel(0);
649  const CTPPSDiamondDetId detId_near(tracks.detId());
650 
651  for (const auto &track : tracks) {
652  if (!track.isValid())
653  continue;
654  if (potPlots_.find(detId_pot) == potPlots_.end())
655  continue;
656 
657  TH1F *trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution->getTH1F();
658  const int startBin =
659  trackHistoInTimeTmp->FindBin(track.x0() - horizontalShiftOfDiamond_[detId_pot] - track.x0Sigma());
660  const int numOfBins = 2 * track.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
661  for (int i = 0; i < numOfBins; ++i) {
662  trackHistoInTimeTmp->Fill(trackHistoInTimeTmp->GetBinCenter(startBin + i));
663  }
664 
665  //this plot was made with 2 stations per arm in mind
666  for (const auto &tracks_far : *timingLocalTracks) {
667  CTPPSDiamondDetId detId_far(tracks_far.detId());
668  detId_far.setPlane(0);
669  detId_far.setChannel(0);
670  if (detId_near.arm() != detId_far.arm() || detId_near.station() == detId_far.station())
671  continue;
672  for (const auto &track_far : tracks_far) {
673  if (!track.isValid())
674  continue;
675  if (sectorPlots_.find(detId_far.armId()) == sectorPlots_.end())
676  continue;
677  TH2F *trackHistoTmp = sectorPlots_[detId_far.armId()].trackCorrelation->getTH2F();
678  TAxis *trackHistoTmpXAxis = trackHistoTmp->GetXaxis();
679  TAxis *trackHistoTmpYAxis = trackHistoTmp->GetYaxis();
680  const int startBin_far =
681  trackHistoTmpYAxis->FindBin(track_far.x0() - horizontalShiftOfDiamond_[detId_far] - track_far.x0Sigma());
682  const int numOfBins_far = 2 * track_far.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
683  for (int i = 0; i < numOfBins; ++i) {
684  for (int y = 0; y < numOfBins_far; ++y) {
685  trackHistoTmp->Fill(trackHistoTmpXAxis->GetBinCenter(startBin + i),
686  trackHistoTmpYAxis->GetBinCenter(startBin_far + y));
687  if (tracks.size() < 3 && tracks_far.size() < trackCorrelationThreshold_)
688  sectorPlots_[detId_far.armId()].trackCorrelationLowMultiplicity->Fill(
689  trackHistoTmpXAxis->GetBinCenter(startBin + i), trackHistoTmpYAxis->GetBinCenter(startBin_far + y));
690  }
691  }
692  }
693  }
694  }
695  }
696  if (plotOnline_) {
697  for (auto &plt : potPlots_) {
698  plt.second.planesWithDigis->Fill(plt.second.planesWithDigisSet.size());
699  plt.second.planesWithDigisSet.clear();
700  plt.second.planesWithTime->Fill(plt.second.planesWithTimeSet.size());
701  plt.second.planesWithTimeSet.clear();
702  }
703 
704  for (const auto &plt : channelsPerPlane)
705  planePlots_[plt.first].hitMultiplicity->Fill(plt.second);
706 
707  for (const auto &plt : channelsPerPlaneWithTime)
708  planePlots_[plt.first].hitMultiplicityWithTime->Fill(plt.second);
709  }
710  timeOfPreviousEvent_ = event.time().value();
711 }
712 
713 //----------------------------------------------------------------------------------------------------
714 
716  auto lumiCache = luminosityBlockCache(iLumi.index());
717  if (!perLSsaving_ && plotOnline_) {
718  for (auto &plot : potPlots_)
719  *(plot.second.hitDistribution2d_lumisection->getTH2F()) = *(lumiCache->hitDistribution2dMap[plot.first]);
721  for (auto &plot : sectorPlots_)
722  plot.second.digiSentPercentage->Reset();
723  TH2F *hitHistoGlobalTmp = globalPlot_.digiSentPercentage->getTH2F();
724  for (auto &plot : potPlots_) {
725  TH2F *hitHistoTmp = plot.second.digiSentPercentage->getTH2F();
726  TH2F *histoSent = plot.second.digiSent->getTH2F();
727  TH2F *histoAll = plot.second.digiAll->getTH2F();
728 
729  hitHistoTmp->Divide(histoSent, histoAll);
730  hitHistoTmp->Scale(100);
731  hitHistoGlobalTmp->Add(hitHistoTmp, 1);
732 
733  plot.second.baseline->Reset();
734  plot.second.noiseRMS->Reset();
735  plot.second.meanAmplitude->Reset();
736  plot.second.cellOfMax->Reset();
737  //plot.second.hitRate->Reset();
738  CTPPSDiamondDetId rpId(plot.first);
739  TH2F *hitHistoSectorTmp = sectorPlots_[rpId.armId()].digiSentPercentage->getTH2F();
740  hitHistoSectorTmp->Add(hitHistoTmp, 1);
741 
742  for (auto &chPlot : channelPlots_) {
743  CTPPSDiamondDetId chId(chPlot.first);
744  if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) {
745  plot.second.baseline->Fill(chId.plane(), chId.channel(), chPlot.second.noiseSamples->getTH1F()->GetMean());
746  plot.second.noiseRMS->Fill(chId.plane(), chId.channel(), chPlot.second.noiseSamples->getTH1F()->GetRMS());
747  plot.second.meanAmplitude->Fill(chId.plane(), chId.channel(), chPlot.second.amplitude->getTH1F()->GetMean());
748  plot.second.cellOfMax->Fill(chId.plane(), chId.channel(), chPlot.second.cellOfMax->getTH1F()->GetMean());
749  //auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[chPlot.first];
750  //plot.second.hitRate->Fill(chId.plane(), chId.channel(), (double)hitsCounterPerLumisection * HIT_RATE_FACTOR);
751  }
752  }
753  }
754 
755  // for (auto &plot : channelPlots_) {
756  // auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[plot.first];
757  // if (hitsCounterPerLumisection != 0) {
758  // plot.second.hitRate->Fill((double)hitsCounterPerLumisection * HIT_RATE_FACTOR);
759  // }
760  // }
761  }
762 }
763 
OptoRx headers and footers.
Definition: TotemFEDInfo.h:17
const Translation & translation() const
Definition: DetGeomDesc.h:80
plots related to the whole system
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
static const double DISPLAY_RESOLUTION_FOR_HITS_MM
edm::TimeValue_t timeOfPreviousEvent_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void setPlane(uint32_t channel)
uint32_t arm() const
Definition: CTPPSDetId.h:57
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
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:134
static const double SAMPIC_ADC_V
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:84
uint32_t channel() const
Transition
Definition: Transition.h:12
void armName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:98
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:90
unsigned long long TimeValue_t
Definition: Timestamp.h:21
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:71
CTPPSDetId armId() const
Definition: CTPPSDetId.h:80
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:221
uint32_t station() const
Definition: CTPPSDetId.h:64
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_