CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuBMSectorReceiver.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuBMSectorReceiver
4 //
5 // Description: Sector Receiver
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister CERN EP
11 // J. Troconiz UAM Madrid
12 //
13 //--------------------------------------------------
14 
15 //-----------------------
16 // This Class's Header --
17 //-----------------------
18 
20 
21 //---------------
22 // C++ Headers --
23 //---------------
24 
25 #include <iostream>
26 #include <cmath>
27 
28 //-------------------------------
29 // Collaborating Class Headers --
30 //-------------------------------
31 
37 
42 
43 using namespace std;
44 
45 // --------------------------------
46 // class L1MuBMSectorReceiver
47 //---------------------------------
48 
49 //----------------
50 // Constructors --
51 //----------------
53  m_sp(sp),
54  m_DTDigiToken(iC.consumes<L1MuDTChambPhContainer>(L1MuBMTFConfig::getBMDigiInputTag())){
55 
56 }
57 
58 
59 //--------------
60 // Destructor --
61 //--------------
63 
64 // reset();
65 
66 }
67 
68 
69 //--------------
70 // Operations --
71 //--------------
72 
73 //
74 // receive track segment data from the BBMX and CSC chamber triggers
75 //
76 void L1MuBMSectorReceiver::run(int bx, const edm::Event& e, const edm::EventSetup& c) {
77 
78  c.get< L1MuDTTFParametersRcd >().get( pars );
79  c.get< L1MuDTTFMasksRcd >().get( msks );
80 
81  // get track segments from BBMX chamber trigger
82  receiveBBMXData(bx, e, c);
83 
84  // get track segments from CSC chamber trigger
85  //if ( L1MuBMTFConfig::overlap() && m_sp.ovl() ) {
86  //receiveCSCData(bx, e, c);
87  //}
88 
89 }
90 
91 
92 //
93 // clear
94 //
96 
97 }
98 
99 
100 //
101 // receive track segment data from the BBMX chamber trigger
102 //
105  //e.getByLabel(L1MuBMTFConfig::getBMDigiInputTag(),dttrig);
106  e.getByToken(m_DTDigiToken,dttrig);
107  L1MuDTChambPhDigi const* ts=0;
108 
109  // const int bx_offset = dttrig->correctBX();
110  int bx_offset=0;
111  bx = bx + bx_offset;
112  // get BBMX phi track segments
113  int address = 0;
114  for ( int station = 1; station <= 4; station++ ) {
115  int max_address = (station == 1) ? 2 : 12;
116  for (int reladr =0; reladr < max_address; reladr++) {
117  address++;
118  //if ( m_sp.ovl() && (reladr/2)%2 != 0 ) continue;
119  int wheel = address2wheel(reladr);
120  int sector = address2sector(reladr);
121  if ( reladr%2 == 0 ) ts = dttrig->chPhiSegm1(wheel,station,sector,bx);
122  if ( reladr%2 == 1 ) ts = dttrig->chPhiSegm2(wheel,station,sector,bx);
123  if ( ts ) {
124  int phi = ts->phi();
125  int phib = ts->phiB();
126  int qual = ts->code();
127  bool tag = (reladr%2 == 1) ? true : false;
128 
129  int lwheel = m_sp.id().wheel();
130  lwheel = abs(lwheel)/lwheel*(abs(wheel)+1);
131 
132  if ( station == 1 ) {
133  if ( msks->get_inrec_chdis_st1(lwheel, sector) ) continue;
134  if ( qual < pars->get_inrec_qual_st1(lwheel, sector) ) continue;
135  }
136  else if ( station == 2 ) {
137  if ( msks->get_inrec_chdis_st2(lwheel, sector) ) continue;
138  if ( qual < pars->get_inrec_qual_st2(lwheel, sector) ) continue;
139  }
140  else if ( station == 3 ) {
141  if ( msks->get_inrec_chdis_st3(lwheel, sector) ) continue;
142  if ( qual < pars->get_inrec_qual_st3(lwheel, sector) ) continue;
143  }
144  else if ( station == 4 ) {
145  if ( msks->get_inrec_chdis_st4(lwheel, sector) ) continue;
146  if ( qual < pars->get_inrec_qual_st4(lwheel, sector) ) continue;
147  }
148 
149  if ( reladr/2 == 1 && qual < pars->get_soc_stdis_n(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
150  if ( reladr/2 == 2 && qual < pars->get_soc_stdis_wl(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
151  if ( reladr/2 == 3 && qual < pars->get_soc_stdis_zl(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
152  if ( reladr/2 == 4 && qual < pars->get_soc_stdis_wr(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
153  if ( reladr/2 == 5 && qual < pars->get_soc_stdis_zr(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
154 
155  //
156  // out-of-time TS filter (compare TS at +-1 bx)
157  //
158  bool skipTS = false;
159 
160  bool nbx_del = pars->get_soc_nbx_del(m_sp.id().wheel(), m_sp.id().sector());
161  if ( L1MuBMTFConfig::getTSOutOfTimeFilter() || nbx_del ) {
162 
163  int sh_phi = 12 - L1MuBMTFConfig::getNbitsExtPhi();
164  int tolerance = L1MuBMTFConfig::getTSOutOfTimeWindow();
165 
166  L1MuDTChambPhDigi const * tsPreviousBX_1 = dttrig->chPhiSegm1(wheel,station,sector,bx-1);
167  if ( tsPreviousBX_1 ) {
168  int phiBX = tsPreviousBX_1->phi();
169  int qualBX = tsPreviousBX_1->code();
170  if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
171  qualBX > qual ) skipTS = true;
172  }
173 
174  L1MuDTChambPhDigi const * tsPreviousBX_2 = dttrig->chPhiSegm2(wheel,station,sector,bx-1);
175  if ( tsPreviousBX_2 ) {
176  int phiBX = tsPreviousBX_2->phi();
177  int qualBX = tsPreviousBX_2->code();
178  if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
179  qualBX > qual ) skipTS = true;
180  }
181 
182  L1MuDTChambPhDigi const * tsNextBX_1 = dttrig->chPhiSegm1(wheel,station,sector,bx+1);
183  if ( tsNextBX_1 ) {
184  int phiBX = tsNextBX_1->phi();
185  int qualBX = tsNextBX_1->code();
186  if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
187  qualBX > qual ) skipTS = true;
188  }
189 
190  L1MuDTChambPhDigi const * tsNextBX_2 = dttrig->chPhiSegm2(wheel,station,sector,bx+1);
191  if ( tsNextBX_2 ) {
192  int phiBX = tsNextBX_2->phi();
193  int qualBX = tsNextBX_2->code();
194  if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
195  qualBX > qual ) skipTS = true;
196  }
197 
198  }
199 
200  if ( !skipTS ) {
201  L1MuBMTrackSegPhi tmpts(wheel,sector,station,phi,phib,
202  static_cast<L1MuBMTrackSegPhi::TSQuality>(qual),
203  tag,bx-bx_offset);
204  m_sp.data()->addTSphi(address-1,tmpts);
205  }
206  }
207 
208  }
209  }
210 
211 }
212 
213 
214 //
215 // receive track segment data from CSC chamber trigger
216 //
217 /*
218 void L1MuBMSectorReceiver::receiveCSCData(int bx, const edm::Event& e, const edm::EventSetup& c) {
219 
220  if ( (L1MuBMTFConfig::getCSCTrSInputTag()).label() == "none" ) return;
221 
222  if ( bx < -6 || bx > 6 ) return;
223 
224  edm::Handle<CSCTriggerContainer<csctf::TrackStub> > csctrig;
225  e.getByLabel(L1MuBMTFConfig::getCSCTrSInputTag(),csctrig);
226 
227  const int bxCSC = 6;
228 
229  vector<csctf::TrackStub> csc_list;
230  vector<csctf::TrackStub>::const_iterator csc_iter;
231 
232  int station = 1; // only ME13
233  int wheel = m_sp.id().wheel();
234  int side = ( wheel == 3 ) ? 1 : 2;
235  int sector = m_sp.id().sector();
236  int csc_sector = ( sector == 0 ) ? 6 : (sector+1)/2;
237  int subsector = ( sector%2 == 0 ) ? 2 : 1;
238 
239  csc_list = csctrig->get(side,station,csc_sector,subsector,bxCSC+bx);
240  int ncsc = 0;
241  for ( csc_iter = csc_list.begin(); csc_iter != csc_list.end(); csc_iter++ ) {
242  bool etaFlag = ( csc_iter->etaPacked() > 17 );
243  int qualCSC = csc_iter->getQuality();
244 
245  // convert CSC quality code to BBMX quality code
246  unsigned int qual = 7;
247  if ( qualCSC == 2 ) qual = 0;
248  if ( qualCSC == 6 ) qual = 1;
249  if ( qualCSC == 7 ) qual = 2;
250  if ( qualCSC == 8 ) qual = 2;
251  if ( qualCSC == 9 ) qual = 3;
252  if ( qualCSC == 10 ) qual = 3;
253  if ( qualCSC == 11 ) qual = 4;
254  if ( qualCSC == 12 ) qual = 5;
255  if ( qualCSC == 13 ) qual = 5;
256  if ( qualCSC == 14 ) qual = 6;
257  if ( qualCSC == 15 ) qual = 6;
258  if ( qual == 7 ) continue;
259 
260  // convert CSC phi to BBMX phi
261  int phi = csc_iter->phiPacked();
262  if ( phi > 2047 ) phi -= 4096;
263  if ( phi < -2048 || phi > 2047 ) continue;
264 
265  if ( msks->get_inrec_chdis_csc(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
266  if ( qual < pars->get_soc_qual_csc(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
267  if ( pars->get_soc_csc_etacanc(m_sp.id().wheel(), m_sp.id().sector()) && etaFlag ) continue;
268  if ( L1MuBMTFConfig::getEtaCanc() && etaFlag ) continue;
269 
270  if ( ncsc < 2 ) {
271  int address = 16 + ncsc;
272  bool tag = (ncsc == 1 ) ? true : false;
273  L1MuBMTrackSegPhi tmpts(wheel,sector,station+2,phi,0,
274  static_cast<L1MuBMTrackSegPhi::TSQuality>(qual),
275  tag,bx,etaFlag);
276  m_sp.data()->addTSphi(address,tmpts);
277  ncsc++;
278  }
279  // else cout << "too many CSC track segments!" << endl;
280  }
281 
282 }
283 
284 */
285 
286 //
287 // find the right sector for a given address
288 //
290 
291  int sector = m_sp.id().sector();
292 
293  if ( adr >= 4 && adr <= 7 ) sector = (sector+13)%12; // +1
294  if ( adr >= 8 && adr <= 11 ) sector = (sector+11)%12; // -1
295 
296  return sector;
297 
298 }
299 
300 
301 //
302 // find the right wheel for a given address
303 //
305 
306  int wheel = m_sp.id().locwheel();
307 
308  // for 2, 3, 6, 7, 10, 11
309  if ( (adr/2)%2 == 1 ) wheel = m_sp.id().wheel();
310 
311  return wheel;
312 
313 }
static int getTSOutOfTimeWindow()
void run(int bx, const edm::Event &e, const edm::EventSetup &c)
receive track segment data from the BBMX and CSC chamber triggers
int address2wheel(int adr) const
find the right wheel for a given address
static int getNbitsExtPhi()
void addTSphi(int adr, const L1MuBMTrackSegPhi &)
add new phi track segment to the Data Buffer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::ESHandle< L1MuDTTFParameters > pars
int address2sector(int adr) const
find the right sector for a given address
L1MuBMSectorReceiver(L1MuBMSectorProcessor &, edm::ConsumesCollector &&iC)
constructor
edm::EDGetTokenT< L1MuDTChambPhContainer > m_DTDigiToken
int sector() const
return sector number
virtual ~L1MuBMSectorReceiver()
destructor
L1MuBMSectorProcessor & m_sp
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool getTSOutOfTimeFilter()
const L1MuBMSecProcId & id() const
return Sector Processor identifier
edm::ESHandle< L1MuDTTFMasks > msks
const T & get() const
Definition: EventSetup.h:56
void reset()
clear Sector Receiver
const L1MuBMDataBuffer * data() const
return pointer to Data Buffer
Definition: sp.h:21
int locwheel() const
return physical wheel number (-2,-1,0,+1,+2)
void receiveBBMXData(int bx, const edm::Event &e, const edm::EventSetup &c)
receive track segment data from BBMX chamber trigger
int wheel() const
return wheel number