File indexing completed on 2024-09-10 02:58:39
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
0024 uint32_t getnpoints() const { return m_data.size(); }
0025 uint32_t getsum(uint32_t ipoint) const {
0026 return m_data[ipoint].adccountsum;
0027 }
0028 uint32_t getsumsquares(uint32_t ipoint) const {
0029 return m_data[ipoint].adccountsumsq;
0030 }
0031 uint32_t getnentries(uint32_t ipoint) const {
0032 return m_data[ipoint].nentries;
0033 }
0034 std::vector<uint32_t> getsum() const;
0035 std::vector<uint32_t> getsumsquares() const;
0036 std::vector<uint8_t> getnentries() const;
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;
0044 uint32_t adccountsum;
0045 uint32_t adccountsumsq;
0046 };
0047
0048 private:
0049
0050 std::vector<datacontainer> m_data;
0051 std::pair<uint16_t, uint16_t> m_row_and_column;
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
0060
0061
0062
0063
0064 return output << "this pixel (row " << digi.row() << ", col " << digi.col() << " has " << digi.getnpoints()
0065 << " calibration points.";
0066 }
0067
0068 #endif