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