CMS 3D CMS Logo

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

BaseCrystal Class Reference

#include <BaseCrystal.h>

List of all members.

Public Types

typedef ROOT::Math::Plane3D Plane3D
typedef math::XYZVector XYZPoint
typedef math::XYZVector XYZVector

Public Member Functions

 BaseCrystal ()
 Empty constructor.
 BaseCrystal (const DetId &cell)
 constructor from DetId
const XYZVectorexitingNormal (const CaloDirection &side) const
 normal exiting vector for the surface
const XYZVectorgetAxis () const
 get crystal axis
const XYZPointgetBackCenter () const
 get front center
const Plane3DgetBackPlane () const
 back plane
void getBackSide (XYZPoint &a, XYZPoint &b, XYZPoint &c, XYZPoint &d) const
 Coordinates of the back side.
void getBackSide (std::vector< XYZPoint > &corners) const
const XYZPointgetCenter () const
 get 1/8*(Sum of corners)
const XYZPointgetCorner (unsigned i) const
 get the i-th corner
const std::vector< XYZPoint > & getCorners () const
const DetIdgetDetId () const
 get the DetId
void getDrawingCoordinates (std::vector< float > &x, std::vector< float > &y, std::vector< float > &z) const
 for debugging.
const XYZVectorgetFifthEdge () const
 Direction of the fifth edge.
const XYZVectorgetFirstEdge () const
 Direction of the first edge.
const XYZPointgetFrontCenter () const
 get front center
const Plane3DgetFrontPlane () const
 front plane
void getFrontSide (std::vector< XYZPoint > &corners) const
void getFrontSide (XYZPoint &a, XYZPoint &b, XYZPoint &c, XYZPoint &d) const
 coordinates of the front side
const XYZVectorgetLateralEdge (unsigned i) const
 lateral directions
void getLateralEdges (unsigned i, XYZPoint &, XYZPoint &) const
 get the lateral edges
const Plane3DgetLateralPlane (unsigned i) const
 lateral planes
void getLateralSide (unsigned i, std::vector< XYZPoint > &corners) const
void getLateralSide (unsigned i, XYZPoint &a, XYZPoint &b, XYZPoint &c, XYZPoint &d) const
 Coordinates of the i=th lateral side.
const Plane3DgetPlane (const CaloDirection &side) const
 generic access
void getSide (const CaloDirection &side, XYZPoint &a, XYZPoint &b, XYZPoint &c, XYZPoint &d) const
 generic access
void getSide (const CaloDirection &side, std::vector< XYZPoint > &corners) const
const int getSubdetNumber () const
 get the subdector
void print () const
void setCorners (const CaloCellGeometry::CornersVec &vec, const GlobalPoint &pos)
 ~BaseCrystal ()
 Copy constructor.

Static Public Member Functions

static unsigned oppositeDirection (unsigned iside)

Private Member Functions

void computeBasicProperties ()

Private Attributes

XYZPoint backcenter_
DetId cellid_
XYZPoint center_
std::vector< XYZPointcorners_
XYZVector crystalaxis_
std::vector< XYZVectorexitingNormal_
XYZVector fifthedgedirection_
XYZVector firstedgedirection_
XYZPoint frontcenter_
std::vector< XYZVectorlateraldirection_
std::vector< Plane3DlateralPlane_
int subdetn_

Detailed Description

Definition at line 19 of file BaseCrystal.h.


Member Typedef Documentation

Definition at line 26 of file BaseCrystal.h.

Definition at line 25 of file BaseCrystal.h.

Definition at line 24 of file BaseCrystal.h.


Constructor & Destructor Documentation

BaseCrystal::BaseCrystal ( ) [inline]

Empty constructor.

Definition at line 31 of file BaseCrystal.h.

{;};
BaseCrystal::BaseCrystal ( const DetId cell)

constructor from DetId

Definition at line 9 of file BaseCrystal.cc.

References cellid_, DetId::subdetId(), and subdetn_.

                                          :cellid_(cell)
{
  subdetn_ = cellid_.subdetId();
}
BaseCrystal::~BaseCrystal ( ) [inline]

Copy constructor.

Definition at line 42 of file BaseCrystal.h.

{;}

Member Function Documentation

void BaseCrystal::computeBasicProperties ( ) [private]

Definition at line 92 of file BaseCrystal.cc.

References backcenter_, center_, corners_, crystalaxis_, exitingNormal_, fifthedgedirection_, firstedgedirection_, frontcenter_, i, lateraldirection_, and lateralPlane_.

