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::ClusterShape ( )

Definition at line 15 of file ClusterShape.cc.

15 {}

◆ ~ClusterShape()

ClusterShape::~ClusterShape ( )

Definition at line 18 of file ClusterShape.cc.

18 {}

Member Function Documentation

◆ determineShape() [1/2]

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

Definition at line 75 of file ClusterShape.cc.

References data, and rpcPointValidation_cfi::recHit.

Referenced by SiPixelClusterShapeCacheProducer::produce().

75  {
76  determineShape(pixelDet, *(recHit.cluster()), data);
77 }
void determineShape(const PixelGeomDetUnit &pixelDet, const SiPixelRecHit &recHit, ClusterData &data)
Definition: ClusterShape.cc:75
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ determineShape() [2/2]

void ClusterShape::determineShape ( const PixelGeomDetUnit pixelDet,
const SiPixelCluster cluster,
ClusterData data 
)

Definition at line 79 of file ClusterShape.cc.

References a, cms::cuda::assert(), b, data, PVValHelper::dx, PVValHelper::dy, mps_fire::i, createfilelist::int, PixelTopology::isItBigPixelInX(), PixelTopology::isItBigPixelInY(), PixelTopology::isItEdgePixelInX(), PixelTopology::isItEdgePixelInY(), LaserClient_cfi::low, SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), heppy_hadd::odir, muonClassificationByHits_cfi::pixel, SiPixelCluster::pixel(), SiPixelCluster::pixelADC(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, alignCSCRings::s, jetsAK4_CHS_cff::sort, PixelGeomDetUnit::specificTopology(), x, and y.

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

◆ getDirection()

int ClusterShape::getDirection ( int  low,
int  hig,
int  olow,
int  ohig 
)
private

Definition at line 21 of file ClusterShape.cc.

References LaserClient_cfi::low.

21  {
22  if (hig == ohig && low == olow)
23  return 0;
24  if (hig >= ohig && low >= olow)
25  return 1;
26  if (hig <= ohig && low <= olow)
27  return -1;
28 
29  return -2;
30 }

◆ processColumn()

bool ClusterShape::processColumn ( std::pair< int, int >  pos,
bool  inTheLoop 
)
private

Definition at line 33 of file ClusterShape.cc.

References DeadROC_duringRun::dir, LaserClient_cfi::low, heppy_hadd::odir, x, and y.

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

Member Data Documentation

◆ hig

int ClusterShape::hig
private

Definition at line 35 of file ClusterShape.h.

◆ low

int ClusterShape::low
private

Definition at line 35 of file ClusterShape.h.

◆ odir

int ClusterShape::odir
private

Definition at line 35 of file ClusterShape.h.

◆ ohig

int ClusterShape::ohig
private

Definition at line 35 of file ClusterShape.h.

◆ olow

int ClusterShape::olow
private

Definition at line 35 of file ClusterShape.h.

◆ pixels_

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

Definition at line 34 of file ClusterShape.h.

◆ x

int ClusterShape::x[2]
private

◆ y

int ClusterShape::y[2]
private