CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/EventFilter/EcalTBRawToDigi/src/MatacqRawEvent.h

Go to the documentation of this file.
00001 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 8; -*-
00002 //$Id: MatacqRawEvent.h,v 1.3 2007/10/20 10:58:01 franzoni Exp $
00003 
00004 #ifndef MATACQTBRAWEVENT_H
00005 #define MATACQTBRAWEVENT_H
00006 
00007 #include <inttypes.h>
00008 
00009 #if 0 //replace 1 by 0 to remove XDAQ dependency. In this case it is assumed
00010       //the machine is little endian.
00011 #include "i2o/utils/endian.h" //from XDAQ
00012 #define UINT32_FROM_LE i2odecodel
00013 #define UINT16_FROM_LE i2odecodes
00014 #define INT16_FROM_LE i2odecodes
00015 
00016 #else //assuming little endianness of the machine
00017 
00018 #define UINT32_FROM_LE
00019 #define UINT16_FROM_LE
00020 #define INT16_FROM_LE
00021 
00022 #endif
00023 
00027 class MatacqTBRawEvent{
00028   //typedefs, enums and static constants
00029 public:
00030   enum matacqError_t {
00034     errorLengthConsistency = 1<<0,
00037     errorLength = 1<<1,
00040     errorWrongBoe = 1<<2
00041   };
00042 
00043   /* The following types are little-endian encoded types. Use of these types
00044    * for the I20 data block should offer portability to big-endian platforms.
00045    */
00047   struct uint32le_t{
00048     uint32_t littleEndianInt;
00049     operator uint32_t() const{
00050       return UINT32_FROM_LE(littleEndianInt);
00051     }
00052   };
00053   
00054   struct uint16le_t{
00055     uint16_t littleEndianInt;
00056     operator uint16_t() const{
00057       return UINT16_FROM_LE(littleEndianInt);
00058     }
00059   };
00060   
00061   struct int16le_t{
00062     int16_t littleEndianInt;
00063     operator int16_t() const{
00064       return INT16_FROM_LE(littleEndianInt);
00065     }
00066   };
00068   
00069   struct ChannelData{
00072     int chId;
00075     int nSamples;
00078     const int16le_t* samples;
00079   };
00080 
00081 private:  
00084   struct matacqHeader_t{                 
00085     uint16le_t version;  
00086     unsigned char freqGHz;       
00087     unsigned char channelCount; 
00088     uint32_t timeStamp;  
00089   };                                          
00090 
00093   struct field32spec_t{
00094     int offset;
00095     int mask;
00096   };
00097   
00100   static const field32spec_t fov32;
00101   static const field32spec_t fedId32;
00102   static const field32spec_t bxId32;
00103   static const field32spec_t lv132;
00104   static const field32spec_t triggerType32;
00105   static const field32spec_t boeType32;
00106   static const field32spec_t dccLen32;
00107   static const field32spec_t dccErrors32;
00108   static const field32spec_t runNum32;
00109   static const field32spec_t h1Marker32;
00110 
00111   
00112   //constructors
00113 public:
00123   MatacqTBRawEvent(const unsigned char* dataBuffer, size_t bufferSize){
00124     setRawData(dataBuffer, bufferSize);
00125   }
00126   //methods
00127 public:
00134   int getFov() const { return read32(daqHeader, fov32);}
00135   
00139   int getFedId() const { return read32(daqHeader, fedId32);}
00140 
00144   int getBxId() const { return read32(daqHeader, bxId32);}
00145 
00149   unsigned getEventId() const { return read32(daqHeader, lv132);}
00150 
00154   int getTriggerType() const { return read32(daqHeader, triggerType32);}
00155 
00159   int getBoe() const { return read32(daqHeader, boeType32);}
00160 
00164   unsigned getDccLen() const { return read32(daqHeader, dccLen32);}
00165 
00169   unsigned getDaqLen() const { return fragLen;}
00170 
00171 
00175   int getDccErrors() const { return read32(daqHeader, dccErrors32);}
00176 
00180   unsigned getRunNum() const { return read32(daqHeader, runNum32);}
00181 
00185   int getH1Marker() const { return read32(daqHeader, h1Marker32);}
00186   
00187 
00191   int getMatacqDataFormatVersion() const { return matacqHeader->version;}
00192 
00197   int32_t getStatus() const { return error;}
00198 
00202   int getFreqGHz() const { return matacqHeader->freqGHz;}
00203 
00207   int getChannelCount() const { return matacqHeader->channelCount;}
00208 
00214   const std::vector<ChannelData>& getChannelData() const{
00215     return channelData;
00216   }
00217 
00222   int getParsedLen() {  return parsedLen; }
00223   
00229   time_t getTimeStamp() const { return matacqHeader->timeStamp;}
00230 
00231 
00236   int getTTrigPs() const { return tTrigPs;}
00237 
00238 private:
00244   int read32(uint32le_t* pData, field32spec_t spec) const;
00245   
00253   void setRawData(const unsigned char* buffer, size_t bufferSize);
00254 
00255   //fields
00256 private:
00259   int boe;
00260 
00263   int bxId;
00264 
00267   int channelCount;
00268   
00271   std::vector<ChannelData> channelData;
00272 
00275   uint32le_t* daqHeader;
00276 
00279   int dccErrors;
00280 
00283   unsigned dccLen;
00284 
00287   unsigned eventId;
00288 
00291   int32_t error;
00292 
00295   int fedId;
00296 
00299   int fov;
00300 
00303   int fragLen;
00304 
00307   int freqGHz;
00308 
00311   int h1Marker;
00312 
00315   matacqHeader_t* matacqHeader;
00316   
00319   int matacqDataFormatVersion;
00320 
00323   int parsedLen;
00324 
00327   uint16le_t* pSamples;
00328 
00331   unsigned runNum;
00332 
00335   time_t timeStamp;
00336 
00339   int tTrigPs;
00340   
00343   int triggerType;
00344 };
00345 
00346 #endif //MATACQRAWEVENT_H not defined