Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-10 00:36:54

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