std::cout<<"Front data station: "<<station<<" sector: "<<sector<<" subSector: "<<subSector<<" tbin: "<<tbin<<" cscId: "<<cscId<<" fpga: "<<fpga<<" LCT_qual="<<lct->getQuality()<<" LCT_strip="<<lct->getStrip()<<" LCT_wire="<<lct->getKeyWG()<<std::endl;
111 bzero(&meDataRecord,
sizeof(meDataRecord));
113 bzero(&meDataHeader,
sizeof(meDataHeader));
121 int station = (*csc).first.station() - 1;
122 int cscId = (*csc).first.triggerCscId() - 1;
123 int sector = (*csc).first.triggerSector() - 1 + ((*csc).first.endcap() == 1 ? 0 : 6);
126 if (tbin > 6 || tbin < 0) {
127 edm::LogError(
"CSCTFPacker|produce") <<
" LCT's BX=" << tbin <<
" is out of 0-6 window";
130 int fpga = (subSector ? subSector - 1 :
station + 1);
134 if (sector < 0 || sector > 11 || station < 0 || station > 3 || cscId < 0 || cscId > 8 || lctId < 0 || lctId > 1) {
135 edm::LogInfo(
"CSCTFPacker: CSC digi are out of range: ")
136 <<
"sector=" << sector <<
", station=" <<
station <<
", cscId=" << cscId <<
", lctId=" << lctId;
141 meDataRecord[sector][tbin][fpga][cscId][lctId].
quality_ = lct->getQuality();
142 meDataRecord[sector][tbin][fpga][cscId][lctId].
wire_group_id = lct->getKeyWG();
145 (
swapME1strips && cscId < 3 &&
station == 0 && (*csc).first.endcap() == 2 && lct->getStrip() < 65
146 ? 65 - lct->getStrip()
148 meDataRecord[sector][tbin][fpga][cscId][lctId].
csc_id = (*csc).first.triggerCscId();
149 meDataRecord[sector][tbin][fpga][cscId][lctId].
left_right = lct->getBend();
150 meDataRecord[sector][tbin][fpga][cscId][lctId].
bx0_ = 0;
151 meDataRecord[sector][tbin][fpga][cscId][lctId].
bc0_ = 0;
153 meDataRecord[sector][tbin][fpga][cscId][lctId].
me_bxn = 0;
158 meDataRecord[sector][tbin][fpga][cscId][lctId].
link_id = lct->getMPCLink();
159 meDataRecord[sector][tbin][fpga][cscId][lctId].
mpc_id = 0;
160 meDataRecord[sector][tbin][fpga][cscId][lctId].
err_prop_cnt = 0;
165 if (lct->isValid()) {
166 switch ((meDataHeader[sector][tbin].vp_bits >> (fpga * 3)) & 0x7) {
168 meDataHeader[sector][tbin].
vp_bits |= (0x1 << (fpga * 3));
171 meDataHeader[sector][tbin].
vp_bits |= (0x3 << (fpga * 3));
174 meDataHeader[sector][tbin].
vp_bits |= (0x7 << (fpga * 3));
177 edm::LogInfo(
"CSCTFPacker: more than 3 LCTs from a single MPC in one BX!!!");
181 meDataRecord[sector][tbin][fpga][cscId][lctId].
valid_pattern = 1;
183 meDataHeader[sector][tbin].
vq_a = 0;
184 meDataHeader[sector][tbin].
vq_b = 0;
185 meDataHeader[sector][tbin].
se_bits = 0;
186 meDataHeader[sector][tbin].
sm_bits = 0;
187 meDataHeader[sector][tbin].
af_bits = 0;
188 meDataHeader[sector][tbin].
bx_bits = 0;
190 meDataHeader[sector][tbin].
spare_1 = 0;
195 bzero(&mbDataRecord,
sizeof(mbDataRecord));
200 std::vector<csctf::TrackStub> stubs = barrelStubs.
product()->get();
201 for (std::vector<csctf::TrackStub>::const_iterator
dt = stubs.begin();
dt != stubs.end();
dt++) {
202 int sector =
dt->sector() - 1 + (
dt->endcap() == 1 ? 0 : 6);
203 int subSector =
dt->subsector() - 1;
205 if (tbin < 0 || tbin > 6 || sector < 0 || sector > 11 || subSector < 0 || subSector > 11) {
206 edm::LogInfo(
"CSCTFPacker: CSC DT digi are out of range: ")
207 <<
" sector=" << sector <<
" subSector=" << subSector <<
" tbin=" << tbin;
210 mbDataRecord[sector][subSector][tbin].
quality_ =
dt->getQuality();
211 mbDataRecord[sector][subSector][tbin].
phi_bend_ =
dt->getBend();
212 mbDataRecord[sector][subSector][tbin].
flag_ =
dt->getStrip();
213 mbDataRecord[sector][subSector][tbin].
cal_ =
dt->getKeyWG();
214 mbDataRecord[sector][subSector][tbin].
phi_ =
dt->phiPacked();
215 mbDataRecord[sector][subSector][tbin].
bxn1_ = (
dt->getBX0() >> 1) & 0
x1;
216 mbDataRecord[sector][subSector][tbin].
bxn0_ =
dt->getBX0() & 0x1;
217 mbDataRecord[sector][subSector][tbin].
bc0_ =
dt->getPattern();
218 mbDataRecord[sector][subSector][tbin].
mb_bxn_ =
dt->getCSCID();
221 meDataHeader[sector][tbin].
vq_a = 1;
224 meDataHeader[sector][tbin].
vq_b = 1;
230 mbDataRecord[sector][subSector][tbin].
id_ =
dt->getMPCLink();
236 bzero(&spDataRecord,
sizeof(spDataRecord));
238 bzero(&nTrk,
sizeof(nTrk));
244 for (L1CSCTrackCollection::const_iterator trk =
tracks->begin(); trk !=
tracks->end(); trk++) {
245 int sector = 6 * (trk->first.endcap() - 1) + trk->first.sector() - 1;
248 if (tbin > 6 || tbin < 0) {
249 edm::LogError(
"CSCTFPacker|analyze") <<
" Track's BX=" << tbin <<
" is out of 0-6 window";
252 if (sector < 0 || sector > 11) {
253 edm::LogError(
"CSCTFPacker|analyze") <<
" Track's sector=" << sector <<
" is out of range";
256 spDataRecord[sector][tbin][nTrk[sector][tbin]].
phi_ = trk->first.localPhi();
257 spDataRecord[sector][tbin][nTrk[sector][tbin]].
sign_ = (trk->first.ptLUTAddress() >> 20) & 0
x1;
258 spDataRecord[sector][tbin][nTrk[sector][tbin]].
front_rear = trk->first.front_rear();
259 spDataRecord[sector][tbin][nTrk[sector][tbin]].
charge_ = trk->first.charge_packed();
260 spDataRecord[sector][tbin][nTrk[sector][tbin]].
eta_ = trk->first.eta_packed();
262 spDataRecord[sector][tbin][nTrk[sector][tbin]].
halo_ = trk->first.finehalo_packed();
263 spDataRecord[sector][tbin][nTrk[sector][tbin]].
se = 0;
264 spDataRecord[sector][tbin][nTrk[sector][tbin]].
deltaPhi12_ = trk->first.ptLUTAddress() & 0xFF;
265 spDataRecord[sector][tbin][nTrk[sector][tbin]].
deltaPhi23_ = (trk->first.ptLUTAddress() >> 8) & 0xF;
266 spDataRecord[sector][tbin][nTrk[sector][tbin]].
bxn0_ = 0;
267 spDataRecord[sector][tbin][nTrk[sector][tbin]].
bc0_ = 0;
269 spDataRecord[sector][tbin][nTrk[sector][tbin]].
me1_id = trk->first.me1ID();
270 spDataRecord[sector][tbin][nTrk[sector][tbin]].
me2_id = trk->first.me2ID();
271 spDataRecord[sector][tbin][nTrk[sector][tbin]].
me3_id = trk->first.me3ID();
272 spDataRecord[sector][tbin][nTrk[sector][tbin]].
me4_id = trk->first.me4ID();
273 spDataRecord[sector][tbin][nTrk[sector][tbin]].
mb_id = trk->first.mb1ID();
274 spDataRecord[sector][tbin][nTrk[sector][tbin]].
ms_id = 0;
277 spDataRecord[sector][tbin][nTrk[sector][tbin]].
me1_tbin = trk->first.me1Tbin();
278 spDataRecord[sector][tbin][nTrk[sector][tbin]].
me2_tbin = trk->first.me2Tbin();
279 spDataRecord[sector][tbin][nTrk[sector][tbin]].
me3_tbin = trk->first.me3Tbin();
280 spDataRecord[sector][tbin][nTrk[sector][tbin]].
me4_tbin = trk->first.me4Tbin();
281 spDataRecord[sector][tbin][nTrk[sector][tbin]].
mb_tbin = trk->first.mb1Tbin();
283 if (trk->first.mb1ID()) {
284 int subSector = (trk->first.mb1ID() - 1) % 2;
285 int MBtbin = tbin - spDataRecord[sector][tbin][nTrk[sector][tbin]].
mb_tbin;
286 if (subSector < 0 || subSector > 1 || MBtbin < 0 || MBtbin > 7 || !mbDataRecord[sector][subSector][MBtbin].id_)
287 spDataRecord[sector][tbin][nTrk[sector][tbin]].
mb_id = (subSector ? 6 : 5);
289 spDataRecord[sector][tbin][nTrk[sector][tbin]].
id_ = nTrk[sector][tbin] + 1;
291 nTrk[sector][tbin]++;
292 switch (nTrk[sector][tbin]) {
294 meDataHeader[sector][tbin].
mode1 = (trk->first.ptLUTAddress() >> 16) & 0xF;
297 meDataHeader[sector][tbin].
mode2 = (trk->first.ptLUTAddress() >> 16) & 0xF;
300 meDataHeader[sector][tbin].
mode3 = (trk->first.ptLUTAddress() >> 16) & 0xF;
303 edm::LogInfo(
"More than 3 tracks from one SP in the BX");
313 header.header_mark_1 = 0x9;
314 header.header_mark_2 = 0x9;
315 header.header_mark_3 = 0x9;
316 header.header_mark_4 = 0x9;
318 header.header_mark_5 = 0xA;
319 header.header_mark_6 = 0xA;
320 header.header_mark_7 = 0xA;
321 header.header_mark_8 = 0xA;
333 bzero(&trailer,
sizeof(trailer));
346 unsigned short spDDUrecord[700 * 12], *
pos = spDDUrecord;
347 bzero(&spDDUrecord,
sizeof(spDDUrecord));
348 int eventNumber =
e.id().event();
351 *
pos++ = 0xFFFF & eventNumber;
352 *
pos++ = 0x5000 | (eventNumber >> 16);
362 for (
int sector = 0; sector < 12; sector++) {
365 header.sp_trigger_sector = sector + 1;
371 for (
int tbin = 0; tbin <
nTBINs; tbin++) {
372 memcpy(
pos, &meDataHeader[sector][tbin], 16);
374 for (
int fpga = 0; fpga < 5; fpga++) {
376 for (
int link = 0; link < 3; link++) {
377 for (
int cscId = 0; cscId < 9; cscId++)
378 for (
int lctId = 0; lctId < 2; lctId++)
380 if (meDataRecord[sector][tbin][fpga][cscId][lctId].valid_pattern &&
381 meDataRecord[sector][tbin][fpga][cscId][lctId].link_id == link + 1) {
382 memcpy(
pos, &meDataRecord[sector][tbin][fpga][cscId][lctId], 8);
388 pos += 4 * (3 - nLCTs);
390 for (
int subSector = 0; subSector < 2; subSector++)
391 if (!
zeroSuppression || (subSector == 0 && meDataHeader[sector][tbin].vq_a) ||
392 (subSector == 1 && meDataHeader[sector][tbin].
vq_b)) {
393 memcpy(
pos, &mbDataRecord[sector][subSector][tbin], 8);
396 for (
int trk = 0; trk < 3; trk++) {
398 memcpy(
pos, &spDataRecord[sector][tbin][trk], 8);
403 memcpy(
pos, &trailer, 16);
421 auto data = std::make_unique<FEDRawDataCollection>();
423 fedRawData.resize((
pos - spDDUrecord) *
sizeof(
unsigned short));
437 fwrite(spDDUrecord, 2,
pos - spDDUrecord,
file);
unsigned aligment_fifo_empty
T const * product() const
unsigned clct_pattern_number
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t uint32_t CAHitNtupletGeneratorKernelsGPU::Counters * counters
unsigned aligment_fifo_full
Log< level::Error, false > LogError
edm::EDGetTokenT< CSCTriggerContainer< csctf::TrackStub > > CSCTC_Tok
unsigned receiver_status_dv2
edm::InputTag trackProducer
unsigned receiver_status_dv1
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
unsigned receiver_status_er2
unsigned receiver_status_er1
Log< level::Info, false > LogInfo
unsigned short activeSectors
auto const & tracks
cannot be loose
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
static int triggerSubSectorFromLabels(int station, int chamber)
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > CSCCDC_Tok
char data[epos_bytes_allocation]
unsigned int valid_pattern
edm::EDGetTokenT< L1CSCTrackCollection > L1CSCTr_Tok