CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackingRecHitPropagator.h
Go to the documentation of this file.
1 #ifndef TrackingTools_TrackingRecHitPropagator_h
2 #define TrackingTools_TrackingRecHitPropagator_h
3 
8 
15 
16 
17 /* propagates the RecHit position from the original reference frame
18  to the reference frame of another detector.
19  Useful for algorithms like the DAF or the MTF
20 */
21 
23  public:
26  };
27 
29 
30 
32  const GeomDet& det,
33  const TrajectoryStateOnSurface ts,
34  const TransientTrackingRecHitBuilder* builder) const{
35 
36  TkClonerImpl hc = static_cast<TkTransientTrackingRecHitBuilder const *>(builder)->cloner();
37 
38  //1) propagate the best possible track parameters to the surface of the hit you want to "move" using a AnalyticalPropagator ;
39  //2) create LocalTrajectoryParameters with the local x,y of the hit and direction + momentum from the propagated track parameters;
40  //3) create a LocalTrajectoryError matrix which is 0 except for the local x,y submatrix, which is filled with the hit errors;
41  //4) create a TSOS from the result of 2) and 3) and propagate it to the reference surface;
42  //5) create a new hit with the local x,y subspace of the result of 4)
43  if (!ts.isValid()) return std::make_shared<InvalidTrackingRecHit>(*hit->det(), TrackingRecHit::missing);
44  // LogTrace("SiTrackerMultiRecHitUpdator") << "the tsos is valid";
45  //check if the ts lays or not on the destination surface and in case propagate it
46  TrajectoryStateOnSurface propagated =ts;
47  if (hit->surface() != &(ts.surface())) propagated = thePropagator->propagate(ts, *(hit->surface()));
48  if (!propagated.isValid()) return std::make_shared<InvalidTrackingRecHit>(*hit->det(), TrackingRecHit::missing);
49  // LogTrace("SiTrackerMultiRecHitUpdator") << "the propagate tsos is valid";
50  // LogTrace("SiTrackerMultiRecHitUpdator") << "Original: position: "<<hit->parameters()<<" error: "<<hit->parametersError()<<std::endl;
51  //clone the original hit with this state
52  TrackingRecHit::RecHitPointer updatedOriginal = hc.makeShared(hit,propagated);
53  // LogTrace("SiTrackerMultiRecHitUpdator") << "New: position: "<<updatedOriginal->parameters()<<" error: "<<updatedOriginal->parametersError()<<std::endl;
54 
55  // LogTrace("SiTrackerMultiRecHitUpdator") << "rechit cloned";
56  LocalTrajectoryParameters ltp(updatedOriginal->localPosition(), propagated.localMomentum(), propagated.charge());
58  ltem(3,3) = (updatedOriginal->parametersError())(1,1);
59  ltem(4,4) = (updatedOriginal->parametersError())(2,2);
60  ltem(3,4) = (updatedOriginal->parametersError())(1,2);
61  // LogTrace("SiTrackerMultiRecHitUpdator") <<"The cov matrix: "<<ltem<<std::endl;
62  LocalTrajectoryError lte(ltem);
63  // LogTrace("SiTrackerMultiRecHitUpdator") <<"Original cov matrix: "<<lte.matrix()<<std::endl;
64  TrajectoryStateOnSurface hit_state(ltp, lte, propagated.surface(), propagated.magneticField());
65  TrajectoryStateOnSurface projected_hit_state = thePropagator->propagate(hit_state, det.surface());
66  if (!projected_hit_state.isValid()) return std::make_shared<InvalidTrackingRecHit>(*hit->det(), TrackingRecHit::missing);
67  LocalPoint p = projected_hit_state.localPosition();
68  LocalError e = projected_hit_state.localError().positionError();
69  // LogTrace("SiTrackerMultiRecHitUpdator") << "position: "<<p<<" error: "<<e<<std::endl;
70  //AlgebraicSymMatrix55 projm=projected_hit_state.localError().matrix();
71  // for(int i=0;i<5;i++){
72  // LogTrace("SiTrackerMultiRecHitUpdator") <<"cov matrix: "<<projm<<std::endl;
73  // }
74  return ResultingHit::build(p, e, &det, updatedOriginal->det(), updatedOriginal, this);
75  }
76 
77 
78  private:
80 };
81 
82 #endif
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
virtual TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:47
const MagneticField * magneticField() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
LocalVector localMomentum() const
const SurfaceType & surface() const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > RecHitPointer
susybsm::HSCParticleCollection hc
Definition: classes.h:25
TrackingRecHit::RecHitPointer project(const TrackingRecHit::ConstRecHitPointer hit, const GeomDet &det, const TrajectoryStateOnSurface ts, const TransientTrackingRecHitBuilder *builder) const
const AnalyticalPropagator * thePropagator
TrackingRecHitPropagator(const MagneticField *magf)