Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-11 03:07:48

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