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> Vec3D ;
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 )
23 {}
24 
26 {
27  *this = cell ;
28 }
29 
32 {
33  if( this != &cell )
34  {
35  m_refPoint = cell.m_refPoint ;
36  m_corners = cell.m_corners ;
37  m_parms = cell.m_parms ;
38  }
39  return *this ;
40 }
41 
43 {}
44 
45 const GlobalPoint&
47 {
48  return m_refPoint ;
49 }
50 
51 bool
53 {
54  return m_corners.empty() ;
55 }
56 
57 const CCGFloat*
59 {
60  return m_parms ;
61 }
62 
64  const CornersMgr* mgr,
65  const CCGFloat* par ) :
66  m_refPoint ( gp ),
67  m_corners ( mgr ),
68  m_parms ( par )
69 {}
70 
72  const CCGFloat* par ) :
73  m_refPoint ( 0.25*( cv[0].x() + cv[1].x() + cv[2].x() + cv[3].x() ),
74  0.25*( cv[0].y() + cv[1].y() + cv[2].y() + cv[3].y() ),
75  0.25*( cv[0].z() + cv[1].z() + cv[2].z() + cv[3].z() ) ),
76  m_corners ( cv ),
77  m_parms ( par )
78 {}
79 
82 {
83  return m_corners ;
84 }
85 
88 {
89  return m_corners ;
90 }
91 
92 std::ostream& operator<<( std::ostream& s, const CaloCellGeometry& cell )
93 {
94  s << ", Center: " << cell.getPosition() << std::endl;
95 
96  if( cell.emptyCorners() )
97  {
98  s << "Corners vector is empty." << std::endl ;
99  }
100  else
101  {
102  const CaloCellGeometry::CornersVec& corners ( cell.getCorners() ) ;
103  for ( unsigned int i ( 0 ) ; i != corners.size() ; ++i )
104  {
105  s << "Corner: " << corners[ i ] << std::endl;
106  }
107  }
108  return s ;
109 }
110 
111 void
113 {
115  const Pt3D gFront ( p.x(), p.y(), p.z() ) ;
116  const DPt3D dgFront ( p.x(), p.y(), p.z() ) ;
117 
118  Pt3D lFront ;
119  assert( 0 != param() ) ;
120  Pt3DVec lc ( 8, Pt3D(0,0,0) ) ;
121  vocalCorners( lc, param(), lFront ) ;
122 
123  DPt3D dlFront ( lFront.x(), lFront.y(), lFront.z() ) ;
124 
125  const Pt3D lBack ( 0.25*(lc[4]+lc[5]+lc[6]+lc[7]) ) ;
126  const DPt3D dlBack ( lBack.x(), lBack.y(), lBack.z() ) ;
127 
128  const Pt3D dlOne ( lc[0].x(), lc[0].y(), lc[0].z() ) ;
129 
130  const CornersVec& cor ( getCorners() ) ;
131  DPt3DVec dkor ( 8, DPt3D(0,0,0) ) ;
132  for( unsigned int i ( 0 ) ; i != 8 ; ++i )
133  {
134  dkor[i] = DPt3D ( cor[i].x(), cor[i].y(), cor[i].z() ) ;
135  }
136 
137  DPt3D dgBack ( 0.25*( dkor[4]+dkor[5]+dkor[6]+dkor[7] ) ) ;
138 
139  const DVec3D dgAxis ( (dgBack-dgFront).unit() ) ;
140 
141  dgBack = ( dgFront + (dlBack-dlFront).mag()*dgAxis ) ;
142  const DPt3D dgOneT ( dgFront + ( dlOne - dlFront ).mag()*( dkor[0] - dgFront ).unit() ) ;
143 
144  const double dlangle ( ( dlBack - dlFront).angle( dlOne - dlFront ) ) ;
145  const double dgangle ( ( dgBack - dgFront).angle( dgOneT- dgFront ) ) ;
146  const double ddangle ( dlangle - dgangle ) ;
147 
148  const DPlane3D dgPl ( dgFront, dgOneT, dgBack ) ;
149  const DPt3D dp2 ( dgFront + dgPl.normal().unit() ) ;
150 
151  const DPt3D dgOne ( dgFront + HepGeom::Rotate3D( -ddangle, dgFront, dp2 )*
152  DVec3D ( dgOneT - dgFront ) ) ;
153 
154  tr = Tr3D( dlFront , dlBack , dlOne ,
155  dgFront , dgBack , dgOne ) ;
156 
157  if( 0 != lptr ) (*lptr) = lc ;
158 }
159 
160 const float*
162  const std::vector<float>& vv ,
164 {
165  const float* pP ( 0 ) ;
166 
167  for( unsigned int ii ( 0 ) ; ii != pvv.size() ; ++ii )
168  {
169  const ParVec& v ( pvv[ii] ) ;
170  assert( v.size() == vv.size() ) ;
171 
172  bool same ( true ) ;
173  for( unsigned int j ( 0 ) ; j != vv.size() ; ++j )
174  {
175  same = same && ( fabs( vv[j] - v[j] )<1.e-6 ) ;
176  if( !same ) break ;
177  }
178  if( same )
179  {
180  pP = &(*v.begin()) ;
181  break ;
182  }
183  }
184  return pP ;
185 }
186 
187 const float*
189  const std::vector<float>& vv ,
192 {
193  const float* pP ( checkParmPtr( vv, pvv ) ) ;
194 
195  if( 0 == pP )
196  {
197  pvv.push_back( ParVec( mgr ) ) ;
198  ParVec& back ( pvv.back() ) ;
199  for( unsigned int i ( 0 ) ; i != vv.size() ; ++i )
200  {
201  back[i] = vv[i] ;
202  }
203  pP = &(*back.begin()) ;
204  }
205  return pP ;
206 }
207 
208 bool
210 {
211  bool ans ( false ) ;
212  const Pt3D p ( point.x(), point.y(), point.z() ) ;
213  const CornersVec& cog ( getCorners() ) ;
214  Pt3D co[8] ;
215  for( unsigned int i ( 0 ) ; i != 8 ; ++i )
216  {
217  co[i] = Pt3D ( cog[i].x(), cog[i].y(), cog[i].z() ) ;
218  }
219 
220  const Plane3D AA ( co[0], co[1], co[2] ) ; // z<0
221  const Plane3D BB ( co[6], co[5], co[4] ) ; // z>0
222 
223  if( AA.distance(p)*BB.distance(p) >= 0 )
224  {
225  const Plane3D CC ( co[0], co[4], co[5] ) ; // x<0
226  const Plane3D DD ( co[2], co[6], co[7] ) ; // x>0
227  if( CC.distance(p)*DD.distance(p) >= 0 )
228  {
229  const Plane3D EE ( co[3], co[7], co[4] ) ; // y<0
230  const Plane3D FF ( co[1], co[5], co[6] ) ; // y>0
231  if( EE.distance(p)*FF.distance(p) >= 0 )
232  {
233  ans = true ;
234  }
235  }
236  }
237  return ans ;
238 }
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())
const CCGFloat * m_parms
T y() const
Definition: PV3DBase.h:62
const_iterator begin() const
Definition: EZArrayFL.h:63
HepGeom::Transform3D Tr3D
std::vector< Pt3D > Pt3DVec
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
double double double z
const CCGFloat * param() const
MgrType::const_reference const_reference
Definition: EZArrayFL.h:29
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:63
int j
Definition: DBlmapReader.cc:9
HepGeom::Vector3D< double > DVec3D
CaloCellGeometry::CCGFloat CCGFloat
Vec4< double > Vec3D
Definition: SSEVec.h:566
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
GlobalPoint m_refPoint
static const CCGFloat k_ScaleFromDDDtoGeant
virtual void vocalCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref) const =0
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
bool empty() const
Definition: EZArrayFL.h:79
HepGeom::Plane3D< double > DPlane3D
CaloCellGeometry::Pt3DVec Pt3DVec
HepGeom::Point3D< CCGFloat > Pt3D
Definition: EZMgrFL.h:8
CaloCellGeometry::Tr3D Tr3D
CornersVec & setCorners() const
std::vector< DPt3D > DPt3DVec
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:61
mathSSE::Vec4< T > v
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
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell&#39;s volume.
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
CaloCellGeometry & operator=(const CaloCellGeometry &cell)