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 
8 
9 typedef HepGeom::Vector3D<CCGFloat> FVec3D ;
10 typedef HepGeom::Plane3D<CCGFloat> Plane3D ;
11 
12 typedef HepGeom::Vector3D<double> DVec3D ;
13 typedef HepGeom::Plane3D<double> DPlane3D ;
14 typedef HepGeom::Point3D<double> DPt3D ;
15 typedef std::vector<DPt3D> DPt3DVec ;
16 
17 const float CaloCellGeometry::k_ScaleFromDDDtoGeant ( 0.1 ) ;
18 
20  m_refPoint ( 0., 0., 0. ),
21  m_corners ( ) ,
22  m_parms ( (CCGFloat*) 0 ), m_eta(0), m_phi(0)
23 {}
24 
25 
27 {}
28 
29 
30 
32  CornersMgr* mgr,
33  const CCGFloat* par ) :
34  m_refPoint ( gp ),
35  m_corners ( mgr ),
36  m_parms ( par ),
37  m_eta(gp.eta()), m_phi(gp.phi())
38 {}
39 
41  const CCGFloat* par ) :
42  m_refPoint ( 0.25*( cv[0].x() + cv[1].x() + cv[2].x() + cv[3].x() ),
43  0.25*( cv[0].y() + cv[1].y() + cv[2].y() + cv[3].y() ),
44  0.25*( cv[0].z() + cv[1].z() + cv[2].z() + cv[3].z() ) ),
45  m_corners ( cv ),
46  m_parms ( par ),
47  m_eta( m_refPoint.eta()), m_phi(m_refPoint.phi())
48 {}
49 
50 std::ostream& operator<<( std::ostream& s, const CaloCellGeometry& cell )
51 {
52  s << ", Center: " << cell.getPosition() << std::endl;
53 
54  if( cell.emptyCorners() )
55  {
56  s << "Corners vector is empty." << std::endl ;
57  }
58  else
59  {
60  const CaloCellGeometry::CornersVec& corners ( cell.getCorners() ) ;
61  for ( unsigned int i ( 0 ) ; i != corners.size() ; ++i )
62  {
63  s << "Corner: " << corners[ i ] << std::endl;
64  }
65  }
66  return s ;
67 }
68 
69 void
71 {
73  const Pt3D gFront ( p.x(), p.y(), p.z() ) ;
74  const DPt3D dgFront ( p.x(), p.y(), p.z() ) ;
75 
76  Pt3D lFront ;
77  assert( 0 != param() ) ;
78  Pt3DVec lc ( 8, Pt3D(0,0,0) ) ;
79  vocalCorners( lc, param(), lFront ) ;
80 
81  DPt3D dlFront ( lFront.x(), lFront.y(), lFront.z() ) ;
82 
83  const Pt3D lBack ( 0.25*(lc[4]+lc[5]+lc[6]+lc[7]) ) ;
84  const DPt3D dlBack ( lBack.x(), lBack.y(), lBack.z() ) ;
85 
86  const Pt3D dlOne ( lc[0].x(), lc[0].y(), lc[0].z() ) ;
87 
88  const CornersVec& cor ( getCorners() ) ;
89  DPt3DVec dkor ( 8, DPt3D(0,0,0) ) ;
90  for( unsigned int i ( 0 ) ; i != 8 ; ++i )
91  {
92  dkor[i] = DPt3D ( cor[i].x(), cor[i].y(), cor[i].z() ) ;
93  }
94 
95  DPt3D dgBack ( 0.25*( dkor[4]+dkor[5]+dkor[6]+dkor[7] ) ) ;
96 
97  const DVec3D dgAxis ( (dgBack-dgFront).unit() ) ;
98 
99  dgBack = ( dgFront + (dlBack-dlFront).mag()*dgAxis ) ;
100  const DPt3D dgOneT ( dgFront + ( dlOne - dlFront ).mag()*( dkor[0] - dgFront ).unit() ) ;
101 
102  const double dlangle ( ( dlBack - dlFront).angle( dlOne - dlFront ) ) ;
103  const double dgangle ( ( dgBack - dgFront).angle( dgOneT- dgFront ) ) ;
104  const double ddangle ( dlangle - dgangle ) ;
105 
106  const DPlane3D dgPl ( dgFront, dgOneT, dgBack ) ;
107  const DPt3D dp2 ( dgFront + dgPl.normal().unit() ) ;
108 
109  const DPt3D dgOne ( dgFront + HepGeom::Rotate3D( -ddangle, dgFront, dp2 )*
110  DVec3D ( dgOneT - dgFront ) ) ;
111 
112  tr = Tr3D( dlFront , dlBack , dlOne ,
113  dgFront , dgBack , dgOne ) ;
114 
115  if( 0 != lptr ) (*lptr) = lc ;
116 }
117 
118 const float*
120  const std::vector<float>& vv ,
122 {
123  const float* pP ( 0 ) ;
124 
125  for( unsigned int ii ( 0 ) ; ii != pvv.size() ; ++ii )
126  {
127  const ParVec& v ( pvv[ii] ) ;
128  assert( v.size() == vv.size() ) ;
129 
130  bool same ( true ) ;
131  for( unsigned int j ( 0 ) ; j != vv.size() ; ++j )
132  {
133  same = same && ( fabs( vv[j] - v[j] )<1.e-6 ) ;
134  if( !same ) break ;
135  }
136  if( same )
137  {
138  pP = &(*v.begin()) ;
139  break ;
140  }
141  }
142  return pP ;
143 }
144 
145 const float*
147  const std::vector<float>& vv ,
150 {
151  const float* pP ( checkParmPtr( vv, pvv ) ) ;
152 
153  if( 0 == pP )
154  {
155  pvv.push_back( ParVec( mgr ) ) ;
156  ParVec& back ( pvv.back() ) ;
157  for( unsigned int i ( 0 ) ; i != vv.size() ; ++i )
158  {
159  back[i] = vv[i] ;
160  }
161  pP = &(*back.begin()) ;
162  }
163  return pP ;
164 }
165 
166 bool
168 {
169  bool ans ( false ) ;
170  const Pt3D p ( point.x(), point.y(), point.z() ) ;
171  const CornersVec& cog ( getCorners() ) ;
172  Pt3D co[8] ;
173  for( unsigned int i ( 0 ) ; i != 8 ; ++i )
174  {
175  co[i] = Pt3D ( cog[i].x(), cog[i].y(), cog[i].z() ) ;
176  }
177 
178  const Plane3D AA ( co[0], co[1], co[2] ) ; // z<0
179  const Plane3D BB ( co[6], co[5], co[4] ) ; // z>0
180 
181  if( AA.distance(p)*BB.distance(p) >= 0 )
182  {
183  const Plane3D CC ( co[0], co[4], co[5] ) ; // x<0
184  const Plane3D DD ( co[2], co[6], co[7] ) ; // x>0
185  if( CC.distance(p)*DD.distance(p) >= 0 )
186  {
187  const Plane3D EE ( co[3], co[7], co[4] ) ; // y<0
188  const Plane3D FF ( co[1], co[5], co[6] ) ; // y>0
189  if( EE.distance(p)*FF.distance(p) >= 0 )
190  {
191  ans = true ;
192  }
193  }
194  }
195  return ans ;
196 }
int i
Definition: DBlmapReader.cc:9
bool emptyCorners() const
EZArrayFL< CCGFloat > ParVec
std::vector< ParVec > ParVecVec
HepGeom::Point3D< double > DPt3D
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T y() const
Definition: PV3DBase.h:63
const_iterator begin() const
Definition: EZArrayFL.h:63
HepGeom::Transform3D Tr3D
std::vector< Pt3D > Pt3DVec
T eta() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
int ii
Definition: cuy.py:588
float float float z
MgrType::const_reference const_reference
Definition: EZArrayFL.h:29
const CCGFloat * param() const
virtual void getTransform(Tr3D &tr, Pt3DVec *lptr) const
--------— only needed by specific utility; overloaded when needed -—
virtual ~CaloCellGeometry()
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:64
int j
Definition: DBlmapReader.cc:9
HepGeom::Vector3D< double > DVec3D
CaloCellGeometry::CCGFloat CCGFloat
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
static const CCGFloat k_ScaleFromDDDtoGeant
virtual void vocalCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref) const =0
dictionary cv
Definition: cuy.py:362
CaloCellGeometry::Pt3D Pt3D
bool inside(const GlobalPoint &point) const
Returns true if the specified point is inside this cell.
size_type size() const
Definition: EZArrayFL.h:81
HepGeom::Plane3D< double > DPlane3D
CaloCellGeometry::Pt3DVec Pt3DVec
HepGeom::Point3D< CCGFloat > Pt3D
Definition: EZMgrFL.h:8
CaloCellGeometry::Tr3D Tr3D
std::vector< DPt3D > DPt3DVec
Definition: DDAxes.h:10
const CornersVec & getCorners() const
Returns the corner points of this cell&#39;s volume.
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
T x() const
Definition: PV3DBase.h:62
HepGeom::Vector3D< CCGFloat > FVec3D
ROOT::Math::Plane3D Plane3D
*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
static const CCGFloat * checkParmPtr(const std::vector< CCGFloat > &vd, ParVecVec &pvv)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
Definition: DDAxes.h:10