CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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   
00023   HcalHTRData();
00024   ~HcalHTRData() { if (m_ownData!=0) delete [] m_ownData; }
00025   HcalHTRData(int version_to_create);
00026   HcalHTRData(const unsigned short* data, int length);
00027   HcalHTRData(const HcalHTRData&);
00028   
00029   HcalHTRData& operator=(const HcalHTRData&);
00030   void allocate(int version_to_create=0);
00031   void adoptData(const unsigned short* data, int length);
00032   
00034   inline int getFormatVersion() const { return m_formatVersion; }
00035   
00037   inline const unsigned short* getRawData() const { return m_rawConst; }
00038   
00040   inline const int getRawLength() const { return m_rawLength; }
00041   
00045   bool check() const;
00046   
00054   void dataPointers(const unsigned short** daq_first,
00055                     const unsigned short** daq_last,
00056                     const unsigned short** tp_first,
00057                     const unsigned short** tp_last) const;
00058   
00059   
00067   void unpack(unsigned char* daq_lengths, unsigned short* daq_samples,
00068               unsigned char* tp_lengths, unsigned short* tp_samples) const;
00069   
00077   bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned
00078                        short* histogram) const;
00079   
00086   void pack(unsigned char* daq_lengths, unsigned short* daq_samples,
00087             unsigned char* tp_lengths, unsigned short* tp_samples, bool
00088             do_capid=false);
00090   void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int
00091                          orbitn, int pipeline, int ndd, int nps, int firmwareRev=0);
00092 
00094   void packUnsuppressed(const bool* mp);
00095   
00096   
00098   inline unsigned int getL1ANumber() const { 
00099     return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8); 
00100   }
00102   inline unsigned int getBunchNumber() const { 
00103     return (m_rawConst[4]&0xFFF); 
00104   }
00106   unsigned int getOrbitNumber() const;
00108   unsigned int getSubmodule() const;
00110   // get the htr slot
00111   unsigned int htrSlot() const;
00113   // get the htr top/bottom (1=top/0=bottom)
00114   unsigned int htrTopBottom() const;
00116   // get the readout VME crate number
00117   unsigned int readoutVMECrateId() const;
00119   bool isCalibrationStream() const;
00121   bool isUnsuppressed() const;
00123   bool wasMarkAndPassZS(int fiber, int fiberchan) const;
00125   bool wasMarkAndPassZSTP(int slb, int slbchan) const;
00127   uint32_t zsBunchMask() const;
00128   
00130   bool isPatternRAMEvent() const;
00133   bool isHistogramEvent() const;
00136   void getHistogramFibers(int& a, int& b) const;
00138   unsigned int getPipelineLength() const;
00140   unsigned int getFirmwareRevision() const;
00142   int getFirmwareFlavor() const;
00144   inline unsigned int getErrorsWord() const { 
00145     return m_rawConst[2]&0xFFFF; }
00147   int getNPrecisionWords() const;
00149   int getNDD() const;
00152   int getNTP() const;
00154   int getNPS() const;
00155 
00157   inline unsigned int getDLLunlock() const { 
00158     return (m_rawConst[5]>>1)&0x3; }
00159 
00161   inline unsigned int getTTCready() const { 
00162     return m_rawConst[5]&0x1; }
00163 
00165   inline unsigned int getFibOrbMsgBCN(int fiber) const {
00166     return (m_formatVersion==-1 || fiber<1 || fiber>8)?(0):(m_rawConst[m_rawLength-12+(fiber-1)]&0xFFF);
00167   }
00168 
00170   inline unsigned int getFib1OrbMsgBCN() const {
00171   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
00172 }
00173   inline unsigned int getFib2OrbMsgBCN() const {
00174   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
00175 }
00176 
00177   inline unsigned int getFib3OrbMsgBCN() const {
00178   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
00179 }
00180 
00181   inline unsigned int getFib4OrbMsgBCN() const {
00182   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
00183 }
00184 
00185   inline unsigned int getFib5OrbMsgBCN() const {
00186   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
00187 }
00188 
00189   inline unsigned int getFib6OrbMsgBCN() const {
00190   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
00191 }
00192 
00193   inline unsigned int getFib7OrbMsgBCN() const {
00194   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
00195 }
00196 
00197   inline unsigned int getFib8OrbMsgBCN() const {
00198   return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
00199 }
00200 
00201 
00202 
00204   inline unsigned int getExtHdr1() const { 
00205     return (m_rawConst[0]);}
00206   inline unsigned int getExtHdr2() const { 
00207     return (m_rawConst[1]); }
00208   inline unsigned int getExtHdr3() const { 
00209     return (m_rawConst[2]);} 
00210   inline unsigned int getExtHdr4() const { 
00211     return (m_rawConst[3]); }
00212   inline unsigned int getExtHdr5() const { 
00213     return (m_rawConst[4]);} 
00214   inline unsigned int getExtHdr6() const { 
00215     return (m_rawConst[5]);} 
00216   inline unsigned int getExtHdr7() const { 
00217     return (m_rawConst[6]);} 
00218   inline unsigned int getExtHdr8() const { 
00219     return (m_rawConst[7]);}  
00220 
00221   /* unsigned int getFib1OrbMsgBCN() const;
00222   unsigned int getFib2OrbMsgBCN() const;
00223   unsigned int getFib3OrbMsgBCN() const;
00224   unsigned int getFib4OrbMsgBCN() const;
00225   unsigned int getFib5OrbMsgBCN() const;
00226   unsigned int getFib6OrbMsgBCN() const;
00227   unsigned int getFib7OrbMsgBCN() const;
00228   unsigned int getFib8OrbMsgBCN() const;
00229   */
00230 
00233   bool wasHistogramError(int ifiber) const;
00234   
00235 protected:
00236   void determineSectionLengths(int& tpWords, int& daqWords, int&
00237                                headerWords, int& trailerWords) const;
00238   void determineStaticLengths(int& headerWords, int& trailerWords) const;
00239   int m_formatVersion;
00240   int m_rawLength;
00241   const unsigned short* m_rawConst;
00242   unsigned short* m_ownData;
00243 };
00244 
00245 #endif
00246