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