CMS 3D CMS Logo

EcalEndcapGeometry Class Reference

#include <Geometry/EcalAlgo/interface/EcalEndcapGeometry.h>

Inheritance diagram for EcalEndcapGeometry:

CaloSubdetectorGeometry

List of all members.

Public Types

typedef EcalEndcapGeometryRecord AlignedRecord
typedef EEAlignmentRcd AlignmentRecord
enum  CornersCount { k_NumberOfCellsForCorners = 14648 }
typedef IdealGeometryRecord IdealRecord
typedef EcalEndcapNumberingScheme NumberingScheme
typedef EZArrayFL< EBDetIdOrderedListOfEBDetId
typedef std::vector
< OrderedListOfEBDetId * > 
VecOrdListEBDetIdPtr

Public Member Functions

 EcalEndcapGeometry ()
virtual
CaloSubdetectorGeometry::DetIdSet 
getCells (const GlobalPoint &r, double dR) const
 Get a list of all cells within a dR of the given cell.
const OrderedListOfEBDetIdgetClosestBarrelCells (EEDetId id) const
virtual DetId getClosestCell (const GlobalPoint &r) const
int getNumberOfCrystalPerModule () const
int getNumberOfModules () const
void initialize ()
void setNumberOfCrystalPerModule (const int nncrys)
void setNumberOfModules (const int nnmods)
virtual ~EcalEndcapGeometry ()

Static Public Member Functions

static std::string hitString ()
static unsigned int numberOfAlignments ()
static std::string producerName ()

Private Member Functions

EEDetId gId (float x, float y, float z) const
unsigned int index (float x) const

Static Private Member Functions

static int myPhi (int i)

Private Attributes

int _nncrys
 number of crystals per module
int _nnmods
 number of modules
EZMgrFL< EBDetId > * m_borderMgr
VecOrdListEBDetIdPtrm_borderPtrVec
float m_href
unsigned int m_nref
float m_wref
float zeN
float zeP


Detailed Description

Definition at line 17 of file EcalEndcapGeometry.h.


Member Typedef Documentation

typedef EcalEndcapGeometryRecord EcalEndcapGeometry::AlignedRecord

Definition at line 22 of file EcalEndcapGeometry.h.

typedef EEAlignmentRcd EcalEndcapGeometry::AlignmentRecord

Definition at line 23 of file EcalEndcapGeometry.h.

typedef IdealGeometryRecord EcalEndcapGeometry::IdealRecord

Definition at line 21 of file EcalEndcapGeometry.h.

typedef EcalEndcapNumberingScheme EcalEndcapGeometry::NumberingScheme

Definition at line 29 of file EcalEndcapGeometry.h.

typedef EZArrayFL<EBDetId> EcalEndcapGeometry::OrderedListOfEBDetId

Definition at line 25 of file EcalEndcapGeometry.h.

typedef std::vector<OrderedListOfEBDetId*> EcalEndcapGeometry::VecOrdListEBDetIdPtr

Definition at line 27 of file EcalEndcapGeometry.h.


Member Enumeration Documentation

enum EcalEndcapGeometry::CornersCount

Enumerator:
k_NumberOfCellsForCorners 

Definition at line 31 of file EcalEndcapGeometry.h.

00031 { k_NumberOfCellsForCorners = 14648 } ;


Constructor & Destructor Documentation

EcalEndcapGeometry::EcalEndcapGeometry (  ) 

Definition at line 8 of file EcalEndcapGeometry.cc.

00008                                        :
00009    _nnmods ( 0 ) ,
00010    _nncrys ( 0 ) ,
00011    m_borderMgr ( 0 ),
00012    m_borderPtrVec ( 0 ) 
00013 {
00014 }

EcalEndcapGeometry::~EcalEndcapGeometry (  )  [virtual]

Definition at line 16 of file EcalEndcapGeometry.cc.

References m_borderMgr, and m_borderPtrVec.

00017 {
00018    delete m_borderPtrVec ;
00019    delete m_borderMgr ;
00020 }


Member Function Documentation

