Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-06-26 23:26:37

0001 #ifndef DataFormats_HGCalDigi_interface_HGCalECONDPacketInfoSoA_h
0002 #define DataFormats_HGCalDigi_interface_HGCalECONDPacketInfoSoA_h
0003 
0004 #include <cstdint>  // for uint8_t
0005 
0006 #include <Eigen/Core>
0007 
0008 #include "DataFormats/SoATemplate/interface/SoACommon.h"
0009 #include "DataFormats/SoATemplate/interface/SoALayout.h"
0010 
0011 namespace hgcaldigi {
0012 
0013   // use Matrix for common modes
0014   using Matrix = Eigen ::Matrix<uint16_t, 12, 2>;
0015   // enum for getting ECONDFlag
0016   namespace ECONDFlag {
0017     constexpr uint8_t BITT_POS = 0, BITM_POS = 1, EBO_POS = 2, EBO_MASK = 0b11, HT_POS = 4, HT_MASK = 0b11,
0018                       BITE_POS = 6, BITS_POS = 7;
0019   }  // namespace ECONDFlag
0020 
0021   // functions to parse ECONDFlag
0022   inline constexpr bool truncatedFlag(uint8_t econdFlag) {
0023     return ((econdFlag >> hgcaldigi::ECONDFlag::BITT_POS) & 0b1);
0024   }
0025   inline constexpr bool matchFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITM_POS) & 0b1); }
0026   inline constexpr uint8_t eboFlag(uint8_t econdFlag) {
0027     return ((econdFlag >> hgcaldigi::ECONDFlag::EBO_POS) & hgcaldigi::ECONDFlag::EBO_MASK);
0028   }
0029   inline constexpr uint8_t htFlag(uint8_t econdFlag) {
0030     return ((econdFlag >> hgcaldigi::ECONDFlag::HT_POS) & hgcaldigi::ECONDFlag::HT_MASK);
0031   }
0032   inline constexpr bool expectedFlag(uint8_t econdFlag) {
0033     return ((econdFlag >> hgcaldigi::ECONDFlag::BITE_POS) & 0b1);
0034   }
0035   inline constexpr bool StatFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITS_POS) & 0b1); }
0036 
0037   // generate structure of arrays (SoA) layout with Digi dataformat
0038   GENERATE_SOA_LAYOUT(HGCalECONDPacketInfoSoALayout,
0039                       // Capture block information:
0040                       // 0b000: Normal packet
0041                       // 0b001: No ECOND packet. Packet was detected and discarded because too large (>250)
0042                       // 0b010: Packet with payload CRC error
0043                       // 0b011: Packet with EventID mismatch.
0044                       // 0b100: No ECOND packet. The event builder state machine timed-out.
0045                       // 0b101: No ECOND packet due to BCID and/or OrbitID mismatch.
0046                       // 0b110: No ECOND packet. Packet was detected but was discarded due to Main Buffer overflow.
0047                       // 0b111: ECOND CRC trailer error.
0048                       SOA_COLUMN(uint16_t, cbFlag),  //cbflag
0049                       // ECON-D header information
0050                       // bit 0: Truncation flag
0051                       // bit 1: Match flag
0052                       // bit 2-3: E/B/O bits
0053                       // bit 4-5: H/T bits
0054                       // bit 6: Expected flag
0055                       // bit 7: logical OR of Stat for all active eRx
0056                       SOA_COLUMN(uint8_t, econdFlag),  //econdFlag
0057                       // Exception flag
0058                       // 0: Normal
0059                       // 1: Wrong S-Link header marker
0060                       // 2: Wrong Capture block header marker
0061                       // These will be saved to the first ECON-D in the block
0062                       // 3: Wrong ECON-D header marker
0063                       // 4: ECON-D payload length overflow(>469)
0064                       // 5: unpacked ECON-D length and payload length not match
0065                       // 6: S-Link trailer location error
0066                       // 7: S-Link End earlier
0067                       SOA_COLUMN(uint8_t, exception),
0068                       // Location
0069                       // If exception found before ECON-D, this would be 0
0070                       // Otherwise the 64b index of ECON-D header
0071                       SOA_COLUMN(uint32_t, location),
0072                       // Payload length
0073                       // If exception found before ECON-D, this would be 0
0074                       // Otherwise the payload length of the ECON-D
0075                       SOA_COLUMN(uint16_t, payloadLength),
0076                       SOA_EIGEN_COLUMN(Matrix, cm))
0077   using HGCalECONDPacketInfoSoA = HGCalECONDPacketInfoSoALayout<>;
0078 }  // namespace hgcaldigi
0079 
0080 #endif