Referenced by setCorners().

{
  if(corners_.size()==0) return;
  center_=XYZPoint(0.,0.,0.);  
  for(unsigned ic=0;ic<8;++ic)
    {
      center_+=corners_[ic];
    }
  
  center_*=0.125;

  //  std::cout << " Ncorners ? " << corners_.size() << std::endl;
  frontcenter_ = 0.25*(corners_[0]+corners_[1]+corners_[2]+corners_[3]);
  backcenter_ = 0.25*(corners_[4]+corners_[5]+corners_[6]+corners_[7]);
  crystalaxis_ = backcenter_-frontcenter_;
  firstedgedirection_=-(corners_[1]-corners_[0]).Unit();
  fifthedgedirection_=-(corners_[5]-corners_[4]).Unit();
  lateraldirection_.resize(4);
  //  std::cout << " Direction laterales " << std::endl;
  for(unsigned il=0;il<4;++il)
    {
      lateraldirection_[il]=-(corners_[(il+1)%4]-corners_[il]).Unit();
    }
  
  Plane3D frontPlane((Point)corners_[0],(Point)corners_[1],(Point)corners_[2]);
  Plane3D backPlane ((Point)corners_[4],(Point)corners_[5],(Point)corners_[6]);
  lateralPlane_.resize(6);
  for(unsigned i=0;i<4;++i)
    {
      lateralPlane_[i]=
        Plane3D((Point)corners_[i],(Point)corners_[(i+1)%4],(Point)corners_[i+4]);
    }
  // Front plane i=4 (UP)
  lateralPlane_[4] = frontPlane;
  // Back plane i =5 (DOWN)
  lateralPlane_[5] = backPlane;

  exitingNormal_.resize(6);
  for(unsigned i=0;i<6;++i)
    {
      exitingNormal_[i] = 
        (lateralPlane_[i].Distance(Point(center_.X(),center_.Y(),center_.Z())) < 0.) ? 
        lateralPlane_[i].Normal().Unit() : -lateralPlane_[i].Normal().Unit();
    }
}
const XYZVector& BaseCrystal::exitingNormal ( const CaloDirection side) const [inline]

normal exiting vector for the surface

Definition at line 95 of file BaseCrystal.h.

References exitingNormal_.

Referenced by Crystal::exitingNormal().

const XYZVector& BaseCrystal::getAxis ( ) const [inline]

get crystal axis

Definition at line 103 of file BaseCrystal.h.

References crystalaxis_.

Referenced by Crystal::getAxis().

{ return crystalaxis_;}
const XYZPoint& BaseCrystal::getBackCenter ( ) const [inline]

get front center

Definition at line 55 of file BaseCrystal.h.

References backcenter_.

Referenced by Crystal::getBackCenter().

{return backcenter_;}
const Plane3D& BaseCrystal::getBackPlane ( ) const [inline]

back plane

Definition at line 85 of file BaseCrystal.h.

References lateralPlane_.

Referenced by Crystal::getBackPlane().

{return lateralPlane_[5];}
void BaseCrystal::getBackSide ( XYZPoint a,
XYZPoint b,
XYZPoint c,
XYZPoint d 
) const

Coordinates of the back side.

Definition at line 166 of file BaseCrystal.cc.

References corners_.

Referenced by Crystal::getBackSide(), and getSide().

{
  a=corners_[4];
  b=corners_[5];
  c=corners_[6];
  d=corners_[7];
}
void BaseCrystal::getBackSide ( std::vector< XYZPoint > &  corners) const

Definition at line 174 of file BaseCrystal.cc.

References corners_.

{
  if(corners.size()==4)
    {
      corners[0]=corners_[4];
      corners[1]=corners_[5];
      corners[2]=corners_[6];
      corners[3]=corners_[7];
    }
}
const XYZPoint& BaseCrystal::getCenter ( ) const [inline]

get 1/8*(Sum of corners)

Definition at line 51 of file BaseCrystal.h.

References center_.

Referenced by Crystal::getCenter().

{return center_;};
const XYZPoint& BaseCrystal::getCorner ( unsigned  i) const [inline]

get the i-th corner

Definition at line 49 of file BaseCrystal.h.

References corners_, and i.

Referenced by Crystal::getCorner().

{ return corners_[i];};
const std::vector<XYZPoint>& BaseCrystal::getCorners ( ) const [inline]

Definition at line 46 of file BaseCrystal.h.

References corners_.

{return corners_;}
const DetId& BaseCrystal::getDetId ( void  ) const [inline]

get the DetId

