CMS 3D CMS Logo

CTPPSDiamondDQMSource.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of CTPPS offline software.
4 * Authors:
5 * Jan Kašpar (jan.kaspar@gmail.com)
6 * Nicola Minafra
7 * Laurent Forthomme
8 *
9 ****************************************************************************/
10 
18 
22 
28 
31 
34 
35 #include <string>
36 
37 //----------------------------------------------------------------------------------------------------
38 
40 {
41  public:
43  ~CTPPSDiamondDQMSource() override;
44 
45  protected:
46  void dqmBeginRun( const edm::Run&, const edm::EventSetup& ) override;
47  void bookHistograms( DQMStore::IBooker&, const edm::Run&, const edm::EventSetup& ) override;
48  void analyze( const edm::Event&, const edm::EventSetup& ) override;
49  void beginLuminosityBlock( const edm::LuminosityBlock&, const edm::EventSetup& ) override;
50  void endLuminosityBlock( const edm::LuminosityBlock&, const edm::EventSetup& ) override;
51  void endRun( const edm::Run&, const edm::EventSetup& ) override;
52 
53  private:
54  // Constants
55  static const double SEC_PER_LUMI_SECTION; // Number of seconds per lumisection: used to compute hit rates in Hz
56  static const int CHANNEL_OF_VFAT_CLOCK; // Channel ID of the VFAT that contains clock data
57  static const double DISPLAY_RESOLUTION_FOR_HITS_MM; // Bin width of histograms showing hits and tracks (in mm)
59  static const double HPTDC_BIN_WIDTH_NS; // ns per HPTDC bin
60  static const int CTPPS_NUM_OF_ARMS;
61  static const int CTPPS_DIAMOND_STATION_ID;
62  static const int CTPPS_DIAMOND_RP_ID;
63  static const int CTPPS_NEAR_RP_ID;
64  static const int CTPPS_FAR_RP_ID;
65  static const int CTPPS_DIAMOND_NUM_OF_PLANES;
67  static const int CTPPS_FED_ID_45;
68  static const int CTPPS_FED_ID_56;
69 
76 
80  std::vector< std::pair<edm::EventRange, int> > runParameters_;
82  unsigned int verbosity_;
83 
85  struct GlobalPlots
86  {
88 
90  GlobalPlots( DQMStore::IBooker& ibooker );
91  };
92 
94 
96  struct PotPlots
97  {
98  MonitorElement* activity_per_bx_0_25 = nullptr;
99  MonitorElement* activity_per_bx_25_50 = nullptr;
100  MonitorElement* activity_per_bx_50_75 = nullptr;
101  std::vector< MonitorElement* > activity_per_bx;
102 
103  MonitorElement* hitDistribution2d = nullptr;
104  MonitorElement* hitDistribution2d_lumisection = nullptr;
105  MonitorElement* hitDistribution2dOOT = nullptr;
106  MonitorElement* hitDistribution2dOOT_le = nullptr;
107  MonitorElement* activePlanes = nullptr, *activePlanesInclusive = nullptr;
108 
109  MonitorElement* trackDistribution = nullptr;
110  MonitorElement* trackDistributionOOT = nullptr;
111 
112  MonitorElement* stripTomographyAllFar_0_25 = nullptr;
113  MonitorElement* stripTomographyAllFar_25_50 = nullptr;
114  MonitorElement* stripTomographyAllFar_50_75 = nullptr;
115  std::vector< MonitorElement* > stripTomographyAllFar;
116 
117  MonitorElement* leadingEdgeCumulative_both = nullptr, *leadingEdgeCumulative_le = nullptr, *trailingEdgeCumulative_te = nullptr;
118  MonitorElement* timeOverThresholdCumulativePot = nullptr, *leadingTrailingCorrelationPot = nullptr;
119  MonitorElement* leadingWithoutTrailingCumulativePot = nullptr;
120 
121  MonitorElement* ECCheck = nullptr;
122 
123  MonitorElement* HPTDCErrorFlags_cumulative = nullptr;
124  MonitorElement* MHComprensive = nullptr;
125 
126  MonitorElement* clock_Digi1_le = nullptr;
127  MonitorElement* clock_Digi1_te = nullptr;
128  MonitorElement* clock_Digi3_le = nullptr;
129  MonitorElement* clock_Digi3_te = nullptr;
130 
131  unsigned int HitCounter, MHCounter, LeadingOnlyCounter, TrailingOnlyCounter, CompleteCounter;
132 
133  PotPlots() {};
134  PotPlots( DQMStore::IBooker& ibooker, unsigned int id );
135  };
136 
137  std::unordered_map<unsigned int, PotPlots> potPlots_;
139 
141  struct PlanePlots
142  {
143  MonitorElement* digiProfileCumulativePerPlane = nullptr;
144  MonitorElement* hitProfile = nullptr;
145  MonitorElement* hit_multiplicity = nullptr;
146 
147  MonitorElement* stripTomography_far = nullptr;
148 
150  PlanePlots( DQMStore::IBooker& ibooker, unsigned int id );
151  };
152 
153  std::unordered_map<unsigned int, PlanePlots> planePlots_;
154 
157  {
158  MonitorElement* activity_per_bx_0_25 = nullptr;
159  MonitorElement* activity_per_bx_25_50 = nullptr;
160  MonitorElement* activity_per_bx_50_75 = nullptr;
161  std::vector< MonitorElement* > activity_per_bx;
162 
164  MonitorElement* leadingEdgeCumulative_both = nullptr, *leadingEdgeCumulative_le = nullptr, *trailingEdgeCumulative_te = nullptr;
165  MonitorElement* TimeOverThresholdCumulativePerChannel = nullptr;
166  MonitorElement* LeadingTrailingCorrelationPerChannel = nullptr;
167  MonitorElement* leadingWithoutTrailing = nullptr;
168  MonitorElement* stripTomography_far = nullptr;
169  MonitorElement* hit_rate = nullptr;
170  MonitorElement* ECCheckPerChannel = nullptr;
172 
173  unsigned int HitCounter, MHCounter, LeadingOnlyCounter, TrailingOnlyCounter, CompleteCounter;
174 
175  ChannelPlots() : hitsCounterPerLumisection( 0 ) {}
176  ChannelPlots( DQMStore::IBooker &ibooker, unsigned int id );
177  };
178 
179  std::unordered_map<unsigned int, ChannelPlots> channelPlots_;
180 };
181 
182 //----------------------------------------------------------------------------------------------------
183 
184 // Values for all constants
189 const double CTPPSDiamondDQMSource::HPTDC_BIN_WIDTH_NS = 25./1024;
199 
200 //----------------------------------------------------------------------------------------------------
201 
203 {
204  ibooker.setCurrentFolder( "CTPPS" );
205 
206  h_trackCorr_hor = ibooker.book2D( "track correlation all hor", "rp, all, hor", 6, -0.5, 5.5, 6, -0.5, 5.5 );
207  TH2F* hist = h_trackCorr_hor->getTH2F();
208  TAxis* xa = hist->GetXaxis(), *ya = hist->GetYaxis();
209  xa->SetBinLabel( 6, "45, 210, near" ); ya->SetBinLabel( 1, "45, 210, near" );
210  xa->SetBinLabel( 5, "45, 210, far" ); ya->SetBinLabel( 2, "45, 210, far" );
211  xa->SetBinLabel( 4, "45, 220, cyl" ); ya->SetBinLabel( 3, "45, 220, cyl" );
212  xa->SetBinLabel( 3, "56, 210, near" ); ya->SetBinLabel( 4, "56, 210, near" );
213  xa->SetBinLabel( 2, "56, 210, far" ); ya->SetBinLabel( 5, "56, 210, far" );
214  xa->SetBinLabel( 1, "56, 220, cyl" ); ya->SetBinLabel( 6, "56, 220, cyl" );
215 }
216 
217 //----------------------------------------------------------------------------------------------------
218 
219 
220 CTPPSDiamondDQMSource::PotPlots::PotPlots( DQMStore::IBooker& ibooker, unsigned int id ): HitCounter(0), MHCounter(0), LeadingOnlyCounter(0), TrailingOnlyCounter(0), CompleteCounter(0)
221 {
224  ibooker.setCurrentFolder( path );
225 
227 
228  activity_per_bx_0_25 = ibooker.book1D( "activity per BX 0 25", title+" Activity per BX 0 - 25 ns;Event.BX", 3600, -1.5, 3598. + 0.5 );
230  activity_per_bx_25_50 = ibooker.book1D( "activity per BX 25 50", title+" Activity per BX 25 - 50 ns;Event.BX", 3600, -1.5, 3598. + 0.5 );
232  activity_per_bx_50_75 = ibooker.book1D( "activity per BX 50 75", title+" Activity per BX 50 - 75 ns;Event.BX", 3600, -1.5, 3598. + 0.5 );
234 
235  hitDistribution2d = ibooker.book2D( "hits in planes", title+" hits in planes;plane number;x (mm)", 10, -0.5, 4.5, 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18 );
236  hitDistribution2d_lumisection = ibooker.book2D( "hits in planes lumisection", title+" hits in planes in the last lumisection;plane number;x (mm)", 10, -0.5, 4.5, 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18 );
237  hitDistribution2dOOT= ibooker.book2D( "hits with OOT in planes", title+" hits with OOT in planes;plane number + 0.25 OOT;x (mm)", 17, -0.25, 4, 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18 );
238  hitDistribution2dOOT_le= ibooker.book2D( "hits with OOT in planes (le only)", title+" hits with OOT in planes (le only);plane number + 0.25 OOT;x (mm)", 17, -0.25, 4, 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18 );
239  activePlanes = ibooker.book1D( "active planes", title+" active planes (per event);number of active planes", 6, -0.5, 5.5 );
240  activePlanesInclusive = ibooker.book1D( "active planes inclusive", title+" active planes, MH and le only included (per event);number of active planes", 6, -0.5, 5.5 );
241 
242  trackDistribution = ibooker.book1D( "tracks", title+" tracks;x (mm)", 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18 );
243  trackDistributionOOT = ibooker.book2D( "tracks with OOT", title+" tracks with OOT;plane number;x (mm)", 9, -0.5, 4, 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18 );
244 
245  stripTomographyAllFar_0_25 = ibooker.book2D( "tomography all far 0 25", title+" tomography with strips far 0 - 25 ns (all planes);x + 25*plane(mm);y (mm)", 100, 0, 100, 12, -2, 10 );
247  stripTomographyAllFar_25_50 = ibooker.book2D( "tomography all far 25 50", title+" tomography with strips far 25 - 50 ns (all planes);x + 25*plane(mm);y (mm)", 100, 0, 100, 12, -2, 10 );
249  stripTomographyAllFar_50_75 = ibooker.book2D( "tomography all far 50 75", title+" tomography with strips far 50 - 75 ns (all planes);x + 25*plane(mm);y (mm)", 100, 0, 100, 12, -2, 10 );
251 
252  leadingEdgeCumulative_both = ibooker.book1D( "leading edge (le and te)", title+" leading edge (le and te); leading edge (ns)", 125, 0, 125 );
253  leadingEdgeCumulative_le = ibooker.book1D( "leading edge (le only)", title+" leading edge (le only); leading edge (ns)", 125, 0, 125 );
254  trailingEdgeCumulative_te = ibooker.book1D( "trailing edge (te only)", title+" trailing edge (te only); trailing edge (ns)", 125, 0, 125 );
255  timeOverThresholdCumulativePot = ibooker.book1D( "time over threshold", title+" time over threshold;time over threshold (ns)", 250, -25, 100 );
256  leadingTrailingCorrelationPot = ibooker.book2D( "leading trailing correlation", title+" leading trailing correlation;leading edge (ns);trailing edge (ns)", 75, 0, 75, 75, 0, 75 );
257 
258  leadingWithoutTrailingCumulativePot = ibooker.book1D( "event category", title+" leading edges without trailing;;%", 3, 0.5, 3.5 );
259  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel( 1, "Leading only" );
260  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel( 2, "Trailing only" );
261  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel( 3, "Both" );
262 
263  ECCheck = ibooker.book1D( "optorxEC(8bit) - vfatEC", title+" EC Error;optorxEC-vfatEC", 128, -64, 64 );
264 
265  HPTDCErrorFlags_cumulative = ibooker.book1D( "HPTDC Errors", title+" HPTDC Errors", 16, -0.5, 16.5 );
266  for ( unsigned short error_index=1; error_index<16; ++error_index )
267  HPTDCErrorFlags_cumulative->getTH1F()->GetXaxis()->SetBinLabel( error_index, HPTDCErrorFlags::getHPTDCErrorName( error_index-1 ).c_str() );
268  HPTDCErrorFlags_cumulative->getTH1F()->GetXaxis()->SetBinLabel( 16, "MH (%)" );
269 
270  MHComprensive = ibooker.book2D( "MH in channels", title+" MH (%) in channels;plane number;ch number", 10, -0.5, 4.5, 14, -1, 13 );
271 
272  ibooker.setCurrentFolder( path+"/clock/" );
273  clock_Digi1_le = ibooker.book1D( "clock1 leading edge", title+" clock1;leading edge (ns)", 1250, 0, 125 );
274  clock_Digi1_te = ibooker.book1D( "clock1 trailing edge", title+" clock1;trailing edge (ns)", 75, 0, 75 );
275  clock_Digi3_le = ibooker.book1D( "clock3 leading edge", title+" clock3;leading edge (ns)", 1250, 0, 125 );
276  clock_Digi3_te = ibooker.book1D( "clock3 trailing edge", title+" clock3;trailing edge (ns)", 75, 0, 75 );
277 }
278 
279 //----------------------------------------------------------------------------------------------------
280 
282 {
285  ibooker.setCurrentFolder( path );
286 
288 
289  digiProfileCumulativePerPlane = ibooker.book1D( "digi profile", title+" digi profile; ch number", 12, -0.5, 11.5 );
290  hitProfile = ibooker.book1D( "hit profile", title+" hit profile;x (mm)", 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -1, 18 );
291  hit_multiplicity = ibooker.book1D( "channels per plane", title+" channels per plane; ch per plane", 13, -0.5, 12.5 );
292 
293  stripTomography_far = ibooker.book2D( "tomography far", title+" tomography with strips far;x + 25 OOT (mm);y (mm)", 50, 0, 50, 12, -2, 10 );
294 }
295 
296 //----------------------------------------------------------------------------------------------------
297 
299 {
302  ibooker.setCurrentFolder( path );
303 
305 
306  leadingWithoutTrailing = ibooker.book1D( "event category", title+" Event Category;;%", 3, 0.5, 3.5 );
307  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel( 1, "Leading only" );
308  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel( 2, "Trailing only" );
309  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel( 3, "Full" );
310 
311  activity_per_bx_0_25 = ibooker.book1D( "activity per BX 0 25", title+" Activity per BX 0 - 25 ns;Event.BX", 1000, -1.5, 998. + 0.5 );
313  activity_per_bx_25_50 = ibooker.book1D( "activity per BX 25 50", title+" Activity per BX 25 - 50 ns;Event.BX", 1000, -1.5, 998. + 0.5 );
315  activity_per_bx_50_75 = ibooker.book1D( "activity per BX 50 75", title+" Activity per BX 50 - 75 ns;Event.BX", 1000, -1.5, 998. + 0.5 );
317 
318  HPTDCErrorFlags = ibooker.book1D( "hptdc_Errors", title+" HPTDC Errors", 16, -0.5, 16.5 );
319  for ( unsigned short error_index=1; error_index<16; ++error_index )
320  HPTDCErrorFlags->getTH1F()->GetXaxis()->SetBinLabel( error_index, HPTDCErrorFlags::getHPTDCErrorName( error_index-1 ).c_str() );
321  HPTDCErrorFlags->getTH1F()->GetXaxis()->SetBinLabel( 16, "MH (%)" );
322 
323  leadingEdgeCumulative_both = ibooker.book1D( "leading edge (le and te)", title+" leading edge; leading edge (ns)", 125, 0, 125 );
324  leadingEdgeCumulative_le = ibooker.book1D( "leading edge (le only)", title+" leading edge; leading edge (ns)", 125, 0, 125 );
325  trailingEdgeCumulative_te = ibooker.book1D( "trailing edge (te only)", title+" trailing edge (te only); trailing edge (ns)", 125, 0, 125 );
326  TimeOverThresholdCumulativePerChannel = ibooker.book1D( "time over threshold", title+" time over threshold;time over threshold (ns)", 75, -25, 50 );
327  LeadingTrailingCorrelationPerChannel = ibooker.book2D( "leading trailing correlation", title+" leading trailing correlation;leading edge (ns);trailing edge (ns)", 75, 0, 75, 75, 0, 75 );
328 
329  ECCheckPerChannel = ibooker.book1D("optorxEC(8bit) - vfatEC vs optorxEC", title+" EC Error;optorxEC-vfatEC", 128, -64, 64 );
330 
331  stripTomography_far = ibooker.book2D( "tomography far", "tomography with strips far;x + 25 OOT (mm);y (mm)", 50, 0, 50, 12, -2, 10 );
332 
333  hit_rate = ibooker.book1D( "hit rate", title+"hit rate;rate (Hz)", 40, 0, 20);
334 }
335 
336 //----------------------------------------------------------------------------------------------------
337 
339  tokenStatus_ ( consumes< edm::DetSetVector<TotemVFATStatus> > ( ps.getParameter<edm::InputTag>( "tagStatus" ) ) ),
340  tokenLocalTrack_ ( consumes< edm::DetSetVector<TotemRPLocalTrack> > ( ps.getParameter<edm::InputTag>( "tagLocalTrack" ) ) ),
341  tokenDigi_ ( consumes< edm::DetSetVector<CTPPSDiamondDigi> > ( ps.getParameter<edm::InputTag>( "tagDigi" ) ) ),
342  tokenDiamondHit_ ( consumes< edm::DetSetVector<CTPPSDiamondRecHit> > ( ps.getParameter<edm::InputTag>( "tagDiamondRecHits" ) ) ),
343  tokenDiamondTrack_( consumes< edm::DetSetVector<CTPPSDiamondLocalTrack> >( ps.getParameter<edm::InputTag>( "tagDiamondLocalTracks" ) ) ),
344  tokenFEDInfo_ ( consumes< std::vector<TotemFEDInfo> > ( ps.getParameter<edm::InputTag>( "tagFEDInfo" ) ) ),
345  excludeMultipleHits_ ( ps.getParameter<bool>( "excludeMultipleHits" ) ),
346  minimumStripAngleForTomography_( ps.getParameter<double>( "minimumStripAngleForTomography" ) ),
347  maximumStripAngleForTomography_( ps.getParameter<double>( "maximumStripAngleForTomography" ) ),
348  centralOOT_( -999 ),
349  verbosity_ ( ps.getUntrackedParameter<unsigned int>( "verbosity", 0 ) ),
350  EC_difference_56_( -500 ), EC_difference_45_( -500 )
351 {
352  for ( const auto& pset : ps.getParameter< std::vector<edm::ParameterSet> >( "offsetsOOT" ) ) {
353  runParameters_.emplace_back( std::make_pair( pset.getParameter<edm::EventRange>( "validityRange" ), pset.getParameter<int>( "centralOOT" ) ) );
354  }
355 }
356 
357 //----------------------------------------------------------------------------------------------------
358 
360 {}
361 
362 //----------------------------------------------------------------------------------------------------
363 
364 void
366 {
367  centralOOT_ = -999;
368  for ( const auto& oot : runParameters_ ) {
369  if ( edm::contains( oot.first, edm::EventID( iRun.run(), 0, 1 ) ) ) {
370  centralOOT_ = oot.second; break;
371  }
372  }
373 }
374 
375 
376 //----------------------------------------------------------------------------------------------------
377 
378 void
380 {
381  ibooker.cd();
382  ibooker.setCurrentFolder( "CTPPS" );
383 
384  globalPlot_= GlobalPlots( ibooker );
385 
386  for ( unsigned short arm = 0; arm < CTPPS_NUM_OF_ARMS; ++arm ) {
388  potPlots_[rpId] = PotPlots( ibooker, rpId );
389  for ( unsigned short pl = 0; pl < CTPPS_DIAMOND_NUM_OF_PLANES; ++pl ) {
391  planePlots_[plId] = PlanePlots( ibooker, plId);
392  for ( unsigned short ch = 0; ch < CTPPS_DIAMOND_NUM_OF_CHANNELS; ++ch ) {
394  channelPlots_[chId] = ChannelPlots( ibooker, chId );
395  }
396  }
397  }
398 }
399 
400 
401 //----------------------------------------------------------------------------------------------------
402 
403 void
405 {
406  for ( auto& plot : potPlots_ )
407  plot.second.hitDistribution2d_lumisection->Reset();
408 }
409 
410 //----------------------------------------------------------------------------------------------------
411 
412 void
414 {
415  // get event data
417  event.getByToken( tokenStatus_, diamondVFATStatus );
418 
420  event.getByToken( tokenLocalTrack_, stripTracks );
421 
423  event.getByToken( tokenDigi_, diamondDigis );
424 
426  event.getByToken( tokenFEDInfo_, fedInfo );
427 
429  event.getByToken( tokenDiamondHit_, diamondRecHits );
430 
432  event.getByToken( tokenDiamondTrack_, diamondLocalTracks );
433 
434  // check validity
435  bool valid = true;
436  valid &= diamondVFATStatus.isValid();
437  valid &= diamondDigis.isValid();
438  valid &= fedInfo.isValid();
439 
440  if ( !valid ) {
441  if ( verbosity_ ) {
442  edm::LogProblem("CTPPSDiamondDQMSource")
443  << "ERROR in TotemDQMModuleRP::analyze > some of the required inputs are not valid. Skipping this event.\n"
444  << " diamondVFATStatus.isValid = " << diamondVFATStatus.isValid() << "\n"
445  << " diamondDigis.isValid = " << diamondDigis.isValid() << "\n"
446  << " fedInfo.isValid = " << fedInfo.isValid();
447  }
448 
449  return;
450  }
451 
452  //------------------------------
453  // RP Plots
454  //------------------------------
455 
456  //------------------------------
457  // Correlation Plots
458  //------------------------------
459 
460  for ( const auto& ds1 : *stripTracks ) {
461  for ( const auto& tr1 : ds1 ) {
462  if ( ! tr1.isValid() ) continue;
463 
464  CTPPSDetId rpId1( ds1.detId() );
465  unsigned int arm1 = rpId1.arm();
466  unsigned int stNum1 = rpId1.station();
467  unsigned int rpNum1 = rpId1.rp();
468  if (stNum1 != 0 || ( rpNum1 != 2 && rpNum1 != 3 ) ) continue;
469  unsigned int idx1 = arm1*3 + rpNum1-2;
470 
471  for ( const auto& ds2 : *stripTracks ) {
472  for ( const auto& tr2 : ds2 ) {
473  if ( ! tr2.isValid() ) continue;
474 
475  CTPPSDetId rpId2(ds2.detId());
476  unsigned int arm2 = rpId2.arm();
477  unsigned int stNum2 = rpId2.station();
478  unsigned int rpNum2 = rpId2.rp();
479  if (stNum2 != 0 || ( rpNum2 != 2 && rpNum2 != 3 ) ) continue;
480  unsigned int idx2 = arm2*3 + rpNum2-2;
481 
482  if ( idx1 >= idx2 ) globalPlot_.h_trackCorr_hor->Fill( 5-idx1, idx2 ); // strips-strips
483  }
484  }
485  for ( const auto& ds2 : *diamondLocalTracks ) {
486  for ( const auto& tr2 : ds2 ) {
487  if ( ! tr2.isValid() ) continue;
488  if ( centralOOT_ != -999 && tr2.getOOTIndex() != centralOOT_ ) continue;
489  if ( excludeMultipleHits_ && tr2.getMultipleHits() > 0 ) continue;
490 
491  CTPPSDetId diamId2( ds2.detId() );
492  unsigned int arm2 = diamId2.arm();
493  if ( idx1 >= arm2*3+2 )
494  globalPlot_.h_trackCorr_hor->Fill( 5-idx1, arm2*3+2 ); // strips-diamonds
495  else
496  globalPlot_.h_trackCorr_hor->Fill( 5-(arm2*3+2 ),idx1 ); // strips-diamonds
497  }
498  }
499  }
500  }
501 
502  for ( const auto& ds1 : *diamondLocalTracks ) {
503  for ( const auto& tr1 : ds1 ) {
504  if ( ! tr1.isValid() ) continue;
505  if ( excludeMultipleHits_ && tr1.getMultipleHits() > 0 ) continue;
506  if ( centralOOT_ != -999 && tr1.getOOTIndex() != centralOOT_ ) continue;
507 
508  CTPPSDetId diamId1( ds1.detId() );
509  unsigned int arm1 = diamId1.arm();
510 
511  globalPlot_.h_trackCorr_hor->Fill( 5-(arm1*3+2), arm1*3+2 ); // diamonds-diamonds
512 
513  for ( const auto& ds2 : *diamondLocalTracks ) {
514  for ( const auto& tr2 : ds2 ) {
515  if ( ! tr2.isValid() ) continue;
516  if ( excludeMultipleHits_ && tr2.getMultipleHits() > 0 ) continue;
517  if ( centralOOT_ != -999 && tr2.getOOTIndex() != centralOOT_ ) continue;
518 
519  CTPPSDetId diamId2( ds2.detId() );
520  unsigned int arm2 = diamId2.arm();
521  if ( arm1 > arm2 ) globalPlot_.h_trackCorr_hor->Fill( 5-(arm1*3+2), arm2*3+2 ); // diamonds-diamonds
522  }
523  }
524  }
525  }
526 
527 
528  // Using CTPPSDiamondDigi
529  for ( const auto& digis : *diamondDigis ) {
530  const CTPPSDiamondDetId detId( digis.detId() );
531  CTPPSDiamondDetId detId_pot( digis.detId() );
532 
533  for ( const auto& digi : digis ) {
534  detId_pot.setPlane( 0 );
535  detId_pot.setChannel( 0 );
536  if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) continue;
537  if ( potPlots_.find( detId_pot ) == potPlots_.end() ) continue;
538  //Leading without trailing investigation
539  if ( digi.getLeadingEdge() != 0 || digi.getTrailingEdge() != 0 ) {
540  ++(potPlots_[detId_pot].HitCounter);
541  if ( digi.getLeadingEdge() != 0 && digi.getTrailingEdge() == 0 ) {
542  ++(potPlots_[detId_pot].LeadingOnlyCounter);
543  potPlots_[detId_pot].leadingEdgeCumulative_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
544  }
545  if ( digi.getLeadingEdge() == 0 && digi.getTrailingEdge() != 0 ) {
546  ++(potPlots_[detId_pot].TrailingOnlyCounter);
547  potPlots_[detId_pot].trailingEdgeCumulative_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
548  }
549  if ( digi.getLeadingEdge() != 0 && digi.getTrailingEdge() != 0 ) {
550  ++(potPlots_[detId_pot].CompleteCounter);
551  potPlots_[detId_pot].leadingTrailingCorrelationPot->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge(), HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
552  }
553  }
554 
555  // HPTDC Errors
556  const HPTDCErrorFlags hptdcErrors = digi.getHPTDCErrorFlags();
557  for ( unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex )
558  if ( hptdcErrors.getErrorId( hptdcErrorIndex-1 ) ) potPlots_[detId_pot].HPTDCErrorFlags_cumulative->Fill( hptdcErrorIndex );
559  if ( digi.getMultipleHit() ) ++(potPlots_[detId_pot].MHCounter);
560  }
561  }
562 
563  // EC Errors
564  for ( const auto& vfat_status : *diamondVFATStatus ) {
565  const CTPPSDiamondDetId detId( vfat_status.detId() );
566  CTPPSDiamondDetId detId_pot( vfat_status.detId() );
567  detId_pot.setPlane( 0 );
568  detId_pot.setChannel( 0 );
569  for ( const auto& status : vfat_status ) {
570  if ( !status.isOK() ) continue;
571  if ( potPlots_.find(detId_pot) == potPlots_.end() ) continue;
572 
573  // Check Event Number
574  for ( const auto& optorx : *fedInfo ) {
575  if ( detId.arm() == 1 && optorx.getFEDId() == CTPPS_FED_ID_56 ) {
576  potPlots_[detId_pot].ECCheck->Fill((int)((optorx.getLV1()& 0xFF)-((unsigned int) status.getEC() & 0xFF)) & 0xFF);
577  if ( ( static_cast<int>( ( optorx.getLV1() & 0xFF )-status.getEC() ) != EC_difference_56_ ) && ( static_cast<uint8_t>( ( optorx.getLV1() & 0xFF )-status.getEC() ) < 128 ) )
578  EC_difference_56_ = static_cast<int>( optorx.getLV1() & 0xFF )-( static_cast<unsigned int>( status.getEC() ) & 0xFF );
579  if ( EC_difference_56_ != 1 && EC_difference_56_ != -500 && EC_difference_56_ < 128 && EC_difference_56_ > -128 )
580  if (verbosity_)
581  edm::LogProblem("CTPPSDiamondDQMSource") << "FED " << CTPPS_FED_ID_56 << ": ECError at EV: 0x"<< std::hex << optorx.getLV1()
582  << "\t\tVFAT EC: 0x"<< static_cast<unsigned int>( status.getEC() )
583  << "\twith ID: " << std::dec << detId
584  << "\tdiff: " << EC_difference_56_;
585  }
586  else if ( detId.arm() == 0 && optorx.getFEDId()== CTPPS_FED_ID_45 ) {
587  potPlots_[detId_pot].ECCheck->Fill((int)((optorx.getLV1()& 0xFF)-status.getEC()) & 0xFF);
588  if ( ( static_cast<int>( ( optorx.getLV1() & 0xFF )-status.getEC() ) != EC_difference_45_ ) && ( static_cast<uint8_t>( ( optorx.getLV1() & 0xFF )-status.getEC() ) < 128 ) )
589  EC_difference_45_ = static_cast<int>( optorx.getLV1() & 0xFF )-( static_cast<unsigned int>( status.getEC() ) & 0xFF );
590  if ( EC_difference_45_ != 1 && EC_difference_45_ != -500 && EC_difference_45_ < 128 && EC_difference_45_ > -128 )
591  if (verbosity_)
592  edm::LogProblem("CTPPSDiamondDQMSource") << "FED " << CTPPS_FED_ID_45 << ": ECError at EV: 0x"<< std::hex << optorx.getLV1()
593  << "\t\tVFAT EC: 0x"<< static_cast<unsigned int>( status.getEC() )
594  << "\twith ID: " << std::dec << detId
595  << "\tdiff: " << EC_difference_45_;
596  }
597  }
598  }
599  }
600 
601  // Using CTPPSDiamondRecHit
602  std::unordered_map<unsigned int, std::set<unsigned int> > planes;
603  std::unordered_map<unsigned int, std::set<unsigned int> > planes_inclusive;
604 
605 
606  for ( const auto& rechits : *diamondRecHits ) {
607  CTPPSDiamondDetId detId_pot( rechits.detId() );
608  detId_pot.setPlane( 0 );
609  detId_pot.setChannel( 0 );
610  const CTPPSDiamondDetId detId( rechits.detId() );
611 
612  for ( const auto& rechit : rechits ) {
613  planes_inclusive[detId_pot].insert( detId.plane() );
614  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
615  if ( rechit.getToT() != 0 && centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_ )
616  planes[detId_pot].insert( detId.plane() );
617 
618  if ( potPlots_.find( detId_pot ) == potPlots_.end() ) continue;
619 
620  float UFSDShift = 0.0;
621  if ( rechit.getYWidth() < 3 ) UFSDShift = 0.5; // Display trick for UFSD that have 2 pixels with same X
622 
623  if ( rechit.getToT() != 0 && centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_ ) {
624  TH2F *hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F();
625  TAxis *hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
626  int startBin = hitHistoTmpYAxis->FindBin( rechit.getX() - 0.5*rechit.getXWidth() );
627  int numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
628  for ( int i=0; i<numOfBins; ++i) {
629  hitHistoTmp->Fill( detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin+i) );
630  }
631 
632  hitHistoTmp = potPlots_[detId_pot].hitDistribution2d_lumisection->getTH2F();
633  hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
634  startBin = hitHistoTmpYAxis->FindBin( rechit.getX() - 0.5*rechit.getXWidth() );
635  numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
636  for ( int i=0; i<numOfBins; ++i) {
637  hitHistoTmp->Fill( detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin+i) );
638  }
639 
640  }
641 
642  if ( rechit.getToT() != 0 ) {
643  // Both
644  potPlots_[detId_pot].leadingEdgeCumulative_both->Fill( rechit.getT() + 25*rechit.getOOTIndex() );
645  potPlots_[detId_pot].timeOverThresholdCumulativePot->Fill( rechit.getToT() );
646 
647  TH2F *hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT->getTH2F();
648  TAxis *hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis();
649  int startBin = hitHistoOOTTmpYAxis->FindBin( rechit.getX() - 0.5*rechit.getXWidth() );
650  int numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
651  for ( int i=0; i<numOfBins; ++i) {
652  hitHistoOOTTmp->Fill( detId.plane() + 0.2 * rechit.getOOTIndex(), hitHistoOOTTmpYAxis->GetBinCenter(startBin+i) );
653  }
654  }
655  else {
656  if ( rechit.getT() != 0 ) {
657  // Only leading
658  TH2F *hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT_le->getTH2F();
659  TAxis *hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis();
660  int startBin = hitHistoOOTTmpYAxis->FindBin( rechit.getX() - 0.5*rechit.getXWidth() );
661  int numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
662  for ( int i=0; i<numOfBins; ++i) {
663  hitHistoOOTTmp->Fill( detId.plane() + 0.2 * rechit.getOOTIndex(), hitHistoOOTTmpYAxis->GetBinCenter(startBin+i) );
664  }
665  }
666  }
667  if ( (unsigned int) rechit.getOOTIndex() < potPlots_[detId_pot].activity_per_bx.size() )
668  potPlots_[detId_pot].activity_per_bx.at( rechit.getOOTIndex() )->Fill( event.bunchCrossing() );
669  }
670  }
671 
672  for ( const auto& plt : potPlots_ ) {
673  plt.second.activePlanes->Fill( planes[plt.first].size() );
674  plt.second.activePlanesInclusive->Fill( planes_inclusive[plt.first].size() );
675  }
676 
677  // Using CTPPSDiamondLocalTrack
678  for ( const auto& tracks : *diamondLocalTracks ) {
679  CTPPSDiamondDetId detId_pot( tracks.detId() );
680  detId_pot.setPlane( 0 );
681  detId_pot.setChannel( 0 );
682  const CTPPSDiamondDetId detId( tracks.detId() );
683 
684  for ( const auto& track : tracks ) {
685  if ( ! track.isValid() ) continue;
686  if ( excludeMultipleHits_ && track.getMultipleHits() > 0 ) continue;
687  if ( potPlots_.find( detId_pot ) == potPlots_.end() ) continue;
688 
689  TH2F *trackHistoOOTTmp = potPlots_[detId_pot].trackDistributionOOT->getTH2F();
690  TAxis *trackHistoOOTTmpYAxis = trackHistoOOTTmp->GetYaxis();
691  int startBin = trackHistoOOTTmpYAxis->FindBin( track.getX0() - track.getX0Sigma() );
692  int numOfBins = 2*track.getX0Sigma()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
693  for ( int i=0; i<numOfBins; ++i) {
694  trackHistoOOTTmp->Fill( track.getOOTIndex(), trackHistoOOTTmpYAxis->GetBinCenter(startBin+i) );
695  }
696 
697  if ( centralOOT_ != -999 && track.getOOTIndex() == centralOOT_ ) {
698  TH1F *trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution->getTH1F();
699  int startBin = trackHistoInTimeTmp->FindBin( track.getX0() - track.getX0Sigma() );
700  int numOfBins = 2*track.getX0Sigma()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
701  for ( int i=0; i<numOfBins; ++i) {
702  trackHistoInTimeTmp->Fill( trackHistoInTimeTmp->GetBinCenter(startBin+i) );
703  }
704  }
705  }
706  }
707 
708  // Tomography of diamonds using strips
709  for ( const auto& rechits : *diamondRecHits ) {
710  CTPPSDiamondDetId detId_pot( rechits.detId() );
711  detId_pot.setPlane( 0 );
712  detId_pot.setChannel( 0 );
713  const CTPPSDiamondDetId detId( rechits.detId() );
714 
715  for ( const auto& rechit : rechits ) {
716  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
717  if ( rechit.getToT() == 0 ) continue;
718  if ( !stripTracks.isValid() ) continue;
719  if ( potPlots_.find( detId_pot ) == potPlots_.end() ) continue;
720 
721  for ( const auto& ds : *stripTracks ) {
722  const CTPPSDetId stripId( ds.detId() );
723  for ( const auto& striplt : ds ) {
724  if ( !striplt.isValid() ) continue;
725  if ( stripId.arm() != detId_pot.arm() ) continue;
726  if ( striplt.getTx() > maximumStripAngleForTomography_ || striplt.getTy() > maximumStripAngleForTomography_) continue;
727  if ( striplt.getTx() < minimumStripAngleForTomography_ || striplt.getTy() < minimumStripAngleForTomography_) continue;
728  if ( stripId.rp() == CTPPS_FAR_RP_ID ) {
729  if ( (unsigned int) rechit.getOOTIndex() < potPlots_[detId_pot].stripTomographyAllFar.size() )
730  potPlots_[detId_pot].stripTomographyAllFar.at( rechit.getOOTIndex() )->Fill( striplt.getX0() + 25*detId.plane(), striplt.getY0() );
731  }
732  }
733  }
734  }
735  }
736 
737  //------------------------------
738  // Clock Plots
739  //------------------------------
740 
741  for ( const auto& digis : *diamondDigis ) {
742  const CTPPSDiamondDetId detId( digis.detId() );
743  CTPPSDiamondDetId detId_pot( digis.detId() );
744  if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) {
745  detId_pot.setPlane( 0 );
746  detId_pot.setChannel( 0 );
747  for ( const auto& digi : digis ) {
748  if ( digi.getLeadingEdge() != 0 ) {
749  if ( detId.plane() == 1 ) {
750  potPlots_[detId_pot].clock_Digi1_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
751  potPlots_[detId_pot].clock_Digi1_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
752  }
753  if ( detId.plane() == 3 ) {
754  potPlots_[detId_pot].clock_Digi3_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
755  potPlots_[detId_pot].clock_Digi3_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
756  }
757  }
758  }
759  }
760  }
761 
762  //------------------------------
763  // Plane Plots
764  //------------------------------
765 
766  // Using CTPPSDiamondDigi
767  std::unordered_map<unsigned int, unsigned int> channelsPerPlane;
768  for ( const auto& digis : *diamondDigis ) {
769  const CTPPSDiamondDetId detId( digis.detId() );
770  CTPPSDiamondDetId detId_plane( digis.detId() );
771  for ( const auto& digi : digis ) {
772  detId_plane.setChannel( 0 );
773  if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) continue;
774  if ( planePlots_.find( detId_plane ) == planePlots_.end() ) continue;
775 
776  if ( digi.getLeadingEdge() != 0 ) {
777  planePlots_[detId_plane].digiProfileCumulativePerPlane->Fill( detId.channel() );
778  if ( channelsPerPlane.find(detId_plane) != channelsPerPlane.end() ) channelsPerPlane[detId_plane]++;
779  else channelsPerPlane[detId_plane] = 0;
780  }
781  }
782  }
783 
784  for ( const auto& plt : channelsPerPlane ) {
785  planePlots_[plt.first].hit_multiplicity->Fill( plt.second );
786  }
787 
788  // Using CTPPSDiamondRecHit
789  for ( const auto& rechits : *diamondRecHits ) {
790  CTPPSDiamondDetId detId_plane( rechits.detId() );
791  detId_plane.setChannel( 0 );
792  for ( const auto& rechit : rechits ) {
793  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
794  if ( rechit.getToT() == 0 ) continue;
795  if ( planePlots_.find( detId_plane ) != planePlots_.end() ) {
796  if ( centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_ ) {
797  TH1F *hitHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F();
798  int startBin = hitHistoTmp->FindBin( rechit.getX() - 0.5*rechit.getXWidth() );
799  int numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
800  for ( int i=0; i<numOfBins; ++i) {
801  hitHistoTmp->Fill( hitHistoTmp->GetBinCenter(startBin+i) );
802  }
803  }
804  }
805  }
806  }
807 
808  // Tomography of diamonds using strips
809  for ( const auto& rechits : *diamondRecHits ) {
810  CTPPSDiamondDetId detId_plane( rechits.detId() );
811  detId_plane.setChannel( 0 );
812  for ( const auto& rechit : rechits ) {
813  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
814  if ( rechit.getToT() == 0 ) continue;
815  if ( !stripTracks.isValid() ) continue;
816  if (planePlots_.find(detId_plane) == planePlots_.end()) continue;
817 
818  for ( const auto& ds : *stripTracks ) {
819  const CTPPSDetId stripId(ds.detId());
820  for ( const auto& striplt : ds ) {
821  if (! striplt.isValid()) continue;
822  if ( stripId.arm() != detId_plane.arm() ) continue;
823  if ( striplt.getTx() > maximumStripAngleForTomography_ || striplt.getTy() > maximumStripAngleForTomography_) continue;
824  if ( striplt.getTx() < minimumStripAngleForTomography_ || striplt.getTy() < minimumStripAngleForTomography_) continue;
825  if ( stripId.rp() == CTPPS_FAR_RP_ID ) {
826  planePlots_[detId_plane].stripTomography_far->Fill( striplt.getX0() + 25*rechit.getOOTIndex() , striplt.getY0() );
827  }
828  }
829  }
830  }
831  }
832  //------------------------------
833  // Channel Plots
834  //------------------------------
835 
836  //Check Event Number
837  for ( const auto& vfat_status : *diamondVFATStatus ) {
838  const CTPPSDiamondDetId detId( vfat_status.detId() );
839  for ( const auto& status : vfat_status ) {
840  if ( !status.isOK() ) continue;
841  if ( channelPlots_.find(detId) != channelPlots_.end() ) {
842  for ( const auto& optorx : *fedInfo ) {
843  if ( ( detId.arm() == 1 && optorx.getFEDId() == CTPPS_FED_ID_56 ) || ( detId.arm() == 0 && optorx.getFEDId() == CTPPS_FED_ID_45 ) ) {
844  channelPlots_[detId].ECCheckPerChannel->Fill((int)((optorx.getLV1()& 0xFF)-((unsigned int) status.getEC() & 0xFF)) & 0xFF);
845  }
846  }
847  }
848  }
849  }
850 
851  // digi profile cumulative
852  for ( const auto& digis : *diamondDigis ) {
853  const CTPPSDiamondDetId detId( digis.detId() );
854  for ( const auto& digi : digis ) {
855  if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) continue;
856  if ( channelPlots_.find( detId ) != channelPlots_.end() ) {
857  // HPTDC Errors
858  const HPTDCErrorFlags hptdcErrors = digi.getHPTDCErrorFlags();
859  for ( unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex )
860  if ( hptdcErrors.getErrorId( hptdcErrorIndex-1 ) ) channelPlots_[detId].HPTDCErrorFlags->Fill( hptdcErrorIndex );
861  if ( digi.getMultipleHit() ) ++(channelPlots_[detId].MHCounter);
862 
863  // Check dropped trailing edges
864  if ( digi.getLeadingEdge() != 0 || digi.getTrailingEdge() != 0 ) {
865  ++(channelPlots_[detId].HitCounter);
866  if ( digi.getLeadingEdge() != 0 && digi.getTrailingEdge() == 0 ) {
867  ++(channelPlots_[detId].LeadingOnlyCounter);
868  channelPlots_[detId].leadingEdgeCumulative_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
869  }
870  if ( digi.getLeadingEdge() == 0 && digi.getTrailingEdge() != 0 ) {
871  ++(channelPlots_[detId].TrailingOnlyCounter);
872  channelPlots_[detId].trailingEdgeCumulative_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
873  }
874  if ( digi.getLeadingEdge() != 0 && digi.getTrailingEdge() != 0 ) {
875  ++(channelPlots_[detId].CompleteCounter);
876  channelPlots_[detId].LeadingTrailingCorrelationPerChannel->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge(), HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
877  }
878  }
879  }
880  }
881  }
882 
883  // Using CTPPSDiamondRecHit
884  for ( const auto& rechits : *diamondRecHits ) {
885  CTPPSDiamondDetId detId( rechits.detId() );
886  for ( const auto& rechit : rechits ) {
887  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
888  if ( channelPlots_.find( detId ) != channelPlots_.end() ) {
889  if ( rechit.getToT() != 0 ) {
890  channelPlots_[detId].leadingEdgeCumulative_both->Fill( rechit.getT() + 25*rechit.getOOTIndex() );
891  channelPlots_[detId].TimeOverThresholdCumulativePerChannel->Fill( rechit.getToT() );
892  }
893  ++(channelPlots_[detId].hitsCounterPerLumisection);
894  }
895 
896  if ( (unsigned int) rechit.getOOTIndex() < channelPlots_[detId].activity_per_bx.size() )
897  channelPlots_[detId].activity_per_bx.at( rechit.getOOTIndex() )->Fill( event.bunchCrossing() );
898  }
899 
900  }
901 
902  // Tomography of diamonds using strips
903  for ( const auto& rechits : *diamondRecHits ) {
904  const CTPPSDiamondDetId detId( rechits.detId() );
905  for ( const auto& rechit : rechits ) {
906  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
907  if ( stripTracks.isValid() ) {
908  if (channelPlots_.find(detId) == channelPlots_.end()) continue;
909  for ( const auto& ds : *stripTracks ) {
910  for ( const auto& striplt : ds ) {
911  CTPPSDetId stripId(ds.detId());
912  if ( !striplt.isValid() ) continue;
913  if ( stripId.arm() != detId.arm() ) continue;
914  if ( striplt.getTx() > maximumStripAngleForTomography_ || striplt.getTy() > maximumStripAngleForTomography_) continue;
915  if ( striplt.getTx() < minimumStripAngleForTomography_ || striplt.getTy() < minimumStripAngleForTomography_) continue;
916  if ( stripId.rp() == CTPPS_FAR_RP_ID ) {
917  channelPlots_[detId].stripTomography_far->Fill( striplt.getX0() + 25*rechit.getOOTIndex(), striplt.getY0() );
918  }
919  }
920  }
921  }
922  }
923  }
924 }
925 
926 //----------------------------------------------------------------------------------------------------
927 
928 void
930 {
931  for ( auto& plot : channelPlots_ ) {
932  if ( plot.second.hitsCounterPerLumisection != 0 ) {
933  plot.second.hit_rate->Fill( (double) plot.second.hitsCounterPerLumisection / SEC_PER_LUMI_SECTION );
934  }
935  plot.second.hitsCounterPerLumisection = 0;
936 
937  double HundredOverHitCounter = .0;
938  if ( plot.second.HitCounter != 0 )
939  HundredOverHitCounter = 100. / plot.second.HitCounter;
940  plot.second.HPTDCErrorFlags->setBinContent( 16, HundredOverHitCounter * plot.second.MHCounter );
941  plot.second.leadingWithoutTrailing->setBinContent(1, HundredOverHitCounter * plot.second.LeadingOnlyCounter );
942  plot.second.leadingWithoutTrailing->setBinContent(2, HundredOverHitCounter * plot.second.TrailingOnlyCounter );
943  plot.second.leadingWithoutTrailing->setBinContent(3, HundredOverHitCounter * plot.second.CompleteCounter );
944  }
945 
946  for ( auto& plot : potPlots_ ) {
947  double HundredOverHitCounterPot = 0.;
948  if ( plot.second.HitCounter !=0 )
949  HundredOverHitCounterPot = 100. / plot.second.HitCounter;
950  plot.second.HPTDCErrorFlags_cumulative->setBinContent( 16, HundredOverHitCounterPot * plot.second.MHCounter );
951  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(1, HundredOverHitCounterPot * plot.second.LeadingOnlyCounter );
952  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(2, HundredOverHitCounterPot * plot.second.TrailingOnlyCounter );
953  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(3, HundredOverHitCounterPot * plot.second.CompleteCounter );
954 
955  plot.second.MHComprensive->Reset();
956  CTPPSDiamondDetId rpId(plot.first);
957  for ( auto& chPlot : channelPlots_ ) {
958  CTPPSDiamondDetId chId(chPlot.first);
959  if ( chId.arm() == rpId.arm() && chId.rp() == rpId.rp() ) {
960  plot.second.MHComprensive->Fill(chId.plane(), chId.channel(), chPlot.second.HPTDCErrorFlags->getBinContent( 16 ) );
961  }
962  }
963 
964  }
965 
966 }
967 
968 //----------------------------------------------------------------------------------------------------
969 
970 void
972 {}
973 
974 //----------------------------------------------------------------------------------------------------
975 
static const int CTPPS_FED_ID_56
void analyze(const edm::Event &, const edm::EventSetup &) override
OptoRx headers and footers.
Definition: TotemFEDInfo.h:17
plots related to one Diamond plane
T getParameter(std::string const &) const
plots related to one Diamond detector package
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
static const int CHANNEL_OF_VFAT_CLOCK
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
RunNumber_t run() const
Definition: RunBase.h:40
static const double DISPLAY_RESOLUTION_FOR_HITS_MM
static const int CTPPS_DIAMOND_NUM_OF_PLANES
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
std::vector< MonitorElement * > activity_per_bx
TH1F * getTH1F() const
void setPlane(uint32_t channel)
Reconstructed hit in diamond detectors.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void endRun(const edm::Run &, const edm::EventSetup &) override
void setChannel(uint32_t channel)
void channelName(std::string &name, NameFlag flag=nFull) const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondDigi > > tokenDigi_
CTPPSDiamondDQMSource(const edm::ParameterSet &)
bool getErrorId(unsigned short id) const
static const int CTPPS_NUM_OF_ARMS
plots related to the whole system
int bunchCrossing() const
Definition: EventBase.h:66
static const int CTPPS_DIAMOND_NUM_OF_CHANNELS
edm::EDGetTokenT< edm::DetSetVector< TotemRPLocalTrack > > tokenLocalTrack_
A track fit through a single RP.
MonitorElement * leadingWithoutTrailingCumulativePot
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void Fill(long long x)
static const int CTPPS_DIAMOND_STATION_ID
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
std::vector< std::pair< edm::EventRange, int > > runParameters_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
static const int CTPPS_NEAR_RP_ID
std::unordered_map< unsigned int, ChannelPlots > channelPlots_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:139
plots related to one Diamond channel
uint32_t plane() const
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
uint32_t arm() const
Definition: CTPPSDetId.h:52
bool isValid() const
Definition: HandleBase.h:74
TH2F * getTH2F() const
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondLocalTrack > > tokenDiamondTrack_
std::vector< MonitorElement * > stripTomographyAllFar
static const double HPTDC_BIN_WIDTH_NS
uint32_t channel() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
static const double INV_DISPLAY_RESOLUTION_FOR_HITS_MM
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
void planeName(std::string &name, NameFlag flag=nFull) const
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
std::unordered_map< unsigned int, PotPlots > potPlots_
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondRecHit > > tokenDiamondHit_
HLT enums.
static const int CTPPS_FAR_RP_ID
static const double SEC_PER_LUMI_SECTION
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
std::unordered_map< unsigned int, PlanePlots > planePlots_
std::vector< MonitorElement * > activity_per_bx
static const int CTPPS_DIAMOND_RP_ID
static std::string getHPTDCErrorName(const unsigned short id)
edm::EDGetTokenT< std::vector< TotemFEDInfo > > tokenFEDInfo_
static const int CTPPS_FED_ID_45
edm::EDGetTokenT< edm::DetSetVector< TotemVFATStatus > > tokenStatus_
Definition: event.py:1
Definition: Run.h:43
uint32_t rp() const
Definition: CTPPSDetId.h:74