8 #include <CLHEP/Geometry/Point3D.h>
9 #include <CLHEP/Geometry/Plane3D.h>
10 #include <CLHEP/Geometry/Vector3D.h>
20 m_borderPtrVec ( 0 ) ,
23 const int neba[] = {25,45,65,85} ;
24 _EtaBaskets = std::vector<int>( &neba[0], &neba[3] ) ;
40 assert( gid.
isEB() ) ;
66 double pointz = r.
z();
72 double pointeta = r.
eta();
77 int guessed_eta = (int)( fabs(pointeta) / 0.0174)+1;
78 int guessed_eta_begin = guessed_eta-1;
79 int guessed_eta_end = guessed_eta+1;
80 if (guessed_eta_begin < 1) guessed_eta_begin = 1;
81 if (guessed_eta_end > 85) guessed_eta_end = 85;
83 for(
int bin=guessed_eta_begin;
bin<= guessed_eta_end;
bin++)
92 if(fabs(pointeta-eta)<deta)
94 deta=fabs(pointeta-eta);
109 const double tilt=twopi/36.;
110 double pointphi = r.
phi()+tilt;
119 int phibin =
static_cast<int>(pointphi / (twopi/
_nnxtalPhi)) + 1;
133 HepGeom::Point3D<double>
A;
134 HepGeom::Point3D<double>
B;
135 HepGeom::Point3D<double>
C;
136 HepGeom::Point3D<double>
point(r.
x(),r.
y(),r.
z());
143 std::vector<double> history;
144 history.resize(4,0.);
150 while (leverx==1 || levery == 1)
156 std::vector<double> SS;
159 for (
short i=0;
i < 4 ; ++
i)
161 A = HepGeom::Point3D<double> (corners[
i%4].x(),corners[
i%4].y(),corners[
i%4].z());
162 B = HepGeom::Point3D<double> (corners[(
i+1)%4].
x(),corners[(
i+1)%4].
y(),corners[(
i+1)%4].
z());
163 C = HepGeom::Point3D<double> (corners[4+(
i+1)%4].
x(),corners[4+(
i+1)%4].
y(),corners[4+(
i+1)%4].
z());
164 HepGeom::Plane3D<double> plane(A,B,C);
166 double distance = plane.distance(
point);
167 if(plane.d()>0.) distance=-distance;
168 if (corners[0].
z()<0.) distance=-distance;
169 SS.push_back(distance);
176 if ( ( SS[0]>0.&&SS[2]>0. )||( SS[0]<0.&&SS[2]<0. ) )
179 if ( history[0]>0. && history[2]>0. && SS[0]<0 && SS[2]<0 &&
180 (fabs(SS[0])+fabs(SS[2]))> (fabs(history[0])+fabs(history[2]))) levery = 0 ;
181 if ( history[0]<0. && history[2]<0. && SS[0]>0 && SS[2]>0 &&
182 (fabs(SS[0])+fabs(SS[2]))> (fabs(history[0])+fabs(history[2]))) levery = 0 ;
212 if ( ( ( SS[1]>0.&&SS[3]>0. )||( SS[1]<0.&&SS[3]<0. )) && start==1 )
216 if ( history[1]>0. && history[3]>0. && SS[1]<0 && SS[3]<0 &&
217 (fabs(SS[1])+fabs(SS[3]))> (fabs(history[1])+fabs(history[3])) )
223 if ( history[1]<0. && history[3]<0. && SS[1]>0 && SS[3]>0 &&
224 (fabs(SS[1])+fabs(SS[3]))> (fabs(history[1])+fabs(history[3])) )
234 if (myCell.
ieta()==-1)
238 int nieta= myCell.
ieta()+1;
239 if(nieta==86) nieta=85;
250 if (myCell.
ieta()==1)
254 int nieta=myCell.
ieta()-1;
255 if(nieta==-86) nieta=-85;
277 return DetId(myCell);
302 const double dR2 ( dR*dR ) ;
303 const double reta ( r.
eta() ) ;
304 const double rz ( r.
z() ) ;
305 const double rphi ( r.
phi() ) ;
306 const double lowEta ( reta - dR ) ;
307 const double highEta ( reta + dR ) ;
309 if( highEta > -1.5 &&
312 const double scale ( maxphi/(2*
M_PI) ) ;
313 const int ieta_center (
int( reta*scale + ((rz<0)?(-1):(1))) ) ;
314 const double phi ( rphi<0 ? rphi + 2*
M_PI : rphi ) ;
315 const int iphi_center (
int( phi*scale + 11. ) ) ;
317 const double fr ( dR*scale ) ;
318 const double frp ( 1.08*fr + 1. ) ;
319 const double frm ( 0.92*fr - 1. ) ;
320 const int idr ( (
int)frp ) ;
321 const int idr2p ( (
int)(frp*frp) ) ;
322 const int idr2m ( frm > 0 ?
int(frm*frm) : 0 ) ;
324 for(
int de ( -idr ) ; de <= idr ; ++de )
326 int ieta ( de + ieta_center ) ;
331 const int de2 ( de*de ) ;
332 for(
int dp ( -idr ) ; dp <= idr ; ++dp )
334 const int irange2 ( dp*dp + de2 ) ;
336 if( irange2 <= idr2p )
338 const int iphi ( ( iphi_center + dp + maxphi - 1 )%maxphi + 1 ) ;
344 bool ok ( irange2 < idr2m ) ;
352 const double eta (
p.eta() ) ;
353 const double phi (
p.phi() ) ;
357 if( ok ) dis.insert(
id ) ;
373 if( 0 !=
id.rawId() )
375 const int iPhi (
id.iphi() ) ;
377 const int iz (
id.ieta()>0 ? 1 : -1 ) ;
384 const int xout ( 1==iq || 4==iq ? 1 : -1 ) ;
385 const int yout ( 1==iq || 2==iq ? 1 : -1 ) ;
394 for(
unsigned int i ( 0 ) ;
i != 720 ; ++
i )
396 const int kz ( 360>
i ? -1 : 1 ) ;
399 const int jx ( eeid.
ix() ) ;
400 const int jy ( eeid.
iy() ) ;
405 for(
unsigned int k ( 1 ) ;
k <= 25 ; ++
k )
407 const int kx ( 1==
k || 2==
k || 3==
k || 12==
k || 13==
k ? 0 :
408 ( 4==
k || 6==
k || 8==
k || 15==
k || 20==
k ? 1 :
409 ( 5==
k || 7==
k || 9==
k || 16==
k || 19==
k ? -1 :
410 ( 10==
k || 14==
k || 21==
k || 22==
k || 25==
k ? 2 : -2 )))) ;
411 const int ky ( 1==
k || 4==
k || 5==
k || 10==
k || 11==
k ? 0 :
412 ( 2==
k || 6==
k || 7==
k || 14==
k || 17==
k ? 1 :
413 ( 3==
k || 8==
k || 9==
k || 18==
k || 21==
k ? -1 :
414 ( 12==
k || 15==
k || 16==
k || 22==
k || 23==
k ? 2 : -2 )))) ;
417 jy + ky*yout , kz ) )
419 olist[il++]=
EEDetId( jx + kx*xout ,
420 jy + ky*yout , kz ) ;
426 ptr = (*m_borderPtrVec)[ iPhi - 1 + ( 0>iz ? 0 : 360 ) ] ;
431 std::vector<HepGeom::Point3D<double> >
434 HepGeom::Point3D<double> & ref )
437 const bool odd ( 1 == i%2 ) ;
439 return ( ( ( negz && !odd ) ||
462 for(
unsigned int i ( 0 ) ;
i != cells.size() ; ++
i )
464 sum += cells[
i]->getPosition().perp() ;
static std::vector< HepGeom::Point3D< double > > localCorners(const double *pv, unsigned int i, HepGeom::Point3D< double > &ref)
static unsigned int alignmentTransformIndexGlobal(const DetId &id)
std::set< DetId > DetIdSet
const OrderedListOfEEDetId * getClosestEndcapCells(EBDetId id) const
static const int MIN_IPHI
virtual CaloSubdetectorGeometry::DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
std::vector< const CaloCellGeometry * > CellCont
static std::vector< HepGeom::Point3D< double > > localCornersSwap(const double *pv, HepGeom::Point3D< double > &ref)
virtual DetId getClosestCell(const GlobalPoint &r) const
static std::vector< HepGeom::Point3D< double > > localCornersReflection(const double *pv, HepGeom::Point3D< double > &ref)
Geom::Phi< T > phi() const
std::vector< int > _EtaBaskets
static CaloCellGeometry * newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, CaloCellGeometry::CornersMgr *mgr, const double *parm, const DetId &detId)
EZArrayFL< EEDetId > OrderedListOfEEDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
int iphi() const
get the crystal iphi
virtual bool present(const DetId &id) const
is this detid present in the geometry?
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
static DetId detIdFromLocalAlignmentIndex(unsigned int iLoc)
VecOrdListEEDetIdPtr * m_borderPtrVec
const CellCont & cellGeometries() const
the cells
int ieta() const
get the crystal ieta
double deltaR2(double eta1, double phi1, double eta2, double phi2)
static const int ETAPHIMODE
static const int MAX_IPHI
EZMgrFL< EEDetId > * m_borderMgr
static const int MAX_IETA
double avgRadiusXYFrontFaceCenter() const
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
std::vector< OrderedListOfEEDetId * > VecOrdListEEDetIdPtr
static EEDetId idOuterRing(int iPhi, int zEnd)
static const int SMCRYSTALMODE
virtual ~EcalBarrelGeometry()
const GlobalPoint & getPosition() const
int ism(int ieta, int iphi)
static unsigned int alignmentTransformIndexLocal(const DetId &id)
*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