CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ClusterShape Class Reference

#include <ClusterShape.h>

List of all members.

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.

{
}
ClusterShape::~ClusterShape ( )

Definition at line 20 of file ClusterShape.cc.

{
}

Member Function Documentation

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

Definition at line 97 of file ClusterShape.cc.

References lumiQTWidget::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.

{
  // Topology
  const PixelTopology * theTopology = (&(pixelDet.specificTopology())); 
 
  // Initialize
  data.isStraight = true;
  data.isComplete = true;
 
  x[0] = -1; x[1] = -1;
  y[0] = -1; y[1] = -1;
  olow = -2; ohig = -2; odir = 0;
  low = 0; hig = 0;

  pair<int,int> pos;
 
  // Get sorted pixels
  vector<SiPixelCluster::Pixel> pixels = recHit.cluster()->pixels();
  sort(pixels.begin(),pixels.end(),lessPixel());

  // Look at all the pixels
  for(vector<SiPixelCluster::Pixel>::const_iterator pixel = pixels.begin();
                                                    pixel!= pixels.end();
                                                    pixel++)
  {
    // Position
    pos.first  = (int)pixel->x;
    pos.second = (int)pixel->y;

    // Check if at the edge or big 
    if(theTopology->isItEdgePixelInX(pos.first) ||
       theTopology->isItEdgePixelInY(pos.second))
    { data.isComplete = false; } // break; }
 
    // Check if straight
    if(pos.first > x[1])
    { // column ready
      if(processColumn(pos, true) == false)
      { data.isStraight = false; } // break; }
    }
    else
    { // increasing column
      if(pos.second > hig+1) // at least a pixel is missing
      { data.isStraight = false; } // break; }
 
      hig = pos.second;
    }
  }

  // Check if straight, process last column
  if(processColumn(pos, false) == false)
    data.isStraight = false;

  // Treat clusters with big pixel(s) inside
  for(int ix = recHit.cluster()->minPixelRow() + 1;
          ix < recHit.cluster()->maxPixelRow(); ix++)
    if(theTopology->isItBigPixelInX(ix)) x[1]++;
 
  for(int iy = recHit.cluster()->minPixelCol() + 1;
          iy < recHit.cluster()->maxPixelCol(); iy++)
    if(theTopology->isItBigPixelInY(iy)) y[1]++;

  // Treat clusters with bix pixel(s) outside, FIXME FIXME
  int px = 0;
  if(theTopology->isItBigPixelInX(recHit.cluster()->minPixelRow())) px++;
  if(theTopology->isItBigPixelInX(recHit.cluster()->maxPixelRow())) px++;

  int py = 0;
  if(theTopology->isItBigPixelInY(recHit.cluster()->minPixelCol())) py++;
  if(theTopology->isItBigPixelInY(recHit.cluster()->maxPixelCol())) py++;

  if(px > 0 || py > 0)
    data.hasBigPixelsOnlyInside = false;
  else
    data.hasBigPixelsOnlyInside = true;

  if( (px > 0 || py > 0) && odir == 0)
  {
    // if outside and don't know the direction FIXME?
    data.isComplete = false;
  }
  // else
  { // FIXME do it
    data.size.reserve(px*py);
    for(int ax = 0; ax <= px; ax++)
    for(int ay = 0; ay <= py; ay++)
    {
      int dx = x[1] - x[0] + ax;
      int dy = y[1] - y[0] + ay;
      if(odir != 0) dy *= odir;
  
      pair<int,int> s(dx,dy);
      data.size.push_back(s); 
    }
  }
}
int ClusterShape::getDirection ( int  low,
int  hig,
int  olow,
int  ohig 
) [private]

Definition at line 25 of file ClusterShape.cc.

{
  if(hig == ohig && low == olow) return  0;
  if(hig >= ohig && low >= olow) return  1; 
  if(hig <= ohig && low <= olow) return -1;
   
  return -2;
}
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.

{
  if(x[1] > -1)
  { // Process previous column
    if(low < y[0] || x[1] == x[0]) y[0] = low;
    if(hig > y[1] || x[1] == x[0]) y[1] = hig;

    if(x[1] > x[0])
    { // Determine direction
      int dir = getDirection(low,hig, olow,ohig);

      // no direction
      if(dir == -2) return false;

      if(x[1] > x[0]+1)
      { // Check if direction changes
        if(odir*dir == -1)
        { odir = -2; return false; }
      }

      if(x[1] <= x[0]+1 || odir == 0)
        odir = dir;

    }

    olow = low; ohig = hig;
  }
  else
  { // Very first column, initialize
    x[0] = pos.first;
  }

  // Open new column
  if(inTheLoop)
  {
    x[1] = pos.first;
    low  = pos.second;
    hig  = pos.second;
  }

  return(true);
}

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]

Definition at line 31 of file ClusterShape.h.

int ClusterShape::y[2] [private]

Definition at line 31 of file ClusterShape.h.