CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes | Static Private Attributes

CrystalPad Class Reference

#include <CrystalPad.h>

List of all members.

Classes

class  padEqual
 equality operator More...

Public Types

typedef
ROOT::Math::Transform3DPJ::Point 
Point
typedef ROOT::Math::Transform3DPJ Transform3D
typedef math::XYZVector XYZPoint
typedef math::XYZVector XYZVector

Public Member Functions

const CLHEP::Hep2Vector & center () const
 get the center
 CrystalPad ()
 CrystalPad (unsigned number, const std::vector< XYZPoint > &corners, const Transform3D &, double scaf=1.)
 CrystalPad (unsigned number, const std::vector< CLHEP::Hep2Vector > &corners)
 Order matters. 1234 2341 3412 4123 are ok but not 1324 ....
 CrystalPad (const CrystalPad &right)
 CrystalPad (unsigned number, int onEcal, const std::vector< XYZPoint > &corners, const XYZPoint &origin, const XYZVector &vec1, const XYZVector &vec2)
CLHEP::Hep2Vector & edge (unsigned iside, int n)
 access to the corners in direction iside; n=0,1
CLHEP::Hep2Vector & edge (CaloDirection)
 access to one corner (NE,NW,SE,SW)
void extrems (double &xmin, double &xmax, double &ymin, double &ymax) const
 xmin xmax, ymin ymax of the quad
const std::vector
< CLHEP::Hep2Vector > & 
getCorners () const
 Check that the point (in the global frame) is inside the crystal.
void getDrawingCoordinates (std::vector< float > &x, std::vector< float > &y) const
 for graphic debugging
unsigned getNumber () const
 access to the number
bool inside (const CLHEP::Hep2Vector &point, bool debug=false) const
 Check that the point (in the local frame) is inside the crystal.
bool operator< (const CrystalPad &quad) const
CrystalPadoperator= (const CrystalPad &rhs)
bool operator== (const CrystalPad &quad) const
 get the coordinates in the original frame
void print () const
 print
void resetCorners ()
 Rescale the Quad to allow for some inaccuracy ...
void setSurvivalProbability (double val)
double survivalProbability () const
 access methods to the survivalProbability
 ~CrystalPad ()

Private Attributes

CLHEP::Hep2Vector center_
std::vector< CLHEP::Hep2Vector > corners_
std::vector< CLHEP::Hep2Vector > dir_
bool dummy_
double epsilon_
unsigned number_
ROOT::Math::Rotation3D rotation_
double survivalProbability_
Transform3D trans_
XYZVector translation_
double yscalefactor_

Static Private Attributes

static std::vector
< CLHEP::Hep2Vector > 
aVector

Detailed Description

Definition at line 14 of file CrystalPad.h.


Member Typedef Documentation

Definition at line 21 of file CrystalPad.h.

Definition at line 20 of file CrystalPad.h.

Definition at line 19 of file CrystalPad.h.

Definition at line 18 of file CrystalPad.h.


Constructor & Destructor Documentation

CrystalPad::CrystalPad ( ) [inline]

Definition at line 24 of file CrystalPad.h.

References dummy_.

{ dummy_ = true;};
CrystalPad::CrystalPad ( unsigned  number,
const std::vector< CLHEP::Hep2Vector > &  corners 
)

Order matters. 1234 2341 3412 4123 are ok but not 1324 ....

Definition at line 33 of file CrystalPad.cc.

