CMS 3D CMS Logo

L1MuDTEUX.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTEUX
4 //
5 // Description: Extrapolator
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister CERN EP
11 //
12 //--------------------------------------------------
13 
14 //-----------------------
15 // This Class's Header --
16 //-----------------------
17 
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 
24 #include <iostream>
25 
26 //-------------------------------
27 // Collaborating Class Headers --
28 //-------------------------------
29 
39 
40 using namespace std;
41 
42 // --------------------------------
43 // class L1MuDTEUX
44 //---------------------------------
45 
46 //----------------
47 // Constructors --
48 //----------------
49 
51  : m_sp(sp),
52  m_seu(seu),
53  m_id(id),
54  m_result(false),
55  m_quality(0),
56  m_address(15),
57  m_start(nullptr),
58  m_target(nullptr),
59  theExtFilter(sp.tf().config()->getExtTSFilter()),
60  nbit_phi(sp.tf().config()->getNbitsExtPhi()),
61  nbit_phib(sp.tf().config()->getNbitsExtPhib()) {}
62 
63 //--------------
64 // Destructor --
65 //--------------
66 
68 
69 //--------------
70 // Operations --
71 //--------------
72 
73 //
74 // Equal operator
75 //
76 bool L1MuDTEUX::operator==(const L1MuDTEUX& eux) const {
77  if (m_id != eux.id())
78  return false;
79  if (m_result != eux.result())
80  return false;
81  if (m_quality != eux.quality())
82  return false;
83  if (m_address != eux.address())
84  return false;
85  return true;
86 }
87 
88 //
89 // run EUX
90 //
91 void L1MuDTEUX::run(const L1MuDTExtLut& extLUTs, const L1MuDTTFParameters& pars) {
92  const bool debug4 = m_sp.tf().config()->Debug(4);
93  if (debug4)
94  cout << "Run EUX " << m_id << endl;
95  if (debug4)
96  cout << "start : " << *m_start << endl;
97  if (debug4)
98  cout << "target : " << *m_target << endl;
99 
100  if (m_start == nullptr || m_target == nullptr) {
101  if (debug4)
102  cout << "Error: EUX has no data loaded" << endl;
103  return;
104  }
105 
106  // start sector
107  int sector_st = m_start->sector();
108 
109  // target sector
110  int sector_ta = m_target->sector();
111 
112  // get index of look-up table
113  int lut_idx = m_seu.ext();
114  if (abs(m_target->wheel()) == 3) {
115  switch (m_seu.ext()) {
116  case EX13: {
117  lut_idx = EX15;
118  break;
119  }
120  case EX23: {
121  lut_idx = EX25;
122  break;
123  }
124  default: {
125  lut_idx = m_seu.ext();
126  break;
127  }
128  }
129  }
130 
131  if (m_sp.tf().config()->Debug(5))
132  cout << "EUX : using look-up table : " << static_cast<Extrapolation>(lut_idx) << endl;
133 
134  // Extrapolation TS quality filter
135  int qcut = 0;
136  if (m_seu.ext() == EX12)
137  qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
138  if (m_seu.ext() == EX13)
139  qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
140  if (m_seu.ext() == EX14)
141  qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
142  if (m_seu.ext() == EX21)
143  qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
144  if (m_seu.ext() == EX23)
145  qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
146  if (m_seu.ext() == EX24)
147  qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
148  if (m_seu.ext() == EX34)
149  qcut = pars.get_soc_qcut_st4(m_sp.id().wheel(), m_sp.id().sector());
150 
151  if (m_start->quality() < qcut)
152  return;
153 
154  // calculate bit shift
155  int sh_phi = 12 - nbit_phi;
156  int sh_phib = 10 - nbit_phib;
157 
158  int phi_target = m_target->phi() >> sh_phi;
159  int phi_start = m_start->phi() >> sh_phi;
160  int phib_start = l1t::bitShift((m_start->phib() >> sh_phib), sh_phib);
161  if (phib_start < 0)
162  phib_start += (1 << sh_phib) - 1;
163 
164  // compute difference in phi
165  int diff = phi_target - phi_start;
166 
167  // get low and high values from look-up table
168  // and add offset (30 degrees ) for extrapolation to adjacent sector
169  int offset = -2144 >> sh_phi;
170  offset *= sec_mod(sector_ta - sector_st);
171  int low = extLUTs.getLow(lut_idx, phib_start);
172  int high = extLUTs.getHigh(lut_idx, phib_start);
173  if (low < 0)
174  low += (1 << sh_phi) - 1;
175  if (high < 0)
176  high += (1 << sh_phi) - 1;
177  low = (low >> sh_phi) + offset;
178  high = (high >> sh_phi) + offset;
179 
180  int phi_offset = phi_target - offset;
181  if ((lut_idx == EX34) || (lut_idx == EX21))
182  phi_offset = phi_start + offset;
183  if (phi_offset >= (1 << (nbit_phi - 1)) - 1)
184  return;
185  if (phi_offset < -(1 << (nbit_phi - 1)) + 1)
186  return;
187 
188  // is phi-difference within the extrapolation window?
189  bool openlut = pars.get_soc_openlut_extr(m_sp.id().wheel(), m_sp.id().sector());
190  if ((diff >= low && diff <= high) || m_sp.tf().config()->getopenLUTs() || openlut) {
191  m_result = true;
192  int qual_st = m_start->quality();
193  int qual_ta = m_target->quality();
194  if (m_seu.ext() == EX34 || m_seu.ext() == EX21) {
195  m_quality = (qual_st == 7) ? 0 : qual_st + 1;
196  } else {
197  m_quality = (qual_ta == 7) ? 0 : qual_ta + 1;
198  }
199  m_address = m_id;
200  }
201 
202  if (m_sp.tf().config()->Debug(5))
203  cout << "diff : " << low << " " << diff << " " << high << " : " << m_result << " " << endl;
204 }
205 
206 //
207 // load data into EUX
208 //
209 void L1MuDTEUX::load(const L1MuDTTrackSegPhi* start_ts, const L1MuDTTrackSegPhi* target_ts) {
210  m_start = start_ts;
211  m_target = target_ts;
212 
213  // in case of EX34 and EX21 exchange start and target
214  if ((m_seu.ext() == EX34) || (m_seu.ext() == EX21)) {
215  m_start = target_ts;
216  m_target = start_ts;
217  }
218 }
219 
220 //
221 // reset this EUX
222 //
223 
225  m_result = false;
226  m_quality = 0;
227  m_address = 15;
228 
229  m_start = nullptr;
230  m_target = nullptr;
231 }
232 
233 //
234 // return pointer to start and target track segment
235 //
236 pair<const L1MuDTTrackSegPhi*, const L1MuDTTrackSegPhi*> L1MuDTEUX::ts() const {
237  return pair<const L1MuDTTrackSegPhi*, const L1MuDTTrackSegPhi*>(m_start, m_target);
238 }
239 
240 //
241 // symmetric modulo function for sectors
242 // output values in the range -6 to +5
243 //
244 int L1MuDTEUX::sec_mod(int sector) const {
245  int new_sector = sector % 12;
246  if (new_sector >= 6)
247  new_sector = new_sector - 12;
248  if (new_sector < -6)
249  new_sector = new_sector + 12;
250 
251  return new_sector;
252 }
bool result() const
return extrapolation result
Definition: L1MuDTEUX.h:93
int wheel() const
return wheel
int wheel() const
return wheel number
std::pair< const L1MuDTTrackSegPhi *, const L1MuDTTrackSegPhi * > ts() const
return pointer to start and target track segment
Definition: L1MuDTEUX.cc:236
const L1MuDTTrackFinder & tf() const
return reference to barrel MTTF
bool getopenLUTs() const
bool m_result
Definition: L1MuDTEUX.h:110
int getLow(int ext_ind, int address) const
get low_value for a given address
int sector() const
return sector number
void reset()
reset Extrapolator
Definition: L1MuDTEUX.cc:224
Definition: config.py:1
unsigned short int get_soc_qcut_st2(int wh, int sc) const
int phib() const
return phib
const L1MuDTSEU & m_seu
Definition: L1MuDTEUX.h:107
unsigned short int get_soc_qcut_st1(int wh, int sc) const
void load(const L1MuDTTrackSegPhi *start_ts, const L1MuDTTrackSegPhi *target_ts)
load data into EUX
Definition: L1MuDTEUX.cc:209
unsigned short int get_soc_qcut_st4(int wh, int sc) const
const L1MuDTSecProcId & id() const
return Sector Processor identifier
int id() const
return Extrapolation identifier
Definition: L1MuDTEUX.h:90
unsigned int quality() const
return extrapolation quality
Definition: L1MuDTEUX.h:96
unsigned short const nbit_phib
Definition: L1MuDTEUX.h:119
int phi() const
return phi
unsigned short const nbit_phi
Definition: L1MuDTEUX.h:118
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool Debug()
const L1MuDTTFConfig * config() const
return configuration
~L1MuDTEUX()
destructor
Definition: L1MuDTEUX.cc:67
int sec_mod(int) const
output sector numbers in the range -6 to +5
Definition: L1MuDTEUX.cc:244
int getHigh(int ext_ind, int address) const
get high_value for a given address
bool operator==(const L1MuDTEUX &) const
equal operator
Definition: L1MuDTEUX.cc:76
L1MuDTEUX(const L1MuDTSectorProcessor &sp, const L1MuDTSEU &seu, int id)
constructor
Definition: L1MuDTEUX.cc:50
unsigned short int address() const
return extrapolation address (0-11) (address = 15 indicates negative ext. result) ...
Definition: L1MuDTEUX.h:99
int sector() const
return sector
int quality() const
return quality code
const L1MuDTTrackSegPhi * m_target
Definition: L1MuDTEUX.h:115
unsigned short int m_quality
Definition: L1MuDTEUX.h:111
const L1MuDTSectorProcessor & m_sp
Definition: L1MuDTEUX.h:106
void run(const L1MuDTExtLut &extLUTs, const L1MuDTTFParameters &pars)
run Extrapolator
Definition: L1MuDTEUX.cc:91
Extrapolation ext() const
return extrapolation type
Definition: L1MuDTSEU.h:78
int m_id
Definition: L1MuDTEUX.h:108
const L1MuDTTrackSegPhi * m_start
Definition: L1MuDTEUX.h:114
unsigned short int m_address
Definition: L1MuDTEUX.h:112
int bitShift(int num, int bits)
Definition: BitShift.h:6
bool get_soc_openlut_extr(int wh, int sc) const