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 
27 
30 
33 
38 
39 #include <string>
40 
41 //----------------------------------------------------------------------------------------------------
42 
43 
44 // Utility for efficiency computations
45 bool channelAlignedWithTrack( const CTPPSGeometry* geom, const CTPPSDiamondDetId& detid, const CTPPSDiamondLocalTrack& localTrack, const float tolerance=1) {
46  const DetGeomDesc* det = geom->getSensor( detid );
47  const float x_pos = det->translation().x(),
48  x_width = 2.0 * det->params().at( 0 ); // parameters stand for half the size
49  return
50  ( ( x_pos + 0.5 * x_width > localTrack.getX0() - localTrack.getX0Sigma() - tolerance
51  && x_pos + 0.5 * x_width < localTrack.getX0() + localTrack.getX0Sigma() + tolerance )
52  || ( x_pos - 0.5 * x_width > localTrack.getX0() - localTrack.getX0Sigma() - tolerance
53  && x_pos - 0.5 * x_width < localTrack.getX0() + localTrack.getX0Sigma() + tolerance )
54  || ( x_pos - 0.5 * x_width < localTrack.getX0() - localTrack.getX0Sigma() - tolerance
55  && x_pos + 0.5 * x_width > localTrack.getX0() + localTrack.getX0Sigma() + tolerance ) );
56 }
57 
58 
60 {
61  public:
63  ~CTPPSDiamondDQMSource() override;
64 
65  protected:
66  void dqmBeginRun( const edm::Run&, const edm::EventSetup& ) override;
67  void bookHistograms( DQMStore::IBooker&, const edm::Run&, const edm::EventSetup& ) override;
68  void analyze( const edm::Event&, const edm::EventSetup& ) override;
69  void beginLuminosityBlock( const edm::LuminosityBlock&, const edm::EventSetup& ) override;
70  void endLuminosityBlock( const edm::LuminosityBlock&, const edm::EventSetup& ) override;
71  void endRun( const edm::Run&, const edm::EventSetup& ) override;
72 
73  private:
74  // Constants
75  static const double SEC_PER_LUMI_SECTION; // Number of seconds per lumisection: used to compute hit rates in Hz
76  static const int CHANNEL_OF_VFAT_CLOCK; // Channel ID of the VFAT that contains clock data
77  static const double DISPLAY_RESOLUTION_FOR_HITS_MM; // Bin width of histograms showing hits and tracks (in mm)
79  static const double HPTDC_BIN_WIDTH_NS; // ns per HPTDC bin
80  static const int CTPPS_NUM_OF_ARMS;
81  static const int CTPPS_DIAMOND_STATION_ID;
82  static const int CTPPS_DIAMOND_RP_ID;
83  static const int CTPPS_PIXEL_STATION_ID;
84  static const int CTPPS_NEAR_RP_ID;
85  static const int CTPPS_FAR_RP_ID;
86  static const int CTPPS_DIAMOND_NUM_OF_PLANES;
88  static const int CTPPS_FED_ID_45;
89  static const int CTPPS_FED_ID_56;
90 
97 
101  std::vector< std::pair<edm::EventRange, int> > runParameters_;
103  unsigned int verbosity_;
104 
106  struct GlobalPlots
107  {
109  GlobalPlots( DQMStore::IBooker& ibooker );
110  };
111 
113 
115  struct PotPlots
116  {
117  MonitorElement* activity_per_bx_0_25 = nullptr;
118  MonitorElement* activity_per_bx_25_50 = nullptr;
119  MonitorElement* activity_per_bx_50_75 = nullptr;
120  std::vector< MonitorElement* > activity_per_bx;
121 
122  MonitorElement* hitDistribution2d = nullptr;
123  MonitorElement* hitDistribution2d_lumisection = nullptr;
124  MonitorElement* hitDistribution2dOOT = nullptr;
125  MonitorElement* hitDistribution2dOOT_le = nullptr;
126  MonitorElement* activePlanes = nullptr, *activePlanesInclusive = nullptr;
127 
128  MonitorElement* trackDistribution = nullptr;
129  MonitorElement* trackDistributionOOT = nullptr;
130 
131  MonitorElement* pixelTomographyAll_0_25 = nullptr;
132  MonitorElement* pixelTomographyAll_25_50 = nullptr;
133  MonitorElement* pixelTomographyAll_50_75 = nullptr;
134  std::vector< MonitorElement* > pixelTomographyAll;
135 
136  MonitorElement* leadingEdgeCumulative_both = nullptr, *leadingEdgeCumulative_all = nullptr, *leadingEdgeCumulative_le = nullptr, *trailingEdgeCumulative_te = nullptr;
137  MonitorElement* timeOverThresholdCumulativePot = nullptr, *leadingTrailingCorrelationPot = nullptr;
138  MonitorElement* leadingWithoutTrailingCumulativePot = nullptr;
139 
140  MonitorElement* ECCheck = nullptr;
141 
142  MonitorElement* HPTDCErrorFlags_2D = nullptr;
143  MonitorElement* MHComprensive = nullptr;
144 
145  // MonitorElement* clock_Digi1_le = nullptr;
146  // MonitorElement* clock_Digi1_te = nullptr;
147  // MonitorElement* clock_Digi3_le = nullptr;
148  // MonitorElement* clock_Digi3_te = nullptr;
149 
150  unsigned int HitCounter, MHCounter, LeadingOnlyCounter, TrailingOnlyCounter, CompleteCounter;
151 
152  std::map<int, int> effTriplecountingChMap;
153  std::map<int, int> effDoublecountingChMap;
154  MonitorElement* EfficiencyOfChannelsInPot = nullptr;
156 
157  PotPlots() {}
158  PotPlots( DQMStore::IBooker& ibooker, unsigned int id );
159  };
160 
161  std::unordered_map<unsigned int, PotPlots> potPlots_;
163 
165  struct PlanePlots
166  {
167  MonitorElement* digiProfileCumulativePerPlane = nullptr;
168  MonitorElement* hitProfile = nullptr;
169  MonitorElement* hit_multiplicity = nullptr;
170 
171  MonitorElement* pixelTomography_far = nullptr;
172  MonitorElement* EfficiencyWRTPixelsInPlane = nullptr;
173 
175 
177  PlanePlots( DQMStore::IBooker& ibooker, unsigned int id );
178  };
179 
180  std::unordered_map<unsigned int, PlanePlots> planePlots_;
181 
184  {
185  MonitorElement* activity_per_bx_0_25 = nullptr;
186  MonitorElement* activity_per_bx_25_50 = nullptr;
187  MonitorElement* activity_per_bx_50_75 = nullptr;
188  std::vector< MonitorElement* > activity_per_bx;
189 
191  MonitorElement* leadingEdgeCumulative_both = nullptr, *leadingEdgeCumulative_le = nullptr, *trailingEdgeCumulative_te = nullptr;
192  MonitorElement* TimeOverThresholdCumulativePerChannel = nullptr;
193  MonitorElement* LeadingTrailingCorrelationPerChannel = nullptr;
194  MonitorElement* leadingWithoutTrailing = nullptr;
195  MonitorElement* pixelTomography_far = nullptr;
196  MonitorElement* hit_rate = nullptr;
198 
199  unsigned int HitCounter, MHCounter, LeadingOnlyCounter, TrailingOnlyCounter, CompleteCounter;
200 
201  ChannelPlots() : hitsCounterPerLumisection( 0 ) {}
202  ChannelPlots( DQMStore::IBooker &ibooker, unsigned int id );
203  };
204 
205  std::unordered_map<unsigned int, ChannelPlots> channelPlots_;
206 };
207 
208 //----------------------------------------------------------------------------------------------------
209 
210 // Values for all constants
215 const double CTPPSDiamondDQMSource::HPTDC_BIN_WIDTH_NS = 25./1024;
226 
227 //----------------------------------------------------------------------------------------------------
228 
230 {
231  ibooker.setCurrentFolder( "CTPPS" );
232 }
233 
234 //----------------------------------------------------------------------------------------------------
235 
236 
237 CTPPSDiamondDQMSource::PotPlots::PotPlots( DQMStore::IBooker& ibooker, unsigned int id ): HitCounter(0), MHCounter(0), LeadingOnlyCounter(0), TrailingOnlyCounter(0), CompleteCounter(0), pixelTracksMap("Pixel track maps for efficiency", "Pixel track maps for efficiency", 25, 0, 25, 12, -2, 10 )
238 {
241  ibooker.setCurrentFolder( path );
242 
244 
245  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 );
247  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 );
249  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 );
251 
252  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, -0.5, 18.5 );
253  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, -0.5, 18.5 );
254  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, -0.5, 18.5 );
255  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, -0.5, 18.5 );
256  activePlanes = ibooker.book1D( "active planes", title+" active planes (per event);number of active planes", 6, -0.5, 5.5 );
257  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 );
258 
259  trackDistribution = ibooker.book1D( "tracks", title+" tracks;x (mm)", 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -0.5, 18.5 );
260  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, -0.5, 18.5 );
261 
262  pixelTomographyAll_0_25 = ibooker.book2D( "tomography pixel 0 25", title+" tomography with pixel 0 - 25 ns (all planes);x + 25*plane(mm);y (mm)", 100, 0, 100, 8, 0, 8 );
264  pixelTomographyAll_25_50 = ibooker.book2D( "tomography pixel 25 50", title+" tomography with pixel 25 - 50 ns (all planes);x + 25*plane(mm);y (mm)", 100, 0, 100, 8, 0, 8 );
266  pixelTomographyAll_50_75 = ibooker.book2D( "tomography pixel 50 75", title+" tomography with pixel 50 - 75 ns (all planes);x + 25*plane(mm);y (mm)", 100, 0, 100, 8, 0, 8 );
268 
269  leadingEdgeCumulative_both = ibooker.book1D( "leading edge (le and te)", title+" leading edge (le and te) (recHits); leading edge (ns)", 75, 0, 75 );
270  leadingEdgeCumulative_all = ibooker.book1D( "leading edge (all)", title+" leading edge (with or without te) (DIGIs); leading edge (ns)", 75, 0, 75 );
271  leadingEdgeCumulative_le = ibooker.book1D( "leading edge (le only)", title+" leading edge (le only) (DIGIs); leading edge (ns)", 75, 0, 75 );
272  trailingEdgeCumulative_te = ibooker.book1D( "trailing edge (te only)", title+" trailing edge (te only) (DIGIs); trailing edge (ns)", 75, 0, 75 );
273  timeOverThresholdCumulativePot = ibooker.book1D( "time over threshold", title+" time over threshold;time over threshold (ns)", 250, -25, 100 );
274  leadingTrailingCorrelationPot = ibooker.book2D( "leading trailing correlation", title+" leading trailing correlation;leading edge (ns);trailing edge (ns)", 75, 0, 75, 75, 0, 75 );
275 
276  leadingWithoutTrailingCumulativePot = ibooker.book1D( "event category", title+" leading edges without trailing;;%", 3, 0.5, 3.5 );
277  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel( 1, "Leading only" );
278  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel( 2, "Trailing only" );
279  leadingWithoutTrailingCumulativePot->getTH1F()->GetXaxis()->SetBinLabel( 3, "Both" );
280 
281  ECCheck = ibooker.book1D( "optorxEC(8bit) - vfatEC", title+" EC Error;optorxEC-vfatEC", 50,-25, 25 );
282 
283  HPTDCErrorFlags_2D = ibooker.book2D( "HPTDC Errors", title+" HPTDC Errors", 16, -0.5, 16.5, 9, -0.5, 8.5 );
284  for ( unsigned short error_index=1; error_index<16; ++error_index )
285  HPTDCErrorFlags_2D->getTH2F()->GetXaxis()->SetBinLabel( error_index, HPTDCErrorFlags::getHPTDCErrorName( error_index-1 ).c_str() );
286  HPTDCErrorFlags_2D->getTH2F()->GetXaxis()->SetBinLabel( 16, "Wrong EC" );
287 
288  int tmpIndex=0;
289  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel( ++tmpIndex, "DB 0 TDC 18" );
290  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel( ++tmpIndex, "DB 0 TDC 17" );
291  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel( ++tmpIndex, "DB 0 TDC 16" );
292  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel( ++tmpIndex, "DB 0 TDC 15" );
293  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel( ++tmpIndex, "DB 1 TDC 18" );
294  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel( ++tmpIndex, "DB 1 TDC 17" );
295  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel( ++tmpIndex, "DB 1 TDC 16" );
296  HPTDCErrorFlags_2D->getTH2F()->GetYaxis()->SetBinLabel( ++tmpIndex, "DB 1 TDC 15" );
297 
298  MHComprensive = ibooker.book2D( "MH in channels", title+" MH (%) in channels;plane number;ch number", 10, -0.5, 4.5, 14, -1, 13 );
299 
300  EfficiencyOfChannelsInPot = ibooker.book2D( "Efficiency in channels", title+" Efficiency (%) in channels (diamonds only);plane number;ch number", 10, -0.5, 4.5, 14, -1, 13 );
301 
302  // ibooker.setCurrentFolder( path+"/clock/" );
303  // clock_Digi1_le = ibooker.book1D( "clock1 leading edge", title+" clock1;leading edge (ns)", 250, 0, 25 );
304  // clock_Digi1_te = ibooker.book1D( "clock1 trailing edge", title+" clock1;trailing edge (ns)", 75, 0, 75 );
305  // clock_Digi3_le = ibooker.book1D( "clock3 leading edge", title+" clock3;leading edge (ns)", 250, 0, 25 );
306  // clock_Digi3_te = ibooker.book1D( "clock3 trailing edge", title+" clock3;trailing edge (ns)", 75, 0, 75 );
307 
308 }
309 
310 //----------------------------------------------------------------------------------------------------
311 
312 CTPPSDiamondDQMSource::PlanePlots::PlanePlots( DQMStore::IBooker& ibooker, unsigned int id ) : pixelTracksMapWithDiamonds("Pixel track maps for efficiency with coincidence", "Pixel track maps for efficiency with coincidence", 25, 0, 25, 12, -2, 10 )
313 {
316  ibooker.setCurrentFolder( path );
317 
319 
320  digiProfileCumulativePerPlane = ibooker.book1D( "digi profile", title+" digi profile; ch number", 12, -0.5, 11.5 );
321  hitProfile = ibooker.book1D( "hit profile", title+" hit profile;x (mm)", 19.*INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -0.5, 18.5 );
322  hit_multiplicity = ibooker.book1D( "channels per plane", title+" channels per plane; ch per plane", 13, -0.5, 12.5 );
323 
324  pixelTomography_far = ibooker.book2D( "tomography pixel", title+" tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, 0, 8 );
325  EfficiencyWRTPixelsInPlane = ibooker.book2D( "Efficiency wrt pixels", title+" Efficiency wrt pixels;x (mm);y (mm)", 25, 0, 25, 12, -2, 10 );
326 
327 }
328 
329 //----------------------------------------------------------------------------------------------------
330 
331 CTPPSDiamondDQMSource::ChannelPlots::ChannelPlots( DQMStore::IBooker& ibooker, unsigned int id ) : hitsCounterPerLumisection(0), HitCounter(0), MHCounter(0), LeadingOnlyCounter(0), TrailingOnlyCounter(0), CompleteCounter(0)
332 {
335  ibooker.setCurrentFolder( path );
336 
338 
339  leadingWithoutTrailing = ibooker.book1D( "event category", title+" Event Category;;%", 3, 0.5, 3.5 );
340  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel( 1, "Leading only" );
341  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel( 2, "Trailing only" );
342  leadingWithoutTrailing->getTH1F()->GetXaxis()->SetBinLabel( 3, "Full" );
343 
344  activity_per_bx_0_25 = ibooker.book1D( "activity per BX 0 25", title+" Activity per BX 0 - 25 ns;Event.BX", 500, -1.5, 498. + 0.5 );
346  activity_per_bx_25_50 = ibooker.book1D( "activity per BX 25 50", title+" Activity per BX 25 - 50 ns;Event.BX", 500, -1.5, 498. + 0.5 );
348  activity_per_bx_50_75 = ibooker.book1D( "activity per BX 50 75", title+" Activity per BX 50 - 75 ns;Event.BX", 500, -1.5, 498. + 0.5 );
350 
351  HPTDCErrorFlags = ibooker.book1D( "hptdc_Errors", title+" HPTDC Errors", 16, -0.5, 16.5 );
352  for ( unsigned short error_index=1; error_index<16; ++error_index )
353  HPTDCErrorFlags->getTH1F()->GetXaxis()->SetBinLabel( error_index, HPTDCErrorFlags::getHPTDCErrorName( error_index-1 ).c_str() );
354  HPTDCErrorFlags->getTH1F()->GetXaxis()->SetBinLabel( 16, "MH (%)" );
355 
356  leadingEdgeCumulative_both = ibooker.book1D( "leading edge (le and te)", title+" leading edge (recHits); leading edge (ns)", 75, 0, 75 );
357  leadingEdgeCumulative_le = ibooker.book1D( "leading edge (le only)", title+" leading edge (DIGIs); leading edge (ns)", 75, 0, 75 );
358  trailingEdgeCumulative_te = ibooker.book1D( "trailing edge (te only)", title+" trailing edge (te only) (DIGIs); trailing edge (ns)", 75, 0, 75 );
359  TimeOverThresholdCumulativePerChannel = ibooker.book1D( "time over threshold", title+" time over threshold;time over threshold (ns)", 75, -25, 50 );
360  LeadingTrailingCorrelationPerChannel = ibooker.book2D( "leading trailing correlation", title+" leading trailing correlation;leading edge (ns);trailing edge (ns)", 75, 0, 75, 75, 0, 75 );
361 
362  pixelTomography_far = ibooker.book2D( "tomography pixel", "tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, 0, 8 );
363 
364  hit_rate = ibooker.book1D( "hit rate", title+"hit rate;rate (Hz)", 40, 0, 20);
365 }
366 
367 //----------------------------------------------------------------------------------------------------
368 
370  tokenStatus_ ( consumes< edm::DetSetVector<TotemVFATStatus> > ( ps.getParameter<edm::InputTag>( "tagStatus" ) ) ),
371  tokenPixelTrack_ ( consumes< edm::DetSetVector<CTPPSPixelLocalTrack> > ( ps.getParameter<edm::InputTag>( "tagPixelLocalTracks" ) ) ),
372  tokenDigi_ ( consumes< edm::DetSetVector<CTPPSDiamondDigi> > ( ps.getParameter<edm::InputTag>( "tagDigi" ) ) ),
373  tokenDiamondHit_ ( consumes< edm::DetSetVector<CTPPSDiamondRecHit> > ( ps.getParameter<edm::InputTag>( "tagDiamondRecHits" ) ) ),
374  tokenDiamondTrack_( consumes< edm::DetSetVector<CTPPSDiamondLocalTrack> >( ps.getParameter<edm::InputTag>( "tagDiamondLocalTracks" ) ) ),
375  tokenFEDInfo_ ( consumes< std::vector<TotemFEDInfo> > ( ps.getParameter<edm::InputTag>( "tagFEDInfo" ) ) ),
376  excludeMultipleHits_ ( ps.getParameter<bool>( "excludeMultipleHits" ) ),
377  centralOOT_( -999 ),
378  verbosity_ ( ps.getUntrackedParameter<unsigned int>( "verbosity", 0 ) ),
379  EC_difference_56_( -500 ), EC_difference_45_( -500 )
380 {
381  for ( const auto& pset : ps.getParameter< std::vector<edm::ParameterSet> >( "offsetsOOT" ) ) {
382  runParameters_.emplace_back( std::make_pair( pset.getParameter<edm::EventRange>( "validityRange" ), pset.getParameter<int>( "centralOOT" ) ) );
383  }
384 }
385 
386 //----------------------------------------------------------------------------------------------------
387 
389 {}
390 
391 //----------------------------------------------------------------------------------------------------
392 
393 void
395 {
396  centralOOT_ = -999;
397  for ( const auto& oot : runParameters_ ) {
398  if ( edm::contains( oot.first, edm::EventID( iRun.run(), 0, 1 ) ) ) {
399  centralOOT_ = oot.second; break;
400  }
401  }
402 
403  // Get detector shifts from the geometry
405  iSetup.get<VeryForwardRealGeometryRecord>().get( geometry_ );
406  const CTPPSGeometry *geom = geometry_.product();
408  const DetGeomDesc* det = geom->getSensor( detid );
409  horizontalShiftOfDiamond_ = det->translation().x() - det->params().at( 0 );
410 
411  // Rough alignement of pixel detector for diamond thomography
413  if ( iRun.run()>300000 ) { //Pixel installed
414  det = geom->getSensor( pixid );
416  }
417 }
418 
419 
420 //----------------------------------------------------------------------------------------------------
421 
422 void
424 {
425  ibooker.cd();
426  ibooker.setCurrentFolder( "CTPPS" );
427 
428  globalPlot_= GlobalPlots( ibooker );
429 
430  for ( unsigned short arm = 0; arm < CTPPS_NUM_OF_ARMS; ++arm ) {
432  potPlots_[rpId] = PotPlots( ibooker, rpId );
433  for ( unsigned short pl = 0; pl < CTPPS_DIAMOND_NUM_OF_PLANES; ++pl ) {
435  planePlots_[plId] = PlanePlots( ibooker, plId);
436  for ( unsigned short ch = 0; ch < CTPPS_DIAMOND_NUM_OF_CHANNELS; ++ch ) {
438  channelPlots_[chId] = ChannelPlots( ibooker, chId );
439  }
440  }
441  }
442 }
443 
444 
445 //----------------------------------------------------------------------------------------------------
446 
447 void
449 {
450  for ( auto& plot : potPlots_ )
451  plot.second.hitDistribution2d_lumisection->Reset();
452 }
453 
454 //----------------------------------------------------------------------------------------------------
455 
456 void
458 {
459  // get event data
461  event.getByToken( tokenStatus_, diamondVFATStatus );
462 
464  event.getByToken( tokenPixelTrack_, pixelTracks );
465 
467  event.getByToken( tokenDigi_, diamondDigis );
468 
470  event.getByToken( tokenFEDInfo_, fedInfo );
471 
473  event.getByToken( tokenDiamondHit_, diamondRecHits );
474 
476  event.getByToken( tokenDiamondTrack_, diamondLocalTracks );
477 
479  iSetup.get<VeryForwardRealGeometryRecord>().get( geometry_ );
480 
481  // check validity
482  bool valid = true;
483  valid &= diamondVFATStatus.isValid();
484  valid &= diamondDigis.isValid();
485  valid &= fedInfo.isValid();
486 
487  if ( !valid ) {
488  if ( verbosity_ ) {
489  edm::LogProblem("CTPPSDiamondDQMSource")
490  << "ERROR in CTPPSDiamondDQMSource::analyze > some of the required inputs are not valid. Skipping this event.\n"
491  << " diamondVFATStatus.isValid = " << diamondVFATStatus.isValid() << "\n"
492  << " diamondDigis.isValid = " << diamondDigis.isValid() << "\n"
493  << " fedInfo.isValid = " << fedInfo.isValid();
494  }
495 
496  return;
497  }
498 
499  //------------------------------
500  // RP Plots
501  //------------------------------
502 
503  //------------------------------
504  // Correlation Plots
505  //------------------------------
506 
507  // Using CTPPSDiamondDigi
508  for ( const auto& digis : *diamondDigis ) {
509  const CTPPSDiamondDetId detId( digis.detId() );
510  CTPPSDiamondDetId detId_pot( digis.detId() );
511 
512  for ( const auto& digi : digis ) {
513  detId_pot.setPlane( 0 );
514  detId_pot.setChannel( 0 );
515  if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) continue;
516  if ( potPlots_.find( detId_pot ) == potPlots_.end() ) continue;
517  //Leading without trailing investigation
518  if ( digi.getLeadingEdge() != 0 || digi.getTrailingEdge() != 0 ) {
519  ++(potPlots_[detId_pot].HitCounter);
520  if ( digi.getLeadingEdge() != 0 ) {
521  potPlots_[detId_pot].leadingEdgeCumulative_all->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
522  }
523  if ( digi.getLeadingEdge() != 0 && digi.getTrailingEdge() == 0 ) {
524  ++(potPlots_[detId_pot].LeadingOnlyCounter);
525  potPlots_[detId_pot].leadingEdgeCumulative_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
526  }
527  if ( digi.getLeadingEdge() == 0 && digi.getTrailingEdge() != 0 ) {
528  ++(potPlots_[detId_pot].TrailingOnlyCounter);
529  potPlots_[detId_pot].trailingEdgeCumulative_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
530  }
531  if ( digi.getLeadingEdge() != 0 && digi.getTrailingEdge() != 0 ) {
532  ++(potPlots_[detId_pot].CompleteCounter);
533  potPlots_[detId_pot].leadingTrailingCorrelationPot->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge(), HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
534  }
535  }
536 
537  // HPTDC Errors
538  const HPTDCErrorFlags hptdcErrors = digi.getHPTDCErrorFlags();
539  if ( detId.channel() == 6 || detId.channel() == 7 ) // ch6 for HPTDC 0 and ch7 for HPTDC 1
540  {
541  int verticalIndex = 2*detId.plane() + (detId.channel() - 6);
542  for ( unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex )
543  if ( hptdcErrors.getErrorId( hptdcErrorIndex-1 ) ) potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill( hptdcErrorIndex, verticalIndex );
544  }
545  if ( digi.getMultipleHit() ) ++(potPlots_[detId_pot].MHCounter);
546  }
547  }
548 
549  // EC Errors
550  for ( const auto& vfat_status : *diamondVFATStatus ) {
551  const CTPPSDiamondDetId detId( vfat_status.detId() );
552  CTPPSDiamondDetId detId_pot( vfat_status.detId() );
553  detId_pot.setPlane( 0 );
554  detId_pot.setChannel( 0 );
555  for ( const auto& status : vfat_status ) {
556  if ( !status.isOK() ) continue;
557  if ( potPlots_.find(detId_pot) == potPlots_.end() ) continue;
558  if ( channelPlots_.find(detId) == channelPlots_.end() ) continue;
559 
560  // Check Event Number
561  for ( const auto& optorx : *fedInfo ) {
562  if ( detId.arm() == 1 && optorx.getFEDId() == CTPPS_FED_ID_56 ) {
563  potPlots_[detId_pot].ECCheck->Fill((int)((optorx.getLV1()& 0xFF)-((unsigned int) status.getEC() & 0xFF)) & 0xFF);
564  if ( ( static_cast<int>( ( optorx.getLV1() & 0xFF )-status.getEC() ) != EC_difference_56_ ) && ( static_cast<uint8_t>( ( optorx.getLV1() & 0xFF )-status.getEC() ) < 128 ) )
565  EC_difference_56_ = static_cast<int>( optorx.getLV1() & 0xFF )-( static_cast<unsigned int>( status.getEC() ) & 0xFF );
566  if ( EC_difference_56_ != 1 && EC_difference_56_ != -500 && std::abs(EC_difference_56_) < 127 )
567  {
568  if ( detId.channel() == 6 || detId.channel() == 7 ) potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill( 16, 2*detId.plane() + (detId.channel() - 6) );
569  if (verbosity_)
570  edm::LogProblem("CTPPSDiamondDQMSource") << "FED " << CTPPS_FED_ID_56 << ": ECError at EV: 0x"<< std::hex << optorx.getLV1()
571  << "\t\tVFAT EC: 0x"<< static_cast<unsigned int>( status.getEC() )
572  << "\twith ID: " << std::dec << detId
573  << "\tdiff: " << EC_difference_56_;
574  }
575  }
576  else if ( detId.arm() == 0 && optorx.getFEDId()== CTPPS_FED_ID_45 ) {
577  potPlots_[detId_pot].ECCheck->Fill((int)((optorx.getLV1()& 0xFF)-status.getEC()) & 0xFF);
578  if ( ( static_cast<int>( ( optorx.getLV1() & 0xFF )-status.getEC() ) != EC_difference_45_ ) && ( static_cast<uint8_t>( ( optorx.getLV1() & 0xFF )-status.getEC() ) < 128 ) )
579  EC_difference_45_ = static_cast<int>( optorx.getLV1() & 0xFF )-( static_cast<unsigned int>( status.getEC() ) & 0xFF );
580  if ( EC_difference_45_ != 1 && EC_difference_45_ != -500 && std::abs(EC_difference_45_) < 127 )
581  {
582  if ( detId.channel() == 6 || detId.channel() == 7 ) potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill( 16, 2*detId.plane() + (detId.channel() - 6) );
583  if (verbosity_)
584  edm::LogProblem("CTPPSDiamondDQMSource") << "FED " << CTPPS_FED_ID_45 << ": ECError at EV: 0x"<< std::hex << optorx.getLV1()
585  << "\t\tVFAT EC: 0x"<< static_cast<unsigned int>( status.getEC() )
586  << "\twith ID: " << std::dec << detId
587  << "\tdiff: " << EC_difference_45_;
588  }
589  }
590  }
591  }
592  }
593 
594  // Using CTPPSDiamondRecHit
595  std::unordered_map<unsigned int, std::set<unsigned int> > planes;
596  std::unordered_map<unsigned int, std::set<unsigned int> > planes_inclusive;
597 
598 
599  for ( const auto& rechits : *diamondRecHits ) {
600  CTPPSDiamondDetId detId_pot( rechits.detId() );
601  detId_pot.setPlane( 0 );
602  detId_pot.setChannel( 0 );
603  const CTPPSDiamondDetId detId( rechits.detId() );
604 
605  for ( const auto& rechit : rechits ) {
606  planes_inclusive[detId_pot].insert( detId.plane() );
607  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
608  if ( rechit.getToT() != 0 && centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_ )
609  planes[detId_pot].insert( detId.plane() );
610 
611  if ( potPlots_.find( detId_pot ) == potPlots_.end() ) continue;
612 
613  float UFSDShift = 0.0;
614  if ( rechit.getYWidth() < 3 ) UFSDShift = 0.5; // Display trick for UFSD that have 2 pixels with same X
615 
616  if ( rechit.getToT() != 0 && centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_ ) {
617  TH2F *hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F();
618  TAxis *hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
619  int startBin = hitHistoTmpYAxis->FindBin( rechit.getX() - horizontalShiftOfDiamond_ - 0.5*rechit.getXWidth() );
620  int numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
621  for ( int i=0; i<numOfBins; ++i) {
622  hitHistoTmp->Fill( detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin+i) );
623  }
624 
625  hitHistoTmp = potPlots_[detId_pot].hitDistribution2d_lumisection->getTH2F();
626  hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
627  startBin = hitHistoTmpYAxis->FindBin( rechit.getX() - horizontalShiftOfDiamond_ - 0.5*rechit.getXWidth() );
628  numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
629  for ( int i=0; i<numOfBins; ++i) {
630  hitHistoTmp->Fill( detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin+i) );
631  }
632 
633  }
634 
635  if ( rechit.getToT() != 0 ) {
636  // Both
637  potPlots_[detId_pot].leadingEdgeCumulative_both->Fill( rechit.getT() + 25*rechit.getOOTIndex() );
638  potPlots_[detId_pot].timeOverThresholdCumulativePot->Fill( rechit.getToT() );
639 
640  TH2F *hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT->getTH2F();
641  TAxis *hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis();
642  int startBin = hitHistoOOTTmpYAxis->FindBin( rechit.getX() - horizontalShiftOfDiamond_ - 0.5*rechit.getXWidth() );
643  int numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
644  for ( int i=0; i<numOfBins; ++i) {
645  hitHistoOOTTmp->Fill( detId.plane() + 0.25 * rechit.getOOTIndex(), hitHistoOOTTmpYAxis->GetBinCenter(startBin+i) );
646  }
647  }
648  else {
649  if ( rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING ) {
650  // Only leading
651  TH2F *hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT_le->getTH2F();
652  TAxis *hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis();
653  int startBin = hitHistoOOTTmpYAxis->FindBin( rechit.getX() - horizontalShiftOfDiamond_ - 0.5*rechit.getXWidth() );
654  int numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
655  for ( int i=0; i<numOfBins; ++i) {
656  hitHistoOOTTmp->Fill( detId.plane() + 0.25 * rechit.getOOTIndex(), hitHistoOOTTmpYAxis->GetBinCenter(startBin+i) );
657  }
658  }
659  }
660  if ( rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && rechit.getOOTIndex() < (int) potPlots_[detId_pot].activity_per_bx.size() )
661  potPlots_[detId_pot].activity_per_bx.at( rechit.getOOTIndex() )->Fill( event.bunchCrossing() );
662  }
663  }
664 
665  for ( const auto& plt : potPlots_ ) {
666  plt.second.activePlanes->Fill( planes[plt.first].size() );
667  plt.second.activePlanesInclusive->Fill( planes_inclusive[plt.first].size() );
668  }
669 
670  // Using CTPPSDiamondLocalTrack
671  for ( const auto& tracks : *diamondLocalTracks ) {
672  CTPPSDiamondDetId detId_pot( tracks.detId() );
673  detId_pot.setPlane( 0 );
674  detId_pot.setChannel( 0 );
675  const CTPPSDiamondDetId detId( tracks.detId() );
676 
677  for ( const auto& track : tracks ) {
678  if ( ! track.isValid() ) continue;
679  if ( track.getOOTIndex() == CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING ) continue;
680  if ( excludeMultipleHits_ && track.getMultipleHits() > 0 ) continue;
681  if ( potPlots_.find( detId_pot ) == potPlots_.end() ) continue;
682 
683  TH2F *trackHistoOOTTmp = potPlots_[detId_pot].trackDistributionOOT->getTH2F();
684  TAxis *trackHistoOOTTmpYAxis = trackHistoOOTTmp->GetYaxis();
685  int startBin = trackHistoOOTTmpYAxis->FindBin( track.getX0() - horizontalShiftOfDiamond_ - track.getX0Sigma() );
686  int numOfBins = 2*track.getX0Sigma()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
687  for ( int i=0; i<numOfBins; ++i) {
688  trackHistoOOTTmp->Fill( track.getOOTIndex(), trackHistoOOTTmpYAxis->GetBinCenter(startBin+i) );
689  }
690 
691  if ( centralOOT_ != -999 && track.getOOTIndex() == centralOOT_ ) {
692  TH1F *trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution->getTH1F();
693  int startBin = trackHistoInTimeTmp->FindBin( track.getX0() - horizontalShiftOfDiamond_ - track.getX0Sigma() );
694  int numOfBins = 2*track.getX0Sigma()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
695  for ( int i=0; i<numOfBins; ++i) {
696  trackHistoInTimeTmp->Fill( trackHistoInTimeTmp->GetBinCenter(startBin+i) );
697  }
698  }
699  }
700  }
701 
702  // Channel efficiency using CTPPSDiamondLocalTrack
703  for ( const auto& tracks : *diamondLocalTracks ) {
704  CTPPSDiamondDetId detId_pot( tracks.detId() );
705  detId_pot.setPlane( 0 );
706  detId_pot.setChannel( 0 );
707  for ( const auto& track : tracks ) {
708  // Find hits and planes in the track
709  int numOfHits = 0;
710  std::set<int> planesInTrackSet;
711  for ( const auto& vec : *diamondRecHits ) {
712  const CTPPSDiamondDetId detid( vec.detId() );
713  if ( detid.arm() != detId_pot.arm() ) continue;
714 
715  for ( const auto& hit : vec ) {
716  // first check if the hit contributes to the track
717  if ( track.containsHit(hit) ) {
718  ++numOfHits;
719  planesInTrackSet.insert(detid.plane());
720  }
721  }
722  }
723 
724  if ( numOfHits > 0 && numOfHits <= 10 && planesInTrackSet.size() > 2 ) {
725  for ( int plane=0; plane<4; ++plane ) {
726  for ( int channel=0; channel<12; ++channel ) {
727  int map_index = plane*100 + channel;
728  if ( potPlots_[detId_pot].effDoublecountingChMap.find( map_index ) == potPlots_[detId_pot].effDoublecountingChMap.end() ) {
729  potPlots_[detId_pot].effTriplecountingChMap[map_index] = 0;
730  potPlots_[detId_pot].effDoublecountingChMap[map_index] = 0;
731  }
732  CTPPSDiamondDetId detId( detId_pot.arm(), CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, plane, channel);
733  if ( channelAlignedWithTrack( geometry_.product(), detId, track, 0.2) ) {
734  // Channel should fire
735  ++(potPlots_[detId_pot].effDoublecountingChMap[map_index]);
736  for ( const auto& rechits : *diamondRecHits ) {
737  CTPPSDiamondDetId detId_hit( rechits.detId() );
738  if ( detId_hit == detId ) {
739  for ( const auto& rechit : rechits ) {
740  if ( track.containsHit( rechit, 1 ) ) {
741  // Channel fired
742  ++(potPlots_[detId_pot].effTriplecountingChMap[map_index]);
743  }
744  }
745  }
746  }
747  }
748  }
749  }
750  }
751  }
752  }
753 
754  // Tomography of diamonds using pixel
755  for ( const auto& rechits : *diamondRecHits ) {
756  CTPPSDiamondDetId detId_pot( rechits.detId() );
757  detId_pot.setPlane( 0 );
758  detId_pot.setChannel( 0 );
759  const CTPPSDiamondDetId detId( rechits.detId() );
760  for ( const auto& rechit : rechits ) {
761  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
762  if ( rechit.getToT() == 0 ) continue;
763  if ( !pixelTracks.isValid() ) continue;
764  if ( potPlots_.find( detId_pot ) == potPlots_.end() ) continue;
765 
766  for ( const auto& ds : *pixelTracks ) {
767  if ( ds.size() > 1 ) continue;
768  const CTPPSPixelDetId pixId( ds.detId() );
769  if ( pixId.station() != CTPPS_PIXEL_STATION_ID || pixId.rp() != CTPPS_FAR_RP_ID ) continue;
770  for ( const auto& lt : ds ) {
771  if ( lt.isValid() && pixId.arm() == detId_pot.arm() ) {
772  if ( rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && rechit.getOOTIndex() < (int) potPlots_[detId_pot].pixelTomographyAll.size() && rechit.getOOTIndex() >= 0 && lt.getX0() - horizontalShiftBwDiamondPixels_ < 24 )
773  potPlots_[detId_pot].pixelTomographyAll.at( rechit.getOOTIndex() )->Fill( lt.getX0() - horizontalShiftBwDiamondPixels_ + 25*detId.plane(), lt.getY0() );
774  }
775  }
776  }
777  }
778  }
779 
780  //------------------------------
781  // Clock Plots
782  //------------------------------
783  // Commented out to save space in the DQM files, but code should be kept
784  // for ( const auto& digis : *diamondDigis ) {
785  // const CTPPSDiamondDetId detId( digis.detId() );
786  // CTPPSDiamondDetId detId_pot( digis.detId() );
787  // if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) {
788  // detId_pot.setPlane( 0 );
789  // detId_pot.setChannel( 0 );
790  // for ( const auto& digi : digis ) {
791  // if ( digi.getLeadingEdge() != 0 ) {
792  // if ( detId.plane() == 1 ) {
793  // potPlots_[detId_pot].clock_Digi1_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
794  // potPlots_[detId_pot].clock_Digi1_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
795  // }
796  // if ( detId.plane() == 3 ) {
797  // potPlots_[detId_pot].clock_Digi3_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
798  // potPlots_[detId_pot].clock_Digi3_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
799  // }
800  // }
801  // }
802  // }
803  // }
804 
805  //------------------------------
806  // Plane Plots
807  //------------------------------
808 
809  // Using CTPPSDiamondDigi
810  std::unordered_map<unsigned int, unsigned int> channelsPerPlane;
811  for ( const auto& digis : *diamondDigis ) {
812  const CTPPSDiamondDetId detId( digis.detId() );
813  CTPPSDiamondDetId detId_plane( digis.detId() );
814  for ( const auto& digi : digis ) {
815  detId_plane.setChannel( 0 );
816  if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) continue;
817  if ( planePlots_.find( detId_plane ) == planePlots_.end() ) continue;
818 
819  if ( digi.getLeadingEdge() != 0 ) {
820  planePlots_[detId_plane].digiProfileCumulativePerPlane->Fill( detId.channel() );
821  if ( channelsPerPlane.find(detId_plane) != channelsPerPlane.end() ) channelsPerPlane[detId_plane]++;
822  else channelsPerPlane[detId_plane] = 0;
823  }
824  }
825  }
826 
827  for ( const auto& plt : channelsPerPlane ) {
828  planePlots_[plt.first].hit_multiplicity->Fill( plt.second );
829  }
830 
831  // Using CTPPSDiamondRecHit
832  for ( const auto& rechits : *diamondRecHits ) {
833  CTPPSDiamondDetId detId_plane( rechits.detId() );
834  detId_plane.setChannel( 0 );
835  for ( const auto& rechit : rechits ) {
836  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
837  if ( rechit.getToT() == 0 ) continue;
838  if ( planePlots_.find( detId_plane ) != planePlots_.end() ) {
839  if ( centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_ ) {
840  TH1F *hitHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F();
841  int startBin = hitHistoTmp->FindBin( rechit.getX() - horizontalShiftOfDiamond_ - 0.5*rechit.getXWidth() );
842  int numOfBins = rechit.getXWidth()*INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
843  for ( int i=0; i<numOfBins; ++i) {
844  hitHistoTmp->Fill( hitHistoTmp->GetBinCenter(startBin+i) );
845  }
846  }
847  }
848  }
849  }
850 
851 
852  //Tomography of diamonds using pixel and Efficiency WRT Pixels
853  for ( const auto& ds : *pixelTracks ) {
854  const CTPPSPixelDetId pixId( ds.detId() );
855  if ( pixId.station() != CTPPS_PIXEL_STATION_ID || pixId.rp() != CTPPS_FAR_RP_ID ) continue;
856  if ( ds.size() > 1 ) continue;
857  for ( const auto& lt : ds ) {
858  if ( lt.isValid() ) {
859  // For efficieny
861  potPlots_[detId_pot].pixelTracksMap.Fill( lt.getX0() - horizontalShiftBwDiamondPixels_, lt.getY0() );
862 
863  std::set< CTPPSDiamondDetId > planesWitHits_set;
864  for ( const auto& rechits : *diamondRecHits ) {
865  CTPPSDiamondDetId detId_plane( rechits.detId() );
866  detId_plane.setChannel( 0 );
867  for ( const auto& rechit : rechits ) {
868  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
869  if ( rechit.getOOTIndex() == CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING || rechit.getToT() == 0 ) continue;
870  if ( planePlots_.find(detId_plane) == planePlots_.end() ) continue;
871  if ( pixId.arm() == detId_plane.arm() && lt.getX0() - horizontalShiftBwDiamondPixels_ < 24 ) {
872  planePlots_[detId_plane].pixelTomography_far->Fill( lt.getX0() - horizontalShiftBwDiamondPixels_ + 25*rechit.getOOTIndex(), lt.getY0() );
873  if ( centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_ ) planesWitHits_set.insert( detId_plane );
874  }
875 
876  }
877  }
878 
879  for (auto& planeId : planesWitHits_set)
880  planePlots_[planeId].pixelTracksMapWithDiamonds.Fill( lt.getX0() - horizontalShiftBwDiamondPixels_, lt.getY0() );
881 
882  }
883 
884  }
885  }
886 
887 
888  //------------------------------
889  // Channel Plots
890  //------------------------------
891 
892  // digi profile cumulative
893  for ( const auto& digis : *diamondDigis ) {
894  const CTPPSDiamondDetId detId( digis.detId() );
895  for ( const auto& digi : digis ) {
896  if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) continue;
897  if ( channelPlots_.find( detId ) != channelPlots_.end() ) {
898  // HPTDC Errors
899  const HPTDCErrorFlags hptdcErrors = digi.getHPTDCErrorFlags();
900  for ( unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex )
901  if ( hptdcErrors.getErrorId( hptdcErrorIndex-1 ) ) channelPlots_[detId].HPTDCErrorFlags->Fill( hptdcErrorIndex );
902  if ( digi.getMultipleHit() ) ++(channelPlots_[detId].MHCounter);
903 
904  // Check dropped trailing edges
905  if ( digi.getLeadingEdge() != 0 || digi.getTrailingEdge() != 0 ) {
906  ++(channelPlots_[detId].HitCounter);
907  if ( digi.getLeadingEdge() != 0 && digi.getTrailingEdge() == 0 ) {
908  ++(channelPlots_[detId].LeadingOnlyCounter);
909  channelPlots_[detId].leadingEdgeCumulative_le->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge() );
910  }
911  if ( digi.getLeadingEdge() == 0 && digi.getTrailingEdge() != 0 ) {
912  ++(channelPlots_[detId].TrailingOnlyCounter);
913  channelPlots_[detId].trailingEdgeCumulative_te->Fill( HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
914  }
915  if ( digi.getLeadingEdge() != 0 && digi.getTrailingEdge() != 0 ) {
916  ++(channelPlots_[detId].CompleteCounter);
917  channelPlots_[detId].LeadingTrailingCorrelationPerChannel->Fill( HPTDC_BIN_WIDTH_NS * digi.getLeadingEdge(), HPTDC_BIN_WIDTH_NS * digi.getTrailingEdge() );
918  }
919  }
920  }
921  }
922  }
923 
924  // Using CTPPSDiamondRecHit
925  for ( const auto& rechits : *diamondRecHits ) {
926  CTPPSDiamondDetId detId( rechits.detId() );
927  for ( const auto& rechit : rechits ) {
928  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
929  if ( channelPlots_.find( detId ) != channelPlots_.end() ) {
930  if ( rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && rechit.getToT() != 0 ) {
931  channelPlots_[detId].leadingEdgeCumulative_both->Fill( rechit.getT() + 25*rechit.getOOTIndex() );
932  channelPlots_[detId].TimeOverThresholdCumulativePerChannel->Fill( rechit.getToT() );
933  }
934  ++(channelPlots_[detId].hitsCounterPerLumisection);
935  }
936 
937  if ( rechit.getOOTIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && rechit.getOOTIndex() < (int) channelPlots_[detId].activity_per_bx.size() )
938  channelPlots_[detId].activity_per_bx.at( rechit.getOOTIndex() )->Fill( event.bunchCrossing() );
939  }
940 
941  }
942 
943  // Tomography of diamonds using pixel
944  for ( const auto& rechits : *diamondRecHits ) {
945  const CTPPSDiamondDetId detId( rechits.detId() );
946  for ( const auto& rechit : rechits ) {
947  if ( excludeMultipleHits_ && rechit.getMultipleHits() > 0 ) continue;
948  if ( rechit.getOOTIndex() == CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING || rechit.getToT() == 0 ) continue;
949  if ( !pixelTracks.isValid() ) continue;
950  if (channelPlots_.find(detId) == channelPlots_.end()) continue;
951 
952  for ( const auto& ds : *pixelTracks ) {
953  const CTPPSPixelDetId pixId( ds.detId() );
954  if ( pixId.station() != CTPPS_PIXEL_STATION_ID || pixId.rp() != CTPPS_FAR_RP_ID ) continue;
955  if ( ds.size() > 1 ) continue;
956  for ( const auto& lt : ds ) {
957  if ( lt.isValid() && pixId.arm() == detId.arm() && lt.getX0() - horizontalShiftBwDiamondPixels_ < 24 )
958  channelPlots_[detId].pixelTomography_far->Fill( lt.getX0() - horizontalShiftBwDiamondPixels_ + 25*rechit.getOOTIndex(), lt.getY0() );
959  }
960  }
961  }
962  }
963 
964 }
965 
966 //----------------------------------------------------------------------------------------------------
967 
968 void
970 {
971  for ( auto& plot : channelPlots_ ) {
972  if ( plot.second.hitsCounterPerLumisection != 0 ) {
973  plot.second.hit_rate->Fill( (double) plot.second.hitsCounterPerLumisection / SEC_PER_LUMI_SECTION );
974  }
975  plot.second.hitsCounterPerLumisection = 0;
976 
977  double HundredOverHitCounter = .0;
978  if ( plot.second.HitCounter != 0 )
979  HundredOverHitCounter = 100. / plot.second.HitCounter;
980  plot.second.HPTDCErrorFlags->setBinContent( 16, HundredOverHitCounter * plot.second.MHCounter );
981  plot.second.leadingWithoutTrailing->setBinContent(1, HundredOverHitCounter * plot.second.LeadingOnlyCounter );
982  plot.second.leadingWithoutTrailing->setBinContent(2, HundredOverHitCounter * plot.second.TrailingOnlyCounter );
983  plot.second.leadingWithoutTrailing->setBinContent(3, HundredOverHitCounter * plot.second.CompleteCounter );
984  }
985 
986  for ( auto& plot : potPlots_ ) {
987  double HundredOverHitCounterPot = 0.;
988  if ( plot.second.HitCounter !=0 )
989  HundredOverHitCounterPot = 100. / plot.second.HitCounter;
990  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(1, HundredOverHitCounterPot * plot.second.LeadingOnlyCounter );
991  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(2, HundredOverHitCounterPot * plot.second.TrailingOnlyCounter );
992  plot.second.leadingWithoutTrailingCumulativePot->setBinContent(3, HundredOverHitCounterPot * plot.second.CompleteCounter );
993 
994  plot.second.MHComprensive->Reset();
995  CTPPSDiamondDetId rpId(plot.first);
996  for ( auto& chPlot : channelPlots_ ) {
997  CTPPSDiamondDetId chId(chPlot.first);
998  if ( chId.arm() == rpId.arm() && chId.rp() == rpId.rp() ) {
999  plot.second.MHComprensive->Fill(chId.plane(), chId.channel(), chPlot.second.HPTDCErrorFlags->getBinContent( 16 ) );
1000  }
1001  }
1002 
1003  }
1004 
1005  // Efficiencies of single channels
1006  for ( auto& plot : potPlots_ ) {
1007  plot.second.EfficiencyOfChannelsInPot->Reset();
1008  for ( auto& element : plot.second.effTriplecountingChMap ) {
1009  if ( plot.second.effDoublecountingChMap[ element.first ] > 0) {
1010  int plane = element.first / 100;
1011  int channel = element.first % 100;
1012  double counted = element.second;
1013  double total = plot.second.effDoublecountingChMap[ element.first ];
1014  double efficiency = counted / total;
1015 // double error = std::sqrt( efficiency * ( 1 - efficiency ) / total );
1016 
1017  plot.second.EfficiencyOfChannelsInPot->Fill(plane, channel, 100*efficiency);
1018  }
1019  }
1020  }
1021 
1022  // Efficeincy wrt pixels //TODO
1023  for ( auto& plot : planePlots_ ) {
1024  TH2F *hitHistoTmp = plot.second.EfficiencyWRTPixelsInPlane->getTH2F();
1025 
1026  CTPPSDiamondDetId detId_pot( plot.first );
1027  detId_pot.setPlane( 0 );
1028 
1029  hitHistoTmp->Divide( &(plot.second.pixelTracksMapWithDiamonds), &(potPlots_[detId_pot].pixelTracksMap) );
1030  }
1031 }
1032 
1033 //----------------------------------------------------------------------------------------------------
1034 
1035 void
1037 {}
1038 
1039 //----------------------------------------------------------------------------------------------------
1040 
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
const double tolerance
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
Event setup record containing the real (actual) geometry information.
MonitorElement * leadingWithoutTrailingCumulativePot
static const int CTPPS_PIXEL_STATION_ID
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static const int CTPPS_DIAMOND_STATION_ID
const DetGeomDesc * getSensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
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_
Geometrical description of a sensor.
Definition: DetGeomDesc.h:37
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
DDTranslation translation() const
Definition: DetGeomDesc.h:84
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:139
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelLocalTrack > > tokenPixelTrack_
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_
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:33
static const double HPTDC_BIN_WIDTH_NS
uint32_t channel() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
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
bool channelAlignedWithTrack(const CTPPSGeometry *geom, const CTPPSDiamondDetId &detid, const CTPPSDiamondLocalTrack &localTrack, const float tolerance=1)
std::unordered_map< unsigned int, PotPlots > potPlots_
static constexpr int TIMESLICE_WITHOUT_LEADING
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondRecHit > > tokenDiamondHit_
HLT enums.
std::vector< MonitorElement * > pixelTomographyAll
static const int CTPPS_FAR_RP_ID
T get() const
Definition: EventSetup.h:63
static const double SEC_PER_LUMI_SECTION
std::vector< double > params() const
Definition: DetGeomDesc.h:89
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
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< edm::DetSetVector< TotemVFATStatus > > tokenStatus_
Definition: event.py:1
Definition: Run.h:44
uint32_t rp() const
Definition: CTPPSDetId.h:74