References center_, corners_, gather_cfg::cout, dir_, and dummy_.

  :
  corners_(corners),
  dir_(aVector),
  number_(number),
  survivalProbability_(1.),
  center_(0.,0.),
  epsilon_(0.001)
{

  //  std::cout << " Hello " << std::endl;
  if(corners.size()!=4)
    {
      std::cout << " Try to construct a quadrilateral with " << corners.size() << " points ! " << std::endl;     
      dummy_=true;
    }
  else
    {
      dummy_=false;
      // Set explicity the z to 0 !
      for(unsigned ic=0; ic<4;++ic)
        {
          dir_[ic] = (corners[(ic+1)%4]-corners[ic]).unit();
          center_+=corners_[ic];
        }
      center_*=0.25;
    }
//  std::cout << " End of 1 constructor " << std::endl;
//  std::cout << " Ncorners " << corners_.size() << std::endl;
//  std::cout << " Ndirs " << dir_.size() << std::endl;
}
CrystalPad::CrystalPad ( unsigned  number,
int  onEcal,
const std::vector< XYZPoint > &  corners,
const XYZPoint origin,
const XYZVector vec1,
const XYZVector vec2 
)

Constructor from space points, with the description of the local frame (origin,vec1,vec2) where vec1 is normal to the plane and vec2 in the plane

Definition at line 66 of file CrystalPad.cc.

References center_, corners_, gather_cfg::cout, dir_, dummy_, ROOT::Math::Transform3DPJ::GetDecomposition(), rotation_, trans_, and translation_.

  : 
  corners_(aVector),
  dir_(aVector),
  number_(number),
  survivalProbability_(1.),
  center_(0.,0.),
  epsilon_(0.001)
{

  //  std::cout << " We are in the 2nd constructor " << std::endl;
  if(corners.size()!=4)
    {
      std::cout << " Try to construct a quadrilateral with " << corners.size() << " points ! " << std::endl;     
      dummy_=true;
    }
  else
    {
      dummy_=false;
      double sign=(onEcal==1) ? -1.: 1.;

      // the good one in the central
      trans_=Transform3D((Point)origin,
                         (Point)(origin+vec1),
                         (Point)(origin+vec2),
                         Point(0.,0.,0.),
                         Point(0.,0.,sign),
                         Point(0.,1.,0.));
      trans_.GetDecomposition(rotation_,translation_);
      //      std::cout << " Constructor 2; input corners "  << std::endl;
      for(unsigned ic=0;ic<4;++ic)
        {       
          //      std::cout << corners[ic]<< " " ;
          XYZPoint corner = rotation_(corners[ic])+translation_;
          //      std::cout << corner << std::endl ;
          corners_[ic] = CLHEP::Hep2Vector(corner.X(),corner.Y());
          center_+=corners_[ic];
        }
      for(unsigned ic=0;ic<4;++ic)
        {
          dir_[ic] = (corners_[(ic+1)%4]-corners_[ic]).unit();
        }
      center_*=0.25;
    }  
//  std::cout << " End of 2 constructor " << std::endl;
//  std::cout << " Corners(constructor) " ;
//  std::cout << corners_[0] << std::endl;
//  std::cout << corners_[1] << std::endl;
//  std::cout << corners_[2] << std::endl;
//  std::cout << corners_[3] << std::endl;
}
CrystalPad::CrystalPad ( unsigned  number,
const std::vector< XYZPoint > &  corners,
const Transform3D trans,
double  scaf = 1. 
)

Definition at line 121 of file CrystalPad.cc.

References center_, corners_, gather_cfg::cout, dir_, dummy_, ROOT::Math::Transform3DPJ::GetDecomposition(), rotation_, trans_, translation_, and yscalefactor_.

  : 
  corners_(aVector),
  dir_(aVector),
  number_(number),
  survivalProbability_(1.),
  center_(0.,0.),
  epsilon_(0.001),
  yscalefactor_(scaf)
{

  //  std::cout << " We are in the 2nd constructor " << std::endl;
  if(corners.size()!=4)
    {
      std::cout << " Try to construct a quadrilateral with " << corners.size() << " points ! " << std::endl;     
      dummy_=true;
    }
  else
    {
      dummy_=false;

      // the good one in the central
      trans_=trans;
      //      std::cout << " Constructor 2; input corners "  << std::endl;
      trans_.GetDecomposition(rotation_,translation_);
      for(unsigned ic=0;ic<4;++ic)
        {       

          XYZPoint corner=rotation_(corners[ic])+translation_;
          //      std::cout << corner << std::endl ;
          corners_[ic] = CLHEP::Hep2Vector(corner.X(),corner.Y()*yscalefactor_);
          center_+=corners_[ic];
        }
      for(unsigned ic=0;ic<4;++ic)
        {
          dir_[ic] = (corners_[(ic+1)%4]-corners_[ic]).unit();
        }
      center_*=0.25;
    }  
}
CrystalPad::CrystalPad ( const CrystalPad right)

