CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ~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
 
int x [2]
 
int y [2]
 

Detailed Description

Definition at line 10 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 97 of file ClusterShape.cc.

References create_public_lumi_plots::ax, ClusterData::hasBigPixelsOnlyInside, ClusterData::isComplete, PixelTopology::isItBigPixelInX(), PixelTopology::isItBigPixelInY(), PixelTopology::isItEdgePixelInX(), PixelTopology::isItEdgePixelInY(), ClusterData::isStraight, pos, alignCSCRings::s, ClusterData::size, python.multivaluedict::sort(), PixelGeomDetUnit::specificTopology(), x, and detailsBasic3DVector::y.

Referenced by ClusterShapeHitFilter::getSizes().

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

int ClusterShape::low
private

Definition at line 31 of file ClusterShape.h.

int ClusterShape::odir
private

Definition at line 31 of file ClusterShape.h.

int ClusterShape::ohig
private

Definition at line 31 of file ClusterShape.h.

int ClusterShape::olow
private

Definition at line 31 of file ClusterShape.h.

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