Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:15:02

0001 /* -*- C++ -*- */
0002 #ifndef AMC13Header_H_included
0003 #define AMC13Header_H_included
0004 
0005 #include <cstdint>
0006 
0007 namespace hcal {
0008   /** \class AMC13Header
0009    *
0010    *  Interpretive class for the AMC13XG common data format
0011    */
0012   class AMC13Header {
0013   public:
0014     /** get the source id from the CDF header */
0015     inline int sourceId() const { return int(cdfHeader >> 8) & 0xFFF; }
0016     /** get the bunch id from the CDF header */
0017     inline int bunchId() const { return int(cdfHeader >> 20) & 0xFFF; }
0018     /** get the Event Number from the CDF header */
0019     inline int l1aNumber() const { return int((cdfHeader >> 32) & 0x00FFFFFF); }
0020     /** Get the Event Type value (2007.11.03 - Not defined, but should stay consistent among events.) */
0021     inline int CDFEventType() const { return (int(cdfHeader >> 56) & 0x0F); }
0022     /** Get the Orbit Number from the CDF. */
0023     inline unsigned int orbitNumber() const { return (unsigned int)((amc13Header >> 4) & 0xFFFFFFFFu); }
0024     /** Get the number of modules in the payload */
0025     inline int NAMC() const { return int((amc13Header >> 52) & 0xF); }
0026     /** Get the format version number */
0027     inline int AMC13FormatVersion() const { return int((amc13Header >> 60) & 0xF); }
0028 
0029     // Per-AMC items
0030     /** Get the board identifier for the given module (sequential) */
0031     inline uint16_t AMCId(int i) const { return uint16_t(modulesHeaders[i] & 0xFFFF); }
0032     /** Get the slot for the given module (sequential) */
0033     inline int AMCSlot(int i) const { return int((modulesHeaders[i] >> 16) & 0xF); }
0034     /** Get the block number */
0035     inline int AMCBlockNumber(int i) const { return int((modulesHeaders[i] >> 20) & 0xFF); }
0036     /** Get the size */
0037     inline int AMCSize(int i) const { return int((modulesHeaders[i] >> 32) & 0xFFFFFF); }
0038     /** More blocks? */
0039     inline bool AMCMore(int i) const { return ((modulesHeaders[i] >> 61) & 0x1) != 0; }
0040     /** Segmented data? */
0041     inline bool AMCSegmented(int i) const { return ((modulesHeaders[i] >> 60) & 0x1) != 0; }
0042     /** Was the length as expected? */
0043     inline bool AMCLengthOk(int i) const { return ((modulesHeaders[i] >> 62) & 0x1) != 0; }
0044     /** Was the CRC correct as received by the AMC13? */
0045     inline bool AMCCRCOk(int i) const { return ((modulesHeaders[i] >> 56) & 0x1) != 0; }
0046     /** Is there data for this AMC? */
0047     inline bool AMCDataPresent(int i) const { return ((modulesHeaders[i] >> 58) & 0x1) != 0; }
0048     /** Does the EvN and BCN match for this AMC? */
0049     inline bool AMCDataValid(int i) const { return ((modulesHeaders[i] >> 57) & 0x1) != 0; }
0050     /** Is this AMC input enabled? */
0051     inline bool AMCEnabled(int i) const { return ((modulesHeaders[i] >> 59) & 0x1) != 0; }
0052 
0053     /** Get the pointer to the beginning of the data for the given AMC */
0054     const uint64_t* AMCPayload(int i) const;
0055 
0056   private:
0057     uint64_t cdfHeader;
0058     uint64_t amc13Header;
0059     uint64_t modulesHeaders[12];
0060   };
0061 }  // namespace hcal
0062 
0063 #endif  // AMC13Header_H_included