CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
CaloCellCrossing Class Reference

#include <CaloCellCrossing.h>

Public Types

typedef std::vector< DetIdDetIds
 
typedef std::vector< double > Lengths
 
typedef std::vector< GlobalPointPoints
 

Public Member Functions

 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)
 
const Pointscenters () const
 
const DetIdsdetIds () const
 
const Pointsentrances () const
 
const Pointsexits () const
 
const GlobalPointgp () const
 
const GlobalVectorgv () const
 
const Lengthslengths () const
 
virtual ~CaloCellCrossing ()
 

Private Member Functions

 CaloCellCrossing (const CaloCellCrossing &)
 
CaloCellCrossing operator= (const CaloCellCrossing &)
 

Private Attributes

Points m_ctr
 
DetIds m_detId
 
Points m_entr
 
Points m_exit
 
GlobalPoint m_gp
 
GlobalVector m_gv
 
Lengths m_len
 

Detailed Description

Definition at line 12 of file CaloCellCrossing.h.

Member Typedef Documentation

typedef std::vector< DetId > CaloCellCrossing::DetIds

Definition at line 16 of file CaloCellCrossing.h.

typedef std::vector< double > CaloCellCrossing::Lengths

Definition at line 18 of file CaloCellCrossing.h.

typedef std::vector< GlobalPoint > CaloCellCrossing::Points

Definition at line 17 of file CaloCellCrossing.h.

Constructor & Destructor Documentation

CaloCellCrossing::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 
)

Definition at line 5 of file CaloCellCrossing.cc.

References assert(), cuy::cv, HepLine3D::dist(), HepLine3D::dist2(), dot(), alignCSCRings::e, newFWLiteAna::found, CaloSubdetectorGeometry::getGeometry(), CaloSubdetectorGeometry::getValidDetIds(), i, geometryCSVtoXML::line, LogDebug, m_ctr, m_detId, m_entr, m_exit, m_len, mag(), mag2(), HepLine3D::point(), EnergyCorrector::pt, HepLine3D::pt(), mathSSE::sqrt(), HepLine3D::uv(), x, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

12  :
13  m_gp ( gp ) ,
14  m_gv ( gv )
15 {
16  const double eps ( fabs( small ) > 1.e-15 ? fabs( small ) : 1.e-10 ) ;
17  static unsigned int k_rlen ( 30 ) ;
18  m_detId.reserve( k_rlen ) ;
19  m_ctr .reserve( k_rlen ) ;
20  m_entr .reserve( k_rlen ) ;
21  m_exit .reserve( k_rlen ) ;
22 //------------------------------------------------------------
23  const HepLine3D line ( HepGeom::Point3D<double> ( gp.x(), gp.y(), gp.z() ),
24  HepGeom::Vector3D<double> ( gv.x(), gv.y(), gv.z() ), eps ) ;
25 
26  LogDebug("CaloCellCrossing") << "*** Line: pt=" << line.pt() << ", unitvec=" << line.uv();
27 
28  const DetIds& ids ( 0 == di ? sg->getValidDetIds( det, subdet ) : *di ) ;
29 //------------------------------------------------------------
30  for( DetIds::const_iterator id ( ids.begin() ) ; id != ids.end() ; ++id )
31  {
32  const DetId dId ( *id ) ;
33  unsigned int found ( 0 ) ;
34  const CaloCellGeometry& cg ( *sg->getGeometry( dId ) ) ;
35  const CaloCellGeometry::CornersVec& gc ( cg.getCorners() ) ;
36  const HepGeom::Point3D<double> fr ( cg.getPosition().x(),
37  cg.getPosition().y(),
38  cg.getPosition().z() ) ;
39  const double bCut2 ( ( gc[0] - gc[6] ).mag2() ) ;
40 
41  if( ( !onewayonly ||
42  eps < HepGeom::Vector3D<double> ( fr - line.pt() ).dot( line.uv() ) ) &&
43  bCut2 > line.dist2( fr ) ) // first loose cut
44  {
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 ) ) // tighter cut
59  {
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 )
66  {
67  const unsigned int* ic ( &nc[face][0] ) ;
68  const HepGeom::Plane3D<double> pl ( cv[ic[0]], cv[ic[1]], cv[ic[2]] ) ;
69  bool parallel ;
70  const HepGeom::Point3D<double> pt ( line.point( pl, parallel ) ) ;
71  LogDebug("CaloCellCrossing")<<"***Face: "<<face<<", pt="<<pt;
72  if( !parallel )
73  {
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 ) ;
77  LogDebug("CaloCellCrossing")<<"la.point="<<la.point(pt);
78 
79 // const double dot ( ( la.point( pt ) - pt ).dot( ( lb.point( pt ) - pt ) ) ) ;
80 // LogDebug("CaloCellCrossing")<<"***Dot1="<<dot;
81  if( eps > ( la.point( pt ) - pt ).dot( ( lb.point( pt ) - pt ) ) )
82  {
83  const HepLine3D lc ( cv[ic[0]], cv[ic[3]], eps ) ;
84  const HepLine3D ld ( cv[ic[1]], cv[ic[2]], eps ) ;
85 // const double dot ( ( lc.point( pt ) - pt ).dot( ( ld.point( pt ) - pt ) ) ) ;
86 // LogDebug("CaloCellCrossing")<<"***Dot2="<<dot;
87  if( eps > ( lc.point( pt ) - pt ).dot( ( ld.point( pt ) - pt ) ) )
88  {
89  if( 0 == found )
90  {
91  ++found ;
92  m_detId.push_back( dId ) ;
93  m_ctr .push_back( GlobalPoint( ctr.x(), ctr.y(), ctr.z() ) ) ;
94  m_entr.push_back( GlobalPoint( pt.x(), pt.y(), pt.z() ) ) ;
95  }
96  else
97  {
98  if( 1 == found )
99  {
100  ++found ;
101  m_exit.push_back( GlobalPoint( pt.x(), pt.y(), pt.z() ) ) ;
102  }
103  else
104  {
105  const double dist1 (
106  ( pt - HepGeom::Point3D<double> ( m_entr.back().x(),
107  m_entr.back().y(),
108  m_entr.back().z() ) ).mag() ) ;
109  const double dist2 (
110  ( pt - HepGeom::Point3D<double> ( m_exit.back().x(),
111  m_exit.back().y(),
112  m_exit.back().z() ) ).mag() ) ;
113  if( eps < dist1 &&
114  eps < dist2 )
115  {
116  edm::LogWarning("CaloCellCrossing") << "********For DetId = " << dId
117  << " distances too big: "
118  << dist1 << ", " << dist2;
119 
120  }
121  }
122  }
123  }
124  }
125  }
126  }
127  }
128  }
129  assert( 2 >= found ) ;
130  if( 1 == found ) m_exit.push_back( m_entr.back() ) ;
131  }
132 //------------------------------------------------------------
133  assert( m_detId.size() == m_entr.size() &&
134  m_detId.size() == m_ctr .size() &&
135  m_detId.size() == m_exit.size() ) ;
136 
137  m_len.reserve( m_entr.size() ) ;
138  for( unsigned int i ( 0 ) ; i != m_entr.size() ; ++i )
139  {
140  m_len.push_back( ( m_exit[i] - m_entr[i] ).mag() ) ;
141  }
142 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
assert(m_qm.get())
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
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 sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
dictionary cv
Definition: cuy.py:362
Definition: DetId.h:18
T dot(const Basic3DVector &v) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
T x() const
Definition: PV3DBase.h:62
GlobalVector m_gv
std::vector< DetId > DetIds
virtual CaloCellCrossing::~CaloCellCrossing ( )
inlinevirtual

