CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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   
00055   void dataPointers(const unsigned short** daq_first,
00056                     const unsigned short** daq_last,
00057                     const unsigned short** tp_first,
00058                     const unsigned short** tp_last) const;
00059   
00060   
00068   void unpack(unsigned char* daq_lengths, unsigned short* daq_samples,
00069               unsigned char* tp_lengths, unsigned short* tp_samples) const;
00070   
00078   bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned
00079                        short* histogram) const;
00080 
00083   static bool unpack_per_channel_header(unsigned short, int& flav, int& error_flags, int& capid0, int& channelid);
00084   
00087   static bool is_channel_header(unsigned short value) { return (value&0x8000)!=0; }
00088 
00095   void pack(unsigned char* daq_lengths, unsigned short* daq_samples,
00096             unsigned char* tp_lengths, unsigned short* tp_samples, bool
00097             do_capid=false);
00099   void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int
00100                          orbitn, int pipeline, int ndd, int nps, int firmwareRev=0);
00101 
00103   void packUnsuppressed(const bool* mp);
00104   
00105   
00107   inline unsigned int getL1ANumber() const { 
00108     return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8); 
00109   }
00111   inline unsigned int getBunchNumber() const { 
00112     return (m_rawConst[4]&0xFFF); 
00113   }
00115   unsigned int getOrbitNumber() const;
00117   unsigned int getSubmodule() const;
00119   // get the htr slot
00120   unsigned int htrSlot() const;
00122   // get the htr top/bottom (1=top/0=bottom)
00123   unsigned int htrTopBottom() const;
00125   // get the readout VME crate number
00126   unsigned int readoutVMECrateId() const;
00128   bool isCalibrationStream() const;
00130   bool isUnsuppressed() const;
00132   bool wasMarkAndPassZS(int fiber, int fiberchan) const;
00134   bool wasMarkAndPassZSTP(int slb, int slbchan) const;
00136   uint32_t zsBunchMask() const;
00137   
00139   bool isPatternRAMEvent() const;
00142   bool isHistogramEvent() const;
00145   void getHistogramFibers(int& a, int& b) const;
00147   unsigned int getPipelineLength() const;
00149   unsigned int getFirmwareRevision() const;
00151   int getFirmwareFlavor() const;
00153   inline unsigned int getErrorsWord() const { 
00154     return m_rawConst[2]&0xFFFF; }
00156   int getNPrecisionWords() const;
00158   int getNDD() const;
00161   int getNTP() const;
00163   int getNPS() const;
00164 
00166   inline unsigned int getDLLunlock() const { 
00167     return (m_rawConst[5]>>1)&0x3; }
00168 
00170   inline unsigned int getTTCready() const { 
00171     return m_rawConst[5]&0x1; }
00172 
00174   inline unsigned int getFibOrbMsgBCN(int fiber) const {
00175     return (m_formatVersion==-1 || fiber<1 || fiber>8)?(0):(m_rawConst[m_rawLength-12+(fiber-1)]&0xFFF);
00176   }
00177 
00179   inline unsigned int getFib1OrbMsgBCN() const {
00180   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
00181 }
00182   inline unsigned int getFib2OrbMsgBCN() const {
00183   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
00184 }
00185 
00186   inline unsigned int getFib3OrbMsgBCN() const {
00187   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
00188 }
00189 
00190   inline unsigned int getFib4OrbMsgBCN() const {
00191   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
00192 }
00193 
00194   inline unsigned int getFib5OrbMsgBCN() const {
00195   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
00196 }
00197 
00198   inline unsigned int getFib6OrbMsgBCN() const {
00199   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
00200 }
00201 
00202   inline unsigned int getFib7OrbMsgBCN() const {
00203   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
00204 }
00205 
00206   inline unsigned int getFib8OrbMsgBCN() const {
00207   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
00208 }
00209 
00210 
00211 
00213   inline unsigned int getExtHdr1() const { 
00214     return (m_rawConst[0]);}
00215   inline unsigned int getExtHdr2() const { 
00216     return (m_rawConst[1]); }
00217   inline unsigned int getExtHdr3() const { 
00218     return (m_rawConst[2]);} 
00219   inline unsigned int getExtHdr4() const { 
00220     return (m_rawConst[3]); }
00221   inline unsigned int getExtHdr5() const { 
00222     return (m_rawConst[4]);} 
00223   inline unsigned int getExtHdr6() const { 
00224     return (m_rawConst[5]);} 
00225   inline unsigned int getExtHdr7() const { 
00226     return (m_rawConst[6]);} 
00227   inline unsigned int getExtHdr8() const { 
00228     return (m_rawConst[7]);}  
00229 
00230   /* unsigned int getFib1OrbMsgBCN() const;
00231   unsigned int getFib2OrbMsgBCN() const;
00232   unsigned int getFib3OrbMsgBCN() const;
00233   unsigned int getFib4OrbMsgBCN() const;
00234   unsigned int getFib5OrbMsgBCN() const;
00235   unsigned int getFib6OrbMsgBCN() const;
00236   unsigned int getFib7OrbMsgBCN() const;
00237   unsigned int getFib8OrbMsgBCN() const;
00238   */
00239 
00242   bool wasHistogramError(int ifiber) const;
00243   
00244 protected:
00245   void determineSectionLengths(int& tpWords, int& daqWords, int&
00246                                headerWords, int& trailerWords) const;
00247   void determineStaticLengths(int& headerWords, int& trailerWords) const;
00248   int m_formatVersion;
00249   int m_rawLength;
00250   const unsigned short* m_rawConst;
00251   unsigned short* m_ownData;
00252 };
00253 
00254 #endif
00255