CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackingRecHitProjector.h
Go to the documentation of this file.
1 #ifndef TrackingRecHitProjector_H
2 #define TrackingRecHitProjector_H
3 
5 //#include <iostream>
6 
7 template <class ResultingHit>
9  public:
10 
12 
13 
15  const GeomDet& det,
16  const TrajectoryStateOnSurface& ts) const {
17 
19  return project(hit, det, gdir);
20  }
22  const GeomDet& det) const {
23  GlobalVector gdir = hit.globalPosition() - GlobalPoint(0,0,0);
24  return project(hit, det, gdir);
25  }
26 
28  const GeomDet& det,
29  const GlobalVector & gdir) const {
30  const BoundPlane& gluedPlane = det.surface();
31  const BoundPlane& hitPlane = hit.det()->surface();
32 
33  // check if the planes are parallel
34  //const float epsilon = 1.e-7; // corresponds to about 0.3 miliradian but cannot be reduced
35  // because of float precision
36 
37  //if (fabs(gluedPlane.normalVector().dot( hitPlane.normalVector())) < 1-epsilon) {
38  // std::cout << "TkGluedMeasurementDet plane not parallel to DetUnit plane: dot product is "
39  // << gluedPlane.normalVector().dot( hitPlane.normalVector()) << endl;
40  // FIXME: throw the appropriate exception here...
41  //throw MeasurementDetException("TkGluedMeasurementDet plane not parallel to DetUnit plane");
42  //}
43 
44  double delta = gluedPlane.localZ( hitPlane.position());
45  LocalVector ldir = gluedPlane.toLocal(gdir);
46  LocalPoint lhitPos = gluedPlane.toLocal( hit.globalPosition());
47  LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.z();
48 
49  LocalVector hitXAxis = gluedPlane.toLocal( hitPlane.toGlobal( LocalVector(1,0,0)));
50  LocalError hitErr = hit.localPositionError();
51  if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
52  // the two planes are inverted, and the correlation element must change sign
53  hitErr = LocalError( hitErr.xx(), -hitErr.xy(), hitErr.yy());
54  }
55  LocalError rotatedError = hitErr.rotate( hitXAxis.x(), hitXAxis.y());
56 
57  return ResultingHit::build( projectedHitPos, rotatedError, &det, hit.det(), hit);
58  }
59 
60 };
61 
62 #endif
dbl * delta
Definition: mlp_gen.cc:36
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
float xx() const
Definition: LocalError.h:24
RecHitPointer project(const TransientTrackingRecHit &hit, const GeomDet &det) const
TransientTrackingRecHit::RecHitPointer RecHitPointer
GlobalVector normalVector() const
Definition: Plane.h:47
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:62
float localZ(const GlobalPoint &gp) const
Fast access to distance from plane for a point.
Definition: Plane.h:52
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
RecHitPointer project(const TransientTrackingRecHit &hit, const GeomDet &det, const TrajectoryStateOnSurface &ts) const
float xy() const
Definition: LocalError.h:25
float yy() const
Definition: LocalError.h:26
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:63
RecHitPointer project(const TransientTrackingRecHit &hit, const GeomDet &det, const GlobalVector &gdir) const
const GlobalTrajectoryParameters & globalParameters() const
virtual LocalError localPositionError() const =0
virtual GlobalPoint globalPosition() const
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
const GeomDet * det() const
The GomeDet* can be zero for InvalidTransientRecHits and for TConstraintRecHit2Ds.
LocalError rotate(float x, float y) const
Return a new LocalError, rotated by an angle defined by the direction (x,y)
Definition: LocalError.h:39
T x() const
Definition: PV3DBase.h:61
const PositionType & position() const