98 auto LCTProduct = std::make_unique<CSCCorrelatedLCTDigiCollection>();
99 auto trackProduct = std::make_unique<L1CSCTrackCollection>();
100 auto statusProduct = std::make_unique<L1CSCStatusDigiCollection>();
101 auto dtProduct = std::make_unique<CSCTriggerContainer<csctf::TrackStub>>();
105 if (fedData.
size() == 0)
110 if (unpacking_status == 0) {
114 for (std::vector<const CSCSPEvent*>::const_iterator spItr = SPs.begin(); spItr != SPs.end(); spItr++) {
132 for (
unsigned int tbin = 0; tbin < sp->
header().
nTBINs(); tbin++) {
139 for (
unsigned int FPGA = 0; FPGA < 5; FPGA++)
140 for (
unsigned int MPClink = 0; MPClink < 3; ++MPClink) {
141 std::vector<CSCSP_MEblock> lct = sp->
record(tbin).
LCT(FPGA, MPClink);
145 status.
link_status[lct[0].spInput()] |= (1 << lct[0].receiver_status_frame1()) |
146 (1 << lct[0].receiver_status_frame2()) |
147 ((lct[0].aligment_fifo() ? 1 : 0) << 4);
148 status.
mpc_link_id |= (lct[0].link() << 2) | lct[0].mpc();
150 int station = (FPGA ? FPGA : 1);
151 int endcap = 0, sector = 0;
161 int subsector = (FPGA > 1 ? 0 : FPGA + 1);
162 int cscid = lct[0].csc();
167 LCTProduct->insertDigi(
id,
173 endcap == 2 && lct[0].
strip() < 65
174 ? 65 - lct[0].
strip()
178 (lct[0].tbin() + (central_lct_bx - central_sp_bx)),
185 << e.
what() <<
"Not adding digi to collection in event " << sp->
header().
L1A()
186 <<
" (endcap=" << endcap <<
",station=" << station <<
",sector=" << sector
187 <<
",subsector=" << subsector <<
",cscid=" << cscid <<
",spSlot=" << sp->
header().
slot() <<
")";
191 std::vector<CSCSP_MBblock> mbStubs = sp->
record(tbin).
mbStubs();
192 for (std::vector<CSCSP_MBblock>::const_iterator iter = mbStubs.begin(); iter != mbStubs.end(); iter++) {
203 const unsigned int csc2dt[6][2] = {{2, 3}, {4, 5}, {6, 7}, {8, 9}, {10, 11}, {12, 1}};
204 DTChamberId id((endcap == 1 ? 2 : -2), 1, csc2dt[sector - 1][iter->id() - 1]);
212 tbin + (central_lct_bx - central_sp_bx),
218 dtProduct->push_back(dtStub);
222 unsigned int trkNumber = 0;
223 for (std::vector<CSCSP_SPblock>::const_iterator iter = tracks.begin(); iter != tracks.end();
224 iter++, trkNumber++) {
229 if (track.first.m_sector > 6)
230 track.first.m_sector -= 6;
236 track.first.m_lphi = iter->phi();
237 track.first.m_ptAddress = iter->ptLUTaddress();
238 track.first.m_fr = iter->f_r();
239 track.first.m_ptAddress |= (iter->f_r() << 21);
241 track.first.setStationIds(iter->ME1_id(), iter->ME2_id(), iter->ME3_id(), iter->ME4_id(), iter->MB_id());
242 track.first.setTbins(
243 iter->ME1_tbin(), iter->ME2_tbin(), iter->ME3_tbin(), iter->ME4_tbin(), iter->MB_tbin());
244 track.first.setBx(iter->tbin() - central_sp_bx);
245 track.first.setBits(iter->syncErr(), iter->bx0(), iter->bc0());
247 track.first.setLocalPhi(iter->phi());
248 track.first.setEtaPacked(iter->eta());
249 track.first.setChargePacked(iter->charge());
251 track.first.m_output_link = iter->id();
252 if (track.first.m_output_link) {
255 track.first.setChargeValidPacked(
258 track.first.m_rank = 0;
259 track.first.setChargeValidPacked(0);
261 track.first.setFineHaloPacked(iter->halo());
263 track.first.m_winner = iter->MS_id() & (1 << trkNumber);
265 std::vector<CSCSP_MEblock> lcts = iter->LCTs();
266 for (std::vector<CSCSP_MEblock>::const_iterator lct = lcts.begin(); lct != lcts.end(); lct++) {
267 int station = (lct->spInput() > 6 ? (lct->spInput() - 1) / 3 : 1);
268 int subsector = (lct->spInput() > 6 ? 0 : (lct->spInput() - 1) / 3 + 1);
271 mapping->
detId(track.first.m_endcap, station, track.first.m_sector, subsector, lct->csc(), 0);
272 track.second.insertDigi(
id,
278 track.first.m_endcap == 2 && lct[0].strip() < 65
279 ? 65 - lct[0].strip()
283 (lct->tbin() + (central_lct_bx - central_sp_bx)),
290 << e.
what() <<
"Not adding track digi to collection in event" << sp->
header().
L1A()
291 <<
" (endcap=" << track.first.m_endcap <<
",station=" << station
292 <<
",sector=" << track.first.m_sector <<
",subsector=" << subsector <<
",cscid=" << lct->csc()
297 std::vector<CSCSP_MBblock> mbStubs = iter->dtStub();
298 for (std::vector<CSCSP_MBblock>::const_iterator iter = mbStubs.begin(); iter != mbStubs.end(); iter++) {
300 track.second.insertDigi(
id,
303 iter->quality() + 100,
308 tbin + (central_lct_bx - central_sp_bx),
315 trackProduct->push_back(track);
318 statusProduct->second.push_back(status);
322 <<
" problem of unpacking TF event: 0x" << std::hex << unpacking_status <<
std::dec <<
" code";
325 statusProduct->first = unpacking_status;
unsigned int unpack(const unsigned short *buf, unsigned int length)
std::vector< CSCSP_MBblock > mbStubs(void) const
std::vector< const CSCSPEvent * > SPs_fast(void) const
unsigned int SEs(void) const
std::pair< csc::L1Track, CSCCorrelatedLCTDigiCollection > L1CSCTrack
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< CSCSP_MEblock > LCT(unsigned int mpc, unsigned int link) const
unsigned int AFs(void) const
char const * what() const override
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
unsigned int VPs(void) const
unsigned int ptSpy(void) const
size_t size() const
Lenght of the data buffer in bytes.
int orbit_counter(void) const
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< CSCSP_SPblock > tracks(void) const
const CSCSPRecord & record(unsigned int tbin) const
int track_counter(void) const
std::vector< int > slot2sector
unsigned int SMs(void) const
unsigned int BXs(void) const
const CSCSPCounters & counters(void) const
unsigned short fmm_status
CSCTriggerMapping * mapping
const CSCSPHeader & header(void) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
unsigned short link_status[15]
CSCDetId detId(int endcap, int station, int sector, int subsector, int cscid, int layer=0) const
unsigned short mpc_link_id