CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/EventFilter/HcalRawToDigi/interface/HcalHTRData.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 #ifndef HcalHTRData_H
00003 #define HcalHTRData_H
00004 
00005 #include <stdint.h>
00006 
00018 class HcalHTRData {
00019  public:
00020   static const int CHANNELS_PER_SPIGOT         = 24;
00021   static const int MAXIMUM_SAMPLES_PER_CHANNEL = 20;
00022   static const int FORMAT_VERSION_COMPACT_DATA =  6;
00023   
00024   HcalHTRData();
00025   ~HcalHTRData() { if (m_ownData!=0) delete [] m_ownData; }
00026   HcalHTRData(int version_to_create);
00027   HcalHTRData(const unsigned short* data, int length);
00028   HcalHTRData(const HcalHTRData&);
00029   
00030   HcalHTRData& operator=(const HcalHTRData&);
00031   void allocate(int version_to_create=0);
00032   void adoptData(const unsigned short* data, int length);
00033   
00035   inline int getFormatVersion() const { return m_formatVersion; }
00036   
00038   inline const unsigned short* getRawData() const { return m_rawConst; }
00039   
00041   inline const int getRawLength() const { return m_rawLength; }
00042   
00046   bool check() const;
00047 
00048   bool isEmptyEvent() const;
00049   bool isOverflowWarning() const;
00050   bool isBusy() const;
00051 
00052   
00060   void dataPointers(const unsigned short** daq_first,
00061                     const unsigned short** daq_last,
00062                     const unsigned short** tp_first,
00063                     const unsigned short** tp_last) const;
00064   
00065   
00073   void unpack(unsigned char* daq_lengths, unsigned short* daq_samples,
00074               unsigned char* tp_lengths, unsigned short* tp_samples) const;
00075   
00083   bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned
00084                        short* histogram) const;
00085 
00088   static bool unpack_per_channel_header(unsigned short, int& flav, int& error_flags, int& capid0, int& channelid);
00089   
00092   static bool is_channel_header(unsigned short value) { return (value&0x8000)!=0; }
00093 
00100   void pack(unsigned char* daq_lengths, unsigned short* daq_samples,
00101             unsigned char* tp_lengths, unsigned short* tp_samples, bool
00102             do_capid=false);
00104   void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int
00105                          orbitn, int pipeline, int ndd, int nps, int firmwareRev=0);
00106 
00108   void packUnsuppressed(const bool* mp);
00109   
00110   
00112   inline unsigned int getL1ANumber() const { 
00113     return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8); 
00114   }
00116   inline unsigned int getBunchNumber() const { 
00117     return (m_rawConst[4]&0xFFF); 
00118   }
00120   unsigned int getOrbitNumber() const;
00122   unsigned int getSubmodule() const;
00124   // get the htr slot
00125   unsigned int htrSlot() const;
00127   // get the htr top/bottom (1=top/0=bottom)
00128   unsigned int htrTopBottom() const;
00130   // get the readout VME crate number
00131   unsigned int readoutVMECrateId() const;
00133   bool isCalibrationStream() const;
00135   bool isUnsuppressed() const;
00137   bool wasMarkAndPassZS(int fiber, int fiberchan) const;
00139   bool wasMarkAndPassZSTP(int slb, int slbchan) const;
00141   uint32_t zsBunchMask() const;
00142   
00144   bool isPatternRAMEvent() const;
00147   bool isHistogramEvent() const;
00150   void getHistogramFibers(int& a, int& b) const;
00152   unsigned int getPipelineLength() const;
00154   unsigned int getFirmwareRevision() const;
00156   int getFirmwareFlavor() const;
00158   inline unsigned int getErrorsWord() const { 
00159     return m_rawConst[2]&0xFFFF; }
00161   int getNPrecisionWords() const;
00163   int getNDD() const;
00166   int getNTP() const;
00168   int getNPS() const;
00169 
00171   inline unsigned int getDLLunlock() const { 
00172     return (m_rawConst[5]>>1)&0x3; }
00173 
00175   inline unsigned int getTTCready() const { 
00176     return m_rawConst[5]&0x1; }
00177 
00179   inline unsigned int getFibOrbMsgBCN(int fiber) const {
00180     return (m_formatVersion==-1 || fiber<1 || fiber>8)?(0):(m_rawConst[m_rawLength-12+(fiber-1)]&0xFFF);
00181   }
00182 
00184   inline unsigned int getFib1OrbMsgBCN() const {
00185   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
00186 }
00187   inline unsigned int getFib2OrbMsgBCN() const {
00188   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
00189 }
00190 
00191   inline unsigned int getFib3OrbMsgBCN() const {
00192   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
00193 }
00194 
00195   inline unsigned int getFib4OrbMsgBCN() const {
00196   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
00197 }
00198 
00199   inline unsigned int getFib5OrbMsgBCN() const {
00200   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
00201 }
00202 
00203   inline unsigned int getFib6OrbMsgBCN() const {
00204   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
00205 }
00206 
00207   inline unsigned int getFib7OrbMsgBCN() const {
00208   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
00209 }
00210 
00211   inline unsigned int getFib8OrbMsgBCN() const {
00212   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
00213 }
00214 
00215 
00216 
00218   inline unsigned int getExtHdr1() const { 
00219     return (m_rawConst[0]);}
00220   inline unsigned int getExtHdr2() const { 
00221     return (m_rawConst[1]); }
00222   inline unsigned int getExtHdr3() const { 
00223     return (m_rawConst[2]);} 
00224   inline unsigned int getExtHdr4() const { 
00225     return (m_rawConst[3]); }
00226   inline unsigned int getExtHdr5() const { 
00227     return (m_rawConst[4]);} 
00228   inline unsigned int getExtHdr6() const { 
00229     return (m_rawConst[5]);} 
00230   inline unsigned int getExtHdr7() const { 
00231     return (m_rawConst[6]);} 
00232   inline unsigned int getExtHdr8() const { 
00233     return (m_rawConst[7]);}  
00234 
00235   /* unsigned int getFib1OrbMsgBCN() const;
00236   unsigned int getFib2OrbMsgBCN() const;
00237   unsigned int getFib3OrbMsgBCN() const;
00238   unsigned int getFib4OrbMsgBCN() const;
00239   unsigned int getFib5OrbMsgBCN() const;
00240   unsigned int getFib6OrbMsgBCN() const;
00241   unsigned int getFib7OrbMsgBCN() const;
00242   unsigned int getFib8OrbMsgBCN() const;
00243   */
00244 
00247   bool wasHistogramError(int ifiber) const;
00248   
00249 protected:
00250   void determineSectionLengths(int& tpWords, int& daqWords, int&
00251                                headerWords, int& trailerWords) const;
00252   void determineStaticLengths(int& headerWords, int& trailerWords) const;
00253   int m_formatVersion;
00254   int m_rawLength;
00255   const unsigned short* m_rawConst;
00256   unsigned short* m_ownData;
00257 };
00258 
00259 #endif
00260