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  const L1TMuonBarrelParamsRcd& bmtfParamsRcd = c.get<L1TMuonBarrelParamsRcd>();
82  bmtfParamsRcd.get(bmtfParamsHandle);
83  const L1TMuonBarrelParams& bmtfParams = *bmtfParamsHandle.product();
84  msks = bmtfParams.l1mudttfmasks;
85  //msks.print();
86 
87  // get track segments from BBMX chamber trigger
88  receiveBBMXData(bx, e, c);
89 
90  // get track segments from CSC chamber trigger
91  //if ( L1MuBMTFConfig::overlap() && m_sp.ovl() ) {
92  //receiveCSCData(bx, e, c);
93  //}
94 
95 }
96 
97 
98 //
99 // clear
100 //
102 
103 }
104 
105 
106 //
107 // receive track segment data from the BBMX chamber trigger
108 //
111  //e.getByLabel(L1MuBMTFConfig::getBMDigiInputTag(),dttrig);
112  e.getByToken(m_DTDigiToken,dttrig);
113  L1MuDTChambPhDigi const* ts=0;
114 
115  // const int bx_offset = dttrig->correctBX();
116  int bx_offset=0;
117  bx = bx + bx_offset;
118  // get BBMX phi track segments
119  int address = 0;
120  for ( int station = 1; station <= 4; station++ ) {
121  int max_address = (station == 1) ? 2 : 12;
122  for (int reladr =0; reladr < max_address; reladr++) {
123  address++;
124  //if ( m_sp.ovl() && (reladr/2)%2 != 0 ) continue;
125  int wheel = address2wheel(reladr);
126  int sector = address2sector(reladr);
127  //if ( (wheel==2 || wheel==-2) && station==1 ) continue;
128 
129  if ( reladr%2 == 0 ) ts = dttrig->chPhiSegm1(wheel,station,sector,bx);
130  if ( reladr%2 == 1 ) ts = dttrig->chPhiSegm2(wheel,station,sector,bx-1);
131  if ( ts ) {
132  int phi = ts->phi();
133 // int phib = ts->phiB();
134  int phib = 0;
135  if(station!=3) phib = ts->phiB();
136 
137  int qual = ts->code();
138  bool tag = (reladr%2 == 1) ? true : false;
139 
140  int lwheel = m_sp.id().wheel();
141  lwheel = abs(lwheel)/lwheel*(abs(wheel)+1);
142 
143  if ( station == 1 ) {
144  if ( msks.get_inrec_chdis_st1(lwheel, sector) ) continue;
145  if ( qual < pars->get_inrec_qual_st1(lwheel, sector) ) continue;
146  }
147  else if ( station == 2 ) {
148  if ( msks.get_inrec_chdis_st2(lwheel, sector) ) continue;
149  if ( qual < pars->get_inrec_qual_st2(lwheel, sector) ) continue;
150  }
151  else if ( station == 3 ) {
152  if ( msks.get_inrec_chdis_st3(lwheel, sector) ) continue;
153  if ( qual < pars->get_inrec_qual_st3(lwheel, sector) ) continue;
154  }
155  else if ( station == 4 ) {
156  if ( msks.get_inrec_chdis_st4(lwheel, sector) ) continue;
157  if ( qual < pars->get_inrec_qual_st4(lwheel, sector) ) continue;
158  }
159 
160  if ( reladr/2 == 1 && qual < pars->get_soc_stdis_n(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
161  if ( reladr/2 == 2 && qual < pars->get_soc_stdis_wl(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
162  if ( reladr/2 == 3 && qual < pars->get_soc_stdis_zl(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
163  if ( reladr/2 == 4 && qual < pars->get_soc_stdis_wr(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
164  if ( reladr/2 == 5 && qual < pars->get_soc_stdis_zr(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
165 
166  //
167  // out-of-time TS filter (compare TS at +-1 bx)
168  //
169  bool skipTS = false;
170 
171  bool nbx_del = pars->get_soc_nbx_del(m_sp.id().wheel(), m_sp.id().sector());
172  if ( L1MuBMTFConfig::getTSOutOfTimeFilter() || nbx_del ) {
173 
174  int sh_phi = 12 - L1MuBMTFConfig::getNbitsExtPhi();
175  int tolerance = L1MuBMTFConfig::getTSOutOfTimeWindow();
176 
177  L1MuDTChambPhDigi const * tsPreviousBX_1 = dttrig->chPhiSegm1(wheel,station,sector,bx-1);
178  if ( tsPreviousBX_1 ) {
179  int phiBX = tsPreviousBX_1->phi();
180  int qualBX = tsPreviousBX_1->code();
181  if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
182  qualBX > qual ) skipTS = true;
183  }
184 
185  L1MuDTChambPhDigi const * tsPreviousBX_2 = dttrig->chPhiSegm2(wheel,station,sector,bx-1);
186  if ( tsPreviousBX_2 ) {
187  int phiBX = tsPreviousBX_2->phi();
188  int qualBX = tsPreviousBX_2->code();
189  if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
190  qualBX > qual ) skipTS = true;
191  }
192 
193  L1MuDTChambPhDigi const * tsNextBX_1 = dttrig->chPhiSegm1(wheel,station,sector,bx+1);
194  if ( tsNextBX_1 ) {
195  int phiBX = tsNextBX_1->phi();
196  int qualBX = tsNextBX_1->code();
197  if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
198  qualBX > qual ) skipTS = true;
199  }
200 
201  L1MuDTChambPhDigi const * tsNextBX_2 = dttrig->chPhiSegm2(wheel,station,sector,bx+1);
202  if ( tsNextBX_2 ) {
203  int phiBX = tsNextBX_2->phi();
204  int qualBX = tsNextBX_2->code();
205  if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
206  qualBX > qual ) skipTS = true;
207  }
208 
209  }
210 
211  if ( !skipTS ) {
212 
213  /* if(reladr%2 == 0) {
214  L1MuBMTrackSegPhi tmpts(wheel,sector,station,phi,phib,
215  static_cast<L1MuBMTrackSegPhi::TSQuality>(qual),
216  tag,bx-bx_offset);
217  m_sp.data()->addTSphi(address-1,tmpts);
218  }
219  if(reladr%2 == 1) {
220  L1MuBMTrackSegPhi tmpts(wheel,sector,station,phi,phib,
221  static_cast<L1MuBMTrackSegPhi::TSQuality>(qual),
222  tag,bx+1);
223  m_sp.data()->addTSphi(address-1,tmpts);
224  }*/
225  L1MuBMTrackSegPhi tmpts(wheel,sector,station,phi,phib,
226  static_cast<L1MuBMTrackSegPhi::TSQuality>(qual),
227  tag,bx-bx_offset);
228  m_sp.data()->addTSphi(address-1,tmpts);
229  }
230  }
231 
232  }
233  }
234 
235 }
236 
237 
238 //
239 // receive track segment data from CSC chamber trigger
240 //
241 /*
242 void L1MuBMSectorReceiver::receiveCSCData(int bx, const edm::Event& e, const edm::EventSetup& c) {
243 
244  if ( (L1MuBMTFConfig::getCSCTrSInputTag()).label() == "none" ) return;
245 
246  if ( bx < -6 || bx > 6 ) return;
247 
248  edm::Handle<CSCTriggerContainer<csctf::TrackStub> > csctrig;
249  e.getByLabel(L1MuBMTFConfig::getCSCTrSInputTag(),csctrig);
250 
251  const int bxCSC = 6;
252 
253  vector<csctf::TrackStub> csc_list;
254  vector<csctf::TrackStub>::const_iterator csc_iter;
255 
256  int station = 1; // only ME13
257  int wheel = m_sp.id().wheel();
258  int side = ( wheel == 3 ) ? 1 : 2;
259  int sector = m_sp.id().sector();
260  int csc_sector = ( sector == 0 ) ? 6 : (sector+1)/2;
261  int subsector = ( sector%2 == 0 ) ? 2 : 1;
262 
263  csc_list = csctrig->get(side,station,csc_sector,subsector,bxCSC+bx);
264  int ncsc = 0;
265  for ( csc_iter = csc_list.begin(); csc_iter != csc_list.end(); csc_iter++ ) {
266  bool etaFlag = ( csc_iter->etaPacked() > 17 );
267  int qualCSC = csc_iter->getQuality();
268 
269  // convert CSC quality code to BBMX quality code
270  unsigned int qual = 7;
271  if ( qualCSC == 2 ) qual = 0;
272  if ( qualCSC == 6 ) qual = 1;
273  if ( qualCSC == 7 ) qual = 2;
274  if ( qualCSC == 8 ) qual = 2;
275  if ( qualCSC == 9 ) qual = 3;
276  if ( qualCSC == 10 ) qual = 3;
277  if ( qualCSC == 11 ) qual = 4;
278  if ( qualCSC == 12 ) qual = 5;
279  if ( qualCSC == 13 ) qual = 5;
280  if ( qualCSC == 14 ) qual = 6;
281  if ( qualCSC == 15 ) qual = 6;
282  if ( qual == 7 ) continue;
283 
284  // convert CSC phi to BBMX phi
285  int phi = csc_iter->phiPacked();
286  if ( phi > 2047 ) phi -= 4096;
287  if ( phi < -2048 || phi > 2047 ) continue;
288 
289  if ( msks.get_inrec_chdis_csc(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
290  if ( qual < pars->get_soc_qual_csc(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
291  if ( pars->get_soc_csc_etacanc(m_sp.id().wheel(), m_sp.id().sector()) && etaFlag ) continue;
292  if ( L1MuBMTFConfig::getEtaCanc() && etaFlag ) continue;
293 
294  if ( ncsc < 2 ) {
295  int address = 16 + ncsc;
296  bool tag = (ncsc == 1 ) ? true : false;
297  L1MuBMTrackSegPhi tmpts(wheel,sector,station+2,phi,0,
298  static_cast<L1MuBMTrackSegPhi::TSQuality>(qual),
299  tag,bx,etaFlag);
300  m_sp.data()->addTSphi(address,tmpts);
301  ncsc++;
302  }
303  // else cout << "too many CSC track segments!" << endl;
304  }
305 
306 }
307 
308 */
309 
310 //
311 // find the right sector for a given address
312 //
314 
315  int sector = m_sp.id().sector();
316 
317  if ( adr >= 4 && adr <= 7 ) sector = (sector+13)%12; // +1
318  if ( adr >= 8 && adr <= 11 ) sector = (sector+11)%12; // -1
319 
320  return sector;
321 
322 }
323 
324 
325 //
326 // find the right wheel for a given address
327 //
329 
330  int wheel = m_sp.id().locwheel();
331 
332  // for 2, 3, 6, 7, 10, 11
333  if ( (adr/2)%2 == 1 ) wheel = m_sp.id().wheel();
334 
335  return wheel;
336 
337 }
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
bool get_inrec_chdis_st1(int wh, int sc) const
bool get_inrec_chdis_st3(int wh, int sc) const
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
L1MuDTTFMasks l1mudttfmasks
L1MuBMSectorProcessor & m_sp
void get(HolderT &iHolder) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool get_inrec_chdis_st2(int wh, int sc) const
static bool getTSOutOfTimeFilter()
const L1MuBMSecProcId & id() const
return Sector Processor identifier
bool get_inrec_chdis_st4(int wh, int sc) const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
void reset()
clear Sector Receiver
const L1MuBMDataBuffer * data() const
return pointer to Data Buffer
Definition: sp.h:21
edm::ESHandle< L1TMuonBarrelParams > bmtfParamsHandle
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