Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-21 02:52:56

0001 #ifndef DataFormats_CSCDigi_CSCStripDigi_h
0002 #define DataFormats_CSCDigi_CSCStripDigi_h
0003 
0004 /** \class CSCStripDigi
0005  *
0006  * Digi for CSC Cathode Strips.
0007  *
0008  *
0009  * \author M. Schmitt, Northwestern
0010  *
0011  */
0012 
0013 #include <vector>
0014 #include <iosfwd>
0015 #include <cstdint>
0016 
0017 class CSCStripDigi {
0018 public:
0019   // Construct from the strip number and all the other data members.
0020   CSCStripDigi(const int& istrip,
0021                const std::vector<int>& vADCCounts,
0022                const std::vector<uint16_t>& vADCOverflow,
0023                const std::vector<uint16_t>& vOverlap,
0024                const std::vector<uint16_t>& vErrorstat)
0025       : strip(istrip),
0026         ADCCounts(vADCCounts),
0027         ADCOverflow(vADCOverflow),
0028         OverlappedSample(vOverlap),
0029         Errorstat(vErrorstat) {}
0030 
0031   // Construct from the strip number and the ADC readings.
0032   CSCStripDigi(const int& istrip, const std::vector<int>& vADCCounts)
0033       : strip(istrip), ADCCounts(vADCCounts), ADCOverflow(8, 0), OverlappedSample(8, 0), Errorstat(8, 0) {}
0034 
0035   CSCStripDigi() : strip(0), ADCCounts(8, 0), ADCOverflow(8, 0), OverlappedSample(8, 0), Errorstat(8, 0) {}
0036 
0037   // Digis are equal if they are on the same strip and have same ADC readings
0038   bool operator==(const CSCStripDigi& digi) const;
0039 
0040   // Get the strip number. counts from 1.
0041   int getStrip() const { return strip; }
0042 
0043   /// Get the CFEB number. Counts from 0.
0044   int getCFEB() const;
0045 
0046   /// Get ADC readings
0047   std::vector<int> const& getADCCounts() const { return ADCCounts; }
0048 
0049   /// Get L1APhase from OverlappedSample (9th bit)
0050   std::vector<int> getL1APhase() const {
0051     std::vector<int> L1APhaseResult(getOverlappedSample().size());
0052     for (int i = 0; i < (int)getOverlappedSample().size(); i++)
0053       L1APhaseResult[i] = (getOverlappedSample()[i] >> 8) & 0x1;
0054     return L1APhaseResult;
0055   }
0056 
0057   int getL1APhase(int i) const { return (getOverlappedSample()[i] >> 8) & 0x1; }
0058 
0059   /// Other getters
0060   std::vector<uint16_t> const& getADCOverflow() const { return ADCOverflow; }
0061   std::vector<uint16_t> const& getOverlappedSample() const { return OverlappedSample; }
0062   std::vector<uint16_t> const& getErrorstat() const { return Errorstat; }
0063 
0064   // Set the strip number
0065   void setStrip(int istrip) { strip = istrip; }
0066 
0067   // Set with a vector of ADC readings
0068   void setADCCounts(const std::vector<int>& ADCCounts);
0069 
0070   // Print content of digi
0071   void print() const;
0072 
0073   ///methods for calibrations
0074   float pedestal() const { return 0.5f * (ADCCounts[0] + ADCCounts[1]); }
0075   float amplitude() const { return ADCCounts[4] - pedestal(); }
0076 
0077 private:
0078   uint16_t strip;
0079   std::vector<int> ADCCounts;
0080   std::vector<uint16_t> ADCOverflow;
0081   std::vector<uint16_t> OverlappedSample;
0082   std::vector<uint16_t> Errorstat;
0083 };
0084 
0085 std::ostream& operator<<(std::ostream& o, const CSCStripDigi& digi);
0086 
0087 #endif