6 #include <CLHEP/Geometry/Point3D.h>
7 #include <CLHEP/Geometry/Plane3D.h>
12 typedef HepGeom::Plane3D<CCGFloat>
Pl3D ;
14 EcalEndcapGeometry::EcalEndcapGeometry(
void )
25 m_cellVec( k_NumberOfCellsForCorners )
41 EcalEndcapGeometry::~EcalEndcapGeometry()
43 delete m_borderPtrVec ;
48 EcalEndcapGeometry::alignmentTransformIndexLocal(
const DetId&
id )
52 assert( gid.isEE() ) ;
59 EcalEndcapGeometry::detIdFromLocalAlignmentIndex(
unsigned int iLoc )
61 return EEDetId( 20 + 50*( iLoc%2 ), 50, 2*( iLoc/2 ) - 1 ) ;
65 EcalEndcapGeometry::alignmentTransformIndexGlobal(
const DetId& )
71 EcalEndcapGeometry::initializeParms()
79 for( uint32_t
i ( 0 ) ;
i != m_cellVec.size() ; ++
i )
84 const CCGFloat z ( cell->getPosition().z() ) ;
96 const unsigned int ix ( myId.ix() ) ;
97 const unsigned int iy ( myId.iy() ) ;
98 if( ix > m_nref ) m_nref = ix ;
99 if( iy > m_nref ) m_nref = iy ;
113 for( uint32_t
i ( 0 ) ;
i != m_cellVec.size() ; ++
i )
120 const CCGFloat zz ( 0 >
z ? zeN : zeP ) ;
124 if( 0 >
z &&
x < m_xlo[0] ) m_xlo[0] =
x ;
125 if( 0 <
z &&
x < m_xlo[1] ) m_xlo[1] =
x ;
126 if( 0 >
z &&
y < m_ylo[0] ) m_ylo[0] =
y ;
127 if( 0 <
z &&
y < m_ylo[1] ) m_ylo[1] =
y ;
129 if( 0 >
z &&
x > m_xhi[0] ) m_xhi[0] =
x ;
130 if( 0 <
z &&
x > m_xhi[1] ) m_xhi[1] =
x ;
131 if( 0 >
z &&
y > m_yhi[0] ) m_yhi[0] =
y ;
132 if( 0 <
z &&
y > m_yhi[1] ) m_yhi[1] =
y ;
136 m_xoff[0] = ( m_xhi[0] + m_xlo[0] )/2. ;
137 m_xoff[1] = ( m_xhi[1] + m_xlo[1] )/2. ;
138 m_yoff[0] = ( m_yhi[0] + m_ylo[0] )/2. ;
139 m_yoff[1] = ( m_yhi[1] + m_ylo[1] )/2. ;
141 m_del = ( m_xhi[0] - m_xlo[0] + m_xhi[1] - m_xlo[1] +
142 m_yhi[0] - m_ylo[0] + m_yhi[1] - m_ylo[1] ) ;
144 if( 1 != m_nref ) m_wref = m_del/(4.*(m_nref-1)) ;
146 m_xlo[0] -= m_wref/2 ;
147 m_xlo[1] -= m_wref/2 ;
148 m_xhi[0] += m_wref/2 ;
149 m_xhi[1] += m_wref/2 ;
151 m_ylo[0] -= m_wref/2 ;
152 m_ylo[1] -= m_wref/2 ;
153 m_yhi[0] += m_wref/2 ;
154 m_yhi[1] += m_wref/2 ;
174 const CCGFloat xlo ( 0 > z ? m_xlo[0] : m_xlo[1] ) ;
175 const int i ( 1 +
int( ( x - xlo )/m_wref ) ) ;
178 ( m_nref < (
unsigned int)
i ? m_nref : (
unsigned int)
i ) ) ;
186 const CCGFloat ylo ( 0 > z ? m_ylo[0] : m_ylo[1] ) ;
187 const int i ( 1 +
int( ( y - ylo )/m_wref ) ) ;
190 ( m_nref < (
unsigned int)
i ? m_nref : (
unsigned int)
i ) ) ;
194 EcalEndcapGeometry::gId(
float x,
198 const CCGFloat fac ( fabs( ( 0 > z ? zeN : zeP )/z ) ) ;
199 const unsigned int ix ( xindex( x*fac, z ) ) ;
200 const unsigned int iy ( yindex( y*fac, z ) ) ;
201 const unsigned int iz ( z>0 ? 1 : -1 ) ;
209 for(
unsigned int i ( 1 ) ;
i != 6 ; ++
i )
211 for(
unsigned int k ( 0 ) ;
k != 8 ; ++
k )
213 const int jx ( 0 ==
k || 4 ==
k || 5 ==
k ? +
i :
214 ( 1 ==
k || 5 <
k ? -
i : 0 ) ) ;
215 const int jy ( 2 ==
k || 4 ==
k || 6 ==
k ? +
i :
216 ( 3 ==
k || 5 ==
k || 7 ==
k ? -
i : 0 ) ) ;
219 return EEDetId( ix + jx, iy + jy, iz ) ;
230 EcalEndcapGeometry::getClosestCell(
const GlobalPoint&
r )
const
234 EEDetId mycellID ( gId( r.
x(), r.
y(), r.
z() ) ) ;
258 if( 0 != getGeometry(mycellID) )
260 const GlobalPoint& myPosition=getGeometry(mycellID)->getPosition();
295 for(
unsigned ic=0;ic<4;++ic)
297 corners[ic]=getGeometry(mycellID)->getCorners()[(unsigned)((zsign*ic+offset)%4)];
298 corners[4+ic]=getGeometry(mycellID)->getCorners()[(unsigned)(4+(zsign*ic+offset)%4)];
302 for (
short i=0;
i < 4 ; ++
i)
304 A =
Pt3D(corners[
i%4].
x(),corners[
i%4].
y(),corners[
i%4].
z());
305 B =
Pt3D(corners[(
i+1)%4].
x(),corners[(
i+1)%4].
y(),corners[(
i+1)%4].
z());
306 C =
Pt3D(corners[4+(
i+1)%4].
x(),corners[4+(
i+1)%4].
y(),corners[4+(
i+1)%4].
z());
310 if (corners[0].
z()<0.) distance=-distance;
316 const bool yout ( 0 > SS[0]*SS[2] ) ;
317 const bool xout ( 0 > SS[1]*SS[3] ) ;
321 const int ydel ( !yout ? 0 : ( 0 < SS[0] ? -1 : 1 ) ) ;
322 const int xdel ( !xout ? 0 : ( 0 < SS[1] ? -1 : 1 ) ) ;
323 const unsigned int ix ( mycellID.ix() + xdel ) ;
324 const unsigned int iy ( mycellID.iy() + ydel ) ;
325 const unsigned int iz ( mycellID.zside() ) ;
327 mycellID =
EEDetId( ix, iy, iz ) ;
343 EcalEndcapGeometry::getCells(
const GlobalPoint& r,
355 const float dR2 ( dR*dR ) ;
356 const float reta ( r.
eta() ) ;
357 const float rphi ( r.
phi() ) ;
358 const float rx ( r.
x() ) ;
359 const float ry ( r.
y() ) ;
360 const float rz ( r.
z() ) ;
361 const float fac (
std::abs( zeP/rz ) ) ;
362 const float xx (
rx*fac ) ;
363 const float yy (
ry*fac ) ;
364 const float zz ( rz*fac ) ;
366 const float xang ( std::atan( xx/zz ) ) ;
367 const float lowX ( zz>0 ? zz*
std::tan( xang - dR ) : zz*
std::tan( xang + dR ) ) ;
368 const float highX ( zz>0 ? zz*
std::tan( xang + dR ) : zz*
std::tan( xang - dR ) ) ;
369 const float yang ( std::atan( yy/zz ) ) ;
370 const float lowY ( zz>0 ? zz*
std::tan( yang - dR ) : zz*
std::tan( yang + dR ) ) ;
371 const float highY ( zz>0 ? zz*
std::tan( yang + dR ) : zz*
std::tan( yang - dR ) ) ;
373 const float refxlo ( 0 > rz ? m_xlo[0] : m_xlo[1] ) ;
374 const float refxhi ( 0 > rz ? m_xhi[0] : m_xhi[1] ) ;
375 const float refylo ( 0 > rz ? m_ylo[0] : m_ylo[1] ) ;
376 const float refyhi ( 0 > rz ? m_yhi[0] : m_yhi[1] ) ;
383 const int ix_ctr ( xindex( xx, rz ) ) ;
384 const int iy_ctr ( yindex( yy, rz ) ) ;
385 const int iz ( rz>0 ? 1 : -1 ) ;
387 const int ix_hi ( ix_ctr +
int( ( highX - xx )/m_wref ) + 2 ) ;
388 const int ix_lo ( ix_ctr -
int( ( xx - lowX )/m_wref ) - 2 ) ;
390 const int iy_hi ( iy_ctr +
int( ( highY - yy )/m_wref ) + 2 ) ;
391 const int iy_lo ( iy_ctr -
int( ( yy - lowY )/m_wref ) - 2 ) ;
393 for(
int kx ( ix_lo ) ; kx <= ix_hi ; ++kx )
398 for(
int ky ( iy_lo ) ; ky <= iy_hi ; ++ky )
405 const EEDetId id ( kx, ky, iz ) ;
421 const EcalEndcapGeometry::OrderedListOfEBDetId*
422 EcalEndcapGeometry::getClosestBarrelCells(
EEDetId id )
const
424 OrderedListOfEBDetId* ptr ( 0 ) ;
425 if( 0 !=
id.rawId() &&
426 0 != getGeometry(
id ) )
428 const float phi ( 370. +
429 getGeometry(
id )->getPosition().
phi().
degrees() );
430 const int iPhi ( 1 +
int(
phi)%360 ) ;
431 const int iz (
id.zside() ) ;
432 if( 0 == m_borderMgr )
436 if( 0 == m_borderPtrVec )
438 m_borderPtrVec =
new VecOrdListEBDetIdPtr() ;
439 m_borderPtrVec->reserve( 720 ) ;
440 for(
unsigned int i ( 0 ) ;
i != 720 ; ++
i )
442 const int kz ( 360>
i ? -1 : 1 ) ;
443 const int iEta ( kz*85 ) ;
444 const int iEtam1 ( kz*84 ) ;
445 const int iEtam2 ( kz*83 ) ;
446 const int jPhi (
i%360 + 1 ) ;
447 OrderedListOfEBDetId&
olist ( *
new OrderedListOfEBDetId( m_borderMgr ) );
457 m_borderPtrVec->push_back( &
olist ) ;
460 ptr = (*m_borderPtrVec)[ ( iPhi - 1 ) + ( 0>iz ? 0 : 360 ) ] ;
466 EcalEndcapGeometry::localCorners(
Pt3DVec& lc ,
471 TruncatedPyramid::localCorners( lc, pv, ref ) ;
481 const unsigned int cellIndex (
EEDetId( detId ).denseIndex() ) ;
482 m_cellVec[ cellIndex ] =
484 m_validIds.push_back( detId ) ;
489 EcalEndcapGeometry::avgAbsZFrontFaceCenter()
const
494 for(
unsigned int i ( 0 ) ;
i != m_cellVec.size() ; ++
i )
499 sum += fabs( cell->getPosition().z() ) ;
502 m_avgZ = sum/m_cellVec.size() ;
508 EcalEndcapGeometry::cellGeomPtr( uint32_t
index )
const
511 return ( m_cellVec.size() < index ||
512 0 == cell->param() ? 0 : cell ) ;
static EEDetId detIdFromDenseIndex(uint32_t din)
double degrees(double radiants)
def degrees
std::set< DetId > DetIdSet
Geom::Phi< T > phi() const
std::vector< Pt3D > Pt3DVec
HepGeom::Plane3D< CCGFloat > Pl3D
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
Tan< T >::type tan(const T &t)
CaloCellGeometry::CCGFloat CCGFloat
unsigned int offset(bool)
CaloCellGeometry::Pt3D Pt3D
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
CaloCellGeometry::Pt3DVec Pt3DVec
HepGeom::Point3D< CCGFloat > Pt3D
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point