Definition at line 61 of file BaseCrystal.h.

References cellid_.

{return cellid_;};
void BaseCrystal::getDrawingCoordinates ( std::vector< float > &  x,
std::vector< float > &  y,
std::vector< float > &  z 
) const

for debugging.

Definition at line 205 of file BaseCrystal.cc.

References corners_, X, and Gflash::Z.

Referenced by Crystal::getDrawingCoordinates().

{
  x.clear();
  y.clear();
  z.clear();

  x.push_back(corners_[0].X());
  x.push_back(corners_[3].X());
  x.push_back(corners_[2].X());
  x.push_back(corners_[1].X());
  x.push_back(corners_[5].X());
  x.push_back(corners_[6].X());
  x.push_back(corners_[7].X());
  x.push_back(corners_[4].X());
  x.push_back(corners_[0].X());
  x.push_back(corners_[1].X());
  x.push_back(corners_[2].X());
  x.push_back(corners_[6].X());
  x.push_back(corners_[5].X());
  x.push_back(corners_[4].X());
  x.push_back(corners_[7].X());
  x.push_back(corners_[3].X());

  y.push_back(corners_[0].Y());
  y.push_back(corners_[3].Y());
  y.push_back(corners_[2].Y());
  y.push_back(corners_[1].Y());
  y.push_back(corners_[5].Y());
  y.push_back(corners_[6].Y());
  y.push_back(corners_[7].Y());
  y.push_back(corners_[4].Y());
  y.push_back(corners_[0].Y());
  y.push_back(corners_[1].Y());
  y.push_back(corners_[2].Y());
  y.push_back(corners_[6].Y());
  y.push_back(corners_[5].Y());
  y.push_back(corners_[4].Y());
  y.push_back(corners_[7].Y());
  y.push_back(corners_[3].Y());

  z.push_back(corners_[0].Z());
  z.push_back(corners_[3].Z());
  z.push_back(corners_[2].Z());
  z.push_back(corners_[1].Z());
  z.push_back(corners_[5].Z());
  z.push_back(corners_[6].Z());
  z.push_back(corners_[7].Z());
  z.push_back(corners_[4].Z());
  z.push_back(corners_[0].Z());
  z.push_back(corners_[1].Z());
  z.push_back(corners_[2].Z());
  z.push_back(corners_[6].Z());
  z.push_back(corners_[5].Z());
  z.push_back(corners_[4].Z());
  z.push_back(corners_[7].Z());
  z.push_back(corners_[3].Z());
}
const XYZVector& BaseCrystal::getFifthEdge ( ) const [inline]

Direction of the fifth edge.

Definition at line 59 of file BaseCrystal.h.

References fifthedgedirection_.

Referenced by Crystal::getFifthEdge().

const XYZVector& BaseCrystal::getFirstEdge ( ) const [inline]

Direction of the first edge.

Definition at line 57 of file BaseCrystal.h.

References firstedgedirection_.

Referenced by Crystal::getFirstEdge().

const XYZPoint& BaseCrystal::getFrontCenter ( ) const [inline]

get front center

Definition at line 53 of file BaseCrystal.h.

References frontcenter_.

Referenced by Crystal::getFrontCenter().

{return frontcenter_;};
const Plane3D& BaseCrystal::getFrontPlane ( ) const [inline]

front plane

Definition at line 83 of file BaseCrystal.h.

References lateralPlane_.

Referenced by Crystal::getFrontPlane().

{return lateralPlane_[4];}
void BaseCrystal::getFrontSide ( std::vector< XYZPoint > &  corners) const

Definition at line 155 of file BaseCrystal.cc.

References corners_.

{
  if(corners.size()==4)
    {
      corners[0]=corners_[0];
      corners[1]=corners_[1];
      corners[2]=corners_[2];
      corners[3]=corners_[3];
    }
}
void BaseCrystal::getFrontSide ( XYZPoint a,
XYZPoint b,
XYZPoint c,
XYZPoint d 
) const

coordinates of the front side

Definition at line 147 of file BaseCrystal.cc.

References corners_.

Referenced by Crystal::getFrontSide(), and getSide().

{
  a=corners_[0];
  b=corners_[1];
  c=corners_[2];
  d=corners_[3];
}
const XYZVector& BaseCrystal::getLateralEdge ( unsigned  i) const [inline]

lateral directions

Definition at line 92 of file BaseCrystal.h.

References i, and lateraldirection_.

Referenced by Crystal::getLateralEdge().

