Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:41

0001 #ifndef DATAFORMATS_SIPIXELCALIBDIGI_SIPIXELCALIBDIGI_H
0002 #define DATAFORMATS_SIPIXELCALIBDIGI_SIPIXELCALIBDIGI_H
0003 
0004 #include <utility>
0005 #include <vector>
0006 #include <iostream>
0007 #include <cstdint>
0008 
0009 class SiPixelCalibDigi {
0010 public:
0011   SiPixelCalibDigi(int packed_value, uint16_t row, uint16_t col) : m_data(packed_value), m_row_and_column(row, col) {
0012     reset();
0013   }
0014   SiPixelCalibDigi(int packed_value) : m_data(packed_value), m_row_and_column(0, 0) { reset(); }
0015   SiPixelCalibDigi() : m_data(0), m_row_and_column(0, 0) { ; }
0016   virtual ~SiPixelCalibDigi() { ; }
0017 
0018   void init(uint16_t row, uint16_t col, uint16_t npoints);
0019   void reset();
0020   void fill(uint32_t ipoint, uint32_t adcval);
0021   void setrowcol(uint16_t row, uint16_t col);
0022 
0023   // analysis methods:
0024   uint32_t getnpoints() const { return m_data.size(); }  // returns the number of calibration points
0025   uint32_t getsum(uint32_t ipoint) const {
0026     return m_data[ipoint].adccountsum;
0027   }  // returns the sum of adc counts for the collected events at point ipoint
0028   uint32_t getsumsquares(uint32_t ipoint) const {
0029     return m_data[ipoint].adccountsumsq;
0030   }  // returns the sum of the squares of adc counts for the collected events at point ipoint
0031   uint32_t getnentries(uint32_t ipoint) const {
0032     return m_data[ipoint].nentries;
0033   }                                             // returns the number of entries made for calibration point ipoint
0034   std::vector<uint32_t> getsum() const;         // returns the sum of adc counts for the collected events for all points
0035   std::vector<uint32_t> getsumsquares() const;  // returns the sum of the squares of adc counts
0036   std::vector<uint8_t> getnentries() const;     // returns the number of entries made
0037   uint16_t row() const { return m_row_and_column.first; }
0038   uint16_t col() const { return m_row_and_column.second; }
0039   std::pair<uint16_t, uint16_t> row_and_col() const { return m_row_and_column; }
0040 
0041   struct datacontainer {
0042     datacontainer() : nentries(0), adccountsum(0), adccountsumsq(0) {}
0043     uint8_t nentries;        // the number of entries per VCAL point
0044     uint32_t adccountsum;    // the sum of the ADC counts
0045     uint32_t adccountsumsq;  // the sum of the square value of the ADC counts
0046   };
0047 
0048 private:
0049   // this is were the data is stored
0050   std::vector<datacontainer> m_data;
0051   std::pair<uint16_t, uint16_t> m_row_and_column;  //the row and column number of this particular pixel
0052 };
0053 
0054 inline bool operator<(const SiPixelCalibDigi& one, const SiPixelCalibDigi& other) {
0055   return one.getnpoints() < other.getnpoints();
0056 }
0057 
0058 inline std::ostream& operator<<(std::ostream& output, const SiPixelCalibDigi& digi) {
0059   /*   std::ostream result; */
0060   /*   result << "this SiPixelCalibDigi object contains: " << m_nentries.size() << " and represents pixel (row,col) (" << m_row_and_column.first << ","<< m_row_and_colum.second <<") \n"; */
0061   /*   for(int iter=0; iter<m_nentries.size(); ++iter) */
0062   /*     result << "calib point " << iter << ", nentries " << m_nentries[iter] << ", sum " << m_adccountsum[iter] << ", sum of squares " << m_adccountsumsq[iter] <<".\n"; */
0063   /*   return output << result; */
0064   return output << "this pixel (row " << digi.row() << ", col " << digi.col() << " has " << digi.getnpoints()
0065                 << " calibration points.";
0066 }
0067 
0068 #endif