CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IdealZPrism.cc
Go to the documentation of this file.
2 #include <math.h>
3 
4 namespace calogeom
5 {
6  static GlobalPoint etaPhiR( float eta ,
7  float phi ,
8  float rad )
9  {
10  return GlobalPoint( rad*cosf( phi )/coshf( eta ) ,
11  rad*sinf( phi )/coshf( eta ) ,
12  rad*tanhf( eta ) ) ;
13  }
14 
15  static GlobalPoint etaPhiPerp( float eta ,
16  float phi ,
17  float perp )
18  {
19  return GlobalPoint( perp*cosf( phi ) ,
20  perp*sinf( phi ) ,
21  perp*sinhf( eta ) );
22  }
23 
24  static GlobalPoint etaPhiZ( float eta ,
25  float phi ,
26  float z )
27  {
28  return GlobalPoint( z*cosf( phi )/sinhf( eta ) ,
29  z*sinf( phi )/sinhf( eta ) ,
30  z ) ;
31  }
32 
33  std::vector<HepGeom::Point3D<double> >
34  IdealZPrism::localCorners( const double* pv ,
35  HepGeom::Point3D<double> & ref )
36  {
37  if( false )
38  {
39  GlobalPoint g1 ( etaPhiR(0,0,0) ) ;
40  GlobalPoint g2 ( etaPhiPerp(0,0,0) ) ;
41  }
42  assert( 0 != pv ) ;
43 
44  const double dEta ( pv[0] ) ;
45  const double dPhi ( pv[1] ) ;
46  const double dz ( pv[2] ) ;
47  const double eta ( pv[3] ) ;
48  const double z ( pv[4] ) ;
49 
50  std::vector<GlobalPoint> gc ( 8, GlobalPoint(0,0,0) ) ;
51  std::vector<HepGeom::Point3D<double> > lc ( 8, HepGeom::Point3D<double> ( 0,0,0) ) ;
52 
53  const GlobalPoint p ( etaPhiZ( eta, 0, z ) ) ;
54 
55  const float z_near ( z ) ;
56  const float z_far ( z*( 1 - 2*dz/p.mag() ) ) ;
57  gc[ 0 ] = etaPhiZ( eta + dEta , +dPhi , z_near ) ; // (+,+,near)
58  gc[ 1 ] = etaPhiZ( eta + dEta , -dPhi , z_near ) ; // (+,-,near)
59  gc[ 2 ] = etaPhiZ( eta - dEta , -dPhi , z_near ) ; // (-,-,near)
60  gc[ 3 ] = etaPhiZ( eta - dEta , +dPhi , z_near ) ; // (-,+,far)
61  gc[ 4 ] = GlobalPoint( gc[0].x(), gc[0].y(), z_far ); // (+,+,far)
62  gc[ 5 ] = GlobalPoint( gc[1].x(), gc[1].y(), z_far ); // (+,-,far)
63  gc[ 6 ] = GlobalPoint( gc[2].x(), gc[2].y(), z_far ); // (-,-,far)
64  gc[ 7 ] = GlobalPoint( gc[3].x(), gc[3].y(), z_far ); // (-,+,far)
65 
66  for( unsigned int i ( 0 ) ; i != 8 ; ++i )
67  {
68  lc[i] = HepGeom::Point3D<double> ( gc[i].x(), gc[i].y(), gc[i].z() ) ;
69  }
70 
71  ref = 0.25*( lc[0] + lc[1] + lc[2] + lc[3] ) ;
72  return lc ;
73  }
74 
77  {
79  if( co.uninitialized() )
80  {
81  CornersVec& corners ( setCorners() ) ;
82 
83  const GlobalPoint p ( getPosition() ) ;
84  const float z_near ( p.z() ) ;
85  const float z_far ( z_near + 2*dz()*p.z()/fabs( p.z() ) ) ;
86  const float eta ( p.eta() ) ;
87  const float phi ( p.phi() ) ;
88 
89  corners[ 0 ] = etaPhiZ( eta + dEta(), phi + dPhi(), z_near ); // (+,+,near)
90  corners[ 1 ] = etaPhiZ( eta + dEta(), phi - dPhi(), z_near ); // (+,-,near)
91  corners[ 2 ] = etaPhiZ( eta - dEta(), phi - dPhi(), z_near ); // (-,-,near)
92  corners[ 3 ] = etaPhiZ( eta - dEta(), phi + dPhi(), z_near ); // (-,+,near)
93  corners[ 4 ] = GlobalPoint( corners[0].x(), corners[0].y(), z_far ); // (+,+,far)
94  corners[ 5 ] = GlobalPoint( corners[1].x(), corners[1].y(), z_far ); // (+,-,far)
95  corners[ 6 ] = GlobalPoint( corners[2].x(), corners[2].y(), z_far ); // (-,-,far)
96  corners[ 7 ] = GlobalPoint( corners[3].x(), corners[3].y(), z_far ); // (-,+,far)
97  }
98  return co ;
99  }
100 
101  std::ostream& operator<<( std::ostream& s, const IdealZPrism& cell )
102  {
103  s << "Center: " << cell.getPosition() << std::endl ;
104  s << "dEta = " << cell.dEta() << ", dPhi = " << cell.dPhi() << ", dz = " << cell.dz() << std::endl ;
105  return s;
106  }
107 
108 }
int i
Definition: DBlmapReader.cc:9
double dz() const
Definition: IdealZPrism.h:44
static GlobalPoint etaPhiPerp(float eta, float phi, float perp)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
static std::vector< HepGeom::Point3D< double > > localCorners(const double *pv, HepGeom::Point3D< double > &ref)
Definition: IdealZPrism.cc:34
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static GlobalPoint etaPhiZ(float eta, float phi, float z)
T eta() const
double dEta() const
Definition: IdealZPrism.h:42
double double double z
T mag() const
Definition: PV3DBase.h:61
double eta() const
Definition: IdealZPrism.h:45
T z() const
Definition: PV3DBase.h:58
double dPhi() const
Definition: IdealZPrism.h:43
CornersVec & setCorners() const
static GlobalPoint etaPhiR(float eta, float phi, float rad)
Definition: IdealZPrism.cc:6
T eta() const
Definition: PV3DBase.h:70
double z() const
Definition: IdealZPrism.h:46
T perp() const
Magnitude of transverse component.
virtual const CornersVec & getCorners() const
Definition: IdealZPrism.cc:76
bool uninitialized() const
Definition: EZArrayFL.h:74
std::ostream & operator<<(std::ostream &s, const IdealObliquePrism &cell)
string s
Definition: asciidump.py:422
Definition: DDAxes.h:10
const GlobalPoint & getPosition() const
virtual const CornersVec & getCorners() const =0
Definition: DDAxes.h:10