Definition at line 8 of file CrystalPad.cc.

References center_, corners_, dir_, dummy_, epsilon_, number_, and survivalProbability_.

{
  corners_ = right.corners_;
  dir_ = right.dir_;
  number_ = right.number_;
  survivalProbability_ = right.survivalProbability_;
  center_ = right.center_;
  epsilon_ = right.epsilon_;
  dummy_ = right.dummy_;
}
CrystalPad::~CrystalPad ( ) [inline]

Definition at line 45 of file CrystalPad.h.

{;};

Member Function Documentation

const CLHEP::Hep2Vector& CrystalPad::center ( ) const [inline]

get the center

Definition at line 101 of file CrystalPad.h.

References center_.

Referenced by operator<().

{return center_;}
CLHEP::Hep2Vector & CrystalPad::edge ( CaloDirection  dir)

access to one corner (NE,NW,SE,SW)

Definition at line 267 of file CrystalPad.cc.

References corners_, gather_cfg::cout, NORTHEAST, NORTHWEST, SOUTHEAST, and SOUTHWEST.

{
  switch(dir)
    {
    case NORTHWEST:
      return corners_[0];
      break;
    case NORTHEAST:
      return corners_[1];
      break;
    case SOUTHEAST:
      return corners_[2];
      break;
    case SOUTHWEST:
      return corners_[3];
      break;
    default:
      {
        std::cout << " Serious problem in CrystalPad ! " << dir << std::endl;
        return corners_[0];
      }
    }
  return corners_[0];
}
CLHEP::Hep2Vector & CrystalPad::edge ( unsigned  iside,
int  n 
)

access to the corners in direction iside; n=0,1

Definition at line 262 of file CrystalPad.cc.

References corners_, and n.

Referenced by EcalHitMaker::cracksPads(), EcalHitMaker::gapsLifting(), and operator<<().

{
  return corners_[(iside+n)%4];
}
void CrystalPad::extrems ( double &  xmin,
double &  xmax,
double &  ymin,
double &  ymax 
) const

xmin xmax, ymin ymax of the quad

Definition at line 294 of file CrystalPad.cc.

References corners_, x, and detailsBasic3DVector::y.

{
  xmin=ymin=999;
  xmax=ymax=-999;
  for(unsigned ic=0;ic<4;++ic)
    {
      if(corners_[ic].x()<xmin) xmin=corners_[ic].x();
      if(corners_[ic].x()>xmax) xmax=corners_[ic].x();
      if(corners_[ic].y()<ymin) ymin=corners_[ic].y();
      if(corners_[ic].y()>ymax) ymax=corners_[ic].y();
    }
}
const std::vector<CLHEP::Hep2Vector>& CrystalPad::getCorners ( ) const [inline]

Check that the point (in the global frame) is inside the crystal.

coordinates of the point in the local frame get the corners

Definition at line 56 of file CrystalPad.h.

References corners_.

{return corners_;}
void CrystalPad::getDrawingCoordinates ( std::vector< float > &  x,
std::vector< float > &  y 
) const

for graphic debugging

Definition at line 334 of file CrystalPad.cc.

References corners_, x, and detailsBasic3DVector::y.

