79 throw cms::Exception(
"OutputFile ") <<
"CSCTFPacker: cannot open output file (errno=" << errno
80 <<
"). Try outputFile=\"\"";
93 produces<FEDRawDataCollection>(
"CSCTFRawData");
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();
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();
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;
165 if (lct->isValid()) {
166 switch ((meDataHeader[
sector][tbin].vp_bits >> (fpga * 3)) & 0x7) {
177 edm::LogInfo(
"CSCTFPacker: more than 3 LCTs from a single MPC in one BX!!!");
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;
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();
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;
260 spDataRecord[
sector][tbin][nTrk[
sector][tbin]].
eta_ = trk->first.eta_packed();
262 spDataRecord[
sector][tbin][nTrk[
sector][tbin]].
halo_ = trk->first.finehalo_packed();
283 if (trk->first.mb1ID()) {
284 int subSector = (trk->first.mb1ID() - 1) % 2;
286 if (subSector < 0 || subSector > 1 || MBtbin < 0 || MBtbin > 7 || !mbDataRecord[
sector][subSector][MBtbin].id_)
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);
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++)
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);
T getParameter(std::string const &) const
unsigned aligment_fifo_empty
T const * product() const
unsigned clct_pattern_number
unsigned aligment_fifo_full
CSCTFPacker(const edm::ParameterSet &conf)
Log< level::Error, false > LogError
edm::EDGetTokenT< CSCTriggerContainer< csctf::TrackStub > > CSCTC_Tok
~CSCTFPacker(void) override
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
unsigned receiver_status_dv2
edm::InputTag trackProducer
unsigned receiver_status_dv1
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
void produce(edm::Event &e, const edm::EventSetup &c) override
unsigned receiver_status_er2
#define DEFINE_FWK_MODULE(type)
unsigned receiver_status_er1
Log< level::Info, false > LogInfo
unsigned short activeSectors
std::pair< const_iterator, const_iterator > Range
edm::InputTag lctProducer
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