File indexing completed on 2024-04-06 12:05:11
0001 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 SiPixelCluster::SiPixelCluster(const SiPixelCluster::PixelPos& pix, int adc)
0018 : theMinPixelRow(pix.row()), theMinPixelCol(pix.col()) {
0019
0020 thePixelADC.push_back(adc);
0021 thePixelOffset.push_back(0);
0022 thePixelOffset.push_back(0);
0023 }
0024
0025 void SiPixelCluster::add(const SiPixelCluster::PixelPos& pix, int adc) {
0026 int ominRow = minPixelRow();
0027 int ominCol = minPixelCol();
0028 bool recalculate = false;
0029
0030 int minRow = ominRow;
0031 int minCol = ominCol;
0032
0033 if (pix.row() < minRow) {
0034 minRow = pix.row();
0035 recalculate = true;
0036 }
0037 if (pix.col() < minCol) {
0038 minCol = pix.col();
0039 recalculate = true;
0040 }
0041
0042 if (recalculate) {
0043 int maxCol = 0;
0044 int maxRow = 0;
0045 int isize = thePixelADC.size();
0046 for (int i = 0; i < isize; ++i) {
0047 int xoffset = thePixelOffset[i * 2] + ominRow - minRow;
0048 int yoffset = thePixelOffset[i * 2 + 1] + ominCol - minCol;
0049 thePixelOffset[i * 2] = std::min(int(MAXSPAN), xoffset);
0050 thePixelOffset[i * 2 + 1] = std::min(int(MAXSPAN), yoffset);
0051 if (xoffset > maxRow)
0052 maxRow = xoffset;
0053 if (yoffset > maxCol)
0054 maxCol = yoffset;
0055 }
0056 packRow(minRow, maxRow);
0057 packCol(minCol, maxCol);
0058 }
0059
0060 if ((!overflowRow()) && pix.row() > maxPixelRow())
0061 packRow(minRow, pix.row() - minRow);
0062
0063 if ((!overflowCol()) && pix.col() > maxPixelCol())
0064 packCol(minCol, pix.col() - minCol);
0065
0066 thePixelADC.push_back(adc);
0067 thePixelOffset.push_back(std::min(int(MAXSPAN), pix.row() - minRow));
0068 thePixelOffset.push_back(std::min(int(MAXSPAN), pix.col() - minCol));
0069 }