{
  x.clear();
  y.clear();
  x.push_back(corners_[0].x());
  x.push_back(corners_[1].x());
  x.push_back(corners_[2].x());
  x.push_back(corners_[3].x());
  x.push_back(corners_[0].x());
  y.push_back(corners_[0].y());
  y.push_back(corners_[1].y());
  y.push_back(corners_[2].y());
  y.push_back(corners_[3].y());
  y.push_back(corners_[0].y());
}
unsigned CrystalPad::getNumber ( ) const [inline]

access to the number

Definition at line 75 of file CrystalPad.h.

References number_.

Referenced by CrystalPad::padEqual::operator()(), operator<<(), and operator==().

{return number_;};
bool CrystalPad::inside ( const CLHEP::Hep2Vector &  point,
bool  debug = false 
) const

Check that the point (in the local frame) is inside the crystal.

Definition at line 165 of file CrystalPad.cc.

References corners_, and dir_.

{
//  std::cout << "Inside " << ppoint <<std::endl;
//  std::cout << "Corners " << corners_.size() << std::endl;
//  std::cout << corners_[0] << std::endl;
//  std::cout << corners_[1] << std::endl;
//  std::cout << corners_[2] << std::endl;
//  std::cout << corners_[3] << std::endl;
//  std::cout << " Got the 2D point " << std::endl;
  CLHEP::Hep2Vector pv0(ppoint-corners_[0]);
  CLHEP::Hep2Vector pv2(ppoint-corners_[2]);
  CLHEP::Hep2Vector n1(pv0-(pv0*dir_[0])*dir_[0]);
  CLHEP::Hep2Vector n2(pv2-(pv2*dir_[2])*dir_[2]);

  //  double N1(n1.mag());
  //  double N2(n2.mag());
  double r1(n1*n2);
  bool inside1(r1<=0.);

  if (!inside1) return false;

//  if(debug) 
//    {
//      std::cout << n1 << std::endl;
//      std::cout << n2 << std::endl;
//      std::cout << r1 << std::endl;
//      std::cout << inside1 << std::endl;
//    }

//  bool close1=(N1<epsilon_||N2<epsilon_);
//  
//  if(!close1&&!inside1) return false;
  //  std::cout << " First calculation " << std::endl;
  CLHEP::Hep2Vector pv1(ppoint-corners_[1]);
  CLHEP::Hep2Vector pv3(ppoint-corners_[3]);
  CLHEP::Hep2Vector n3(pv1-(pv1*dir_[1])*dir_[1]);
  CLHEP::Hep2Vector n4(pv3-(pv3*dir_[3])*dir_[3]);
  //  double N3(n3.mag());
  //  double N4(n4.mag());
  //  bool close2=(N3<epsilon_||N4<epsilon_);
  double r2(n3*n4);
  bool inside2(r2<=0.);
//  //  std::cout << " pv1 & pv3 " << pv1.mag() << " " << pv3.mag() << std::endl;
//  //  double tmp=(pv1-(pv1*dir_[1])*dir_[1])*(pv3-(pv3*dir_[3])*dir_[3]);
//  //  std::cout << " Computed tmp " << tmp << std::endl;
//  if(debug) 
//    {
//      std::cout << n3 << std::endl;
//      std::cout << n4 << std::endl;
//      std::cout << r2 << std::endl;
//      std::cout << inside2 << std::endl;
//    }
  //  if(!close2&&!inside2) return false;
//  std::cout << " Second calculation " << std::endl;
//  std::cout << " True " << std::endl;
  //    return (!close1&&!close2||(close2&&inside1||close1&&inside2));

  return inside2;
}
bool CrystalPad::operator< ( const CrystalPad quad) const [inline]

Definition at line 92 of file CrystalPad.h.

References center(), and center_.

    {
      return (center_.mag()<quad.center().mag());
    }
CrystalPad & CrystalPad::operator= ( const CrystalPad rhs)

Definition at line 20 of file CrystalPad.cc.

