00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorReceiver.h"
00022
00023
00024
00025
00026
00027 #include <iostream>
00028 #include <cmath>
00029
00030
00031
00032
00033
00034 #include "L1Trigger/DTTrackFinder/src/L1MuDTTFConfig.h"
00035 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.h"
00036 #include "L1Trigger/DTTrackFinder/src/L1MuDTDataBuffer.h"
00037 #include "L1Trigger/DTTrackFinder/src/L1MuDTTrackSegLoc.h"
00038 #include "L1Trigger/DTTrackFinder/src/L1MuDTTrackSegPhi.h"
00039 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
00040 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
00041 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
00042 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
00043 #include "CondFormats/L1TObjects/interface/L1MuDTTFParameters.h"
00044 #include "CondFormats/DataRecord/interface/L1MuDTTFParametersRcd.h"
00045 #include "CondFormats/L1TObjects/interface/L1MuDTTFMasks.h"
00046 #include "CondFormats/DataRecord/interface/L1MuDTTFMasksRcd.h"
00047
00048 using namespace std;
00049
00050
00051
00052
00053
00054
00055
00056
00057 L1MuDTSectorReceiver::L1MuDTSectorReceiver(L1MuDTSectorProcessor& sp) :
00058 m_sp(sp) {
00059
00060 }
00061
00062
00063
00064
00065
00066 L1MuDTSectorReceiver::~L1MuDTSectorReceiver() {
00067
00068
00069
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 void L1MuDTSectorReceiver::run(int bx, const edm::Event& e, const edm::EventSetup& c) {
00081
00082 c.get< L1MuDTTFParametersRcd >().get( pars );
00083 c.get< L1MuDTTFMasksRcd >().get( msks );
00084
00085
00086 receiveDTBXData(bx, e, c);
00087
00088
00089 if ( L1MuDTTFConfig::overlap() && m_sp.ovl() ) {
00090 receiveCSCData(bx, e, c);
00091 }
00092
00093 }
00094
00095
00096
00097
00098
00099 void L1MuDTSectorReceiver::reset() {
00100
00101 }
00102
00103
00104
00105
00106
00107 void L1MuDTSectorReceiver::receiveDTBXData(int bx, const edm::Event& e, const edm::EventSetup& c) {
00108
00109 edm::Handle<L1MuDTChambPhContainer> dttrig;
00110 e.getByLabel(L1MuDTTFConfig::getDTDigiInputTag(),dttrig);
00111
00112 L1MuDTChambPhDigi* ts=0;
00113
00114
00115 int bx_offset=0;
00116 bx = bx + bx_offset;
00117
00118
00119 int address = 0;
00120 for ( int station = 1; station <= 4; station++ ) {
00121 int max_address = (station == 1) ? 2 : 12;
00122 for (int reladr =0; reladr < max_address; reladr++) {
00123 address++;
00124 if ( m_sp.ovl() && (reladr/2)%2 != 0 ) continue;
00125 int wheel = address2wheel(reladr);
00126 int sector = address2sector(reladr);
00127 if ( reladr%2 == 0 ) ts = dttrig->chPhiSegm1(wheel,station,sector,bx);
00128 if ( reladr%2 == 1 ) ts = dttrig->chPhiSegm2(wheel,station,sector,bx);
00129 if ( ts ) {
00130 int phi = ts->phi();
00131 int phib = ts->phiB();
00132 int qual = ts->code();
00133 bool tag = (reladr%2 == 1) ? true : false;
00134
00135 int lwheel = m_sp.id().wheel();
00136 lwheel = abs(lwheel)/lwheel*(abs(wheel)+1);
00137
00138 if ( station == 1 ) {
00139 if ( msks->get_inrec_chdis_st1(lwheel, sector) ) continue;
00140 if ( qual < pars->get_inrec_qual_st1(lwheel, sector) ) continue;
00141 }
00142 else if ( station == 2 ) {
00143 if ( msks->get_inrec_chdis_st2(lwheel, sector) ) continue;
00144 if ( qual < pars->get_inrec_qual_st2(lwheel, sector) ) continue;
00145 }
00146 else if ( station == 3 ) {
00147 if ( msks->get_inrec_chdis_st3(lwheel, sector) ) continue;
00148 if ( qual < pars->get_inrec_qual_st3(lwheel, sector) ) continue;
00149 }
00150 else if ( station == 4 ) {
00151 if ( msks->get_inrec_chdis_st4(lwheel, sector) ) continue;
00152 if ( qual < pars->get_inrec_qual_st4(lwheel, sector) ) continue;
00153 }
00154
00155 if ( reladr/2 == 1 && qual < pars->get_soc_stdis_n(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
00156 if ( reladr/2 == 2 && qual < pars->get_soc_stdis_wl(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
00157 if ( reladr/2 == 3 && qual < pars->get_soc_stdis_zl(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
00158 if ( reladr/2 == 4 && qual < pars->get_soc_stdis_wr(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
00159 if ( reladr/2 == 5 && qual < pars->get_soc_stdis_zr(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
00160
00161
00162
00163
00164 bool skipTS = false;
00165
00166 bool nbx_del = pars->get_soc_nbx_del(m_sp.id().wheel(), m_sp.id().sector());
00167 if ( L1MuDTTFConfig::getTSOutOfTimeFilter() || nbx_del ) {
00168
00169 int sh_phi = 12 - L1MuDTTFConfig::getNbitsExtPhi();
00170 int tolerance = L1MuDTTFConfig::getTSOutOfTimeWindow();
00171
00172 L1MuDTChambPhDigi* tsPreviousBX_1 = dttrig->chPhiSegm1(wheel,station,sector,bx-1);
00173 if ( tsPreviousBX_1 ) {
00174 int phiBX = tsPreviousBX_1->phi();
00175 int qualBX = tsPreviousBX_1->code();
00176 if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
00177 qualBX > qual ) skipTS = true;
00178 }
00179
00180 L1MuDTChambPhDigi* tsPreviousBX_2 = dttrig->chPhiSegm2(wheel,station,sector,bx-1);
00181 if ( tsPreviousBX_2 ) {
00182 int phiBX = tsPreviousBX_2->phi();
00183 int qualBX = tsPreviousBX_2->code();
00184 if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
00185 qualBX > qual ) skipTS = true;
00186 }
00187
00188 L1MuDTChambPhDigi* tsNextBX_1 = dttrig->chPhiSegm1(wheel,station,sector,bx+1);
00189 if ( tsNextBX_1 ) {
00190 int phiBX = tsNextBX_1->phi();
00191 int qualBX = tsNextBX_1->code();
00192 if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
00193 qualBX > qual ) skipTS = true;
00194 }
00195
00196 L1MuDTChambPhDigi* tsNextBX_2 = dttrig->chPhiSegm2(wheel,station,sector,bx+1);
00197 if ( tsNextBX_2 ) {
00198 int phiBX = tsNextBX_2->phi();
00199 int qualBX = tsNextBX_2->code();
00200 if ( abs( (phi >> sh_phi) - (phiBX >> sh_phi) ) <= tolerance &&
00201 qualBX > qual ) skipTS = true;
00202 }
00203
00204 }
00205
00206 if ( !skipTS ) {
00207 L1MuDTTrackSegPhi tmpts(wheel,sector,station,phi,phib,
00208 static_cast<L1MuDTTrackSegPhi::TSQuality>(qual),
00209 tag,bx-bx_offset);
00210 m_sp.data()->addTSphi(address-1,tmpts);
00211 }
00212 }
00213
00214 }
00215 }
00216
00217 }
00218
00219
00220
00221
00222
00223 void L1MuDTSectorReceiver::receiveCSCData(int bx, const edm::Event& e, const edm::EventSetup& c) {
00224
00225 if ( (L1MuDTTFConfig::getCSCTrSInputTag()).label() == "none" ) return;
00226
00227 if ( bx < -6 || bx > 6 ) return;
00228
00229 edm::Handle<CSCTriggerContainer<csctf::TrackStub> > csctrig;
00230 e.getByLabel(L1MuDTTFConfig::getCSCTrSInputTag(),csctrig);
00231
00232 const int bxCSC = 6;
00233
00234 vector<csctf::TrackStub> csc_list;
00235 vector<csctf::TrackStub>::const_iterator csc_iter;
00236
00237 int station = 1;
00238 int wheel = m_sp.id().wheel();
00239 int side = ( wheel == 3 ) ? 1 : 2;
00240 int sector = m_sp.id().sector();
00241 int csc_sector = ( sector == 0 ) ? 6 : (sector+1)/2;
00242 int subsector = ( sector%2 == 0 ) ? 2 : 1;
00243
00244 csc_list = csctrig->get(side,station,csc_sector,subsector,bxCSC+bx);
00245 int ncsc = 0;
00246 for ( csc_iter = csc_list.begin(); csc_iter != csc_list.end(); csc_iter++ ) {
00247 bool etaFlag = ( csc_iter->etaPacked() > 17 );
00248 int qualCSC = csc_iter->getQuality();
00249
00250
00251 unsigned int qual = 7;
00252 if ( qualCSC == 2 ) qual = 0;
00253 if ( qualCSC == 6 ) qual = 1;
00254 if ( qualCSC == 7 ) qual = 2;
00255 if ( qualCSC == 8 ) qual = 2;
00256 if ( qualCSC == 9 ) qual = 3;
00257 if ( qualCSC == 10 ) qual = 3;
00258 if ( qualCSC == 11 ) qual = 4;
00259 if ( qualCSC == 12 ) qual = 5;
00260 if ( qualCSC == 13 ) qual = 5;
00261 if ( qualCSC == 14 ) qual = 6;
00262 if ( qualCSC == 15 ) qual = 6;
00263 if ( qual == 7 ) continue;
00264
00265
00266 int phi = csc_iter->phiPacked();
00267 if ( phi > 2047 ) phi -= 4096;
00268 if ( phi < -2048 || phi > 2047 ) continue;
00269
00270 if ( msks->get_inrec_chdis_csc(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
00271 if ( qual < pars->get_soc_qual_csc(m_sp.id().wheel(), m_sp.id().sector()) ) continue;
00272
00273 if ( ncsc < 2 ) {
00274 int address = 16 + ncsc;
00275 bool tag = (ncsc == 1 ) ? true : false;
00276 L1MuDTTrackSegPhi tmpts(wheel,sector,station+2,phi,0,
00277 static_cast<L1MuDTTrackSegPhi::TSQuality>(qual),
00278 tag,bx,etaFlag);
00279 m_sp.data()->addTSphi(address,tmpts);
00280 ncsc++;
00281 }
00282
00283 }
00284
00285 }
00286
00287
00288
00289
00290
00291
00292 int L1MuDTSectorReceiver::address2sector(int adr) const {
00293
00294 int sector = m_sp.id().sector();
00295
00296 if ( adr >= 4 && adr <= 7 ) sector = (sector+13)%12;
00297 if ( adr >= 8 && adr <= 11 ) sector = (sector+11)%12;
00298
00299 return sector;
00300
00301 }
00302
00303
00304
00305
00306
00307 int L1MuDTSectorReceiver::address2wheel(int adr) const {
00308
00309 int wheel = m_sp.id().locwheel();
00310
00311
00312 if ( (adr/2)%2 == 1 ) wheel = m_sp.id().wheel();
00313
00314 return wheel;
00315
00316 }