CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/EventFilter/HcalRawToDigi/interface/HcalDTCHeader.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 #ifndef HcalDTCHeader_H
00003 #define HcalDTCHeader_H
00004 
00005 #include <iostream>
00006 #include <stdint.h>
00007 #include "DataFormats/HcalDigi/interface/HcalCalibrationEventTypes.h"
00008 class HcalHTRData;
00009 
00020 class HcalDTCHeader {
00021  public:
00022   static const int SLOT_COUNT;
00023   static const int MINIMUM_SLOT;
00024   static const int MAXIMUM_SLOT;
00025 
00026   HcalDTCHeader();
00027 
00029   unsigned int getTotalLengthBytes() const; 
00030 
00032 
00033   inline bool thereIsASecondCDFHeaderWord() const {return ((commondataformat0>>3) & 0x0001); }
00035   inline short getCDFversionNumber() const {return ((commondataformat0>>4) & 0x0F); }
00037   inline int getSourceId() const { return (commondataformat0>>8)&0xFFF; }
00039   inline int getBunchId() const { return (commondataformat0>>20)&0xFFF; }
00041   inline unsigned long getDTCEventNumber() const { return (commondataformat1 & 0x00FFFFFF); }
00043   inline unsigned short getCDFEventType() const { return ( (commondataformat1>>24) & 0x0F ); }
00045   inline unsigned short BOEshouldBe5Always() const { return ( (commondataformat1>>28) & 0x0F ); }
00046 
00048 
00049   inline bool thereIsAThirdCDFHeaderWord() const {return ((commondataformat2>>3) & 0x0001); }
00051   inline unsigned int getOrbitNumber() const { return ( ((commondataformat3 && 0xF) << 28) + ( commondataformat2>>4) ); }
00053   inline unsigned int getSlink64ReservedBits() const { return (  (commondataformat3>>4)&0x00FFFFFF ); }
00055   inline short BOEshouldBeZeroAlways() const { return ( (commondataformat3>>28) & 0x0F); }
00056 
00058   inline bool isCalibType() const { return ( 0 != getCalibType ());}
00059   inline HcalCalibrationEventType  getCalibType() const { return HcalCalibrationEventType ((commondataformat3>>24)&0x0000000F);}
00060 
00062   inline short getDTCDataFormatVersion() const { return (dcch0 & 0xFF); }
00063   inline int nSlotWords() const { return ((dcch0>>20)& 0x0000000F); }
00064   inline int nDTCWords() const { return ((dcch0>>8)& 0x00000FFF); }
00065   
00067   inline int getSlotSummary(int nslot) const { return slotInfo[nslot]; }
00068 
00073   int getSlotData(int nslot, HcalHTRData& decodeTool, int validSize) const;
00074 
00075 
00077   inline unsigned int getSlotDataLength(int nslot) const { return (nslot<1 || nslot>12)?(0):(slotInfo[nslot-1]&0xfff); }
00078 
00080   inline bool getSlotEnabled(unsigned int nslot) const { return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x8000); }
00082   inline bool getSlotPresent(unsigned int nslot) const { return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x4000); }
00084   inline bool getSlotValid(unsigned int nslot) const { return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x2000); }
00086   inline bool getSlotCRCError(unsigned int nslot) const { return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x1000); }
00087 
00088   /* (for packing only) */
00095   void copySlotData(unsigned int slot_id, const HcalHTRData& data, bool valid=true);
00096 
00098   void clear();
00100   void setHeader(int sourceid, int bcn, int l1aN, int orbN);
00101 
00102  private:
00103   // CURRENTLY VALID FOR LITTLE-ENDIAN (LINUX/x86) ONLY
00104   uint32_t commondataformat0;
00105   uint32_t commondataformat1;
00106   uint32_t commondataformat2;
00107   uint32_t commondataformat3;
00108   uint32_t dcch0;
00109   uint32_t dcch1;
00110   uint16_t slotInfo[12];
00111 
00112 };
00113 
00114 std::ostream& operator<<(std::ostream&, const HcalDTCHeader& head);
00115 
00116 #endif