References center_, corners_, dir_, dummy_, epsilon_, number_, and survivalProbability_.

                                                {
  if (this != &right) { // don't copy into yourself
    corners_ = right.corners_;
    dir_ = right.dir_;
    number_ = right.number_;
    survivalProbability_ = right.survivalProbability_;
    center_ = right.center_;
    epsilon_ = right.epsilon_;
    dummy_ = right.dummy_;
  }
  return *this;
}
bool CrystalPad::operator== ( const CrystalPad quad) const [inline]

get the coordinates in the original frame

Definition at line 86 of file CrystalPad.h.

References getNumber().

    {
      //      std::cout << " First " << quad.getCellID() << " Second " << this->getCellID() << std::endl;
      return quad.getNumber()==this->getNumber();
    }
void CrystalPad::print ( void  ) const

print

Definition at line 244 of file CrystalPad.cc.

References corners_, and gather_cfg::cout.

{
  std::cout << " Corners " << std::endl;
  std::cout << corners_[0] << std::endl;
  std::cout << corners_[1] << std::endl;
  std::cout << corners_[2] << std::endl;
  std::cout << corners_[3] << std::endl;
}
void CrystalPad::resetCorners ( )

Rescale the Quad to allow for some inaccuracy ...

Definition at line 308 of file CrystalPad.cc.

References center_, and corners_.

                         {

  // Find the centre-of-gravity of the Quad (after re-organization)
  center_ = CLHEP::Hep2Vector(0.,0.);
  for(unsigned ic=0;ic<4;++ic) center_ += corners_[ic];
  center_ *= 0.25;

  // Rescale the corners to allow for some inaccuracies in 
  // in the inside test
  for(unsigned ic=0;ic<4;++ic) 
    corners_[ic] += 0.001 * (corners_[ic] - center_) ;

}
void CrystalPad::setSurvivalProbability ( double  val) [inline]

Definition at line 66 of file CrystalPad.h.

References survivalProbability_.

Referenced by EcalHitMaker::cracksPads().

double CrystalPad::survivalProbability ( ) const [inline]

access methods to the survivalProbability

Definition at line 65 of file CrystalPad.h.

References survivalProbability_.


Member Data Documentation

std::vector< CLHEP::Hep2Vector > CrystalPad::aVector [static, private]

Definition at line 109 of file CrystalPad.h.

CLHEP::Hep2Vector CrystalPad::center_ [private]

Definition at line 118 of file CrystalPad.h.

Referenced by center(), CrystalPad(), operator<(), operator=(), and resetCorners().

std::vector<CLHEP::Hep2Vector> CrystalPad::corners_ [private]
std::vector<CLHEP::Hep2Vector> CrystalPad::dir_ [private]

Definition at line 112 of file CrystalPad.h.

Referenced by CrystalPad(), inside(), and operator=().

bool CrystalPad::dummy_ [private]

Definition at line 120 of file CrystalPad.h.

Referenced by CrystalPad(), and operator=().

double CrystalPad::epsilon_ [private]

Definition at line 119 of file CrystalPad.h.

Referenced by CrystalPad(), and operator=().

unsigned CrystalPad::number_ [private]

Definition at line 113 of file CrystalPad.h.

Referenced by CrystalPad(), getNumber(), and operator=().

ROOT::Math::Rotation3D CrystalPad::rotation_ [private]

Definition at line 115 of file CrystalPad.h.

Referenced by CrystalPad().

Definition at line 117 of file CrystalPad.h.

Referenced by CrystalPad(), operator=(), setSurvivalProbability(), and survivalProbability().

Definition at line 114 of file CrystalPad.h.

Referenced by CrystalPad().

Definition at line 116 of file CrystalPad.h.

Referenced by CrystalPad().

double CrystalPad::yscalefactor_ [private]

Definition at line 121 of file CrystalPad.h.

Referenced by CrystalPad().