CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ClusterShape Class Reference

#include <ClusterShape.h>

Public Member Functions

 ClusterShape ()
 
void determineShape (const PixelGeomDetUnit &pixelDet, const SiPixelRecHit &recHit, ClusterData &data)
 
void determineShape (const PixelGeomDetUnit &pixelDet, const SiPixelCluster &cluster, ClusterData &data)
 
 ~ClusterShape ()
 

Private Member Functions

int getDirection (int low, int hig, int olow, int ohig)
 
bool processColumn (std::pair< int, int > pos, bool inTheLoop)
 

Private Attributes

int hig
 
int low
 
int odir
 
int ohig
 
int olow
 
std::vector< SiPixelCluster::Pixelpixels_
 
int x [2]
 
int y [2]
 

Detailed Description

Definition at line 14 of file ClusterShape.h.

Constructor & Destructor Documentation

ClusterShape::ClusterShape ( )

Definition at line 15 of file ClusterShape.cc.

16 {
17 }
ClusterShape::~ClusterShape ( )

Definition at line 20 of file ClusterShape.cc.

21 {
22 }

Member Function Documentation

void ClusterShape::determineShape ( const PixelGeomDetUnit pixelDet,
const SiPixelRecHit recHit,
ClusterData data 
)

Definition at line 92 of file ClusterShape.cc.

References SiPixelRecHit::cluster().

Referenced by lessPixel::operator()(), and SiPixelClusterShapeCacheProducer::produce().

94 {
95  determineShape(pixelDet, *(recHit.cluster()), data);
96 }
void determineShape(const PixelGeomDetUnit &pixelDet, const SiPixelRecHit &recHit, ClusterData &data)
Definition: ClusterShape.cc:92
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
void ClusterShape::determineShape ( const PixelGeomDetUnit pixelDet,
const SiPixelCluster cluster,
ClusterData data 
)

Definition at line 99 of file ClusterShape.cc.

References create_public_lumi_plots::ax, edm::VecArray< T, N >::capacity(), PVValHelper::dx, PVValHelper::dy, ClusterData::hasBigPixelsOnlyInside, mps_fire::i, createfilelist::int, ClusterData::isComplete, PixelTopology::isItBigPixelInX(), PixelTopology::isItBigPixelInY(), PixelTopology::isItEdgePixelInX(), PixelTopology::isItEdgePixelInY(), ClusterData::isStraight, SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), heppy_hadd::odir, digi_MixPreMix_cfi::pixel, SiPixelCluster::pixel(), SiPixelCluster::pixelADC(), edm::VecArray< T, N >::push_back_unchecked(), alignCSCRings::s, ClusterData::size, PixelGeomDetUnit::specificTopology(), and x().

