CMS 3D CMS Logo

HcalDCCHeader.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 #ifndef HcalDCCHeader_H
00003 #define HcalDCCHeader_H
00004 
00005 #include <iostream>
00006 class HcalHTRData;
00007 
00018 class HcalDCCHeader {
00019  public:
00020   static const int SPIGOT_COUNT;
00021 
00022   HcalDCCHeader();
00023 
00025   unsigned int getTotalLengthBytes() const; 
00026 
00028 
00029   inline bool thereIsASecondCDFHeaderWord() const {return ((commondataformat0>>3) & 0x0001); }
00031   inline short getCDFversionNumber() const {return ((commondataformat0>>4) & 0x0F); }
00033   inline int getSourceId() const { return (commondataformat0>>8)&0xFFF; }
00035   inline int getBunchId() const { return (commondataformat0>>20)&0xFFF; }
00037   inline unsigned long getDCCEventNumber() const { return (commondataformat1 & 0x00FFFFFF); }
00039   inline unsigned short getCDFEventType() const { return ( (commondataformat1>>24) & 0x0F ); }
00041   inline unsigned short BOEshouldBe5Always() const { return ( (commondataformat1>>28) & 0x0F ); }
00042 
00044 
00045   inline bool thereIsAThirdCDFHeaderWord() const {return ((commondataformat2>>3) & 0x0001); }
00047   inline unsigned int getOrbitNumber() const { return (commondataformat2>>4); }
00049   inline unsigned int getSlink64ReservedBits() const { return (  (commondataformat3>>4)&0x00FFFFFF ); }
00051   inline short BOEshouldBeZeroAlways() const { return ( (commondataformat3>>28) & 0x0F); }
00052 
00054   inline short getDCCDataFormatVersion() const { return (dcch0 & 0xFF); }
00055   inline int getAcceptTimeTTS() const { return ((dcch0>>8)& 0x0000000F); }
00056   inline int getByte1Zeroes() const {  return ((dcch0>>12)& 0x00000003); }
00057   inline int getHTRStatusBits () const { return ((dcch0>>14)& 0x00007FFF); }
00058   inline int getByte3Zeroes() const {  return ((dcch0>>29)& 0x00000007); }
00059   inline int getDCCStatus() const {return (dcch1 & 0x000003FF);}
00060   inline int getByte567Zeroes() const {  return (dcch1 & 0xFF00FC00); }
00061 
00063   inline bool getSpigotErrorFlag(int nspigot) const { 
00064     return (( dcch0>>(14+nspigot) )&0x0001);  }
00065 
00067   inline bool SawTTS_OFW()        const { return ((getDCCStatus()>>0) & 0x00000001);}
00068   inline bool SawTTS_BSY()        const { return ((getDCCStatus()>>1) & 0x00000001);}
00069   inline bool SawTTS_SYN()        const { return ((getDCCStatus()>>2) & 0x00000001);}
00070   inline bool SawL1A_EvN_MxMx()   const { return ((getDCCStatus()>>3) & 0x00000001);}
00071   inline bool SawL1A_BcN_MxMx()   const { return ((getDCCStatus()>>4) & 0x00000001);}
00072   inline bool SawCT_EvN_MxMx()    const { return ((getDCCStatus()>>5) & 0x00000001);}
00073   inline bool SawCT_BcN_MxMx()    const { return ((getDCCStatus()>>6) & 0x00000001);}
00074   inline bool SawOrbitLengthErr() const { return ((getDCCStatus()>>7) & 0x00000001);}
00075   inline bool SawTTC_SingErr()    const { return ((getDCCStatus()>>8) & 0x00000001);}
00076   inline bool SawTTC_DoubErr()    const { return ((getDCCStatus()>>9) & 0x00000001);}
00077 
00079   inline int getSpigotSummary(int nspigot) const { return spigotInfo[nspigot]; }
00080 
00085   int getSpigotData(int nspigot, HcalHTRData& decodeTool, int validSize) const;
00086 
00090   void getSpigotData(int nspigot, HcalHTRData& decodeTool) const;
00091 
00093   inline unsigned int getSpigotDataLength(int nspigot) const { return (nspigot>=15)?(0):(spigotInfo[nspigot]&0x3ff); }
00094 
00096   inline bool getSpigotEnabled(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x8000); }
00098   inline bool getSpigotPresent(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x4000); }
00100   inline bool getBxMismatchWithDCC(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x2000); }
00102   inline bool getSpigotValid(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x1000); }
00104   inline bool getSpigotDataTruncated(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x0800); }
00106   inline bool getSpigotCRCError(unsigned int nspigot) const { return (nspigot>=15)?(false):(spigotInfo[nspigot]&0x0400); }
00108   inline unsigned char getSpigotErrorBits(unsigned int nspigot) const { return (nspigot>=15)?(0):((unsigned char)(spigotInfo[nspigot]>>24)); }
00110   inline unsigned char getLRBErrorBits(unsigned int nspigot) const { return (nspigot>=15)?(0):((unsigned char)(spigotInfo[nspigot]>>16)); }
00111 
00112   /* (for packing only) */
00119   void copySpigotData(unsigned int spigot_id, const HcalHTRData& data, bool valid=true, unsigned char LRB_error_word=0);
00120 
00122   void clear();
00124   void setHeader(int sourceid, int bcn, int l1aN, int orbN);
00125 
00126  private:
00127   // CURRENTLY VALID FOR LITTLE-ENDIAN (LINUX/x86) ONLY
00128   unsigned int commondataformat0;
00129   unsigned int commondataformat1;
00130   unsigned int commondataformat2;
00131   unsigned int commondataformat3;
00132   unsigned int dcch0;
00133   unsigned int dcch1;
00134   unsigned int spigotInfo[18];   //The last three of these 32bit words should always be zero!
00135 
00136 };
00137 
00138 std::ostream& operator<<(std::ostream&, const HcalDCCHeader& head);
00139 
00140 #endif

Generated on Tue Jun 9 17:34:41 2009 for CMSSW by  doxygen 1.5.4