CMS 3D CMS Logo

TotemTimingDQMSource.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of CTPPS offline software.
4  * Authors:
5  * Nicola Minafra
6  * Laurent Forthomme
7  *
8  ****************************************************************************/
9 
17 
21 
28 
32 
37 
38 #include <string>
39 
40 //----------------------------------------------------------------------------------------------------
41 
42 namespace totemds {
43  struct Cache {
44  std::unordered_map<unsigned int, std::unique_ptr<TH2F>> hitDistribution2dMap;
45 
46  std::unordered_map<unsigned int, unsigned long> hitsCounterMap;
47  };
48 }
49 
50 class TotemTimingDQMSource : public one::DQMEDAnalyzer<edm::LuminosityBlockCache<totemds::Cache>>
51 {
52 public:
54  ~TotemTimingDQMSource() override;
55 
56 protected:
57  void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
59  const edm::EventSetup &) override;
60  void analyze(const edm::Event &, const edm::EventSetup &) override;
61  std::shared_ptr<totemds::Cache> globalBeginLuminosityBlock(const edm::LuminosityBlock &,
62  const edm::EventSetup &) const override;
63  void globalEndLuminosityBlock(const edm::LuminosityBlock &,
64  const edm::EventSetup &) override;
65  void endRun(const edm::Run &, const edm::EventSetup &) override;
66 
67 private:
68  // Constants
69  static const double SEC_PER_LUMI_SECTION; // Number of seconds per
70  // lumisection: used to compute hit
71  // rates in Hz
72  static const double LHC_CLOCK_PERIOD_NS;
73  static const double DQM_FRACTION_OF_EVENTS; // approximate fraction of events
74  // sent to DQM stream
75  static const double HIT_RATE_FACTOR; // factor to have real rate in Hz
76  static const double DISPLAY_RESOLUTION_FOR_HITS_MM; // Bin width of histograms
77  // showing hits and tracks
78  // (in mm)
80  static const double TOMOGRAPHY_RESOLUTION_MM;
81  static const double SAMPIC_SAMPLING_PERIOD_NS; // ns per HPTDC bin
82  static const double SAMPIC_MAX_NUMBER_OF_SAMPLES;
83  static const double SAMPIC_ADC_V;
84  static const int CTPPS_NUM_OF_ARMS;
85  static const int TOTEM_TIMING_STATION_ID;
86  static const int TOTEM_STATION_210;
87  static const int TOTEM_STATION_220;
88  static const int TOTEM_TIMING_TOP_RP_ID;
89  static const int TOTEM_TIMING_BOT_RP_ID;
90  static const int TOTEM_STRIP_MIN_RP_ID;
91  static const int TOTEM_STRIP_MAX_RP_ID;
92  static const int CTPPS_NEAR_RP_ID;
93  static const int CTPPS_FAR_RP_ID;
94  static const int TOTEM_TIMING_NUM_OF_PLANES;
95  static const int TOTEM_TIMING_NUM_OF_CHANNELS;
96  static const int TOTEM_TIMING_FED_ID_45;
97  static const int TOTEM_TIMING_FED_ID_56;
98  static const float COS_8_DEG;
99  static const float SIN_8_DEG;
100 
104  // edm::EDGetTokenT<edm::DetSetVector<TotemTimingLocalTrack>> tokenTrack_;
106 
109  unsigned int samplesForNoise_;
110  unsigned int verbosity_;
112 
113  float verticalShiftBot_, verticalShiftTop_;
114 
116  struct GlobalPlots
117  {
118  MonitorElement *digiSentPercentage = nullptr;
119 
121  GlobalPlots(DQMStore::IBooker &ibooker);
122  };
123 
125 
127  struct PotPlots
128  {
129  // Digis
130  MonitorElement *activityPerBX = nullptr;
131  MonitorElement *digiDistribution = nullptr;
132  MonitorElement *dataSamplesRaw = nullptr;
133  MonitorElement *baseline = nullptr;
134  MonitorElement *noiseRMS = nullptr;
135 
136  MonitorElement *digiSent = nullptr;
137  MonitorElement *digiAll = nullptr;
138  MonitorElement *digiSentPercentage = nullptr;
139 
140  // RecHits
141  MonitorElement *hitDistribution2d = nullptr;
142  MonitorElement *hitDistribution2dWithTime = nullptr;
143  MonitorElement *hitDistribution2d_lumisection = nullptr;
144 
145  MonitorElement *recHitTime = nullptr;
147  MonitorElement *baselineRMS = nullptr;
148  MonitorElement *tirggerCellTime = nullptr;
149  MonitorElement *meanAmplitude = nullptr;
150  MonitorElement *cellOfMax = nullptr;
151 
152  MonitorElement *hitRate = nullptr;
153 
154  MonitorElement *planesWithDigis = nullptr;
155  MonitorElement *planesWithTime = nullptr;
156 
157  // MonitorElement *trackDistribution = nullptr;
158 
159  MonitorElement *stripTomography210 = nullptr;
160  MonitorElement *stripTomography220 = nullptr;
161 
162  std::set<unsigned int> planesWithDigisSet;
163  std::set<unsigned int> planesWithTimeSet;
164 
165  PotPlots(){};
166  PotPlots(DQMStore::IBooker &ibooker, unsigned int id);
167  };
168 
169  std::unordered_map<unsigned int, PotPlots> potPlots_;
170 
172  struct PlanePlots
173  {
174  MonitorElement *digiDistribution = nullptr;
175 
176  MonitorElement *hitProfile = nullptr;
177  MonitorElement *hitMultiplicity = nullptr;
178  MonitorElement *hitMultiplicityWithTime = nullptr;
179 
181  PlanePlots(DQMStore::IBooker &ibooker, unsigned int id);
182  };
183 
184  std::unordered_map<unsigned int, PlanePlots> planePlots_;
185 
188  {
189  // Digis
190  MonitorElement *activityPerBX = nullptr;
191  MonitorElement *dataSamplesRaw = nullptr;
192  MonitorElement *cellOfMax = nullptr;
193  MonitorElement *maxTimeAfterTrigger = nullptr;
194 
195  // RecHits
196  MonitorElement *tirggerCellTime = nullptr;
197  MonitorElement *recHitTime = nullptr;
199  MonitorElement *noiseSamples = nullptr;
200 
201  MonitorElement *hitTime = nullptr;
202  MonitorElement *hitRate = nullptr;
203 
204  MonitorElement *stripTomography210 = nullptr;
205  MonitorElement *stripTomography220 = nullptr;
206 
208  ChannelPlots(DQMStore::IBooker &ibooker, unsigned int id);
209  };
210 
211  std::unordered_map<unsigned int, ChannelPlots> channelPlots_;
212 };
213 
214 //----------------------------------------------------------------------------------------------------
215 
216 // Values for all constants
217 const double TotemTimingDQMSource::SEC_PER_LUMI_SECTION = 23.31;
218 const double TotemTimingDQMSource::LHC_CLOCK_PERIOD_NS = 24.95;
221  DQM_FRACTION_OF_EVENTS / SEC_PER_LUMI_SECTION;
224  1. / DISPLAY_RESOLUTION_FOR_HITS_MM;
226 const double TotemTimingDQMSource::SAMPIC_SAMPLING_PERIOD_NS = 1. / 7.8e9;
228 const double TotemTimingDQMSource::SAMPIC_ADC_V = 1./256;
245 const float TotemTimingDQMSource::COS_8_DEG = 0.990268;
246 const float TotemTimingDQMSource::SIN_8_DEG = -0.139173;
247 
248 //----------------------------------------------------------------------------------------------------
249 
251 {
252  ibooker.setCurrentFolder("CTPPS/TimingFastSilicon");
253 
254  digiSentPercentage = ibooker.book2D( "sent digis percentage",
255  "sent digis percentage (sampic);board + 0.5 sampic;channel",
256  14, -0.5, 6.5, 16, 0, 16);
257 }
258 
259 //----------------------------------------------------------------------------------------------------
260 
262 {
265  ibooker.setCurrentFolder(path);
266 
268 
269  activityPerBX = ibooker.book1D("activity per BX CMS",
270  title + " Activity per BX;Event.BX",
271  3600, -1.5, 3598. + 0.5);
272 
273  digiDistribution = ibooker.book2D("digi distribution",
274  title + " digi distribution;plane;channel",
275  10, -0.5, 4.5, 12, 0, 12);
276 
277  dataSamplesRaw = ibooker.book1D("raw Samples",
278  title + " Raw Samples; ADC",
279  256, 0, 256);
280 
281  baseline = ibooker.book2D("baseline",
282  title + " baseline (V);plane;channel",
283  10, -0.5, 4.5, 12, 0, 12);
284  noiseRMS = ibooker.book2D( "noise RMS",
285  title+" noise RMS (V);plane;channel",
286  10, -0.5, 4.5, 12, 0, 12);
287 
288  digiSent = ibooker.book2D( "digis sent",
289  title + " digi sent (sampic);board + 0.5 sampic;channel",
290  14, -0.5, 6.5, 16, 0, 16);
291  digiAll = ibooker.book2D( "all digis",
292  title + " all digis(sampic);board + 0.5 sampic;channel",
293  14, -0.5, 6.5, 16, 0, 16);
294  digiSentPercentage = ibooker.book2D( "sent digis percentage",
295  title + " sent digis percentage (sampic);board + 0.5 sampic;channel",
296  14, -0.5, 6.5, 16, 0, 16);
297 
298  hitDistribution2d = ibooker.book2D( "hits in planes",
299  title+" hits in planes;plane number;x (mm)",
300  18, -0.5, 4, 15.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, 0, 15 );
301  hitDistribution2dWithTime = ibooker.book2D( "hits in planes with time",
302  title+" hits in planes with time;plane number;x (mm)",
303  18, -0.5, 4, 15.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, 0, 15 );
304  hitDistribution2d_lumisection = ibooker.book2D( "hits in planes lumisection",
305  title+" hits in planes in the last lumisection;plane number;x (mm)",
306  18, -0.5, 4, 15.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, 0, 15 );
307 
308  recHitTime = ibooker.book1D("recHit time",
309  title + " time in the recHits; t (ns)", 500, -25, 25);
310  amplitude = ibooker.book1D("amplitude",
311  title + " amplitude above baseline; amplitude (V)", 50, 0, 1);
312  tirggerCellTime = ibooker.book1D( "trigger cell time",
313  title + " Trigger Cell Time; t (ns)", 390, -25, 25);
314  baselineRMS = ibooker.book2D("noise RMS",
315  title + " noise RMS (V);plane;channel",
316  10, -0.5, 4.5, 12, 0, 12);
317  meanAmplitude = ibooker.book2D("mean amplitude",
318  title + " Mean Amplitude (V);plane;channel",
319  10, -0.5, 4.5, 12, 0, 12);
320  cellOfMax = ibooker.book2D("cell of max", title + " cell of max (0-23);plane;channel",
321  10, -0.5, 4.5, 12, 0, 12);
322 
323  hitRate = ibooker.book2D("hit rate", title + " hit rate (Hz);plane;channel",
324  10, -0.5, 4.5, 12, 0, 12);
325 
326  planesWithDigis = ibooker.book1D("active planes digis",
327  title + " active planes with digis sent (per event);number of active planes",
328  6, -0.5, 5.5);
329  planesWithTime = ibooker.book1D("active planes with time",
330  title + " active planes with time (per event);number of active planes",
331  6, -0.5, 5.5);
332 
333  // trackDistribution = ibooker.book1D( "tracks", title+" tracks;x (mm)",
334  // 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18 ); //TODO needs tracks
335 
336  stripTomography210 = ibooker.book2D("tomography 210",
337  title + " tomography (only with time) with strips 210 (all planes);x + 50*plane(mm);y (mm)",
338  190/TOMOGRAPHY_RESOLUTION_MM, -20, 170, 25/TOMOGRAPHY_RESOLUTION_MM, 0, 25);
339  stripTomography220 = ibooker.book2D("tomography 220",
340  title + " tomography (only with time) with strips 220 (all planes);x + 50*plane(mm);y (mm)",
341  190/TOMOGRAPHY_RESOLUTION_MM, -20, 170, 25/TOMOGRAPHY_RESOLUTION_MM, 0, 25);
342 }
343 
344 //----------------------------------------------------------------------------------------------------
345 
347 {
350  ibooker.setCurrentFolder(path);
351 
353 
354  digiDistribution = ibooker.book1D("digi distribution",
355  title + " digi distribution;channel",
356  12, 0, 12);
357 
358  hitProfile = ibooker.book1D( "hit distribution with time",
359  title+" hit distribution (with time);y (+ 15 for x>3) (mm)",
360  30.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, 0, 30 );
361 
362  hitMultiplicity = ibooker.book1D("channels per plane",
363  title + " channels per plane; ch per plane",
364  13, -0.5, 12.5);
365 
366  hitMultiplicityWithTime = ibooker.book1D("channels per plane with time",
367  title + " channels per plane with time; ch per plane",
368  13, -0.5, 12.5);
369 }
370 
371 //----------------------------------------------------------------------------------------------------
372 
374 {
377  ibooker.setCurrentFolder(path);
378 
380 
381  activityPerBX = ibooker.book1D("activity per BX",
382  title + " Activity per BX;Event.BX",
383  1000, -1.5, 998. + 0.5);
384  dataSamplesRaw = ibooker.book1D("raw samples",
385  title + " Raw Samples; ADC", 256, 0, 256);
386  cellOfMax = ibooker.book1D("cell of max",
387  title + " cell of max; cell", 24, 0, 24);
388 
389  tirggerCellTime = ibooker.book1D("sampic trigger time",
390  title + " Sampic Trigger Time; t (ns)", 100, -25, 25);
391  recHitTime = ibooker.book1D("recHit Time",
392  title + " recHit Time; t (ns)", 500, -25, 25);
393  amplitude = ibooker.book1D("amplitude",
394  title + " amplitude above baseline; amplitude (V)", 50, 0, 1);
395  noiseSamples = ibooker.book1D( "noise samples",
396  title+" noise samples; V", 50, 0, 1 );
397 
398  hitTime = ibooker.book1D("hit time",
399  title + "hit time;t - t_previous (us)", 100, 0, 10000);
400  hitRate = ibooker.book1D("hit rate",
401  title + "hit rate;rate (Hz)", 100, 0, 10000);
402 
403  stripTomography210 = ibooker.book2D("tomography 210",
404  title + " tomography with strips 210;x (mm);y (mm)",
405  20/TOMOGRAPHY_RESOLUTION_MM, -20, 20,
406  25/TOMOGRAPHY_RESOLUTION_MM, 0, 25);
407  stripTomography220 = ibooker.book2D("tomography 220",
408  title + " tomography with strips 220;x (mm);y (mm)",
409  20/TOMOGRAPHY_RESOLUTION_MM, -20, 20,
410  25/TOMOGRAPHY_RESOLUTION_MM, 0, 25);
411 }
412 
413 //----------------------------------------------------------------------------------------------------
414 
416  : tokenLocalTrack_(consumes<edm::DetSetVector<TotemRPLocalTrack>>(
417  ps.getParameter<edm::InputTag>("tagLocalTrack"))),
418  tokenDigi_(consumes<edm::DetSetVector<TotemTimingDigi>>(
419  ps.getParameter<edm::InputTag>("tagDigi"))),
420  tokenRecHit_(consumes<edm::DetSetVector<TotemTimingRecHit>>(
421  ps.getParameter<edm::InputTag>("tagRecHits"))),
422  // tokenTrack_(consumes<edm::DetSetVector<TotemTimingLocalTrack>>(
423  // ps.getParameter<edm::InputTag>("tagLocalTracks"))),
424  tokenFEDInfo_(consumes<std::vector<TotemFEDInfo>>(
425  ps.getParameter<edm::InputTag>("tagFEDInfo"))),
426  minimumStripAngleForTomography_(
427  ps.getParameter<double>("minimumStripAngleForTomography")),
428  maximumStripAngleForTomography_(
429  ps.getParameter<double>("maximumStripAngleForTomography")),
430  samplesForNoise_(
431  ps.getUntrackedParameter<unsigned int>("samplesForNoise", 5)),
432  verbosity_(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
433  timeOfPreviousEvent_(0) {}
434 
435 //----------------------------------------------------------------------------------------------------
436 
438 
439 //----------------------------------------------------------------------------------------------------
440 
442  const edm::EventSetup &iSetup)
443 {
444  // Get detector shifts from the geometry (if present)
446  iSetup.get<VeryForwardRealGeometryRecord>().get( geometry_ );
447  const CTPPSGeometry *geom = geometry_.product();
450  verticalShiftTop_ = 0;
451  verticalShiftBot_ = 0;
452  {
453  const DetGeomDesc* det_top = geom->getSensorNoThrow( detid_top );
454  if(det_top) {
455  verticalShiftTop_ = det_top->translation().y() + det_top->params().at( 1 );
456  }
457  const DetGeomDesc* det_bot = geom->getSensorNoThrow( detid_bot );
458  if(det_bot)
459  verticalShiftBot_ = det_bot->translation().y() + det_bot->params().at( 1 );
460  }
461 }
462 
463 //----------------------------------------------------------------------------------------------------
464 
466  const edm::Run &,
467  const edm::EventSetup &)
468 {
469  ibooker.cd();
470  ibooker.setCurrentFolder("CTPPS");
471 
472  globalPlot_ = GlobalPlots(ibooker);
473 
474  for (unsigned short arm = 0; arm < CTPPS_NUM_OF_ARMS; ++arm)
475  {
476  for (unsigned short rp = TOTEM_TIMING_TOP_RP_ID;
477  rp <= TOTEM_TIMING_BOT_RP_ID; ++rp)
478  {
480  potPlots_[rpId] = PotPlots(ibooker, rpId);
481  for (unsigned short pl = 0; pl < TOTEM_TIMING_NUM_OF_PLANES; ++pl)
482  {
483  const TotemTimingDetId plId(arm, TOTEM_TIMING_STATION_ID, rp, pl);
484  planePlots_[plId] = PlanePlots(ibooker, plId);
485  for (unsigned short ch = 0; ch < TOTEM_TIMING_NUM_OF_CHANNELS; ++ch)
486  {
487  const TotemTimingDetId chId(arm, TOTEM_TIMING_STATION_ID, rp, pl, ch);
488  channelPlots_[chId] = ChannelPlots(ibooker, chId);
489  }
490  }
491  }
492  }
493 }
494 
495 //----------------------------------------------------------------------------------------------------
496 
497 std::shared_ptr<totemds::Cache>
499  const edm::EventSetup &) const
500 {
501  auto d = std::make_shared<totemds::Cache>();
502  d->hitDistribution2dMap.reserve(potPlots_.size());
503  for ( auto& plot : potPlots_ )
504  d->hitDistribution2dMap[plot.first] = std::unique_ptr<TH2F>(static_cast<TH2F*>(plot.second.hitDistribution2d_lumisection->getTH2F()->Clone()));
505  return d;
506 }
507 
508 //----------------------------------------------------------------------------------------------------
509 
511  const edm::EventSetup &eventSetup)
512 {
513  // get event setup data
515  eventSetup.get<VeryForwardRealGeometryRecord>().get(geometry);
516 
517  // get event data
519  event.getByToken(tokenLocalTrack_, stripTracks);
520 
522  event.getByToken(tokenDigi_, timingDigis);
523 
525  event.getByToken(tokenFEDInfo_, fedInfo);
526 
528  event.getByToken(tokenRecHit_, timingRecHits);
529 
530  // edm::Handle<edm::DetSetVector<TotemTimingLocalTrack>> timingLocalTracks;
531  // event.getByToken(timingLocalTracks, timingLocalTracks);
532 
533  // check validity
534  bool valid = true;
535  valid &= timingDigis.isValid();
536  valid &= fedInfo.isValid();
537 
538  if (!valid)
539  {
540  if (verbosity_)
541  {
542  edm::LogProblem("TotemTimingDQMSource")
543  << "ERROR in TotemTimingDQMSource::analyze > some of the required inputs "
544  "are not valid. Skipping this event.\n"
545  << " timingDigis.isValid = " << timingDigis.isValid() << "\n"
546  << " fedInfo.isValid = " << fedInfo.isValid();
547  }
548 
549  return;
550  }
551 
552  // Using TotemTimingDigi
553  std::set<uint8_t> boardSet;
554  std::unordered_map<unsigned int, unsigned int> channelsPerPlane;
555  std::unordered_map<unsigned int, unsigned int> channelsPerPlaneWithTime;
556 
557  auto lumiCache = luminosityBlockCache(event.getLuminosityBlock().index());
558  for (const auto &digis : *timingDigis)
559  {
560  const TotemTimingDetId detId(digis.detId());
561  TotemTimingDetId detId_pot(digis.detId());
562  detId_pot.setPlane(0);
563  detId_pot.setChannel(0);
564  TotemTimingDetId detId_plane(digis.detId());
565  detId_plane.setChannel(0);
566 
567  for (const auto &digi : digis)
568  {
569  // Pot Plots
570  if (potPlots_.find(detId_pot) != potPlots_.end())
571  {
572  potPlots_[detId_pot].activityPerBX->Fill(event.bunchCrossing());
573 
574  potPlots_[detId_pot].digiDistribution->Fill(detId.plane(), detId.channel());
575 
576  for (auto it = digi.getSamplesBegin(); it != digi.getSamplesEnd(); ++it)
577  potPlots_[detId_pot].dataSamplesRaw->Fill(*it);
578 
579  float boardId = digi.getEventInfo().getHardwareBoardId() +
580  0.5 * digi.getEventInfo().getHardwareSampicId();
581  potPlots_[detId_pot].digiSent->Fill(boardId, digi.getHardwareChannelId());
582  if (boardSet.find(digi.getEventInfo().getHardwareId()) == boardSet.end())
583  {
584  // This guarantees that every board is counted only once
585  boardSet.insert(digi.getEventInfo().getHardwareId());
586  std::bitset<16> chMap(digi.getEventInfo().getChannelMap());
587  for (int i = 0; i < 16; ++i)
588  {
589  if (chMap.test(i))
590  {
591  potPlots_[detId_pot].digiAll->Fill(boardId, i);
592  }
593  }
594  }
595 
596  potPlots_[detId_pot].planesWithDigisSet.insert(detId.plane());
597  }
598 
599  // Plane Plots
600  if (planePlots_.find(detId_plane) != planePlots_.end())
601  {
602  planePlots_[detId_plane].digiDistribution->Fill(detId.channel());
603 
604  if (channelsPerPlane.find(detId_plane) != channelsPerPlane.end())
605  channelsPerPlane[detId_plane]++;
606  else
607  channelsPerPlane[detId_plane] = 0;
608  }
609 
610  // Channel Plots
611  if (channelPlots_.find(detId) != channelPlots_.end()) {
612  channelPlots_[detId].activityPerBX->Fill(event.bunchCrossing());
613 
614  for (auto it = digi.getSamplesBegin(); it != digi.getSamplesEnd(); ++it)
615  channelPlots_[detId].dataSamplesRaw->Fill(*it);
616  for (unsigned short i = 0; i < samplesForNoise_; ++i)
617  channelPlots_[detId].noiseSamples->Fill(SAMPIC_ADC_V *
618  digi.getSampleAt(i));
619 
620  unsigned int cellOfMax =
621  std::max_element(digi.getSamplesBegin(), digi.getSamplesEnd()) -
622  digi.getSamplesBegin();
623  channelPlots_[detId].cellOfMax->Fill((int)cellOfMax);
624 
625  if (timeOfPreviousEvent_ != 0)
626  channelPlots_[detId].hitTime->Fill(
627  1e-3 * LHC_CLOCK_PERIOD_NS *
628  (event.time().value() - timeOfPreviousEvent_));
629  ++(lumiCache->hitsCounterMap[detId]);
630  }
631  }
632  }
633  // End digis
634 
635  for (const auto &rechits : *timingRecHits)
636  {
637  const TotemTimingDetId detId(rechits.detId());
638  TotemTimingDetId detId_pot(rechits.detId());
639  detId_pot.setPlane(0);
640  detId_pot.setChannel(0);
641  TotemTimingDetId detId_plane(rechits.detId());
642  detId_plane.setChannel(0);
643 
644  for (const auto &rechit : rechits)
645  {
646  if (potPlots_.find(detId_pot) != potPlots_.end())
647  {
648  potPlots_[detId_pot].amplitude->Fill(rechit.getAmplitude());
649 
650 
651  TH2F *hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F();
652  TAxis *hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
653  float yCorrected = rechit.getY();
654  yCorrected += (detId.rp()==TOTEM_TIMING_TOP_RP_ID)?
657  float x_shift = detId.plane();
658  x_shift += (rechit.getX()>2)? 0.25 : 0;
659  int startBin = hitHistoTmpYAxis->FindBin( yCorrected - 0.5*rechit.getYWidth() );
660  int numOfBins = rechit.getYWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
661  for ( int i=0; i<numOfBins; ++i)
662  {
663  potPlots_[detId_pot].hitDistribution2d->Fill(
664  detId.plane() + 0.25 * (rechit.getX()>2),
665  hitHistoTmpYAxis->GetBinCenter(startBin+i) );
666  potPlots_[detId_pot].hitDistribution2d_lumisection->Fill(
667  x_shift,
668  hitHistoTmpYAxis->GetBinCenter(startBin+i) );
669  }
670 
671  //All plots with Time
672  if ( rechit.getT() != TotemTimingRecHit::NO_T_AVAILABLE )
673  {
674  for ( int i=0; i<numOfBins; ++i)
675  potPlots_[detId_pot].hitDistribution2dWithTime->Fill(
676  detId.plane() + 0.25 * (rechit.getX()>2),
677  hitHistoTmpYAxis->GetBinCenter(startBin+i) );
678 
679  potPlots_[detId_pot].recHitTime->Fill(rechit.getT());
680  potPlots_[detId_pot].planesWithTimeSet.insert(detId.plane());
681 
682  // Plane Plots
683  if (planePlots_.find(detId_plane) != planePlots_.end())
684  {
685  // Visualization tricks
686  float x_shift = (rechit.getX()>2)? 15 : 0;
687  TH1F *hitProfileHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F();
688  int numOfBins = rechit.getYWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
689  if (detId.rp()==TOTEM_TIMING_TOP_RP_ID)
690  {
691  float yCorrected = rechit.getY()+verticalShiftTop_-0.5*rechit.getYWidth()+x_shift;
692  int startBin = hitProfileHistoTmp->FindBin(yCorrected);
693  for ( int i=0; i<numOfBins; ++i)
694  hitProfileHistoTmp->Fill( hitProfileHistoTmp->GetBinCenter(startBin+i) );
695  }
696  else
697  {
698  float yCorrected = rechit.getY()+verticalShiftBot_+0.5*rechit.getYWidth()+(15-x_shift);
699  int startBin = hitProfileHistoTmp->FindBin(yCorrected);
700  int totBins = hitProfileHistoTmp->GetNbinsX();
701  for ( int i=0; i<numOfBins; ++i)
702  hitProfileHistoTmp->Fill( hitProfileHistoTmp->GetBinCenter(totBins-startBin+i) );
703  }
704 
705  if (channelsPerPlaneWithTime.find(detId_plane) != channelsPerPlaneWithTime.end())
706  channelsPerPlaneWithTime[detId_plane]++;
707  else
708  channelsPerPlaneWithTime[detId_plane] = 0;
709  }
710 
711  if (channelPlots_.find(detId) != channelPlots_.end())
712  {
713  potPlots_[detId_pot].tirggerCellTime->Fill(rechit.getSampicThresholdTime());
714  channelPlots_[detId].tirggerCellTime->Fill(rechit.getSampicThresholdTime());
715  channelPlots_[detId].recHitTime->Fill(rechit.getT());
716  channelPlots_[detId].amplitude->Fill(rechit.getAmplitude());
717  }
718  }
719  }
720  }
721  }
722  // End RecHits
723 
724  // Tomography of timing using strips
725  for (const auto &rechits : *timingRecHits)
726  {
727  const TotemTimingDetId detId(rechits.detId());
728  TotemTimingDetId detId_pot(rechits.detId());
729  detId_pot.setPlane(0);
730  detId_pot.setChannel(0);
731  TotemTimingDetId detId_plane(rechits.detId());
732  detId_plane.setChannel(0);
733 
734  float y_shift=(detId.rp()==TOTEM_TIMING_TOP_RP_ID)?20:5;
735 
736  for (const auto &rechit : rechits)
737  {
738  if (rechit.getT() != TotemTimingRecHit::NO_T_AVAILABLE &&
739  potPlots_.find(detId_pot) != potPlots_.end() &&
740  planePlots_.find(detId_plane) != planePlots_.end() &&
741  channelPlots_.find(detId) != channelPlots_.end() )
742  {
743  if ( stripTracks.isValid() )
744  {
745  for (const auto &ds : *stripTracks) {
746  const CTPPSDetId stripId(ds.detId());
747  // mean position of U and V planes
748  TotemRPDetId plId_V(stripId);
749  plId_V.setPlane(0);
750  TotemRPDetId plId_U(stripId);
751  plId_U.setPlane(1);
752 
753  double rp_x = 0;
754  double rp_y = 0;
755  try
756  {
757  rp_x = (geometry->getSensor(plId_V)->translation().x() +
758  geometry->getSensor(plId_U)->translation().x())/2;
759  rp_y = (geometry->getSensor(plId_V)->translation().y() +
760  geometry->getSensor(plId_U)->translation().y())/2;
761  }
762  catch(const cms::Exception &)
763  {
764  continue;
765  }
766 
767  for (const auto &striplt : ds) {
768  if (striplt.isValid() && stripId.arm() == detId.arm()) {
769  if (striplt.getTx() > maximumStripAngleForTomography_ ||
770  striplt.getTy() > maximumStripAngleForTomography_)
771  continue;
772  if (striplt.getTx() < minimumStripAngleForTomography_ ||
773  striplt.getTy() < minimumStripAngleForTomography_)
774  continue;
775  if (stripId.rp() - detId.rp() ==
777  {
778  double x = striplt.getX0() - rp_x;
779  double y = striplt.getY0() - rp_y;
780  if (stripId.station() == TOTEM_STATION_210)
781  {
782  potPlots_[detId_pot].stripTomography210->Fill(x + detId.plane()*50, y + y_shift);
783  channelPlots_[detId].stripTomography210->Fill(x, y + y_shift);
784  }
785  else if (stripId.station() == TOTEM_STATION_220)
786  {
787  potPlots_[detId_pot].stripTomography220->Fill(x+detId.plane()*50, y + y_shift);
788  channelPlots_[detId].stripTomography220->Fill(x, y + y_shift);
789  }
790  }
791  }
792  }
793  }
794  }
795  }
796  }
797  }
798 
799 
800  for (auto &plt : potPlots_) {
801  plt.second.planesWithDigis->Fill(plt.second.planesWithDigisSet.size());
802  plt.second.planesWithDigisSet.clear();
803  plt.second.planesWithTime->Fill(plt.second.planesWithTimeSet.size());
804  plt.second.planesWithTimeSet.clear();
805  }
806 
807  for (const auto &plt : channelsPerPlane) {
808  planePlots_[plt.first].hitMultiplicity->Fill(plt.second);
809  }
810  for (const auto &plt : channelsPerPlaneWithTime) {
811  planePlots_[plt.first].hitMultiplicityWithTime->Fill(plt.second);
812  }
813 
814  timeOfPreviousEvent_ = event.time().value();
815 }
816 
817 //----------------------------------------------------------------------------------------------------
818 
820  const edm::EventSetup &) {
821  auto lumiCache = luminosityBlockCache(iLumi.index());
822  for ( auto& plot : potPlots_ ) {
823  *(plot.second.hitDistribution2d_lumisection->getTH2F())=*(lumiCache->hitDistribution2dMap[plot.first]);
824  }
825 
827  TH2F *hitHistoGlobalTmp = globalPlot_.digiSentPercentage->getTH2F();
828  for (auto &plot : potPlots_) {
829  TH2F *hitHistoTmp = plot.second.digiSentPercentage->getTH2F();
830  TH2F *histoSent = plot.second.digiSent->getTH2F();
831  TH2F *histoAll = plot.second.digiAll->getTH2F();
832 
833  hitHistoTmp->Divide(histoSent, histoAll);
834  hitHistoTmp->Scale(100);
835  hitHistoGlobalTmp->Add(hitHistoTmp,1);
836 
837  plot.second.baseline->Reset();
838  plot.second.noiseRMS->Reset();
839  plot.second.meanAmplitude->Reset();
840  plot.second.cellOfMax->Reset();
841  plot.second.hitRate->Reset();
842  TotemTimingDetId rpId(plot.first);
843  for (auto &chPlot : channelPlots_) {
844  TotemTimingDetId chId(chPlot.first);
845  if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) {
846  plot.second.baseline->Fill(
847  chId.plane(), chId.channel(),
848  chPlot.second.noiseSamples->getTH1F()->GetMean());
849  plot.second.noiseRMS->Fill(
850  chId.plane(), chId.channel(),
851  chPlot.second.noiseSamples->getTH1F()->GetRMS());
852  plot.second.meanAmplitude->Fill(
853  chId.plane(), chId.channel(),
854  chPlot.second.amplitude->getTH1F()->GetMean());
855  plot.second.cellOfMax->Fill(
856  chId.plane(), chId.channel(),
857  chPlot.second.cellOfMax->getTH1F()->GetMean());
858  auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[chPlot.first];
859  plot.second.hitRate->Fill(
860  chId.plane(), chId.channel(),
861  (double)hitsCounterPerLumisection * HIT_RATE_FACTOR);
862  }
863  }
864  }
865 
866  for (auto &plot : channelPlots_) {
867  auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[plot.first];
868  if (hitsCounterPerLumisection != 0) {
869  plot.second.hitRate->Fill((double)hitsCounterPerLumisection *
871  }
872  }
873 }
874 
875 //----------------------------------------------------------------------------------------------------
876 
878 
879 //----------------------------------------------------------------------------------------------------
880 
static const double INV_DISPLAY_RESOLUTION_FOR_HITS_MM
static const double LHC_CLOCK_PERIOD_NS
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
OptoRx headers and footers.
Definition: TotemFEDInfo.h:17
static const int TOTEM_STRIP_MAX_RP_ID
static const int CTPPS_NEAR_RP_ID
static const int TOTEM_STATION_210
Translation translation() const
Definition: DetGeomDesc.h:66
void channelName(std::string &name, NameFlag flag=nFull) const
void setChannel(uint32_t channel)
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::DetSetVector< TotemTimingDigi > > tokenDigi_
LuminosityBlockIndex index() const
std::unordered_map< unsigned int, PlanePlots > planePlots_
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
static const int CTPPS_NUM_OF_ARMS
const DetGeomDesc * getSensorNoThrow(unsigned int id) const
plots related to one Diamond detector package
edm::EDGetTokenT< edm::DetSetVector< TotemTimingRecHit > > tokenRecHit_
std::unordered_map< unsigned int, ChannelPlots > channelPlots_
std::set< unsigned int > planesWithTimeSet
uint32_t channel() const
int bunchCrossing() const
Definition: EventBase.h:64
void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::DetSetVector< TotemRPLocalTrack > > tokenLocalTrack_
static const double TOMOGRAPHY_RESOLUTION_MM
std::unordered_map< unsigned int, unsigned long > hitsCounterMap
static const double SAMPIC_SAMPLING_PERIOD_NS
plots related to one Diamond channel
static const double SAMPIC_MAX_NUMBER_OF_SAMPLES
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
static const double HIT_RATE_FACTOR
static const int TOTEM_STATION_220
static const int CTPPS_FAR_RP_ID
A track fit through a single RP.
plots related to the whole system
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
Event setup record containing the real (actual) geometry information.
std::unordered_map< unsigned int, std::unique_ptr< TH2F > > hitDistribution2dMap
void endRun(const edm::Run &, const edm::EventSetup &) override
static const double DQM_FRACTION_OF_EVENTS
const DetGeomDesc * getSensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static const double SEC_PER_LUMI_SECTION
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
static const int TOTEM_STRIP_MIN_RP_ID
void setPlane(uint32_t channel)
static const int TOTEM_TIMING_STATION_ID
Geometrical description of a sensor.
Definition: DetGeomDesc.h:35
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:128
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:97
static const int TOTEM_TIMING_TOP_RP_ID
std::unordered_map< unsigned int, PotPlots > potPlots_
uint32_t arm() const
Definition: CTPPSDetId.h:51
void Reset()
reset ME (ie. contents, errors, etc)
bool isValid() const
Definition: HandleBase.h:74
unsigned long long TimeValue_t
Definition: Timestamp.h:28
std::set< unsigned int > planesWithDigisSet
TH2F * getTH2F() const
TotemTimingDQMSource(const edm::ParameterSet &)
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:33
static const float COS_8_DEG
uint32_t plane() const
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
void setPlane(uint32_t det)
Definition: TotemRPDetId.h:48
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
static const double SAMPIC_ADC_V
static const float SIN_8_DEG
static const int TOTEM_TIMING_NUM_OF_PLANES
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
ESHandle< TrackerGeometry > geometry
HLT enums.
T get() const
Definition: EventSetup.h:71
edm::TimeValue_t timeOfPreviousEvent_
edm::EDGetTokenT< std::vector< TotemFEDInfo > > tokenFEDInfo_
std::vector< double > params() const
Definition: DetGeomDesc.h:68
static const int TOTEM_TIMING_FED_ID_45
static const double DISPLAY_RESOLUTION_FOR_HITS_MM
static const int TOTEM_TIMING_BOT_RP_ID
static const int TOTEM_TIMING_FED_ID_56
T const * product() const
Definition: ESHandle.h:86
void planeName(std::string &name, NameFlag flag=nFull) const
std::shared_ptr< totemds::Cache > globalBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const override
TimeValue_t value() const
Definition: Timestamp.h:56
edm::Timestamp time() const
Definition: EventBase.h:60
static const int TOTEM_TIMING_NUM_OF_CHANNELS
plots related to one Diamond plane
Definition: event.py:1
Definition: Run.h:45
uint32_t rp() const
Definition: CTPPSDetId.h:65
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...