Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:22

0001 #ifndef EventFilter_CSCRawToDigi_CSCDDUEventData_h
0002 #define EventFilter_CSCRawToDigi_CSCDDUEventData_h
0003 
0004 /** \class CSCDDUEventData
0005  *
0006  * \author Rick Wilkinson
0007  * \author A. Tumanov
0008  */
0009 
0010 #include <vector>
0011 #include "EventFilter/CSCRawToDigi/interface/CSCEventData.h"
0012 #include "EventFilter/CSCRawToDigi/interface/CSCDDUHeader.h"
0013 #include "EventFilter/CSCRawToDigi/interface/CSCDDUTrailer.h"
0014 #include "EventFilter/CSCRawToDigi/interface/CSCDCCHeader.h"
0015 #include "EventFilter/CSCRawToDigi/interface/CSCDCCTrailer.h"
0016 #include "EventFilter/CSCRawToDigi/interface/CSCDCCExaminer.h"
0017 #include <boost/dynamic_bitset.hpp>
0018 
0019 class CSCDDUEventData {
0020 public:
0021   explicit CSCDDUEventData(const CSCDDUHeader &);
0022 
0023   // buf may need to stay pinned in memory as long
0024   // as this data is used.  Not sure
0025   explicit CSCDDUEventData(const uint16_t *buf, CSCDCCExaminer *examiner = nullptr);
0026 
0027   ~CSCDDUEventData();
0028 
0029   static void setDebug(bool value) { debug = value; }
0030   static void setErrorMask(unsigned int value) { errMask = value; }
0031 
0032   /// accessor to data
0033   const std::vector<CSCEventData> &cscData() const { return theData; }
0034 
0035   CSCDDUHeader header() const { return theDDUHeader; }
0036   CSCDDUTrailer trailer() const { return theDDUTrailer; }
0037   uint16_t trailer0() const { return theDDUTrailer0; }
0038 
0039   CSCDCCHeader dccHeader() const { return theDCCHeader; }
0040   CSCDCCTrailer dccTrailer() const { return theDCCTrailer; }
0041 
0042   /// for making events.  Sets the bxnum and lvl1num inside the chamber event
0043   void add(CSCEventData &, int dmbId, int dduInput, unsigned int format_version = 2005);
0044 
0045   /// trailer info
0046   long unsigned int errorstat;
0047 
0048   bool check() const;
0049 
0050   /// prints out the error associated with this status
0051   /// from the header or trailer
0052   void decodeStatus(int status) const;
0053   void decodeStatus() const;
0054   int sizeInWords() const { return theSizeInWords; }
0055   int size() const { return theSizeInWords * 16; }  ///Alex check this 16 or 64
0056 
0057   /// returns packed event data
0058   boost::dynamic_bitset<> pack();
0059 
0060 #ifdef LOCAL_UNPACK
0061   static bool debug;
0062   static unsigned int errMask;
0063 #else
0064   static std::atomic<bool> debug;
0065   static std::atomic<unsigned int> errMask;
0066 #endif
0067 
0068   /// a good test routine would be to unpack data, then pack it again.
0069 protected:
0070   void unpack_data(const uint16_t *buf, CSCDCCExaminer *examiner = nullptr);
0071   CSCDCCHeader theDCCHeader;
0072   CSCDDUHeader theDDUHeader;
0073   // CSCData is unpacked and stored in this vector
0074   std::vector<CSCEventData> theData;
0075   CSCDDUTrailer theDDUTrailer;
0076   CSCDCCTrailer theDCCTrailer;
0077   uint16_t theDDUTrailer0;
0078   int theSizeInWords;
0079   uint16_t theFormatVersion;
0080 };
0081 
0082 #endif