CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IdealObliquePrism.cc
Go to the documentation of this file.
2 #include <math.h>
3 
4 namespace calogeom {
5 
6  /*
7  static GlobalPoint etaPhiR( float eta, float phi, float rad )
8  {
9  return GlobalPoint( rad*cosf(phi)/coshf(eta) ,
10  rad*sinf(phi)/coshf(eta) ,
11  rad*tanhf(eta) ) ;
12  }
13  */
14 
15  static GlobalPoint etaPhiPerp( float eta, float phi, float perp )
16  {
17  return GlobalPoint( perp*cosf(phi) ,
18  perp*sinf(phi) ,
19  perp*sinhf(eta) ) ;
20  }
21 
22  static GlobalPoint etaPhiZ(float eta, float phi, float z)
23  {
24  return GlobalPoint( z*cosf(phi)/sinhf(eta) ,
25  z*sinf(phi)/sinhf(eta) ,
26  z ) ;
27  }
28 
29 
30  std::vector<HepGeom::Point3D<double> >
31  IdealObliquePrism::localCorners( const double* pv ,
32  HepGeom::Point3D<double> & ref )
33  {
34  assert( 0 != pv ) ;
35 
36  const double dEta ( pv[0] ) ;
37  const double dPhi ( pv[1] ) ;
38  const double dz ( pv[2] ) ;
39  const double eta ( pv[3] ) ;
40  const double z ( pv[4] ) ;
41 
42  std::vector<GlobalPoint> gc ( 8, GlobalPoint(0,0,0) ) ;
43  std::vector<HepGeom::Point3D<double> > lc ( 8, HepGeom::Point3D<double> ( 0,0,0) ) ;
44 
45  const GlobalPoint p ( etaPhiZ( eta, 0, z ) ) ;
46 
47  if( 0 < dz )
48  {
49  const float r_near ( p.perp()/cos( dPhi ) ) ;
50  const float r_far ( r_near*( ( p.mag() + 2*dz )/p.mag() ) ) ;
51  gc[ 0 ] = etaPhiPerp( eta + dEta , +dPhi , r_near ) ; // (+,+,near)
52  gc[ 1 ] = etaPhiPerp( eta + dEta , -dPhi , r_near ) ; // (+,-,near)
53  gc[ 2 ] = etaPhiPerp( eta - dEta , -dPhi , r_near ) ; // (-,-,near)
54  gc[ 3 ] = etaPhiPerp( eta - dEta , +dPhi , r_near ) ; // (-,+,far)
55  gc[ 4 ] = etaPhiPerp( eta + dEta , +dPhi , r_far ) ; // (+,+,far)
56  gc[ 5 ] = etaPhiPerp( eta + dEta , -dPhi , r_far ) ; // (+,-,far)
57  gc[ 6 ] = etaPhiPerp( eta - dEta , -dPhi , r_far ) ; // (-,-,far)
58  gc[ 7 ] = etaPhiPerp( eta - dEta , +dPhi , r_far ) ; // (-,+,far)
59  }
60  else
61  {
62  const float z_near ( z ) ;
63  const float z_far ( z*( 1 - 2*dz/p.mag() ) ) ;
64  gc[ 0 ] = etaPhiZ( eta + dEta , +dPhi , z_near ) ; // (+,+,near)
65  gc[ 1 ] = etaPhiZ( eta + dEta , -dPhi , z_near ) ; // (+,-,near)
66  gc[ 2 ] = etaPhiZ( eta - dEta , -dPhi , z_near ) ; // (-,-,near)
67  gc[ 3 ] = etaPhiZ( eta - dEta , +dPhi , z_near ) ; // (-,+,far)
68  gc[ 4 ] = etaPhiZ( eta + dEta , +dPhi , z_far ) ; // (+,+,far)
69  gc[ 5 ] = etaPhiZ( eta + dEta , -dPhi , z_far ) ; // (+,-,far)
70  gc[ 6 ] = etaPhiZ( eta - dEta , -dPhi , z_far ) ; // (-,-,far)
71  gc[ 7 ] = etaPhiZ( eta - dEta , +dPhi , z_far ) ; // (-,+,far)
72  }
73  for( unsigned int i ( 0 ) ; i != 8 ; ++i )
74  {
75  lc[i] = HepGeom::Point3D<double> ( gc[i].x(), gc[i].y(), gc[i].z() ) ;
76  }
77 
78  ref = 0.25*( lc[0] + lc[1] + lc[2] + lc[3] ) ;
79  return lc ;
80  }
81 
84  {
86  if( co.uninitialized() )
87  {
88  CornersVec& corners ( setCorners() ) ;
89  if( dz()>0 )
90  {
91  /* In this case, the faces are parallel to the zaxis.
92  This implies that all corners will have the same
93  cylindrical radius.
94  */
95  const GlobalPoint p ( getPosition() ) ;
96  const float r_near ( p.perp()/cos(dPhi()) ) ;
97  const float r_far ( r_near*( ( p.mag() + 2*dz() )/p.mag() ) ) ;
98  const float eta ( p.eta() ) ;
99  const float phi ( p.phi() ) ;
100  corners[ 0 ] = etaPhiPerp( eta + dEta() , phi + dPhi() , r_near ) ; // (+,+,near)
101  corners[ 1 ] = etaPhiPerp( eta + dEta() , phi - dPhi() , r_near ) ; // (+,-,near)
102  corners[ 2 ] = etaPhiPerp( eta - dEta() , phi - dPhi() , r_near ) ; // (-,-,near)
103  corners[ 3 ] = etaPhiPerp( eta - dEta() , phi + dPhi() , r_near ) ; // (-,+,near)
104  corners[ 4 ] = etaPhiPerp( eta + dEta() , phi + dPhi() , r_far ) ; // (+,+,far)
105  corners[ 5 ] = etaPhiPerp( eta + dEta() , phi - dPhi() , r_far ) ; // (+,-,far)
106  corners[ 6 ] = etaPhiPerp( eta - dEta() , phi - dPhi() , r_far ) ; // (-,-,far)
107  corners[ 7 ] = etaPhiPerp( eta - dEta() , phi + dPhi() , r_far ) ; // (-,+,far)
108  }
109  else
110  {
111  /* In this case, the faces are perpendicular to the zaxis.
112  This implies that all corners will have the same
113  z-dimension.
114  */
115  const GlobalPoint p ( getPosition() ) ;
116  const float z_near ( p.z() ) ;
117  const float mag ( p.mag() ) ;
118  const float z_far ( z_near*( 1 - 2*dz()/mag ) ) ; // negative to correct sign
119  const float eta ( p.eta() ) ;
120  const float phi ( p.phi() ) ;
121 
122  corners[ 0 ] = etaPhiZ( eta + dEta(), phi + dPhi(), z_near ) ; // (+,+,near)
123  corners[ 1 ] = etaPhiZ( eta + dEta(), phi - dPhi(), z_near ) ; // (+,-,near)
124  corners[ 2 ] = etaPhiZ( eta - dEta(), phi - dPhi(), z_near ) ; // (-,-,near)
125  corners[ 3 ] = etaPhiZ( eta - dEta(), phi + dPhi(), z_near ) ; // (-,+,near)
126  corners[ 4 ] = etaPhiZ( eta + dEta(), phi + dPhi(), z_far ) ; // (+,+,far)
127  corners[ 5 ] = etaPhiZ( eta + dEta(), phi - dPhi(), z_far ) ; // (+,-,far)
128  corners[ 6 ] = etaPhiZ( eta - dEta(), phi - dPhi(), z_far ) ; // (-,-,far)
129  corners[ 7 ] = etaPhiZ( eta - dEta(), phi + dPhi(), z_far ) ; // (-,+,far)
130 
131  }
132  }
133  return co ;
134  }
135 
136  std::ostream& operator<<( std::ostream& s, const IdealObliquePrism& cell )
137  {
138  s << "Center: " << cell.getPosition() << std::endl ;
139  s << "dEta = " << cell.dEta() << ", dPhi = " << cell.dPhi() << ", dz = " << cell.dz() << std::endl ;
140  return s;
141 }
142 
143 }
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:66
static GlobalPoint etaPhiPerp(float eta, float phi, float perp)
virtual const CornersVec & getCorners() const
T perp() const
Magnitude of transverse component.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static GlobalPoint etaPhiZ(float eta, float phi, float z)
T eta() const
static std::vector< HepGeom::Point3D< double > > localCorners(const double *pv, HepGeom::Point3D< double > &ref)
T mag() const
Definition: PV3DBase.h:61
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: DDAxes.h:10
T z() const
Definition: PV3DBase.h:58
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
CornersVec & setCorners() const
T eta() const
Definition: PV3DBase.h:70
bool uninitialized() const
Definition: EZArrayFL.h:74
std::ostream & operator<<(std::ostream &s, const IdealObliquePrism &cell)
string s
Definition: asciidump.py:422
const GlobalPoint & getPosition() const
virtual const CornersVec & getCorners() const =0
Definition: DDAxes.h:10