35 LogDebug(
"CSCTFUnpacker|ctor") <<
"Started ...";
46 LogDebug(
"CSCTFUnpacker|ctor") <<
"Verifying slot<->sector map from 'vint32 slot2sector'";
47 for (
int slot = 0; slot < 22; slot++)
49 throw cms::Exception(
"Invalid configuration") <<
"CSCTFUnpacker: sector index is set out of range (slot2sector["
50 << slot <<
"]=" <<
slot2sector[slot] <<
", should be [0-12])";
57 LogDebug(
"CSCTFUnpacker|ctor") <<
"Define ``mapping'' only if you want to screw up real geometry";
60 LogDebug(
"CSCTFUnpacker|ctor") <<
"Generating default hw<->geometry mapping";
62 void fill(
void)
override {}
67 for (
int sector = 1; sector <= 6; sector++)
79 produces<CSCCorrelatedLCTDigiCollection>();
80 produces<L1CSCTrackCollection>();
81 produces<L1CSCStatusDigiCollection>();
82 produces<CSCTriggerContainer<csctf::TrackStub>>(
"DT");
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,
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}};
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);
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;