CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/EventFilter/HcalRawToDigi/interface/HcalDCCHeader.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 #ifndef HcalDCCHeader_H
00003 #define HcalDCCHeader_H
00004 
00005 #include <iostream>
00006 #include "DataFormats/HcalDigi/interface/HcalCalibrationEventTypes.h"
00007 class HcalHTRData;
00008 
00019 class HcalDCCHeader {
00020  public:
00021   static const int SPIGOT_COUNT;
00022 
00023   HcalDCCHeader();
00024 
00026   unsigned int getTotalLengthBytes() const; 
00027 
00029 
00030   inline bool thereIsASecondCDFHeaderWord() const {return ((commondataformat0>>3) & 0x0001); }
00032   inline short getCDFversionNumber() const {return ((commondataformat0>>4) & 0x0F); }
00034   inline int getSourceId() const { return (commondataformat0>>8)&0xFFF; }
00036   inline int getBunchId() const { return (commondataformat0>>20)&0xFFF; }
00038   inline unsigned long getDCCEventNumber() const { return (commondataformat1 & 0x00FFFFFF); }
00040   inline unsigned short getCDFEventType() const { return ( (commondataformat1>>24) & 0x0F ); }
00042   inline unsigned short BOEshouldBe5Always() const { return ( (commondataformat1>>28) & 0x0F ); }
00043 
00045 
00046   inline bool thereIsAThirdCDFHeaderWord() const {return ((commondataformat2>>3) & 0x0001); }
00048   inline unsigned int getOrbitNumber() const { return ( ((commondataformat3 && 0xF) << 28) + ( commondataformat2>>4) ); }
00050   inline unsigned int getSlink64ReservedBits() const { return (  (commondataformat3>>4)&0x00FFFFFF ); }
00052   inline short BOEshouldBeZeroAlways() const { return ( (commondataformat3>>28) & 0x0F); }
00053 
00055   inline bool isCalibType() const { return ( 0 != getCalibType ());}
00056   inline HcalCalibrationEventType  getCalibType() const { return HcalCalibrationEventType ((commondataformat3>>24)&0x0000000F);}
00057 
00059   inline short getDCCDataFormatVersion() const { return (dcch0 & 0xFF); }
00060   inline int getAcceptTimeTTS() const { return ((dcch0>>8)& 0x0000000F); }
00061   inline int getByte1Zeroes() const {  return ((dcch0>>12)& 0x00000003); }
00062   inline int getHTRStatusBits () const { return ((dcch0>>14)& 0x00007FFF); }
00063   inline int getByte3Zeroes() const {  return ((dcch0>>29)& 0x00000007); }
00064   inline int getDCCStatus() const {return (dcch1 & 0x000003FF);}
00065   inline int getByte567Zeroes() const {  return (dcch1 & 0xFF00FC00); }
00066 
00068   inline bool getSpigotErrorFlag(int nspigot) const { 
00069     return (( dcch0>>(14+nspigot) )&0x0001);  }
00070 
00072   inline bool SawTTS_OFW()        const { return ((getDCCStatus()>>0) & 0x00000001);}
00073   inline bool SawTTS_BSY()        const { return ((getDCCStatus()>>1) & 0x00000001);}
00074   inline bool SawTTS_SYN()        const { return ((getDCCStatus()>>2) & 0x00000001);}
00075   inline bool SawL1A_EvN_MxMx()   const { return ((getDCCStatus()>>3) & 0x00000001);}
00076   inline bool SawL1A_BcN_MxMx()   const { return ((getDCCStatus()>>4) & 0x00000001);}
00077   inline bool SawCT_EvN_MxMx()    const { return ((getDCCStatus()>>5) & 0x00000001);}
00078   inline bool SawCT_BcN_MxMx()    const { return ((getDCCStatus()>>6) & 0x00000001);}
00079   inline bool SawOrbitLengthErr() const { return ((getDCCStatus()>>7) & 0x00000001);}
00080   inline bool SawTTC_SingErr()    const { return ((getDCCStatus()>>8) & 0x00000001);}
00081   inline bool SawTTC_DoubErr()    const { return ((getDCCStatus()>>9) & 0x00000001);}
00082 
00084   inline int getSpigotSummary(int nspigot) const { return spigotInfo[nspigot]; }
00085 
00090   int getSpigotData(int nspigot, HcalHTRData& decodeTool, int validSize) const;
00091 
00095   void getSpigotData(int nspigot, HcalHTRData& decodeTool) const;
00096 
00098   inline unsigned int getSpigotDataLength(int nspigot) const { return (nspigot>=15)?(0):(spigotInfo[nspigot]&0x3ff); }
00099 
00101   inline bool getSpigotEnabled(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x8000); }
00103   inline bool getSpigotPresent(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x4000); }
00105   inline bool getBxMismatchWithDCC(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x2000); }
00107   inline bool getSpigotValid(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x1000); }
00109   inline bool getSpigotDataTruncated(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x0800); }
00111   inline bool getSpigotCRCError(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x0400); }
00113   inline unsigned char getSpigotErrorBits(unsigned int nspigot) const { return (nspigot>=15)?(0):((unsigned char)(spigotInfo[nspigot]>>24)); }
00115   inline unsigned char getLRBErrorBits(unsigned int nspigot) const { return (nspigot>=15)?(0):((unsigned char)(spigotInfo[nspigot]>>16)); }
00116 
00117   /* (for packing only) */
00124   void copySpigotData(unsigned int spigot_id, const HcalHTRData& data, bool valid=true, unsigned char LRB_error_word=0);
00125 
00127   void clear();
00129   void setHeader(int sourceid, int bcn, int l1aN, int orbN);
00130 
00131  private:
00132   // CURRENTLY VALID FOR LITTLE-ENDIAN (LINUX/x86) ONLY
00133   unsigned int commondataformat0;
00134   unsigned int commondataformat1;
00135   unsigned int commondataformat2;
00136   unsigned int commondataformat3;
00137   unsigned int dcch0;
00138   unsigned int dcch1;
00139   unsigned int spigotInfo[18];   //The last three of these 32bit words should always be zero!
00140 
00141 };
00142 
00143 std::ostream& operator<<(std::ostream&, const HcalDCCHeader& head);
00144 
00145 #endif