Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:11

0001 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0002 
0003 //---------------------------------------------------------------------------
0004 //!  \class SiPixelCluster
0005 //!  \brief Pixel cluster -- collection of pixels with ADC counts
0006 //!
0007 //!  Class to contain and store all the topological information of pixel clusters:
0008 //!  charge, global size, size and the barycenter in x and y
0009 //!  local directions. It builds a vector of SiPixel (which is
0010 //!  an inner class) and a container of channels.
0011 //!
0012 //!  March 2007: Edge pixel methods moved to RectangularPixelTopology (V.Chiochia)
0013 //!  May   2008: Offset based packing (D.Fehling / A. Rizzi)
0014 //!  \author Petar Maksimovic, JHU
0015 //---------------------------------------------------------------------------
0016 
0017 SiPixelCluster::SiPixelCluster(const SiPixelCluster::PixelPos& pix, int adc)
0018     : theMinPixelRow(pix.row()), theMinPixelCol(pix.col()) {
0019   // First pixel in this cluster.
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 }