16 const double eps ( fabs( small ) > 1.
e-15 ? fabs( small ) : 1.
e-10 ) ;
17 static unsigned int k_rlen ( 30 ) ;
19 m_ctr .reserve( k_rlen ) ;
20 m_entr .reserve( k_rlen ) ;
21 m_exit .reserve( k_rlen ) ;
24 HepGeom::Vector3D<double> ( gv.
x(), gv.
y(), gv.
z() ), eps ) ;
26 LogDebug(
"CaloCellCrossing") <<
"*** Line: pt=" << line.
pt() <<
", unitvec=" << line.
uv();
30 for( DetIds::const_iterator
id ( ids.begin() ) ;
id != ids.end() ; ++id )
32 const DetId dId ( *
id ) ;
33 unsigned int found ( 0 ) ;
36 const HepGeom::Point3D<double> fr ( cg.getPosition().x(),
38 cg.getPosition().z() ) ;
39 const double bCut2 ( ( gc[0] - gc[6] ).
mag2() ) ;
42 eps < HepGeom::Vector3D<double> ( fr - line.
pt() ).
dot( line.
uv() ) ) &&
43 bCut2 > line.
dist2( fr ) )
45 LogDebug(
"CaloCellCrossing") <<
"*** fr=" << fr <<
", bCut =" <<
sqrt(bCut2) <<
", dis=" << line.
dist(fr);
46 const HepGeom::Point3D<double>
cv[8] =
47 { HepGeom::Point3D<double> ( gc[0].x(), gc[0].y(), gc[0].z() ) ,
48 HepGeom::Point3D<double> ( gc[1].
x(), gc[1].y(), gc[1].z() ) ,
49 HepGeom::Point3D<double> ( gc[2].
x(), gc[2].y(), gc[2].z() ) ,
50 HepGeom::Point3D<double> ( gc[3].
x(), gc[3].y(), gc[3].z() ) ,
51 HepGeom::Point3D<double> ( gc[4].
x(), gc[4].y(), gc[4].z() ) ,
52 HepGeom::Point3D<double> ( gc[5].
x(), gc[5].y(), gc[5].z() ) ,
53 HepGeom::Point3D<double> ( gc[6].
x(), gc[6].y(), gc[6].z() ) ,
54 HepGeom::Point3D<double> ( gc[7].
x(), gc[7].y(), gc[7].z() ) } ;
55 const HepGeom::Point3D<double> ctr ( 0.125*(cv[0]+cv[1]+cv[2]+cv[3]+
56 cv[4]+cv[5]+cv[6]+cv[7]) ) ;
57 const double dCut2 ( bCut2/4. ) ;
58 if( dCut2 > line.
dist2( ctr ) )
60 LogDebug(
"CaloCellCrossing") <<
"** 2nd cut: ctr=" << ctr
61 <<
", dist=" << line.
dist(ctr);
62 static const unsigned int nc[6][4] =
63 { { 0,1,2,3 }, { 0,4,5,1 }, { 0,4,7,3 },
64 { 6,7,4,5 }, { 6,2,3,7 }, { 6,2,1,5 } } ;
65 for(
unsigned int face ( 0 ) ; face != 6 ; ++face )
67 const unsigned int* ic ( &nc[face][0] ) ;
68 const HepGeom::Plane3D<double> pl ( cv[ic[0]], cv[ic[1]], cv[ic[2]] ) ;
70 const HepGeom::Point3D<double>
pt ( line.
point( pl, parallel ) ) ;
71 LogDebug(
"CaloCellCrossing")<<
"***Face: "<<face<<
", pt="<<
pt;
74 LogDebug(
"CaloCellCrossing")<<
"Not parallel";
75 const HepLine3D la ( cv[ic[0]], cv[ic[1]], eps ) ;
76 const HepLine3D lb ( cv[ic[2]], cv[ic[3]], eps ) ;
83 const HepLine3D lc ( cv[ic[0]], cv[ic[3]], eps ) ;
84 const HepLine3D ld ( cv[ic[1]], cv[ic[2]], eps ) ;
106 ( pt - HepGeom::Point3D<double> (
m_entr.back().x(),
108 m_entr.back().z() ) ).mag() ) ;
110 ( pt - HepGeom::Point3D<double> (
m_exit.back().x(),
112 m_exit.back().z() ) ).mag() ) ;
117 <<
" distances too big: "
118 << dist1 <<
", " << dist2;
129 assert( 2 >= found ) ;
138 for(
unsigned int i ( 0 ) ;
i !=
m_entr.size() ; ++
i )
double dist2(const HepGeom::Point3D< double > &q) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Global3DPoint GlobalPoint
const HepGeom::Vector3D< double > & uv() const
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
double dist(const HepGeom::Point3D< double > &q) const
CaloCellCrossing(const GlobalPoint &gp, const GlobalVector &gv, const DetIds *di, const CaloSubdetectorGeometry *sg, DetId::Detector det, int subdet, double small=1.e-10, bool onewayonly=false)
HepGeom::Point3D< double > point(const HepGeom::Plane3D< double > &pl, bool ¶llel) const
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
const HepGeom::Point3D< double > & pt() const
std::vector< DetId > DetIds