@@ -24,6 +24,7 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
2424 const HGCalMappingModuleIndexer& moduleIndexer,
2525 const HGCalConfiguration& config,
2626 hgcaldigi::HGCalDigiHost& digis,
27+ hgcaldigi::HGCalFEDPacketInfoHost& fedPacketInfo,
2728 hgcaldigi::HGCalECONDPacketInfoHost& econdPacketInfo,
2829 bool headerOnlyMode) {
2930 // ReadoutSequence object for this FED
@@ -54,7 +55,20 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
5455 LogDebug (" [HGCalUnpacker]" ) << " fedId = " << fedId << " , nwords (64b) = " << std::distance (header, trailer);
5556 const auto * ptr = header;
5657
58+ // read L1A number from the SLink header
59+ uint64_t SLinkL1Amask = (uint64_t (BACKEND_FRAME::SLINK_GLOBAL_EVENTID_MSB_MASK) << 32 ) |
60+ uint64_t (BACKEND_FRAME::SLINK_GLOBAL_EVENTID_LSB_MASK);
61+ uint64_t L1ASLink = ((*(header + 1 ) >> BACKEND_FRAME::SLINK_GLOBAL_EVENTID_LSB_POS) & SLinkL1Amask);
62+ // read BX number and Orbit number from the SLink trailer
63+ uint16_t BXSLink = ((*(trailer - 1 ) >> BACKEND_FRAME::SLINK_BXID_POS) & BACKEND_FRAME::SLINK_BXID_MASK);
64+ uint32_t OrbitSLink = ((*(trailer - 2 ) >> (BACKEND_FRAME::SLINK_ORBID_POS + 32 )) & BACKEND_FRAME::SLINK_ORBID_MASK);
65+ fedPacketInfo.view ()[fedId].FEDL1A () = L1ASLink;
66+ fedPacketInfo.view ()[fedId].FEDBX () = BXSLink;
67+ fedPacketInfo.view ()[fedId].FEDOrbit () = OrbitSLink;
5768#ifdef EDM_ML_DEBUG
69+ LogDebug (" [HGCalUnpacker]" ) << " S-Link BX number:" << std::dec << BXSLink << " , L1A number:" << std::dec
70+ << (int )L1ASLink << " , Orbit ID:" << std::dec << (int )OrbitSLink;
71+
5872 for (unsigned iword = 0 ; ptr < trailer; ++iword) {
5973 LogDebug (" [HGCalUnpacker]" ) << std::setw (8 ) << iword << " : 0x" << std::hex << std::setfill (' 0' ) << std::setw (16 )
6074 << *ptr << " (" << std::setfill (' 0' ) << std::setw (8 )
@@ -65,7 +79,6 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
6579 LogDebug (" [HGCalUnpacker]" ) << " @@@\n " ;
6680 ptr = header;
6781#endif
68-
6982 // check SLink header (128b)
7083 // sanity check
7184 auto slink_header = *(ptr + 1 );
@@ -92,6 +105,7 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
92105 for (uint32_t captureblockIdx = 0 ; captureblockIdx < HGCalMappingModuleIndexer::maxCBperFED_ && ptr < trailer - 2 ;
93106 captureblockIdx++) {
94107 // check capture block header (64b)
108+
95109 LogDebug (" [HGCalUnpacker]" ) << " @" << std::setw (8 ) << std::distance (header, ptr) << " : 0x" << std::hex
96110 << std::setfill (' 0' ) << std::setw (16 ) << *ptr << std::dec;
97111 auto cb_header = *ptr;
@@ -126,11 +140,21 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
126140 << " from 0x" << cb_header << " ." ;
127141 return (0x1 << hgcaldigi::FEDUnpackingFlags::ErrorCaptureBlockHeader);
128142 }
143+ uint16_t BXCaptureBlock =
144+ ((cb_header >> (BACKEND_FRAME::CAPTUREBLOCK_BC_POS + 32 )) & BACKEND_FRAME::CAPTUREBLOCK_BC_MASK);
145+ uint8_t L1ACaptureBlock =
146+ ((cb_header >> (BACKEND_FRAME::CAPTUREBLOCK_EC_POS + 32 )) & BACKEND_FRAME::CAPTUREBLOCK_EC_MASK);
147+ uint8_t OrbitCaptureBlock =
148+ ((cb_header >> (BACKEND_FRAME::CAPTUREBLOCK_OC_POS + 32 )) & BACKEND_FRAME::CAPTUREBLOCK_OC_MASK);
149+ LogDebug (" [HGCalUnpacker]" ) << " CB BX number:" << std::dec << BXCaptureBlock << " , L1A number:" << std::dec
150+ << (int )L1ACaptureBlock << " , Orbit number:" << std::dec << (int )OrbitCaptureBlock;
129151 ++ptr;
130152
131153 // parse Capture Block body (ECON-Ds)
132154 for (uint32_t econdIdx = 0 ; econdIdx < HGCalMappingModuleIndexer::maxECONDperCB_; econdIdx++) {
133155 auto econd_pkt_status = (cb_header >> (3 * econdIdx)) & 0b111 ;
156+ LogDebug (" [HGCalUnpacker]" ) << " fedId = " << fedId << " , captureblockIdx = " << captureblockIdx
157+ << " , econdIdx = " << econdIdx << " , econd_pkt_status = " << econd_pkt_status;
134158 if (econd_pkt_status != backend::ECONDPacketStatus::InactiveECOND) {
135159 // always increment the global ECON-D index (unless inactive/unconnected)
136160 globalECONDIdx++;
@@ -157,6 +181,19 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
157181 econdPacketInfo.view ()[ECONDdenseIdx].location () = (uint32_t )(ptr - header);
158182 const auto econd_payload_length = ((econd_headers[0 ] >> ECOND_FRAME::PAYLOAD_POS) & ECOND_FRAME::PAYLOAD_MASK);
159183
184+ // read BX, L1A, and Orbit number from the ECON-D header
185+ uint16_t BXECOND = ((econd_headers[1 ] >> ECOND_FRAME::BX_POS) & ECOND_FRAME::BX_MASK);
186+ uint8_t L1AECOND = ((econd_headers[1 ] >> ECOND_FRAME::L1A_POS) & ECOND_FRAME::L1A_MASK);
187+ uint8_t OrbitECOND = ((econd_headers[1 ] >> ECOND_FRAME::ORBIT_POS) & ECOND_FRAME::ORBIT_MASK);
188+ econdPacketInfo.view ()[ECONDdenseIdx].BX () = BXECOND;
189+ econdPacketInfo.view ()[ECONDdenseIdx].L1A () = L1AECOND;
190+ econdPacketInfo.view ()[ECONDdenseIdx].Orbit () = OrbitECOND;
191+ econdPacketInfo.view ()[ECONDdenseIdx].CBBX () = BXCaptureBlock;
192+ econdPacketInfo.view ()[ECONDdenseIdx].CBL1A () = L1ACaptureBlock;
193+ econdPacketInfo.view ()[ECONDdenseIdx].CBOrbit () = OrbitCaptureBlock;
194+ LogDebug (" [HGCalUnpacker]" ) << " ECON-D BX number:" << std::dec << BXECOND << " , L1A number:" << std::dec
195+ << (int )L1AECOND << " , Orbit number:" << std::dec << (int )OrbitECOND;
196+ // sanity check
160197 // ECON-D header marker check
161198 if (((econd_headers[0 ] >> ECOND_FRAME::HEADER_POS) & ECOND_FRAME::HEADER_MASK) !=
162199 fedConfig.econds [globalECONDIdx].headerMarker ) {
@@ -213,7 +250,6 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
213250 << " , E/B/O = 0b"
214251 << std::bitset<2 >((econd_headers[0 ] >> ECOND_FRAME::EBO_POS) & ECOND_FRAME::EBO_MASK)
215252 << " , M = " << ((econd_headers[0 ] >> ECOND_FRAME::BITM_POS) & 0b1 );
216-
217253 // quality check for ECON-D (check econd_pkt_status here for error in trailer CRC)
218254 if ((((econd_headers[0 ] >> ECOND_FRAME::HT_POS) & ECOND_FRAME::HT_MASK) >= 0b10 ) ||
219255 (((econd_headers[0 ] >> ECOND_FRAME::EBO_POS) & ECOND_FRAME::EBO_MASK) >= 0b10 ) ||
@@ -240,7 +276,6 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
240276 }
241277 LogDebug (" [HGCalUnpacker]" ) << " fedId = " << fedId << " , captureblockIdx = " << captureblockIdx
242278 << " , econdIdx = " << econdIdx << " , erxIdx = " << erxIdx;
243-
244279 econdPacketInfo.view ()[ECONDdenseIdx].cm ()(erxIdx, 0 ) =
245280 (econd_payload[iword] >> ECOND_FRAME::COMMONMODE0_POS) & ECOND_FRAME::COMMONMODE0_MASK;
246281 econdPacketInfo.view ()[ECONDdenseIdx].cm ()(erxIdx, 1 ) =
0 commit comments