CMS 3D CMS Logo

DTBunchCrossingCleaner.cc
Go to the documentation of this file.
1 #include <algorithm>
8 
12 
13 using namespace L1TMuon;
14 
15 namespace {
16  typedef edm::ParameterSet PSet;
17 }
18 
20  bx_window_size(ps.getParameter<int>("bxWindowSize")) {
21 }
22 
24 clean( const TriggerPrimitiveCollection& inlist ) const {
25  TriggerPrimitiveCollection leftovers = inlist;
27 
28  auto tpin = inlist.cbegin();
29  auto inend = inlist.cend();
30  for( ; tpin != inend; ++tpin ) {
31  const TriggerPrimitive::DTData data = tpin->getDTData();
32 
33  // automatically add well matched tracks
34  if( data.qualityCode != -1 && data.theta_quality != -1) {
35  outlist.push_back(*tpin);
36  auto toerase = std::find(leftovers.begin(), leftovers.end(), *tpin);
37  if( toerase != leftovers.end() ) {
38  leftovers.erase(toerase);
39  }
40  }
41 
42  // clean up phi/theta digis split across a BX
43  // key off of the phi digis since they are of higher quality
44  if( data.qualityCode != -1 && data.theta_quality == -1) {
45  auto tp_bx = leftovers.cbegin();
46  auto tp_bx_end = leftovers.cend();
47  for( ; tp_bx != tp_bx_end; ++tp_bx ) {
48  if( *tp_bx == *tpin ) continue;
49  const TriggerPrimitive::DTData bx_data = tp_bx->getDTData();
50  // look in-window and match to the segment number
51  // requiring that we find a theta-segment with no phi info
52  if( std::abs(bx_data.bx - data.bx) <= bx_window_size &&
53  bx_data.qualityCode == -1 && bx_data.theta_quality != -1 &&
54  data.segment_number == bx_data.segment_number ) {
55  // we need spoof the Digis used to create the individual objects
56  L1MuDTChambPhDigi phi_digi(data.bx,
57  data.wheel,
58  data.sector,
59  data.station,
60  data.radialAngle,
61  data.bendingAngle,
62  data.qualityCode,
63  data.Ts2TagCode,
64  data.BxCntCode);
65  int qual[7], position[7];
66  for( int i = 0; i < 7; ++i ) {
67  qual[i] = 0;
68  position[i] = 0;
69  if( bx_data.theta_bti_group == i ) {
70  qual[i] = bx_data.theta_quality;
71  position[i] = bx_data.segment_number;
72  }
73  }
74  L1MuDTChambThDigi the_digi(data.bx,
75  data.wheel,
76  data.sector,
77  data.station,
78  position,
79  qual);
80 
81  DTChamberId the_id = tpin->detId<DTChamberId>();
82  TriggerPrimitive newtp(the_id,
83  phi_digi,
84  the_digi,
85  bx_data.theta_bti_group);
86 
87  outlist.push_back(newtp);
88  // remove these primitives from the leftovers list
89  auto phierase = std::find(leftovers.begin(), leftovers.end(), *tpin);
90  auto theerase = std::find(leftovers.begin(),leftovers.end(),*tp_bx);
91  if( phierase != leftovers.end() ) {
92  leftovers.erase(phierase);
93  }
94  if( theerase != leftovers.end() ) {
95  leftovers.erase(theerase);
96  }
97  break; // do not look for further matches!
98  }
99  }
100  }
101  }
102  // re-insert any un-used trigger primitives
103  auto lo_tp = leftovers.cbegin();
104  auto lo_end = leftovers.cend();
105  for( ; lo_tp != lo_end; ++lo_tp ) {
106  outlist.push_back(*lo_tp);
107  }
108  return outlist;
109 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< TriggerPrimitive > TriggerPrimitiveCollection
edm::ParameterSet PSet
Definition: DiagMaker.cc:74
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DTBunchCrossingCleaner(const edm::ParameterSet &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static int position[264][3]
Definition: ReadPGInfo.cc:509
TriggerPrimitiveCollection clean(const TriggerPrimitiveCollection &) const