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  try
445  {
446  const DetGeomDesc* det_top = geom->getSensor( detid_top );
447  verticalShiftTop_ = det_top->translation().y() + det_top->params().at( 1 );
448  const DetGeomDesc* det_bot = geom->getSensor( detid_bot );
449  verticalShiftBot_ = det_bot->translation().y() + det_bot->params().at( 1 );
450  } catch (const cms::Exception &) {
451  verticalShiftTop_ = 0;
452  verticalShiftBot_ = 0;
453  }
454 }
455 
456 //----------------------------------------------------------------------------------------------------
457 
459  const edm::Run &,
460  const edm::EventSetup &)
461 {
462  ibooker.cd();
463  ibooker.setCurrentFolder("CTPPS");
464 
465  globalPlot_ = GlobalPlots(ibooker);
466 
467  for (unsigned short arm = 0; arm < CTPPS_NUM_OF_ARMS; ++arm)
468  {
469  for (unsigned short rp = TOTEM_TIMING_TOP_RP_ID;
470  rp <= TOTEM_TIMING_BOT_RP_ID; ++rp)
471  {
472  const TotemTimingDetId rpId(arm, TOTEM_TIMING_STATION_ID, rp);
473  potPlots_[rpId] = PotPlots(ibooker, rpId);
474  for (unsigned short pl = 0; pl < TOTEM_TIMING_NUM_OF_PLANES; ++pl)
475  {
476  const TotemTimingDetId plId(arm, TOTEM_TIMING_STATION_ID, rp, pl);
477  planePlots_[plId] = PlanePlots(ibooker, plId);
478  for (unsigned short ch = 0; ch < TOTEM_TIMING_NUM_OF_CHANNELS; ++ch)
479  {
480  const TotemTimingDetId chId(arm, TOTEM_TIMING_STATION_ID, rp, pl, ch);
481  channelPlots_[chId] = ChannelPlots(ibooker, chId);
482  }
483  }
484  }
485  }
486 }
487 
488 //----------------------------------------------------------------------------------------------------
489 
491  const edm::EventSetup &)
492 {
493  for ( auto& plot : potPlots_ )
494  plot.second.hitDistribution2d_lumisection->Reset();
495 }
496 
497 //----------------------------------------------------------------------------------------------------
498 
500  const edm::EventSetup &eventSetup)
501 {
502  // get event setup data
504  eventSetup.get<VeryForwardRealGeometryRecord>().get(geometry);
505 
506  // get event data
508  event.getByToken(tokenLocalTrack_, stripTracks);
509 
511  event.getByToken(tokenDigi_, timingDigis);
512 
514  event.getByToken(tokenFEDInfo_, fedInfo);
515 
517  event.getByToken(tokenRecHit_, timingRecHits);
518 
519  // edm::Handle<edm::DetSetVector<TotemTimingLocalTrack>> timingLocalTracks;
520  // event.getByToken(timingLocalTracks, timingLocalTracks);
521 
522  // check validity
523  bool valid = true;
524  valid &= timingDigis.isValid();
525  valid &= fedInfo.isValid();
526 
527  if (!valid)
528  {
529  if (verbosity_)
530  {
531  edm::LogProblem("TotemTimingDQMSource")
532  << "ERROR in TotemTimingDQMSource::analyze > some of the required inputs "
533  "are not valid. Skipping this event.\n"
534  << " timingDigis.isValid = " << timingDigis.isValid() << "\n"
535  << " fedInfo.isValid = " << fedInfo.isValid();
536  }
537 
538  return;
539  }
540 
541  // Using TotemTimingDigi
542  std::set<uint8_t> boardSet;
543  std::unordered_map<unsigned int, unsigned int> channelsPerPlane;
544  std::unordered_map<unsigned int, unsigned int> channelsPerPlaneWithTime;
545 
546  for (const auto &digis : *timingDigis)
547  {
548  const TotemTimingDetId detId(digis.detId());
549  TotemTimingDetId detId_pot(digis.detId());
550  detId_pot.setPlane(0);
551  detId_pot.setChannel(0);
552  TotemTimingDetId detId_plane(digis.detId());
553  detId_plane.setChannel(0);
554 
555  for (const auto &digi : digis)
556  {
557  // Pot Plots
558  if (potPlots_.find(detId_pot) != potPlots_.end())
559  {
560  potPlots_[detId_pot].activityPerBX->Fill(event.bunchCrossing());
561 
562  potPlots_[detId_pot].digiDistribution->Fill(detId.plane(), detId.channel());
563 
564  for (auto it = digi.getSamplesBegin(); it != digi.getSamplesEnd(); ++it)
565  potPlots_[detId_pot].dataSamplesRaw->Fill(*it);
566 
567  float boardId = digi.getEventInfo().getHardwareBoardId() +
568  0.5 * digi.getEventInfo().getHardwareSampicId();
569  potPlots_[detId_pot].digiSent->Fill(boardId, digi.getHardwareChannelId());
570  if (boardSet.find(digi.getEventInfo().getHardwareId()) == boardSet.end())
571  {
572  // This guarantees that every board is counted only once
573  boardSet.insert(digi.getEventInfo().getHardwareId());
574  std::bitset<16> chMap(digi.getEventInfo().getChannelMap());
575  for (int i = 0; i < 16; ++i)
576  {
577  if (chMap.test(i))
578  {
579  potPlots_[detId_pot].digiAll->Fill(boardId, i);
580  }
581  }
582  }
583 
584  potPlots_[detId_pot].planesWithDigisSet.insert(detId.plane());
585  }
586 
587  // Plane Plots
588  if (planePlots_.find(detId_plane) != planePlots_.end())
589  {
590  planePlots_[detId_plane].digiDistribution->Fill(detId.channel());
591 
592  if (channelsPerPlane.find(detId_plane) != channelsPerPlane.end())
593  channelsPerPlane[detId_plane]++;
594  else
595  channelsPerPlane[detId_plane] = 0;
596  }
597 
598  // Channel Plots
599  if (channelPlots_.find(detId) != channelPlots_.end()) {
600  channelPlots_[detId].activityPerBX->Fill(event.bunchCrossing());
601 
602  for (auto it = digi.getSamplesBegin(); it != digi.getSamplesEnd(); ++it)
603  channelPlots_[detId].dataSamplesRaw->Fill(*it);
604  for (unsigned short i = 0; i < samplesForNoise_; ++i)
605  channelPlots_[detId].noiseSamples->Fill(SAMPIC_ADC_V *
606  digi.getSampleAt(i));
607 
608  unsigned int cellOfMax =
609  std::max_element(digi.getSamplesBegin(), digi.getSamplesEnd()) -
610  digi.getSamplesBegin();
611  channelPlots_[detId].cellOfMax->Fill((int)cellOfMax);
612 
613  if (timeOfPreviousEvent_ != 0)
614  channelPlots_[detId].hitTime->Fill(
615  1e-3 * LHC_CLOCK_PERIOD_NS *
616  (event.time().value() - timeOfPreviousEvent_));
617  ++(channelPlots_[detId].hitsCounterPerLumisection);
618  }
619  }
620  }
621  // End digis
622 
623  for (const auto &rechits : *timingRecHits)
624  {
625  const TotemTimingDetId detId(rechits.detId());
626  TotemTimingDetId detId_pot(rechits.detId());
627  detId_pot.setPlane(0);
628  detId_pot.setChannel(0);
629  TotemTimingDetId detId_plane(rechits.detId());
630  detId_plane.setChannel(0);
631 
632  for (const auto &rechit : rechits)
633  {
634  if (potPlots_.find(detId_pot) != potPlots_.end())
635  {
636  potPlots_[detId_pot].amplitude->Fill(rechit.getAmplitude());
637 
638 
639  TH2F *hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F();
640  TAxis *hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
641  float yCorrected = rechit.getY();
642  yCorrected += (detId.rp()==TOTEM_TIMING_TOP_RP_ID)?
645  float x_shift = detId.plane();
646  x_shift += (rechit.getX()>2)? 0.25 : 0;
647  int startBin = hitHistoTmpYAxis->FindBin( yCorrected - 0.5*rechit.getYWidth() );
648  int numOfBins = rechit.getYWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
649  for ( int i=0; i<numOfBins; ++i)
650  {
651  potPlots_[detId_pot].hitDistribution2d->Fill(
652  detId.plane() + 0.25 * (rechit.getX()>2),
653  hitHistoTmpYAxis->GetBinCenter(startBin+i) );
654  potPlots_[detId_pot].hitDistribution2d_lumisection->Fill(
655  x_shift,
656  hitHistoTmpYAxis->GetBinCenter(startBin+i) );
657  }
658 
659  //All plots with Time
660  if ( rechit.getT() != TotemTimingRecHit::NO_T_AVAILABLE )
661  {
662  for ( int i=0; i<numOfBins; ++i)
663  potPlots_[detId_pot].hitDistribution2dWithTime->Fill(
664  detId.plane() + 0.25 * (rechit.getX()>2),
665  hitHistoTmpYAxis->GetBinCenter(startBin+i) );
666 
667  potPlots_[detId_pot].recHitTime->Fill(rechit.getT());
668  potPlots_[detId_pot].planesWithTimeSet.insert(detId.plane());
669 
670  // Plane Plots
671  if (planePlots_.find(detId_plane) != planePlots_.end())
672  {
673  // Visualization tricks
674  float x_shift = (rechit.getX()>2)? 15 : 0;
675  TH1F *hitProfileHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F();
676  int numOfBins = rechit.getYWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
677  if (detId.rp()==TOTEM_TIMING_TOP_RP_ID)
678  {
679  float yCorrected = rechit.getY()+verticalShiftTop_-0.5*rechit.getYWidth()+x_shift;
680  int startBin = hitProfileHistoTmp->FindBin(yCorrected);
681  for ( int i=0; i<numOfBins; ++i)
682  hitProfileHistoTmp->Fill( hitProfileHistoTmp->GetBinCenter(startBin+i) );
683  }
684  else
685  {
686  float yCorrected = rechit.getY()+verticalShiftBot_+0.5*rechit.getYWidth()+(15-x_shift);
687  int startBin = hitProfileHistoTmp->FindBin(yCorrected);
688  int totBins = hitProfileHistoTmp->GetNbinsX();
689  for ( int i=0; i<numOfBins; ++i)
690  hitProfileHistoTmp->Fill( hitProfileHistoTmp->GetBinCenter(totBins-startBin+i) );
691  }
692 
693  if (channelsPerPlaneWithTime.find(detId_plane) != channelsPerPlaneWithTime.end())
694  channelsPerPlaneWithTime[detId_plane]++;
695  else
696  channelsPerPlaneWithTime[detId_plane] = 0;
697  }
698 
699  if (channelPlots_.find(detId) != channelPlots_.end())
700  {
701  potPlots_[detId_pot].tirggerCellTime->Fill(rechit.getSampicThresholdTime());
702  channelPlots_[detId].tirggerCellTime->Fill(rechit.getSampicThresholdTime());
703  channelPlots_[detId].recHitTime->Fill(rechit.getT());
704  channelPlots_[detId].amplitude->Fill(rechit.getAmplitude());
705  }
706  }
707  }
708  }
709  }
710  // End RecHits
711 
712  // Tomography of timing using strips
713  for (const auto &rechits : *timingRecHits)
714  {
715  const TotemTimingDetId detId(rechits.detId());
716  TotemTimingDetId detId_pot(rechits.detId());
717  detId_pot.setPlane(0);
718  detId_pot.setChannel(0);
719  TotemTimingDetId detId_plane(rechits.detId());
720  detId_plane.setChannel(0);
721 
722  float y_shift=(detId.rp()==TOTEM_TIMING_TOP_RP_ID)?20:5;
723 
724  for (const auto &rechit : rechits)
725  {
726  if (rechit.getT() != TotemTimingRecHit::NO_T_AVAILABLE &&
727  potPlots_.find(detId_pot) != potPlots_.end() &&
728  planePlots_.find(detId_plane) != planePlots_.end() &&
729  channelPlots_.find(detId) != channelPlots_.end() )
730  {
731  if ( stripTracks.isValid() )
732  {
733  for (const auto &ds : *stripTracks) {
734  const CTPPSDetId stripId(ds.detId());
735  // mean position of U and V planes
736  TotemRPDetId plId_V(stripId);
737  plId_V.setPlane(0);
738  TotemRPDetId plId_U(stripId);
739  plId_U.setPlane(1);
740 
741  double rp_x = 0;
742  double rp_y = 0;
743  try
744  {
745  rp_x = (geometry->getSensor(plId_V)->translation().x() +
746  geometry->getSensor(plId_U)->translation().x())/2;
747  rp_y = (geometry->getSensor(plId_V)->translation().y() +
748  geometry->getSensor(plId_U)->translation().y())/2;
749  }
750  catch(const cms::Exception &)
751  {
752  continue;
753  }
754 
755  for (const auto &striplt : ds) {
756  if (striplt.isValid() && stripId.arm() == detId.arm()) {
757  if (striplt.getTx() > maximumStripAngleForTomography_ ||
758  striplt.getTy() > maximumStripAngleForTomography_)
759  continue;
760  if (striplt.getTx() < minimumStripAngleForTomography_ ||
761  striplt.getTy() < minimumStripAngleForTomography_)
762  continue;
763  if (stripId.rp() - detId.rp() ==
765  {
766  double x = striplt.getX0() - rp_x;
767  double y = striplt.getY0() - rp_y;
768  if (stripId.station() == TOTEM_STATION_210)
769  {
770  potPlots_[detId_pot].stripTomography210->Fill(x + detId.plane()*50, y + y_shift);
771  channelPlots_[detId].stripTomography210->Fill(x, y + y_shift);
772  }
773  else if (stripId.station() == TOTEM_STATION_220)
774  {
775  potPlots_[detId_pot].stripTomography220->Fill(x+detId.plane()*50, y + y_shift);
776  channelPlots_[detId].stripTomography220->Fill(x, y + y_shift);
777  }
778  }
779  }
780  }
781  }
782  }
783  }
784  }
785  }
786 
787 
788  for (auto &plt : potPlots_) {
789  plt.second.planesWithDigis->Fill(plt.second.planesWithDigisSet.size());
790  plt.second.planesWithDigisSet.clear();
791  plt.second.planesWithTime->Fill(plt.second.planesWithTimeSet.size());
792  plt.second.planesWithTimeSet.clear();
793  }
794 
795  for (const auto &plt : channelsPerPlane) {
796  planePlots_[plt.first].hitMultiplicity->Fill(plt.second);
797  }
798  for (const auto &plt : channelsPerPlaneWithTime) {
799  planePlots_[plt.first].hitMultiplicityWithTime->Fill(plt.second);
800  }
801 
802  timeOfPreviousEvent_ = event.time().value();
803 }
804 
805 //----------------------------------------------------------------------------------------------------
806 
808  const edm::EventSetup &) {
810  TH2F *hitHistoGlobalTmp = globalPlot_.digiSentPercentage->getTH2F();
811  for (auto &plot : potPlots_) {
812  TH2F *hitHistoTmp = plot.second.digiSentPercentage->getTH2F();
813  TH2F *histoSent = plot.second.digiSent->getTH2F();
814  TH2F *histoAll = plot.second.digiAll->getTH2F();
815 
816  hitHistoTmp->Divide(histoSent, histoAll);
817  hitHistoTmp->Scale(100);
818  hitHistoGlobalTmp->Add(hitHistoTmp,1);
819 
820  plot.second.baseline->Reset();
821  plot.second.noiseRMS->Reset();
822  plot.second.meanAmplitude->Reset();
823  plot.second.cellOfMax->Reset();
824  plot.second.hitRate->Reset();
825  TotemTimingDetId rpId(plot.first);
826  for (auto &chPlot : channelPlots_) {
827  TotemTimingDetId chId(chPlot.first);
828  if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) {
829  plot.second.baseline->Fill(
830  chId.plane(), chId.channel(),
831  chPlot.second.noiseSamples->getTH1F()->GetMean());
832  plot.second.noiseRMS->Fill(
833  chId.plane(), chId.channel(),
834  chPlot.second.noiseSamples->getTH1F()->GetRMS());
835  plot.second.meanAmplitude->Fill(
836  chId.plane(), chId.channel(),
837  chPlot.second.amplitude->getTH1F()->GetMean());
838  plot.second.cellOfMax->Fill(
839  chId.plane(), chId.channel(),
840  chPlot.second.cellOfMax->getTH1F()->GetMean());
841  plot.second.hitRate->Fill(
842  chId.plane(), chId.channel(),
843  (double)chPlot.second.hitsCounterPerLumisection * HIT_RATE_FACTOR);
844  }
845  }
846  }
847 
848  for (auto &plot : channelPlots_) {
849  if (plot.second.hitsCounterPerLumisection != 0) {
850  plot.second.hitRate->Fill((double)plot.second.hitsCounterPerLumisection *
852  }
853  plot.second.hitsCounterPerLumisection = 0;
854  }
855 }
856 
857 //----------------------------------------------------------------------------------------------------
858 
860 
861 //----------------------------------------------------------------------------------------------------
862 
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
#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:279
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
const T & get() const
Definition: EventSetup.h:59
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.
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:43
uint32_t rp() const
Definition: CTPPSDetId.h:74
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...