Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:07

0001 /** \file
0002  *
0003  *  \author N. Amapane - CERN, R. Mommsen - FNAL
0004  */
0005 
0006 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
0007 #include "DataFormats/FEDRawData/src/fed_header.h"
0008 
0009 FEDHeader::FEDHeader(const unsigned char* header) : theHeader(reinterpret_cast<const fedh_t*>(header)) {}
0010 
0011 FEDHeader::~FEDHeader() {}
0012 
0013 uint8_t FEDHeader::triggerType() const { return FED_EVTY_EXTRACT(theHeader->eventid); }
0014 
0015 uint32_t FEDHeader::lvl1ID() const { return FED_LVL1_EXTRACT(theHeader->eventid); }
0016 
0017 uint16_t FEDHeader::bxID() const { return FED_BXID_EXTRACT(theHeader->sourceid); }
0018 
0019 uint16_t FEDHeader::sourceID() const { return FED_SOID_EXTRACT(theHeader->sourceid); }
0020 
0021 uint8_t FEDHeader::version() const { return FED_VERSION_EXTRACT(theHeader->sourceid); }
0022 
0023 bool FEDHeader::moreHeaders() const { return (FED_MORE_HEADERS_EXTRACT(theHeader->sourceid) != 0); }
0024 
0025 void FEDHeader::set(unsigned char* header,
0026                     uint8_t triggerType,
0027                     uint32_t lvl1ID,
0028                     uint16_t bxID,
0029                     uint16_t sourceID,
0030                     uint8_t version,
0031                     bool moreHeaders) {
0032   // FIXME: should check that input ranges are OK!!!
0033   fedh_t* h = reinterpret_cast<fedh_t*>(header);
0034   h->eventid = (FED_SLINK_START_MARKER << FED_HCTRLID_SHIFT) | ((triggerType << FED_EVTY_SHIFT) & FED_EVTY_MASK) |
0035                ((lvl1ID << FED_LVL1_SHIFT) & FED_LVL1_MASK);
0036 
0037   h->sourceid = (((bxID & FED_BXID_WIDTH) << FED_BXID_SHIFT) & FED_BXID_MASK) |
0038                 ((sourceID << FED_SOID_SHIFT) & FED_SOID_MASK) | ((version << FED_VERSION_SHIFT) & FED_VERSION_MASK);
0039 
0040   if (moreHeaders)
0041     h->sourceid |= (FED_MORE_HEADERS_WIDTH << FED_MORE_HEADERS_SHIFT);
0042 }
0043 
0044 bool FEDHeader::check() const { return (FED_HCTRLID_EXTRACT(theHeader->eventid) == FED_SLINK_START_MARKER); }
0045 
0046 const uint32_t FEDHeader::length = sizeof(fedh_t);