CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloCellGeometry.cc
Go to the documentation of this file.
2 #include <CLHEP/Geometry/Plane3D.h>
3 
4 const float CaloCellGeometry::k_ScaleFromDDDtoGeant ( 0.1 ) ;
5 
8 {
9  return m_corners ;
10 }
11 
12 std::ostream& operator<<( std::ostream& s, const CaloCellGeometry& cell )
13 {
14  s << ", Center: " << cell.getPosition() << std::endl;
15 
16  if( cell.emptyCorners() )
17  {
18  s << "Corners vector is empty." << std::endl ;
19  }
20  else
21  {
22  const CaloCellGeometry::CornersVec& corners ( cell.getCorners() ) ;
23  for ( unsigned int i ( 0 ) ; i != corners.size() ; ++i )
24  {
25  s << "Corner: " << corners[ i ] << std::endl;
26  }
27  }
28  return s ;
29 }
30 
31 HepGeom::Transform3D
32 CaloCellGeometry::getTransform( std::vector<HepGeom::Point3D<double> >* lptr ) const
33 {
35  const HepGeom::Point3D<double> gFront ( p.x(), p.y(), p.z() ) ;
36 
37  HepGeom::Point3D<double> lFront ;
38  assert( 0 != param() ) ;
39  std::vector<HepGeom::Point3D<double> > lc ( vocalCorners( param(), lFront ) ) ;
40 
41  HepGeom::Point3D<double> lBack ( 0.25*(lc[4]+lc[5]+lc[6]+lc[7]) ) ;
42 
43  const HepGeom::Point3D<double> lOne ( lc[0] ) ;
44 
45  const CornersVec& cor ( getCorners() ) ;
46  std::vector<HepGeom::Point3D<double> > kor ( 8, HepGeom::Point3D<double> (0,0,0) ) ;
47  for( unsigned int i ( 0 ) ; i != 8 ; ++i )
48  {
49  kor[i] = HepGeom::Point3D<double> ( cor[i].x(), cor[i].y(), cor[i].z() ) ;
50  }
51 
52  HepGeom::Point3D<double> gBack ( 0.25*( kor[4]+kor[5]+kor[6]+kor[7] ) ) ;
53 
54  const HepGeom::Vector3D<double> gAxis ( (gBack-gFront).unit() ) ;
55 
56  gBack = ( gFront + (lBack-lFront).mag()*gAxis ) ;
57  const HepGeom::Point3D<double> gOneT ( gFront + ( lOne - lFront ).mag()*( kor[0] - gFront ).unit() ) ;
58 
59  const double langle ( ( lBack - lFront).angle( lOne - lFront ) ) ;
60  const double gangle ( ( gBack - gFront).angle( gOneT- gFront ) ) ;
61  const double dangle ( langle - gangle ) ;
62 
63  const HepGeom::Plane3D<double> gPl ( gFront, gOneT, gBack ) ;
64  const HepGeom::Point3D<double> p2 ( gFront + gPl.normal().unit() ) ;
65 
66  const HepGeom::Point3D<double> gOne ( gFront + HepGeom::Rotate3D( -dangle, gFront, p2 )*
67  HepGeom::Vector3D<double> ( gOneT - gFront ) ) ;
68 
69  const HepGeom::Transform3D tr ( lFront , lBack , lOne ,
70  gFront , gBack , gOne ) ;
71 
72  if( 0 != lptr ) (*lptr) = lc ;
73 
74  return tr ;
75 }
76 
77 const double*
79  const std::vector<double>& vv ,
81 {
82  const double* pP ( 0 ) ;
83 
84  for( unsigned int ii ( 0 ) ; ii != pvv.size() ; ++ii )
85  {
86  const ParVec& v ( pvv[ii] ) ;
87  assert( v.size() == vv.size() ) ;
88 
89  bool same ( true ) ;
90  for( unsigned int j ( 0 ) ; j != vv.size() ; ++j )
91  {
92  same = same && ( fabs( vv[j] - v[j] )<1.e-6 ) ;
93  if( !same ) break ;
94  }
95  if( same )
96  {
97  pP = &(*v.begin()) ;
98  break ;
99  }
100  }
101  return pP ;
102 }
103 
104 const double*
106  const std::vector<double>& vv ,
109 {
110  const double* pP ( checkParmPtr( vv, pvv ) ) ;
111 
112  if( 0 == pP )
113  {
114  pvv.push_back( ParVec( mgr ) ) ;
115  ParVec& back ( pvv.back() ) ;
116  for( unsigned int i ( 0 ) ; i != vv.size() ; ++i )
117  {
118  back[i] = vv[i] ;
119  }
120  pP = &(*back.begin()) ;
121  }
122  return pP ;
123 }
124 
125 bool
127 {
128  bool ans ( false ) ;
129  const HepGeom::Point3D<double> p ( point.x(), point.y(), point.z() ) ;
130  const CornersVec& cog ( getCorners() ) ;
131  HepGeom::Point3D<double> co[8] ;
132  for( unsigned int i ( 0 ) ; i != 8 ; ++i )
133  {
134  co[i] = HepGeom::Point3D<double> ( cog[i].x(), cog[i].y(), cog[i].z() ) ;
135  }
136 
137  const HepGeom::Plane3D<double> AA ( co[0], co[1], co[2] ) ; // z<0
138  const HepGeom::Plane3D<double> BB ( co[6], co[5], co[4] ) ; // z>0
139 
140  if( AA.distance(p)*BB.distance(p) >= 0 )
141  {
142  const HepGeom::Plane3D<double> CC ( co[0], co[4], co[5] ) ; // x<0
143  const HepGeom::Plane3D<double> DD ( co[2], co[6], co[7] ) ; // x>0
144  if( CC.distance(p)*DD.distance(p) >= 0 )
145  {
146  const HepGeom::Plane3D<double> EE ( co[3], co[7], co[4] ) ; // y<0
147  const HepGeom::Plane3D<double> FF ( co[1], co[5], co[6] ) ; // y>0
148  if( EE.distance(p)*FF.distance(p) >= 0 )
149  {
150  ans = true ;
151  }
152  }
153  }
154  return ans ;
155 }
int i
Definition: DBlmapReader.cc:9
CornersVec m_corners
bool emptyCorners() const
std::vector< ParVec > ParVecVec
EZArrayFL< double > ParVec
virtual std::vector< HepGeom::Point3D< double > > vocalCorners(const double *pv, HepGeom::Point3D< double > &ref) const =0
T y() const
Definition: PV3DBase.h:57
const double * param() const
const_iterator begin() const
Definition: EZArrayFL.h:60
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
virtual HepGeom::Transform3D getTransform(std::vector< HepGeom::Point3D< double > > *lptr) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:58
int j
Definition: DBlmapReader.cc:9
static const float k_ScaleFromDDDtoGeant
double p2[4]
Definition: TauolaWrapper.h:90
bool inside(const GlobalPoint &point) const
size_type size() const
Definition: EZArrayFL.h:78
static const double * getParmPtr(const std::vector< double > &vd, ParMgr *mgr, ParVecVec &pvv)
static const double * checkParmPtr(const std::vector< double > &vd, ParVecVec &pvv)
Definition: EZMgrFL.h:8
string s
Definition: asciidump.py:422
const GlobalPoint & getPosition() const
T x() const
Definition: PV3DBase.h:56
mathSSE::Vec4< T > v
*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
Definition: invegas.h:5
virtual const CornersVec & getCorners() const =0
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11