Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:20

0001 /** \file
0002  *
0003  *  \author N. Amapane - CERN, R. Mommsen - FNAL
0004  */
0005 
0006 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
0007 #include "DataFormats/FEDRawData/src/fed_trailer.h"
0008 
0009 FEDTrailer::FEDTrailer(const unsigned char* trailer) : theTrailer(reinterpret_cast<const fedt_t*>(trailer)) {}
0010 
0011 FEDTrailer::~FEDTrailer() {}
0012 
0013 uint32_t FEDTrailer::fragmentLength() const { return FED_EVSZ_EXTRACT(theTrailer->eventsize); }
0014 
0015 uint16_t FEDTrailer::crc() const { return FED_CRCS_EXTRACT(theTrailer->conscheck); }
0016 
0017 uint8_t FEDTrailer::evtStatus() const { return FED_STAT_EXTRACT(theTrailer->conscheck); }
0018 
0019 uint8_t FEDTrailer::ttsBits() const { return FED_TTSI_EXTRACT(theTrailer->conscheck); }
0020 
0021 bool FEDTrailer::moreTrailers() const { return (FED_MORE_TRAILERS_EXTRACT(theTrailer->conscheck) != 0); }
0022 
0023 bool FEDTrailer::crcModified() const { return (FED_CRC_MODIFIED_EXTRACT(theTrailer->conscheck) != 0); }
0024 
0025 bool FEDTrailer::slinkError() const { return (FED_SLINK_ERROR_EXTRACT(theTrailer->conscheck) != 0); }
0026 
0027 bool FEDTrailer::wrongFedId() const { return (FED_WRONG_FEDID_EXTRACT(theTrailer->conscheck) != 0); }
0028 
0029 uint32_t FEDTrailer::conscheck() const { return theTrailer->conscheck; }
0030 
0031 void FEDTrailer::set(
0032     unsigned char* trailer, uint32_t lenght, uint16_t crc, uint8_t evtStatus, uint8_t ttsBits, bool moreTrailers) {
0033   // FIXME: should check that input ranges are OK!!!
0034   fedt_t* t = reinterpret_cast<fedt_t*>(trailer);
0035 
0036   t->eventsize = (FED_SLINK_END_MARKER << FED_TCTRLID_SHIFT) | ((lenght << FED_EVSZ_SHIFT) & FED_EVSZ_MASK);
0037 
0038   t->conscheck = ((crc << FED_CRCS_SHIFT) & FED_CRCS_MASK) | ((evtStatus << FED_STAT_SHIFT) & FED_STAT_MASK) |
0039                  ((ttsBits << FED_TTSI_SHIFT) & FED_TTSI_MASK);
0040 
0041   if (moreTrailers)
0042     t->conscheck |= (FED_MORE_TRAILERS_WIDTH << FED_MORE_TRAILERS_SHIFT);
0043 }
0044 
0045 bool FEDTrailer::check() const { return (FED_TCTRLID_EXTRACT(theTrailer->eventsize) == FED_SLINK_END_MARKER); }
0046 
0047 const uint32_t FEDTrailer::length = sizeof(fedt_t);