101 {
102  // Topology
103  const PixelTopology * theTopology = (&(pixelDet.specificTopology()));
104 
105  // Initialize
106  data.isStraight = true;
107  data.isComplete = true;
108 
109  x[0] = -1; x[1] = -1;
110  y[0] = -1; y[1] = -1;
111  olow = -2; ohig = -2; odir = 0;
112  low = 0; hig = 0;
113 
114  pair<int,int> pos;
115 
116  // Get sorted pixels
117  size_t npixels = cluster.pixelADC().size();
118  pixels_.reserve(npixels);
119  for(size_t i=0; i<npixels; ++i) {
120  pixels_.push_back(cluster.pixel(i));
121  }
122  sort(pixels_.begin(),pixels_.end(),lessPixel());
123 
124  // Look at all the pixels
125  for(const auto& pixel: pixels_)
126  {
127  // Position
128  pos.first = (int)pixel.x;
129  pos.second = (int)pixel.y;
130 
131  // Check if at the edge or big
132  if(theTopology->isItEdgePixelInX(pos.first) ||
133  theTopology->isItEdgePixelInY(pos.second))
134  { data.isComplete = false; } // break; }
135 
136  // Check if straight
137  if(pos.first > x[1])
138  { // column ready
139  if(processColumn(pos, true) == false)
140  { data.isStraight = false; } // break; }
141  }
142  else
143  { // increasing column
144  if(pos.second > hig+1) // at least a pixel is missing
145  { data.isStraight = false; } // break; }
146 
147  hig = pos.second;
148  }
149  }
150  pixels_.clear();
151 
152  // Check if straight, process last column
153  if(processColumn(pos, false) == false)
154  data.isStraight = false;
155 
156  // Treat clusters with big pixel(s) inside
157  const int minPixelRow = cluster.minPixelRow();
158  const int maxPixelRow = cluster.maxPixelRow();
159  for(int ix = minPixelRow + 1;
160  ix < maxPixelRow; ix++)
161  x[1] += theTopology->isItBigPixelInX(ix);
162 
163  const int minPixelCol = cluster.minPixelCol();
164  const int maxPixelCol = cluster.maxPixelCol();
165  for(int iy = minPixelCol + 1;
166  iy < maxPixelCol; iy++)
167  y[1] += theTopology->isItBigPixelInY(iy);
168 
169  // Treat clusters with bix pixel(s) outside, FIXME FIXME
170  unsigned int px = 0;
171  px += theTopology->isItBigPixelInX(minPixelRow);
172  px += theTopology->isItBigPixelInX(maxPixelRow);
173 
174  unsigned int py = 0;
175  py += theTopology->isItBigPixelInY(minPixelCol);
176  py += theTopology->isItBigPixelInY(maxPixelCol);
177 
178  data.hasBigPixelsOnlyInside = (px <= 0 && py <= 0);
179 
180  //if( (px > 0 || py > 0) && odir == 0)
181  if( !data.hasBigPixelsOnlyInside && odir == 0)
182  {
183  // if outside and don't know the direction FIXME?
184  data.isComplete = false;
185  }
186  // else
187  { // FIXME do it
188  assert((px+1)*(py+1) <= data.size.capacity());
189  const int pre_dx = x[1] - x[0];
190  const int pre_dy = y[1] - y[0];
191  for(unsigned int ax = 0; ax <= px; ax++)
192  for(unsigned int ay = 0; ay <= py; ay++)
193  {
194  int dx = pre_dx + ax;
195  int dy = pre_dy + ay;
196  if(odir != 0) dy *= odir;
197 
198  pair<int,int> s(dx,dy);
199  data.size.push_back_unchecked(s);
200  }
201  }
202 }
int minPixelCol() const
virtual bool isItEdgePixelInX(int ixbin) const =0
std::vector< SiPixelCluster::Pixel > pixels_
Definition: ClusterShape.h:37
virtual bool isItEdgePixelInY(int iybin) const =0
virtual bool isItBigPixelInX(int ixbin) const =0
bool isComplete
Definition: ClusterData.h:12
int maxPixelRow() const
int minPixelRow() const
bool processColumn(std::pair< int, int > pos, bool inTheLoop)
Definition: ClusterShape.cc:35
virtual bool isItBigPixelInY(int iybin) const =0
const std::vector< uint16_t > & pixelADC() const
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
bool hasBigPixelsOnlyInside
Definition: ClusterData.h:12
int maxPixelCol() const
Pixel pixel(int i) const
void push_back_unchecked(const T &value)
Definition: VecArray.h:85
ArrayType size
Definition: ClusterData.h:11
static constexpr size_type capacity() noexcept
Definition: VecArray.h:71
bool isStraight
Definition: ClusterData.h:12
int ClusterShape::getDirection ( int  low,
int  hig,
int  olow,
int  ohig 
)
private

Definition at line 25 of file ClusterShape.cc.

26 {
27  if(hig == ohig && low == olow) return 0;
28  if(hig >= ohig && low >= olow) return 1;
29  if(hig <= ohig && low <= olow) return -1;
30 
31  return -2;
32 }
bool ClusterShape::processColumn ( std::pair< int, int >  pos,
bool  inTheLoop 
)
private

Definition at line 35 of file ClusterShape.cc.

References dir, heppy_hadd::odir, x, and y.

36 {
37  if(x[1] > -1)
38  { // Process previous column
39  if(low < y[0] || x[1] == x[0]) y[0] = low;
40  if(hig > y[1] || x[1] == x[0]) y[1] = hig;
41 
42  if(x[1] > x[0])
43  { // Determine direction
44  int dir = getDirection(low,hig, olow,ohig);
45 
46  // no direction
47  if(dir == -2) return false;
48 
49  if(x[1] > x[0]+1)
50  { // Check if direction changes
51  if(odir*dir == -1)
52  { odir = -2; return false; }
53  }
54 
55  if(x[1] <= x[0]+1 || odir == 0)
56  odir = dir;
57 
58  }
59 
60  olow = low; ohig = hig;
61  }
62  else
63  { // Very first column, initialize
64  x[0] = pos.first;
65  }
66 
67  // Open new column
68  if(inTheLoop)
69  {
70  x[1] = pos.first;
71  low = pos.second;
72  hig = pos.second;
73  }
74 
75  return(true);
76 }
int getDirection(int low, int hig, int olow, int ohig)
Definition: ClusterShape.cc:25
dbl *** dir
Definition: mlp_gen.cc:35

Member Data Documentation

int ClusterShape::hig
private

Definition at line 38 of file ClusterShape.h.

int ClusterShape::low
private

Definition at line 38 of file ClusterShape.h.

int ClusterShape::odir
private

Definition at line 38 of file ClusterShape.h.

int ClusterShape::ohig
private

Definition at line 38 of file ClusterShape.h.

int ClusterShape::olow
private

Definition at line 38 of file ClusterShape.h.

std::vector<SiPixelCluster::Pixel> ClusterShape::pixels_
private

Definition at line 37 of file ClusterShape.h.

int ClusterShape::x[2]
private
int ClusterShape::y[2]
private