CMS 3D CMS Logo

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