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