CMS 3D CMS Logo

CTPPSPixelCluster.h
Go to the documentation of this file.
1 #ifndef DataFormats_CTPPS_CTPPSPixelCluster_h
2 #define DataFormats_CTPPS_CTPPSPixelCluster_h
3 
4 /*
5  \class CTPPSPixelCluster
6  \brief CTPPSPixelCluster stores the information of CTPPS Tracker clusters of 3D pixels
7  Author: F.Ferro - INFN Genova - 2016
8 */
9 
10 #include <vector>
11 #include <cstdint>
12 #include <cassert>
13 
15 public:
17  static constexpr uint8_t MAXSPAN = 255;
18  static constexpr uint8_t MAXCOL = 155;
19  static constexpr uint8_t MAXROW = 159;
20 
21  CTPPSPixelCluster(uint16_t isize, uint16_t* adcs, uint8_t const* rowpos, uint8_t const* colpos)
23  2 *
24  isize), // the pixel offset is the pixel position inside the cluster wrt rowmin (even positions) and colmin (odd positions)
25  thePixelADC(adcs, adcs + isize) {
26  uint8_t maxCol = 0;
27  uint8_t maxRow = 0;
28  uint8_t rowmin = MAXROW;
29  uint8_t colmin = MAXCOL;
30  for (unsigned int j = 0; j != isize; ++j) {
31  rowmin = std::min(rowpos[j], rowmin);
32  colmin = std::min(colpos[j], colmin);
33  }
34  for (unsigned int i = 0; i != isize; ++i) {
35  uint8_t rowoffset = rowpos[i] - rowmin;
36  uint8_t coloffset = colpos[i] - colmin;
37  thePixelOffset[i * 2] = std::min(MAXSPAN, rowoffset);
38  thePixelOffset[i * 2 + 1] = std::min(MAXSPAN, coloffset);
39  if (rowoffset > maxRow)
40  maxRow = rowoffset;
41  if (coloffset > maxCol)
42  maxCol = coloffset;
43  }
44 
45  theMinPixelRow = rowmin;
46  thePixelRowSpan = std::min(maxRow, MAXSPAN);
47 
48  theMinPixelCol = colmin;
49  thePixelColSpan = std::min(maxCol, MAXSPAN);
50  }
51 
52  // barycenter
53 
54  float avg_row() const {
55  float qm = 0.0;
56  unsigned int isize = thePixelADC.size();
57  for (unsigned int i = 0; i < isize; ++i)
58  qm += float(thePixelADC[i]) * (thePixelOffset[i * 2] + theMinPixelRow + 0.5f);
59  return qm / charge();
60  }
61 
62  float avg_col() const {
63  float qm = 0.0;
64  unsigned int isize = thePixelADC.size();
65  for (unsigned int i = 0; i < isize; ++i)
66  qm += float(thePixelADC[i]) * (thePixelOffset[i * 2 + 1] + theMinPixelCol + 0.5f);
67  return qm / charge();
68  }
69 
70  //cluster charge
71 
72  inline float charge() const {
73  float qm = 0.0;
74  unsigned int isize = thePixelADC.size();
75  for (unsigned int i = 0; i < isize; ++i)
76  qm += float(thePixelADC[i]);
77  return qm;
78  }
79 
80  // Return number of pixels.
81  unsigned int size() const { return thePixelADC.size(); }
82 
83  // Return cluster dimension in rows
84  unsigned int sizeRow() const { return thePixelRowSpan + 1; }
85 
86  // Return cluster dimension in columns
87  unsigned int sizeCol() const { return thePixelColSpan + 1; }
88 
89  inline unsigned int minPixelRow() const { return theMinPixelRow; }
90  inline unsigned int minPixelCol() const { return theMinPixelCol; }
91 
92  inline unsigned int colSpan() const { return thePixelColSpan; }
93  inline unsigned int rowSpan() const { return thePixelRowSpan; }
94 
95  const std::vector<uint8_t>& pixelOffset() const { return thePixelOffset; }
96  const std::vector<uint16_t>& pixelADC() const { return thePixelADC; }
97 
98  unsigned int pixelRow(unsigned int i) const { return theMinPixelRow + thePixelOffset[i * 2]; }
99  unsigned int pixelCol(unsigned int i) const { return theMinPixelCol + thePixelOffset[i * 2 + 1]; }
100  unsigned int pixelADC(unsigned int i) const { return thePixelADC[i]; }
101 
102 private:
103  std::vector<uint8_t> thePixelOffset;
104  std::vector<uint16_t> thePixelADC;
105 
108  uint8_t thePixelRowSpan = 0;
109  uint8_t thePixelColSpan = 0;
110 };
111 
112 inline bool operator<(const CTPPSPixelCluster& one, const CTPPSPixelCluster& two) {
113  if (one.minPixelRow() < two.minPixelRow()) {
114  return true;
115  } else if (one.minPixelRow() > two.minPixelRow()) {
116  return false;
117  } else if (one.minPixelCol() < two.minPixelCol()) {
118  return true;
119  } else {
120  return false;
121  }
122 }
123 
124 #endif
CTPPSPixelCluster::thePixelRowSpan
uint8_t thePixelRowSpan
Definition: CTPPSPixelCluster.h:108
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelPI::one
Definition: SiPixelPayloadInspectorHelper.h:39
CTPPSPixelCluster::pixelCol
unsigned int pixelCol(unsigned int i) const
Definition: CTPPSPixelCluster.h:99
CTPPSPixelCluster::size
unsigned int size() const
Definition: CTPPSPixelCluster.h:81
CTPPSPixelCluster::pixelOffset
const std::vector< uint8_t > & pixelOffset() const
Definition: CTPPSPixelCluster.h:95
CTPPSPixelCluster::charge
float charge() const
Definition: CTPPSPixelCluster.h:72
min
T min(T a, T b)
Definition: MathUtil.h:58
CTPPSPixelCluster::minPixelRow
unsigned int minPixelRow() const
Definition: CTPPSPixelCluster.h:89
CTPPSPixelCluster::CTPPSPixelCluster
CTPPSPixelCluster()
Definition: CTPPSPixelCluster.h:16
CTPPSPixelCluster::pixelADC
unsigned int pixelADC(unsigned int i) const
Definition: CTPPSPixelCluster.h:100
CTPPSPixelCluster::pixelRow
unsigned int pixelRow(unsigned int i) const
Definition: CTPPSPixelCluster.h:98
CTPPSPixelCluster::CTPPSPixelCluster
CTPPSPixelCluster(uint16_t isize, uint16_t *adcs, uint8_t const *rowpos, uint8_t const *colpos)
Definition: CTPPSPixelCluster.h:21
CTPPSPixelCluster::MAXROW
static constexpr uint8_t MAXROW
Definition: CTPPSPixelCluster.h:19
CTPPSPixelCluster::thePixelADC
std::vector< uint16_t > thePixelADC
Definition: CTPPSPixelCluster.h:104
CTPPSPixelCluster::MAXCOL
static constexpr uint8_t MAXCOL
Definition: CTPPSPixelCluster.h:18
CTPPSPixelCluster::thePixelOffset
std::vector< uint8_t > thePixelOffset
Definition: CTPPSPixelCluster.h:103
CTPPSPixelCluster::thePixelColSpan
uint8_t thePixelColSpan
Definition: CTPPSPixelCluster.h:109
CTPPSPixelCluster::pixelADC
const std::vector< uint16_t > & pixelADC() const
Definition: CTPPSPixelCluster.h:96
CTPPSPixelCluster::MAXSPAN
static constexpr uint8_t MAXSPAN
Definition: CTPPSPixelCluster.h:17
CTPPSPixelCluster::avg_col
float avg_col() const
Definition: CTPPSPixelCluster.h:62
CTPPSPixelCluster::sizeCol
unsigned int sizeCol() const
Definition: CTPPSPixelCluster.h:87
SiPixelPI::two
Definition: SiPixelPayloadInspectorHelper.h:39
CTPPSPixelCluster::colSpan
unsigned int colSpan() const
Definition: CTPPSPixelCluster.h:92
CTPPSPixelCluster::avg_row
float avg_row() const
Definition: CTPPSPixelCluster.h:54
CTPPSPixelCluster::theMinPixelRow
uint8_t theMinPixelRow
Definition: CTPPSPixelCluster.h:106
CTPPSPixelCluster::sizeRow
unsigned int sizeRow() const
Definition: CTPPSPixelCluster.h:84
CTPPSPixelCluster::rowSpan
unsigned int rowSpan() const
Definition: CTPPSPixelCluster.h:93
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CTPPSPixelCluster
Definition: CTPPSPixelCluster.h:14
CTPPSPixelCluster::minPixelCol
unsigned int minPixelCol() const
Definition: CTPPSPixelCluster.h:90
CTPPSPixelCluster::theMinPixelCol
uint8_t theMinPixelCol
Definition: CTPPSPixelCluster.h:107
operator<
bool operator<(const CTPPSPixelCluster &one, const CTPPSPixelCluster &two)
Definition: CTPPSPixelCluster.h:112