8 #include <CLHEP/Geometry/Point3D.h>
9 #include <CLHEP/Geometry/Plane3D.h>
10 #include <CLHEP/Geometry/Vector3D.h>
18 typedef HepGeom::Plane3D<CCGFloat>
Pl3D ;
20 EcalBarrelGeometry::EcalBarrelGeometry() :
25 m_borderPtrVec ( 0 ) ,
27 m_cellVec ( k_NumberOfCellsForCorners )
29 const int neba[] = {25,45,65,85} ;
30 _EtaBaskets = std::vector<int>( neba, neba+4 ) ;
34 EcalBarrelGeometry::~EcalBarrelGeometry()
36 delete m_borderPtrVec ;
42 EcalBarrelGeometry::alignmentTransformIndexLocal(
const DetId&
id )
46 assert( gid.isEB() ) ;
54 EcalBarrelGeometry::detIdFromLocalAlignmentIndex(
unsigned int iLoc )
60 EcalBarrelGeometry::alignmentTransformIndexGlobal(
const DetId& )
66 EcalBarrelGeometry::getClosestCell(
const GlobalPoint&
r)
const
83 int guessed_eta = (int)( fabs(pointeta) / 0.0174)+1;
84 int guessed_eta_begin = guessed_eta-1;
85 int guessed_eta_end = guessed_eta+1;
86 if (guessed_eta_begin < 1) guessed_eta_begin = 1;
87 if (guessed_eta_end > 85) guessed_eta_end = 85;
89 for(
int bin=guessed_eta_begin;
bin<= guessed_eta_end;
bin++)
98 if(fabs(pointeta-eta)<deta)
100 deta=fabs(pointeta-eta);
125 int phibin =
static_cast<int>(pointphi / (twopi/_nnxtalPhi)) + 1;
136 if (!present(myCell))
156 while (leverx==1 || levery == 1)
161 ( getGeometry(myCell)->getCorners() ) ;
165 for (
short i=0;
i < 4 ; ++
i)
167 A =
Pt3D(corners[
i%4].
x(),corners[
i%4].
y(),corners[
i%4].
z());
168 B =
Pt3D(corners[(
i+1)%4].
x(),corners[(
i+1)%4].
y(),corners[(
i+1)%4].
z());
169 C =
Pt3D(corners[4+(
i+1)%4].
x(),corners[4+(
i+1)%4].
y(),corners[4+(
i+1)%4].
z());
173 if(plane.d()>0.) distance=-distance;
174 if (corners[0].
z()<0.) distance=-distance;
182 if ( ( SS[0]>0.&&SS[2]>0. )||( SS[0]<0.&&SS[2]<0. ) )
185 if ( history[0]>0. && history[2]>0. && SS[0]<0 && SS[2]<0 &&
186 (fabs(SS[0])+fabs(SS[2]))> (fabs(history[0])+fabs(history[2]))) levery = 0 ;
187 if ( history[0]<0. && history[2]<0. && SS[0]>0 && SS[2]>0 &&
188 (fabs(SS[0])+fabs(SS[2]))> (fabs(history[0])+fabs(history[2]))) levery = 0 ;
197 nextPoint=
EBDetId(myCell.ieta(),myCell.iphi()-1);
198 if (present(nextPoint))
209 nextPoint=
EBDetId(myCell.ieta(),myCell.iphi()+1);
210 if (present(nextPoint))
218 if ( ( ( SS[1]>0.&&SS[3]>0. )||( SS[1]<0.&&SS[3]<0. )) && start==1 )
222 if ( history[1]>0. && history[3]>0. && SS[1]<0 && SS[3]<0 &&
223 (fabs(SS[1])+fabs(SS[3]))> (fabs(history[1])+fabs(history[3])) )
229 if ( history[1]<0. && history[3]<0. && SS[1]>0 && SS[3]>0 &&
230 (fabs(SS[1])+fabs(SS[3]))> (fabs(history[1])+fabs(history[3])) )
240 if (myCell.ieta()==-1)
241 nextPoint=
EBDetId (1,myCell.iphi());
244 int nieta= myCell.
ieta()+1;
245 if(nieta==86) nieta=85;
246 nextPoint=
EBDetId(nieta,myCell.iphi());
248 if (present(nextPoint))
256 if (myCell.ieta()==1)
257 nextPoint=
EBDetId(-1,myCell.iphi());
260 int nieta=myCell.
ieta()-1;
261 if(nieta==-86) nieta=-85;
262 nextPoint=
EBDetId(nieta,myCell.iphi());
264 if (present(nextPoint))
283 return DetId(myCell);
293 EcalBarrelGeometry::getCells(
const GlobalPoint& r,
310 const float dR2 ( dR*dR ) ;
311 const float reta ( r.
eta() ) ;
312 const float rz ( r.
z() ) ;
313 const float rphi ( r.
phi() ) ;
314 const float lowEta ( reta - dR ) ;
315 const float highEta ( reta + dR ) ;
317 if( highEta > -1.5 &&
320 const int ieta_center (
int( reta*
scale + ((rz<0)?(-1):(1))) ) ;
321 const float phi ( rphi<0 ? rphi +
float(2*M_PI) : rphi ) ;
322 const int iphi_center (
int(
phi*
scale + 11.
f ) ) ;
324 const float fr ( dR*
scale ) ;
325 const float frp ( 1.08
f*fr + 1.
f ) ;
326 const float frm ( 0.92
f*fr - 1.
f ) ;
327 const int idr ( (
int)frp ) ;
328 const int idr2p ( (
int)(frp*frp) ) ;
329 const int idr2m ( frm > 0 ?
int(frm*frm) : 0 ) ;
331 for(
int de ( -idr ) ; de <= idr ; ++de )
333 int ieta ( de + ieta_center ) ;
338 const int de2 ( de*de ) ;
339 for(
int dp ( -idr ) ;
dp <= idr ; ++
dp )
341 const int irange2 (
dp*
dp + de2 ) ;
343 if( irange2 <= idr2p )
345 const int iphi ( ( iphi_center +
dp + maxphi - 1 )%maxphi + 1 ) ;
349 const EBDetId id ( ieta, iphi ) ;
351 bool ok ( irange2 < idr2m ) ;
360 if(
ok ) dis.insert(
id ) ;
372 const EcalBarrelGeometry::OrderedListOfEEDetId*
373 EcalBarrelGeometry::getClosestEndcapCells(
EBDetId id )
const
375 OrderedListOfEEDetId* ptr ( 0 ) ;
376 if( 0 !=
id.rawId() )
378 const int iPhi (
id.iphi() ) ;
380 const int iz (
id.ieta()>0 ? 1 : -1 ) ;
386 const int iq ( eeid.iquadrant() ) ;
387 const int xout ( 1==iq || 4==iq ? 1 : -1 ) ;
388 const int yout ( 1==iq || 2==iq ? 1 : -1 ) ;
389 if( 0 == m_borderMgr )
393 if( 0 == m_borderPtrVec )
395 m_borderPtrVec =
new VecOrdListEEDetIdPtr() ;
396 m_borderPtrVec->reserve( 720 ) ;
397 for(
unsigned int i ( 0 ) ;
i != 720 ; ++
i )
399 const int kz ( 360>
i ? -1 : 1 ) ;
402 const int jx ( eeid.ix() ) ;
403 const int jy ( eeid.iy() ) ;
405 OrderedListOfEEDetId&
olist ( *
new OrderedListOfEEDetId( m_borderMgr ) );
408 for(
unsigned int k ( 1 ) ;
k <= 25 ; ++
k )
410 const int kx ( 1==
k || 2==
k || 3==
k || 12==
k || 13==
k ? 0 :
411 ( 4==
k || 6==
k || 8==
k || 15==
k || 20==
k ? 1 :
412 ( 5==
k || 7==
k || 9==
k || 16==
k || 19==
k ? -1 :
413 ( 10==
k || 14==
k || 21==
k || 22==
k || 25==
k ? 2 : -2 )))) ;
414 const int ky ( 1==
k || 4==
k || 5==
k || 10==
k || 11==
k ? 0 :
415 ( 2==
k || 6==
k || 7==
k || 14==
k || 17==
k ? 1 :
416 ( 3==
k || 8==
k || 9==
k || 18==
k || 21==
k ? -1 :
417 ( 12==
k || 15==
k || 16==
k || 22==
k || 23==
k ? 2 : -2 )))) ;
420 jy + ky*yout , kz ) )
423 jy + ky*yout , kz ) ;
426 m_borderPtrVec->push_back( &
olist ) ;
429 ptr = (*m_borderPtrVec)[ iPhi - 1 + ( 0>iz ? 0 : 360 ) ] ;
435 EcalBarrelGeometry::localCorners(
Pt3DVec& lc ,
441 const bool odd ( 1 == i%2 ) ;
443 if( ( ( negz && !odd ) ||
446 TruncatedPyramid::localCornersReflection( lc, pv, ref ) ;
450 TruncatedPyramid::localCornersSwap( lc, pv, ref ) ;
461 const unsigned int cellIndex (
EBDetId( detId ).denseIndex() ) ;
462 m_cellVec[ cellIndex ] =
464 m_validIds.push_back( detId ) ;
468 EcalBarrelGeometry::avgRadiusXYFrontFaceCenter()
const
473 for( uint32_t i ( 0 ) ; i != m_cellVec.size() ; ++
i )
482 m_radius = sum/m_cellVec.size() ;
488 EcalBarrelGeometry::cellGeomPtr( uint32_t
index )
const
491 return ( m_cellVec.size() < index ||
492 0 == cell->param() ? 0 : cell ) ;
std::set< DetId > DetIdSet
static const int MIN_IPHI
tuple start
Check for commandline option errors.
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.
CaloCellGeometry::CCGFloat CCGFloat
int ieta() const
get the crystal ieta
static const int ETAPHIMODE
CaloCellGeometry::Pt3D Pt3D
static const int MAX_IPHI
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
static const int MAX_IETA
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...
static EEDetId idOuterRing(int iPhi, int zEnd)
static const int SMCRYSTALMODE
int ism(int ieta, int iphi)
*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