Definition at line 29 of file CaloCellCrossing.h.

29 {} ;
CaloCellCrossing::CaloCellCrossing ( const CaloCellCrossing )
private

Member Function Documentation

const Points& CaloCellCrossing::centers ( ) const
inline

Definition at line 35 of file CaloCellCrossing.h.

References m_ctr.

35 { return m_ctr ; }
const DetIds& CaloCellCrossing::detIds ( ) const
inline

Definition at line 34 of file CaloCellCrossing.h.

References m_detId.

34 { return m_detId ; }
const Points& CaloCellCrossing::entrances ( ) const
inline

Definition at line 36 of file CaloCellCrossing.h.

References m_entr.

36 { return m_entr ; }
const Points& CaloCellCrossing::exits ( ) const
inline

Definition at line 37 of file CaloCellCrossing.h.

References m_exit.

37 { return m_exit ; }
const GlobalPoint& CaloCellCrossing::gp ( ) const
inline

Definition at line 31 of file CaloCellCrossing.h.

References m_gp.

31 { return m_gp ; }
const GlobalVector& CaloCellCrossing::gv ( ) const
inline

Definition at line 32 of file CaloCellCrossing.h.

References m_gv.

32 { return m_gv ; }
GlobalVector m_gv
const Lengths& CaloCellCrossing::lengths ( ) const
inline

Definition at line 38 of file CaloCellCrossing.h.

References m_len.

38 { return m_len ; }
CaloCellCrossing CaloCellCrossing::operator= ( const CaloCellCrossing )
private

Member Data Documentation

Points CaloCellCrossing::m_ctr
private

Definition at line 50 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and centers().

DetIds CaloCellCrossing::m_detId
private

Definition at line 48 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and detIds().

Points CaloCellCrossing::m_entr
private

Definition at line 52 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and entrances().

Points CaloCellCrossing::m_exit
private

Definition at line 53 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and exits().

GlobalPoint CaloCellCrossing::m_gp
private

Definition at line 45 of file CaloCellCrossing.h.

Referenced by gp().

GlobalVector CaloCellCrossing::m_gv
private

Definition at line 46 of file CaloCellCrossing.h.

Referenced by gv().

Lengths CaloCellCrossing::m_len
private

Definition at line 54 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and lengths().