{return lateraldirection_[i];};
void BaseCrystal::getLateralEdges ( unsigned  i,
XYZPoint a,
XYZPoint b 
) const

get the lateral edges

Definition at line 138 of file BaseCrystal.cc.

References corners_, and i.

Referenced by Crystal::getLateralEdges(), and getLateralSide().

{
  if(i<4U) // i >= 0, since i is unsigned
    {
      a=corners_[i];
      b=corners_[i+4]; 
    }
}
const Plane3D& BaseCrystal::getLateralPlane ( unsigned  i) const [inline]

lateral planes

Definition at line 87 of file BaseCrystal.h.

References i, and lateralPlane_.

Referenced by Crystal::getLateralPlane().

{return lateralPlane_[i];};
void BaseCrystal::getLateralSide ( unsigned  i,
XYZPoint a,
XYZPoint b,
XYZPoint c,
XYZPoint d 
) const

Coordinates of the i=th lateral side.

Definition at line 185 of file BaseCrystal.cc.

References getLateralEdges().

Referenced by Crystal::getLateralSide(), and getSide().

{
  if(i<4U) // i >= 0, since i is unsigned
    {
      getLateralEdges(i,a,b);
      getLateralEdges((i+1)%4,c,d);
    }
}
void BaseCrystal::getLateralSide ( unsigned  i,
std::vector< XYZPoint > &  corners 
) const

Definition at line 194 of file BaseCrystal.cc.

References corners_, and i.

{
  if(corners.size()==4&&i<4U) // i >= 0, since i is unsigned
    {
      corners[0]=corners_[i];
      corners[1]=corners_[i+4];
      corners[2]=corners_[4+(i+1)%4];
      corners[3]=corners_[(i+1)%4];
    }
}
const Plane3D& BaseCrystal::getPlane ( const CaloDirection side) const [inline]

generic access

Definition at line 89 of file BaseCrystal.h.

References lateralPlane_.

Referenced by Crystal::getPlane().

void BaseCrystal::getSide ( const CaloDirection side,
std::vector< XYZPoint > &  corners 
) const

Definition at line 294 of file BaseCrystal.cc.

References DOWN, getBackSide(), getFrontSide(), getLateralSide(), CaloDirectionOperations::Side(), and UP.

{
  switch (side)
    {
    case UP:
      getFrontSide(corners);
      break;
    case DOWN:
      getBackSide(corners);
      break;
    default:
      getLateralSide(CaloDirectionOperations::Side(side),corners);
    }
}
void BaseCrystal::getSide ( const CaloDirection side,
XYZPoint a,
XYZPoint b,
XYZPoint c,
XYZPoint d 
) const

generic access

Definition at line 266 of file BaseCrystal.cc.

References DOWN, getBackSide(), getFrontSide(), getLateralSide(), CaloDirectionOperations::Side(), and UP.

Referenced by Crystal::getSide().

{
  switch (side)
    {
    case UP:
      getFrontSide(a,b,c,d);
      break;
    case DOWN:
      getBackSide(a,b,c,d);
      break;
    default:
      getLateralSide(CaloDirectionOperations::Side(side),a,b,c,d);
    }
}
const int BaseCrystal::getSubdetNumber ( ) const [inline]

get the subdector

Definition at line 63 of file BaseCrystal.h.

References subdetn_.

Referenced by Crystal::getSubdetNumber().

{return subdetn_;}
static unsigned BaseCrystal::oppositeDirection ( unsigned  iside) [static]
void BaseCrystal::print ( void  ) const

Definition at line 281 of file BaseCrystal.cc.

References backcenter_, cellid_, center_, corners_, gather_cfg::cout, exitingNormal_, frontcenter_, errorMatrix2Lands_multiChannel::id, and DetId::rawId().

Referenced by Crystal::print().

                             {
  std::cout << "CellID " << cellid_.rawId() << std::endl;
  std::cout << " Corners " << std::endl;
  for(unsigned ic=0;ic<corners_.size();++ic)
    std::cout << corners_[ic] << std::endl;
  std::cout << " Center " << center_ << std::endl;
  std::cout << " Front Center " << frontcenter_ << std::endl;
  std::cout << " Back Center " << backcenter_ << std::endl;
  std::cout << " Normales sortantes " << std::endl;
  for(unsigned id=0;id<exitingNormal_.size();++id)
    std::cout << exitingNormal_[id] << std::endl;
}
void BaseCrystal::setCorners ( const CaloCellGeometry::CornersVec vec,
const GlobalPoint pos 
)

Definition at line 14 of file BaseCrystal.cc.

