Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:35

0001 #ifndef EventFilter_CSCRawToDigi_CSCAnodeData2006_h
0002 #define EventFilter_CSCRawToDigi_CSCAnodeData2006_h
0003 #include "EventFilter/CSCRawToDigi/interface/CSCAnodeDataFormat.h"
0004 #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
0005 #include <cassert>
0006 class CSCALCTHeader;
0007 
0008 class CSCAnodeDataFrame2006 {
0009 public:
0010   CSCAnodeDataFrame2006() {}
0011   CSCAnodeDataFrame2006(unsigned short frame) : theFrame(frame) {}
0012   CSCAnodeDataFrame2006(unsigned chip, unsigned tbin, unsigned data);
0013 
0014   /// given a wiregroup between 0 and 7, it tells whether this bit was on
0015   bool isHit(unsigned wireGroup) const {
0016     assert(wireGroup < 8);
0017     return ((theFrame >> wireGroup) & 0x1);
0018   }
0019 
0020   /// sets a bit, from 0 to 7
0021   void addHit(unsigned wireBit) { theFrame |= (1 << wireBit); }
0022 
0023   /// time bin
0024   unsigned tbin() const { return (theFrame >> 8) & 0x1F; }
0025   /// kind of the chip ID.  But it's only 2-bit, and we really need
0026   /// three, so it's the lowest bit, plus the OR of the next two.
0027   unsigned chip() const { return (theFrame >> 13) & 0x3; }
0028   unsigned short data() const { return theFrame & 0xFF; }
0029   unsigned short frame() const { return theFrame; }
0030 
0031 private:
0032   unsigned short theFrame;
0033   //unsigned short data_ : 8;
0034   //unsigned short tbin_ : 5;
0035   //unsigned short chip_ : 2;
0036   //unsigned short ddu_code_ : 1;
0037 };
0038 
0039 class CSCAnodeData2006 : public CSCAnodeDataFormat {
0040 public:
0041   /// a blank one, for Monte Carlo
0042   CSCAnodeData2006(const CSCALCTHeader &);
0043   /// fill from a real datastream
0044   CSCAnodeData2006(const CSCALCTHeader &, const unsigned short *buf);
0045 
0046   unsigned short *data() override { return theDataFrames; }
0047   /// the amount of the input binary buffer read, in 16-bit words
0048   unsigned short int sizeInWords() const override { return nAFEBs_ * nTimeBins_ * 6 * 2; }
0049 
0050   /// input layer is from 1 to 6
0051   std::vector<CSCWireDigi> wireDigis(int layer) const override;
0052 
0053   void add(const CSCWireDigi &, int layer) override;
0054 
0055   static void selfTest();
0056 
0057 private:
0058   void init();
0059 
0060   CSCAnodeDataFrame2006 rawHit(int afeb, int tbin, int layer, int halfLayer) const;
0061 
0062   /// the index into theDataFrames
0063   int index(int afeb, int tbin, int layer) const;
0064 
0065   void addHit(int afeb, int tbin, int layer, int halfLayer, unsigned wireBit);
0066 
0067   /// we don't know the size at first.  Max should be 7 boards * 32 bins * 6 layers * 2
0068   unsigned short theDataFrames[2700];
0069   /// in 2007 format the max number of frames is 1860
0070   int nAFEBs_;
0071   int nTimeBins_;
0072   unsigned int alctBX_;  /// To account BX in wire digis
0073 };
0074 
0075 #endif