CaloSubdetectorGeometry::DetIdSet EcalEndcapGeometry::getCells ( const GlobalPoint r,
double  dR 
) const [virtual]

Get a list of all cells within a dR of the given cell.

The default implementation makes a loop over all cell geometries. Cleverer implementations are suggested to use rough conversions between eta/phi and ieta/iphi and test on the boundaries.

Reimplemented from CaloSubdetectorGeometry.

Definition at line 242 of file EcalEndcapGeometry.cc.

References reco::deltaR2(), eta, PV3DBase< T, PVType, FrameType >::eta(), CaloSubdetectorGeometry::getCells(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), id, m_href, m_nref, m_wref, p, PV3DBase< T, PVType, FrameType >::phi(), phi, funct::tan(), EEDetId::validDetId(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and zeP.

00244 {
00245    CaloSubdetectorGeometry::DetIdSet dis ; // return object
00246    if( 0.000001 < dR )
00247    {
00248       if( dR > M_PI/2. ) // this code assumes small dR
00249       {
00250          dis = CaloSubdetectorGeometry::getCells( r, dR ) ; // base class version
00251       }
00252       else
00253       {
00254          const double dR2  ( dR*dR ) ;
00255          const double reta ( r.eta() ) ;
00256          const double rphi ( r.phi() ) ;
00257          const double rx   ( r.x() ) ;
00258          const double ry   ( r.y() ) ;
00259          const double rz   ( r.z() ) ;
00260          const double fac  ( fabs( zeP/rz ) ) ;
00261          const double xx   ( rx*fac ) ; // xyz at endcap z
00262          const double yy   ( ry*fac ) ; 
00263          const double zz   ( rz*fac ) ; 
00264 
00265          const double xang  ( atan( xx/zz ) ) ;
00266          const double lowX  ( zz>0 ? zz*tan( xang - dR ) : zz*tan( xang + dR ) ) ;
00267          const double highX ( zz>0 ? zz*tan( xang + dR ) : zz*tan( xang - dR ) ) ;
00268          const double yang  ( atan( yy/zz ) ) ;
00269          const double lowY  ( zz>0 ? zz*tan( yang - dR ) : zz*tan( yang + dR ) ) ;
00270          const double highY ( zz>0 ? zz*tan( yang + dR ) : zz*tan( yang - dR ) ) ;
00271 
00272          if( lowX  <  m_href &&   // proceed if any possible overlap with the endcap
00273              lowY  <  m_href &&
00274              highX > -m_href &&
00275              highY > -m_href    )
00276          {
00277             const int ix_ctr ( 1 + (int)floor( ( xx + m_href )/m_wref ) ) ;
00278             const int iy_ctr ( 1 + (int)floor( ( yy + m_href )/m_wref ) ) ;
00279             const int iz     ( rz>0 ? 1 : -1 ) ;
00280             
00281             const int ix_hi  ( ix_ctr + int( ( highX - xx )/m_wref ) + 2 ) ;
00282             const int ix_lo  ( ix_ctr - int( ( xx - lowX  )/m_wref ) - 2 ) ;
00283             
00284             const int iy_hi  ( iy_ctr + int( ( highY - yy )/m_wref ) + 2 ) ;
00285             const int iy_lo  ( iy_ctr - int( ( yy - lowY  )/m_wref ) - 2 ) ;
00286             
00287             for( int kx ( ix_lo ) ; kx <= ix_hi ; ++kx ) 
00288             {
00289                if( kx >  0      && 
00290                    kx <= m_nref    )
00291                {
00292                   for( int ky ( iy_lo ) ; ky <= iy_hi ; ++ky ) 
00293                   {
00294                      if( ky >  0      && 
00295                          ky <= m_nref    )
00296                      {
00297                         if( EEDetId::validDetId( kx, ky, iz ) ) // reject invalid ids
00298                         {
00299                            const EEDetId id ( kx, ky, iz ) ;
00300                            const CaloCellGeometry* cell ( getGeometry( id ) );
00301                            if( 0 != cell )
00302                            {
00303                               const GlobalPoint& p    ( cell->getPosition() ) ;
00304                               const double       eta  ( p.eta() ) ;
00305                               const double       phi  ( p.phi() ) ;
00306                               if( reco::deltaR2( eta, phi, reta, rphi ) < dR2 ) dis.insert( id ) ;
00307                            }
00308                         }
00309                      }
00310                   }
00311                }
00312             }
00313          }
00314       }
00315    }
00316    return dis;
00317 }

const EcalEndcapGeometry::OrderedListOfEBDetId * EcalEndcapGeometry::getClosestBarrelCells ( EEDetId  id  )  const

Definition at line 320 of file EcalEndcapGeometry.cc.

References degrees(), CaloSubdetectorGeometry::getGeometry(), i, m_borderMgr, m_borderPtrVec, myPhi(), phi, and ptr.

Referenced by PFRecHitProducerECAL::stdsimplemove().

00321 {
00322    OrderedListOfEBDetId* ptr ( 0 ) ;
00323    if( 0 != id.rawId() )
00324    {
00325       const float phi ( 370. +
00326                         getGeometry( id )->getPosition().phi().degrees() );
00327       const int iPhi ( 1 + int(phi)%360 ) ;
00328       const int iz ( id.zside() ) ;
00329       if( 0 == m_borderMgr )
00330       {
00331          m_borderMgr = new EZMgrFL<EBDetId>( 720*9, 9 ) ;
00332       }
00333       if( 0 == m_borderPtrVec )
00334       {
00335          m_borderPtrVec = new VecOrdListEBDetIdPtr() ;
00336          m_borderPtrVec->reserve( 720 ) ;
00337          for( unsigned int i ( 0 ) ; i != 720 ; ++i )
00338          {
00339             const int kz     ( 360>i ? -1 : 1 ) ;
00340             const int iEta   ( kz*85 ) ;
00341             const int iEtam1 ( kz*84 ) ;
00342             const int iEtam2 ( kz*83 ) ;
00343             const int jPhi   ( i%360 + 1 ) ;
00344             OrderedListOfEBDetId& olist ( *new OrderedListOfEBDetId( m_borderMgr ) );
00345             olist[0]=EBDetId( iEta  ,        jPhi     ) ;
00346             olist[1]=EBDetId( iEta  , myPhi( jPhi+1 ) ) ;
00347             olist[2]=EBDetId( iEta  , myPhi( jPhi-1 ) ) ;
00348             olist[3]=EBDetId( iEtam1,        jPhi     ) ;
00349             olist[4]=EBDetId( iEtam1, myPhi( jPhi+1 ) ) ;
00350             olist[5]=EBDetId( iEtam1, myPhi( jPhi-1 ) ) ;
00351             olist[6]=EBDetId( iEta  , myPhi( jPhi+2 ) ) ;
00352             olist[7]=EBDetId( iEta  , myPhi( jPhi-2 ) ) ;
00353             olist[8]=EBDetId( iEtam2,        jPhi     ) ;
00354             m_borderPtrVec->push_back( &olist ) ;
00355          }
00356       }
00357       ptr = (*m_borderPtrVec)[ ( iPhi - 1 ) + ( 0>iz ? 0 : 360 ) ] ;
00358    }
00359    return ptr ;
00360 }

DetId EcalEndcapGeometry::getClosestCell ( const GlobalPoint r  )  const [virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 133 of file EcalEndcapGeometry.cc.

References funct::A, funct::C, e, CaloCellGeometry::getCorners(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), gId(), i, EEDetId::ix(), EEDetId::iy(), offset, EEDetId::validDetId(), PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), y, PV3DBase< T, PVType, FrameType >::z(), z, and EEDetId::zside().

Referenced by CaloGeometryHelper::getClosestCell().

00134 {
00135    try
00136    {
00137       EEDetId mycellID ( gId( r.x(), r.y(), r.z() ) ) ; // educated guess
00138 
00139       if( EEDetId::validDetId( mycellID.ix(), 
00140                                mycellID.iy(),
00141                                mycellID.zside() ) )
00142       {
00143          // now get points in convenient ordering
00144 
00145          HepPoint3D  A;
00146          HepPoint3D  B;
00147          HepPoint3D  C;
00148          HepPoint3D  point(r.x(),r.y(),r.z());
00149          // D.K. : equation of plane : AA*x+BB*y+CC*z+DD=0;
00150          // finding equation for each edge
00151          
00152          // ================================================================
00153          double x,y,z;
00154          unsigned offset=0;
00155          int zsign=1;
00156          //================================================================
00157          std::vector<double> SS;
00158       
00159          // compute the distance of the point with respect of the 4 crystal lateral planes
00160          const GlobalPoint& myPosition=getGeometry(mycellID)->getPosition();
00161          
00162          x=myPosition.x();
00163          y=myPosition.y();
00164          z=myPosition.z();
00165          
00166          offset=0;
00167          // This will disappear when Andre has applied his fix
00168          zsign=1;
00169          
00170          if(z>0)
00171          {
00172             if(x>0&&y>0)
00173                offset=1;
00174             else  if(x<0&&y>0)
00175                offset=2;
00176             else if(x>0&&y<0)
00177                offset=0;
00178             else if (x<0&&y<0)
00179                offset=3;
00180             zsign=1;
00181          }
00182          else
00183          {
00184             if(x>0&&y>0)
00185                offset=3;
00186             else if(x<0&&y>0)
00187                offset=2;
00188             else if(x>0&&y<0)
00189                offset=0;
00190             else if(x<0&&y<0)
00191                offset=1;
00192             zsign=-1;
00193          }
00194          std::vector<GlobalPoint> corners;
00195          corners.clear();
00196          corners.resize(8);
00197          for(unsigned ic=0;ic<4;++ic)
00198          {
00199             corners[ic]=getGeometry(mycellID)->getCorners()[(unsigned)((zsign*ic+offset)%4)];
00200             corners[4+ic]=getGeometry(mycellID)->getCorners()[(unsigned)(4+(zsign*ic+offset)%4)];
00201          }
00202          
00203          for (short i=0; i < 4 ; ++i)
00204          {
00205             A = HepPoint3D(corners[i%4].x(),corners[i%4].y(),corners[i%4].z());
00206             B = HepPoint3D(corners[(i+1)%4].x(),corners[(i+1)%4].y(),corners[(i+1)%4].z());
00207             C = HepPoint3D(corners[4+(i+1)%4].x(),corners[4+(i+1)%4].y(),corners[4+(i+1)%4].z());
00208             HepPlane3D plane(A,B,C);
00209             plane.normalize();
00210             double distance = plane.distance(point);
00211             if (corners[0].z()<0.) distance=-distance;
00212             SS.push_back(distance);
00213          }
00214          
00215          // Only one move in necessary direction
00216          
00217          const bool yout ( 0 > SS[0]*SS[2] ) ;
00218          const bool xout ( 0 > SS[1]*SS[3] ) ;
00219          
00220          if( yout || xout )
00221          {
00222             const int ydel ( !yout ? 0 :  ( 0 < SS[0] ? -1 : 1 ) ) ;
00223             const int xdel ( !xout ? 0 :  ( 0 < SS[1] ? -1 : 1 ) ) ;
00224             const unsigned int ix ( mycellID.ix() + xdel ) ;
00225             const unsigned int iy ( mycellID.iy() + ydel ) ;
00226             const unsigned int iz ( mycellID.zside()     ) ;
00227             if( EEDetId::validDetId( ix, iy, iz ) ) 
00228                mycellID = EEDetId( ix, iy, iz ) ;
00229          }
00230   
00231          return mycellID;
00232       }
00233       return DetId(0);
00234    }
00235    catch ( cms::Exception &e ) 
00236    { 
00237       return DetId(0);
00238    }
00239 }

int EcalEndcapGeometry::getNumberOfCrystalPerModule (  )  const [inline]

Definition at line 39 of file EcalEndcapGeometry.h.

References _nncrys.

00039 { return _nncrys ; }

int EcalEndcapGeometry::getNumberOfModules (  )  const [inline]

Definition at line 37 of file EcalEndcapGeometry.h.

References _nnmods.

00037 { return _nnmods ; }

EEDetId EcalEndcapGeometry::gId ( float  x,
float  y,
float  z 
) const [private]

Definition at line 97 of file EcalEndcapGeometry.cc.

References i, index(), k, EEDetId::validDetId(), and zeP.

Referenced by getClosestCell().

00100 {
00101    const double       fac ( fabs(zeP/z) ) ;
00102    const unsigned int ix  ( index( x*fac ) ) ; 
00103    const unsigned int iy  ( index( y*fac ) ) ; 
00104    const unsigned int iz  ( z>0 ? 1 : -1 ) ;
00105 
00106    if( EEDetId::validDetId( ix, iy, iz ) ) 
00107    {
00108       return EEDetId( ix, iy, iz ) ; // first try is on target
00109    }
00110    else // try nearby coordinates, spiraling out from center
00111    {
00112       for( unsigned int i ( 1 ) ; i != 6 ; ++i )
00113       {
00114          for( unsigned int k ( 0 ) ; k != 8 ; ++k )
00115          {
00116             const int jx ( 0 == k || 4 == k || 5 == k ? +i :
00117                            ( 1 == k || 5 < k ? -i : 0 ) ) ;
00118             const int jy ( 2 == k || 4 == k || 6 == k ? +i :
00119                            ( 3 == k || 5 == k || 7 == k ? -i : 0 ) ) ;
00120             if( EEDetId::validDetId( ix + jx, iy + jy, iz ) ) 
00121             {
00122                return EEDetId( ix + jx, iy + jy, iz ) ;
00123             }
00124          }
00125       }
00126    }
00127    return EEDetId() ; // nowhere near any crystal
00128 }

static std::string EcalEndcapGeometry::hitString (  )  [inline, static]

Definition at line 55 of file EcalEndcapGeometry.h.

00055 { return "EcalHitsEE" ; }

unsigned int EcalEndcapGeometry::index ( float  x  )  const [private]

Definition at line 82 of file EcalEndcapGeometry.cc.

References i, m_href, m_nref, and m_wref.

Referenced by gId().

00083 {
00084    int i ( 1 + (int)floor( ( x + m_href )/m_wref ) ) ;
00085    if( 1      > i )
00086    {
00087       i = 1 ;
00088    }
00089    else
00090    {
00091       if( m_nref < (unsigned int)i ) i = m_nref ;
00092    }
00093    return i ;
00094 }

void EcalEndcapGeometry::initialize (  ) 

Definition at line 23 of file EcalEndcapGeometry.cc.

References funct::abs(), begin, CaloSubdetectorGeometry::cellGeometries(), i, EEDetId::ix(), EEDetId::iy(), m_href, m_nref, m_wref, p, x, z, zeN, and zeP.

00024 {
00025   zeP=0.;
00026   zeN=0.;
00027   unsigned nP=0;
00028   unsigned nN=0;
00029   m_nref = 0 ;
00030   for( CaloSubdetectorGeometry::CellCont::const_iterator i ( cellGeometries().begin() ) ; 
00031        i != cellGeometries().end(); ++i )
00032   {
00033 //      addCrystalToZGridmap(i->first,dynamic_cast<const TruncatedPyramid*>(i->second));
00034      float z=dynamic_cast<const TruncatedPyramid*>(i->second)->getPosition(0.).z();
00035      if(z>0.)
00036      {
00037         zeP+=z;
00038         ++nP;
00039      }
00040      else
00041      {
00042         zeN+=z;
00043         ++nN;
00044      }
00045      const EEDetId myId ( i->first ) ;
00046      const unsigned int ix ( myId.ix() ) ;
00047      const unsigned int iy ( myId.iy() ) ;
00048      if( abs( ix ) > m_nref ) m_nref = abs( ix ) ;
00049      if( abs( iy ) > m_nref ) m_nref = abs( iy ) ;
00050   }
00051   zeP/=(float)nP;
00052   zeN/=(float)nN;
00053 
00054   m_href = 0 ;
00055   for( CaloSubdetectorGeometry::CellCont::const_iterator i ( cellGeometries().begin() ) ; 
00056        i != cellGeometries().end(); ++i )
00057   {
00058      const EEDetId myId ( i->first ) ;
00059      const unsigned int ix ( myId.ix() ) ;
00060      const unsigned int iy ( myId.iy() ) ;
00061      if( ix == m_nref ) 
00062      {
00063         const GlobalPoint p ( dynamic_cast<const TruncatedPyramid*>
00064                               (i->second)->getPosition(0.)  ) ;
00065         const float x ( p.x()*fabs(zeP/p.z()) ) ;
00066         if( m_href < x ) m_href = x ;
00067      }
00068      if( iy == m_nref ) 
00069      {
00070         const GlobalPoint p ( dynamic_cast<const TruncatedPyramid*>
00071                               (i->second)->getPosition(0.)  ) ;
00072         const float x ( p.y()*fabs(zeP/p.z()) ) ;
00073         if( m_href < x ) m_href = x ;
00074      }
00075   }
00076   m_href = m_href*(1.*m_nref)/( 1.*m_nref - 1. ) ;
00077   m_wref = m_href/(0.5*m_nref) ;
00078 }

static int EcalEndcapGeometry::myPhi ( int  i  )  [inline, static, private]

Definition at line 63 of file EcalEndcapGeometry.h.

Referenced by getClosestBarrelCells().

00063 { i+=720; return ( 1 + (i-1)%360 ) ; }

static unsigned int EcalEndcapGeometry::numberOfAlignments (  )  [inline, static]

Definition at line 59 of file EcalEndcapGeometry.h.

Referenced by FakeCaloAlignmentEP::produceEEAli().

00059 { return 4 ; }

static std::string EcalEndcapGeometry::producerName (  )  [inline, static]

Definition at line 57 of file EcalEndcapGeometry.h.

00057 { return "EcalEndcap" ; }

void EcalEndcapGeometry::setNumberOfCrystalPerModule ( const int  nncrys  )  [inline]

Definition at line 43 of file EcalEndcapGeometry.h.

References _nncrys.

00043 { _nncrys=nncrys ; }

void EcalEndcapGeometry::setNumberOfModules ( const int  nnmods  )  [inline]

Definition at line 41 of file EcalEndcapGeometry.h.

References _nnmods.

00041 { _nnmods=nnmods ; }


Member Data Documentation

int EcalEndcapGeometry::_nncrys [private]

number of crystals per module

Definition at line 69 of file EcalEndcapGeometry.h.

Referenced by getNumberOfCrystalPerModule(), and setNumberOfCrystalPerModule().

int EcalEndcapGeometry::_nnmods [private]

number of modules

Definition at line 66 of file EcalEndcapGeometry.h.

Referenced by getNumberOfModules(), and setNumberOfModules().

EZMgrFL<EBDetId>* EcalEndcapGeometry::m_borderMgr [mutable, private]

Definition at line 80 of file EcalEndcapGeometry.h.

Referenced by getClosestBarrelCells(), and ~EcalEndcapGeometry().

VecOrdListEBDetIdPtr* EcalEndcapGeometry::m_borderPtrVec [mutable, private]

Definition at line 82 of file EcalEndcapGeometry.h.

Referenced by getClosestBarrelCells(), and ~EcalEndcapGeometry().

float EcalEndcapGeometry::m_href [private]

Definition at line 73 of file EcalEndcapGeometry.h.

Referenced by getCells(), index(), and initialize().

unsigned int EcalEndcapGeometry::m_nref [private]

Definition at line 75 of file EcalEndcapGeometry.h.

Referenced by getCells(), index(), and initialize().

float EcalEndcapGeometry::m_wref [private]

Definition at line 73 of file EcalEndcapGeometry.h.

Referenced by getCells(), index(), and initialize().

float EcalEndcapGeometry::zeN [private]

Definition at line 71 of file EcalEndcapGeometry.h.

Referenced by initialize().

float EcalEndcapGeometry::zeP [private]

Definition at line 71 of file EcalEndcapGeometry.h.

Referenced by getCells(), gId(), and initialize().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:19:30 2009 for CMSSW by  doxygen 1.5.4