CMS 3D CMS Logo

L1MuBMEUX.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuBMEUX
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 
34 
40 using namespace std;
41 
42 // --------------------------------
43 // class L1MuBMEUX
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(L1MuBMTFConfig::getExtTSFilter()),
60  nbit_phi(L1MuBMTFConfig::getNbitsExtPhi()),
61  nbit_phib(L1MuBMTFConfig::getNbitsExtPhib()) {}
62 
63 //--------------
64 // Destructor --
65 //--------------
66 
68 
69 //--------------
70 // Operations --
71 //--------------
72 
73 //
74 // Equal operator
75 //
76 bool L1MuBMEUX::operator==(const L1MuBMEUX& 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 L1MuBMEUX::run(const L1TMuonBarrelParams& bmtfParams) {
92  pars = bmtfParams.l1mudttfparams;
93  theExtLUTs = new L1MuBMLUTHandler(bmtfParams);
94 
95  if (L1MuBMTFConfig::Debug(4))
96  cout << "Run EUX " << m_id << endl;
97  if (L1MuBMTFConfig::Debug(4))
98  cout << "start : " << *m_start << endl;
99  if (L1MuBMTFConfig::Debug(4))
100  cout << "target : " << *m_target << endl;
101 
102  if (m_start == nullptr || m_target == nullptr) {
103  if (L1MuBMTFConfig::Debug(4))
104  cout << "Error: EUX has no data loaded" << endl;
105  delete theExtLUTs;
106  return;
107  }
108 
109  // start sector
110  int sector_st = m_start->sector();
111 
112  // target sector
113  int sector_ta = m_target->sector();
114 
115  // get index of look-up table
116  int lut_idx = m_seu.ext();
117  if (abs(m_target->wheel()) == 3) {
118  switch (m_seu.ext()) {
119  case EX13: {
120  lut_idx = EX15;
121  break;
122  }
123  case EX23: {
124  lut_idx = EX25;
125  break;
126  }
127  default: {
128  lut_idx = m_seu.ext();
129  break;
130  }
131  }
132  }
133 
134  if (L1MuBMTFConfig::Debug(5))
135  cout << "EUX : using look-up table : " << static_cast<Extrapolation>(lut_idx) << endl;
136 
137  // Extrapolation TS quality filter
138  int qcut = 0;
139  if (m_seu.ext() == EX12)
140  qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
141  if (m_seu.ext() == EX13)
142  qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
143  if (m_seu.ext() == EX14)
144  qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
145  if (m_seu.ext() == EX21)
146  qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
147  if (m_seu.ext() == EX23)
148  qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
149  if (m_seu.ext() == EX24)
150  qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
151  if (m_seu.ext() == EX34)
152  qcut = pars.get_soc_qcut_st4(m_sp.id().wheel(), m_sp.id().sector());
153 
154  if (m_start->quality() < qcut) {
155  delete theExtLUTs;
156  return;
157  }
158  // calculate bit shift
159  int sh_phi = 12 - nbit_phi;
160  int sh_phib = 10 - nbit_phib;
161 
162  int phi_target = m_target->phi() >> sh_phi;
163  int phi_start = m_start->phi() >> sh_phi;
164  int phib_start = (m_start->phib() >> sh_phib) << sh_phib;
165  if (phib_start < 0)
166  phib_start += (1 << sh_phib) - 1;
167 
168  // compute difference in phi
169  int diff = phi_target - phi_start;
170 
171  // get low and high values from look-up table
172  // and add offset (30 degrees ) for extrapolation to adjacent sector
173  int offset = -2144 >> sh_phi;
174  offset *= sec_mod(sector_ta - sector_st);
175  int low = theExtLUTs->getLow(lut_idx, phib_start);
176  int high = theExtLUTs->getHigh(lut_idx, phib_start);
177  if (low < 0)
178  low += (1 << sh_phi) - 1;
179  if (high < 0)
180  high += (1 << sh_phi) - 1;
181  low = (low >> sh_phi) + offset;
182  high = (high >> sh_phi) + offset;
183 
184  int phi_offset = phi_target - offset;
185  if ((lut_idx == EX34) || (lut_idx == EX21))
186  phi_offset = phi_start + offset;
187  if (phi_offset >= (1 << (nbit_phi - 1)) - 1) {
188  delete theExtLUTs;
189  return;
190  }
191  if (phi_offset < -(1 << (nbit_phi - 1)) + 1) {
192  delete theExtLUTs;
193  return;
194  }
195  // is phi-difference within the extrapolation window?
196  bool openlut = pars.get_soc_openlut_extr(m_sp.id().wheel(), m_sp.id().sector());
197  if ((diff >= low && diff <= high) || L1MuBMTFConfig::getopenLUTs() || openlut) {
198  m_result = true;
199  int qual_st = m_start->quality();
200  int qual_ta = m_target->quality();
201  if (m_seu.ext() == EX34 || m_seu.ext() == EX21) {
202  m_quality = (qual_st == 7) ? 0 : qual_st + 1;
203  } else {
204  m_quality = (qual_ta == 7) ? 0 : qual_ta + 1;
205  }
206  m_address = m_id;
207  }
208  delete theExtLUTs;
209  if (L1MuBMTFConfig::Debug(5))
210  cout << "diff : " << low << " " << diff << " " << high << " : " << m_result << " " << endl;
211 }
212 
213 //
214 // load data into EUX
215 //
216 void L1MuBMEUX::load(const L1MuBMTrackSegPhi* start_ts, const L1MuBMTrackSegPhi* target_ts) {
217  m_start = start_ts;
218  m_target = target_ts;
219 
220  // in case of EX34 and EX21 exchange start and target
221  if ((m_seu.ext() == EX34) || (m_seu.ext() == EX21)) {
222  m_start = target_ts;
223  m_target = start_ts;
224  }
225 }
226 
227 //
228 // reset this EUX
229 //
230 
232  m_result = false;
233  m_quality = 0;
234  m_address = 15;
235 
236  m_start = nullptr;
237  m_target = nullptr;
238 }
239 
240 //
241 // return pointer to start and target track segment
242 //
243 pair<const L1MuBMTrackSegPhi*, const L1MuBMTrackSegPhi*> L1MuBMEUX::ts() const {
244  return pair<const L1MuBMTrackSegPhi*, const L1MuBMTrackSegPhi*>(m_start, m_target);
245 }
246 
247 //
248 // symmetric modulo function for sectors
249 // output values in the range -6 to +5
250 //
251 int L1MuBMEUX::sec_mod(int sector) const {
252  int new_sector = sector % 12;
253  if (new_sector >= 6)
254  new_sector = new_sector - 12;
255  if (new_sector < -6)
256  new_sector = new_sector + 12;
257 
258  return new_sector;
259 }
const L1MuBMSEU & m_seu
Definition: L1MuBMEUX.h:109
L1MuBMLUTHandler * theExtLUTs
Definition: L1MuBMEUX.h:119
const L1MuBMSecProcId & id() const
return Sector Processor identifier
L1MuDTTFParameters l1mudttfparams
unsigned int quality() const
return extrapolation quality
Definition: L1MuBMEUX.h:98
static bool getopenLUTs()
void reset()
reset Extrapolator
Definition: L1MuBMEUX.cc:231
int m_id
Definition: L1MuBMEUX.h:110
unsigned short int m_address
Definition: L1MuBMEUX.h:114
int wheel() const
return wheel
int wheel() const
return wheel number
const L1MuBMTrackSegPhi * m_target
Definition: L1MuBMEUX.h:117
L1MuDTTFParameters pars
Definition: L1MuBMEUX.h:124
unsigned short int get_soc_qcut_st2(int wh, int sc) const
unsigned short int get_soc_qcut_st1(int wh, int sc) const
const L1MuBMTrackSegPhi * m_start
Definition: L1MuBMEUX.h:116
unsigned short int get_soc_qcut_st4(int wh, int sc) const
std::pair< const L1MuBMTrackSegPhi *, const L1MuBMTrackSegPhi * > ts() const
return pointer to start and target track segment
Definition: L1MuBMEUX.cc:243
int quality() const
return quality code
const L1MuBMSectorProcessor & m_sp
Definition: L1MuBMEUX.h:108
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int phib() const
return phib
Extrapolation
bool operator==(const L1MuBMEUX &) const
equal operator
Definition: L1MuBMEUX.cc:76
int getHigh(int ext_ind, int address) const
get high_value for a given address
int sector() const
return sector number
int getLow(int ext_ind, int address) const
get low_value for a given address
int sec_mod(int) const
output sector numbers in the range -6 to +5
Definition: L1MuBMEUX.cc:251
bool m_result
Definition: L1MuBMEUX.h:112
bool result() const
return extrapolation result
Definition: L1MuBMEUX.h:95
static bool Debug()
unsigned short const nbit_phi
Definition: L1MuBMEUX.h:121
void load(const L1MuBMTrackSegPhi *start_ts, const L1MuBMTrackSegPhi *target_ts)
load data into EUX
Definition: L1MuBMEUX.cc:216
unsigned short const nbit_phib
Definition: L1MuBMEUX.h:122
int sector() const
return sector
int phi() const
return phi
~L1MuBMEUX()
destructor
Definition: L1MuBMEUX.cc:67
unsigned short int m_quality
Definition: L1MuBMEUX.h:113
unsigned short int address() const
return extrapolation address (0-11) (address = 15 indicates negative ext. result) ...
Definition: L1MuBMEUX.h:101
int id() const
return Extrapolation identifier
Definition: L1MuBMEUX.h:92
void run(const L1TMuonBarrelParams &c)
run Extrapolator
Definition: L1MuBMEUX.cc:91
Extrapolation ext() const
return extrapolation type
Definition: L1MuBMSEU.h:78
L1MuBMEUX(const L1MuBMSectorProcessor &sp, const L1MuBMSEU &seu, int id)
constructor
Definition: L1MuBMEUX.cc:50
bool get_soc_openlut_extr(int wh, int sc) const