References computeBasicProperties(), corners_, EcalBarrel, EcalEndcap, evf::evtn::offset(), EZArrayFL< T >::size(), subdetn_, PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::z(), and z.

Referenced by CaloGeometryHelper::buildCrystalArray().

{
  unsigned ncorners= vec.size();
  if(ncorners!=8) return;

  // This is really a pity to have to make the conversion GlobalPoint to XYZPoint, but the latter have many
  // useful properties (transformations, conversions....) that aren't implemented
  // for the GlobalPoints and GlobalVectors. 

  if(subdetn_==EcalBarrel)
    {
      if(pos.z()>0.)
        {
          corners_.clear();
          corners_.resize(8);
          for(unsigned ic=0;ic<8;++ic)
            {
              corners_[ic]=XYZPoint(vec[ic].x(),vec[ic].y(),vec[ic].z());
            }
        }
      else
        {
          corners_.clear();
          corners_.resize(8);
          corners_[0]=XYZPoint(vec[2].x(),vec[2].y(),vec[2].z());
          corners_[1]=XYZPoint(vec[3].x(),vec[3].y(),vec[3].z());
          corners_[2]=XYZPoint(vec[0].x(),vec[0].y(),vec[0].z());
          corners_[3]=XYZPoint(vec[1].x(),vec[1].y(),vec[1].z());
          corners_[4]=XYZPoint(vec[6].x(),vec[6].y(),vec[6].z());
          corners_[5]=XYZPoint(vec[7].x(),vec[7].y(),vec[7].z());
          corners_[6]=XYZPoint(vec[4].x(),vec[4].y(),vec[4].z());
          corners_[7]=XYZPoint(vec[5].x(),vec[5].y(),vec[5].z());
        }
    }
  else if(subdetn_==EcalEndcap)
    {
      double x=pos.x();
      double y=pos.y();
      double z=pos.z();
      unsigned offset=0;
      int zsign=1;
      if(z>0) 
        {
          if(x>0&&y>0) 
            offset=1;
          else  if(x<0&&y>0) 
            offset=2;
          else if(x>0&&y<0) 
            offset=0;
          else if (x<0&&y<0) 
            offset=3;
          zsign=1;
        }
      else
        {
          if(x>0&&y>0) 
            offset=3;
          else if(x<0&&y>0) 
            offset=2;
          else if(x>0&&y<0) 
            offset=0;
          else if(x<0&&y<0) 
            offset=1;
          zsign=-1;
        }
      corners_.clear();
      corners_.resize(8);
      for(unsigned ic=0;ic<4;++ic)
        {
          unsigned i1=(unsigned)((zsign*ic+offset)%4);
          unsigned i2=i1+4;
          corners_[ic]=XYZPoint(vec[i1].x(),vec[i1].y(),vec[i1].z());
          corners_[4+ic]=XYZPoint(vec[i2].x(),vec[i2].y(),vec[i2].z());
        }
    }
  computeBasicProperties();
}

Member Data Documentation

Definition at line 116 of file BaseCrystal.h.

Referenced by computeBasicProperties(), getBackCenter(), and print().

Definition at line 112 of file BaseCrystal.h.

Referenced by BaseCrystal(), getDetId(), and print().

Definition at line 114 of file BaseCrystal.h.

Referenced by computeBasicProperties(), getCenter(), and print().

std::vector<XYZPoint> BaseCrystal::corners_ [private]

Definition at line 119 of file BaseCrystal.h.

Referenced by computeBasicProperties(), and getAxis().

std::vector<XYZVector> BaseCrystal::exitingNormal_ [private]

Definition at line 122 of file BaseCrystal.h.

Referenced by computeBasicProperties(), exitingNormal(), and print().

Definition at line 118 of file BaseCrystal.h.

Referenced by computeBasicProperties(), and getFifthEdge().

Definition at line 117 of file BaseCrystal.h.

Referenced by computeBasicProperties(), and getFirstEdge().

Definition at line 115 of file BaseCrystal.h.

Referenced by computeBasicProperties(), getFrontCenter(), and print().

std::vector<XYZVector> BaseCrystal::lateraldirection_ [private]

Definition at line 120 of file BaseCrystal.h.

Referenced by computeBasicProperties(), and getLateralEdge().

std::vector<Plane3D> BaseCrystal::lateralPlane_ [private]
int BaseCrystal::subdetn_ [private]

Definition at line 113 of file BaseCrystal.h.

Referenced by BaseCrystal(), getSubdetNumber(), and setCorners().