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 80 of file ClusterShape.cc.

References SiPixelRecHit::cluster().

Referenced by processColumn(), and SiPixelClusterShapeCacheProducer::produce().

82 {
83  determineShape(pixelDet, *(recHit.cluster()), data);
84 }
void determineShape(const PixelGeomDetUnit &pixelDet, const SiPixelRecHit &recHit, ClusterData &data)
Definition: ClusterShape.cc:80
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
void ClusterShape::determineShape ( const PixelGeomDetUnit pixelDet,
const SiPixelCluster cluster,
ClusterData data 
)

Definition at line 87 of file ClusterShape.cc.

References a, create_public_lumi_plots::ax, b, 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, digitizers_cfi::pixel, SiPixelCluster::pixel(), SiPixelCluster::pixelADC(), edm::VecArray< T, N >::push_back_unchecked(), alignCSCRings::s, ClusterData::size, jetUpdater_cfi::sort, PixelGeomDetUnit::specificTopology(), x, and y.

89 {
90  // Topology
91  const PixelTopology * theTopology = (&(pixelDet.specificTopology()));
92 
93  // Initialize
94  data.isStraight = true;
95  data.isComplete = true;
96 
97  x[0] = -1; x[1] = -1;
98  y[0] = -1; y[1] = -1;
99  olow = -2; ohig = -2; odir = 0;
100  low = 0; hig = 0;
101 
102  pair<int,int> pos;
103 
104  // Get sorted pixels
105  size_t npixels = cluster.pixelADC().size();
106  pixels_.reserve(npixels);
107  for(size_t i=0; i<npixels; ++i) {
108  pixels_.push_back(cluster.pixel(i));
109  }
110  sort(pixels_.begin(),pixels_.end(),[](auto const& a, auto const& b){
111  // slightly faster by avoiding branches
112  return (a.x < b.x) | ((a.x == b.x) & (a.y < b.y));
113  });
114 
115  // Look at all the pixels
116  for(const auto& pixel: pixels_)
117  {
118  // Position
119  pos.first = (int)pixel.x;
120  pos.second = (int)pixel.y;
121 
122  // Check if at the edge or big
123  if(theTopology->isItEdgePixelInX(pos.first) ||
124  theTopology->isItEdgePixelInY(pos.second))
125  { data.isComplete = false; } // break; }
126 
127  // Check if straight
128  if(pos.first > x[1])
129  { // column ready
130  if(processColumn(pos, true) == false)
131  { data.isStraight = false; } // break; }
132  }
133  else
134  { // increasing column
135  if(pos.second > hig+1) // at least a pixel is missing
136  { data.isStraight = false; } // break; }
137 
138  hig = pos.second;
139  }
140  }
141  pixels_.clear();
142 
143  // Check if straight, process last column
144  if(processColumn(pos, false) == false)
145  data.isStraight = false;
146 
147  // Treat clusters with big pixel(s) inside
148  const int minPixelRow = cluster.minPixelRow();
149  const int maxPixelRow = cluster.maxPixelRow();
150  for(int ix = minPixelRow + 1;
151  ix < maxPixelRow; ix++)
152  x[1] += theTopology->isItBigPixelInX(ix);
153 
154  const int minPixelCol = cluster.minPixelCol();
155  const int maxPixelCol = cluster.maxPixelCol();
156  for(int iy = minPixelCol + 1;
157  iy < maxPixelCol; iy++)
158  y[1] += theTopology->isItBigPixelInY(iy);
159 
160  // Treat clusters with bix pixel(s) outside, FIXME FIXME
161  unsigned int px = 0;
162  px += theTopology->isItBigPixelInX(minPixelRow);
163  px += theTopology->isItBigPixelInX(maxPixelRow);
164 
165  unsigned int py = 0;
166  py += theTopology->isItBigPixelInY(minPixelCol);
167  py += theTopology->isItBigPixelInY(maxPixelCol);
168 
169  data.hasBigPixelsOnlyInside = (px <= 0 && py <= 0);
170 
171  //if( (px > 0 || py > 0) && odir == 0)
172  if( !data.hasBigPixelsOnlyInside && odir == 0)
173  {
174  // if outside and don't know the direction FIXME?
175  data.isComplete = false;
176  }
177  // else
178  { // FIXME do it
179  assert((px+1)*(py+1) <= data.size.capacity());
180  const int pre_dx = x[1] - x[0];
181  const int pre_dy = y[1] - y[0];
182  for(unsigned int ax = 0; ax <= px; ax++)
183  for(unsigned int ay = 0; ay <= py; ay++)
184  {
185  int dx = pre_dx + ax;
186  int dy = pre_dy + ay;
187  if(odir != 0) dy *= odir;
188 
189  pair<int,int> s(dx,dy);
190  data.size.push_back_unchecked(s);
191  }
192  }
193 }
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
double b
Definition: hdecay.h:120
int maxPixelCol() const
Pixel pixel(int i) const
void push_back_unchecked(const T &value)
Definition: VecArray.h:83
double a
Definition: hdecay.h:121
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 determineShape(), 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