CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TkClonerImpl.cc
Go to the documentation of this file.
2 
9 
12 
13 
16 
21 
23 
24 #include<iostream>
25 #include <memory>
26 
27 std::unique_ptr<SiPixelRecHit> TkClonerImpl::operator()(SiPixelRecHit const & hit, TrajectoryStateOnSurface const& tsos) const {
28  const SiPixelCluster& clust = *hit.cluster();
29  auto && params = pixelCPE->getParameters( clust, *hit.detUnit(), tsos);
30  return std::unique_ptr<SiPixelRecHit>(new SiPixelRecHit(std::get<0>(params), std::get<1>(params), std::get<2>(params), *hit.det(), hit.cluster()));
31 }
32 
33 std::unique_ptr<SiStripRecHit2D> TkClonerImpl::operator()(SiStripRecHit2D const & hit, TrajectoryStateOnSurface const& tsos) const {
35  const SiStripCluster& clust = hit.stripCluster();
37  stripCPE->localParameters( clust, *hit.detUnit(), tsos);
38  return std::unique_ptr<SiStripRecHit2D>{new SiStripRecHit2D(lv.first, lv.second, *hit.det(), hit.omniCluster())};
39 }
40 
41 std::unique_ptr<SiStripRecHit1D> TkClonerImpl::operator()(SiStripRecHit1D const & hit, TrajectoryStateOnSurface const& tsos) const {
43  const SiStripCluster& clust = hit.stripCluster();
45  stripCPE->localParameters( clust, *hit.detUnit(), tsos);
46  LocalError le(lv.second.xx(),0.,std::numeric_limits<float>::max()); //Correct??
47  return std::unique_ptr<SiStripRecHit1D>{new SiStripRecHit1D(lv.first, le, *hit.det(), hit.omniCluster())};
48 }
49 
50 std::unique_ptr<Phase2TrackerRecHit1D> TkClonerImpl::operator()(Phase2TrackerRecHit1D const & hit, TrajectoryStateOnSurface const& tsos) const {
51  const Phase2TrackerCluster1D& clust = hit.phase2OTCluster();
52  const PixelGeomDetUnit & gdu = (const PixelGeomDetUnit &) *(hit.detUnit()) ;
53  auto && params = phase2TrackerCPE->localParameters( clust, gdu );
54  return std::unique_ptr<Phase2TrackerRecHit1D>{new Phase2TrackerRecHit1D(params.first, params.second, *hit.det(), hit.cluster())};
55 }
56 
58  // std::cout << "cloning " << typeid(hit).name() << std::endl;
59  const SiPixelCluster& clust = *hit.cluster();
60  auto && params = pixelCPE->getParameters( clust, *hit.detUnit(), tsos);
61  return std::make_shared<SiPixelRecHit>(std::get<0>(params), std::get<1>(params), std::get<2>(params), *hit.det(), hit.cluster());
62 }
63 
65  // std::cout << "cloning " << typeid(hit).name() << std::endl;
67  const SiStripCluster& clust = hit.stripCluster();
69  stripCPE->localParameters( clust, *hit.detUnit(), tsos);
70  return std::make_shared<SiStripRecHit2D>(lv.first, lv.second, *hit.det(), hit.omniCluster());
71 }
72 
74  // std::cout << "cloning " << typeid(hit).name() << std::endl;
76  const SiStripCluster& clust = hit.stripCluster();
78  stripCPE->localParameters( clust, *hit.detUnit(), tsos);
79  LocalError le(lv.second.xx(),0.,std::numeric_limits<float>::max()); //Correct??
80  return std::make_shared<SiStripRecHit1D>(lv.first, le, *hit.det(), hit.omniCluster());
81 }
82 
84  const Phase2TrackerCluster1D& clust = hit.phase2OTCluster();
85  const PixelGeomDetUnit & gdu = (const PixelGeomDetUnit &) *(hit.detUnit()) ;
86  auto && params = phase2TrackerCPE->localParameters( clust, gdu );
87  return std::unique_ptr<Phase2TrackerRecHit1D>{new Phase2TrackerRecHit1D(params.first, params.second, *hit.det(), hit.cluster())};
88 }
89 
90 
91 namespace {
92 #undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj
93 #undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL
94 #ifdef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL
95 // Local lo Global lo Local
96  inline LocalTrajectoryParameters gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
97  const BoundPlane &stripPlane = gdet->stereoDet()->surface();
98  LocalPoint lp = stripPlane.toLocal(tsos.globalPosition());
99  LocalVector ld = stripPlane.toLocal(tsos.globalParameters().momentum());
100  return LocalTrajectoryParameters(lp,ld,tsos.charge());
101  }
102 #elif defined(RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj)
103  // A la RecHitProjector
104  inline LocalTrajectoryParameters gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
105  const BoundPlane &stripPlane = gdet->stereoDet()->surface();
106  double delta = stripPlane.localZ( tsos.globalPosition());
107  LocalVector ld = stripPlane.toLocal(tsos.globalParameters().momentum());
108  LocalPoint lp = stripPlane.toLocal(tsos.globalPosition()) - ld*delta/ld.z();
109  return LocalTrajectoryParameters(lp,ld,tsos.charge());
110  }
111 #else
112  // Dummy
113  inline const LocalTrajectoryParameters & gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
114  return tsos.localParameters();
115  }
116 #endif
117 }
118 
119 std::unique_ptr<SiStripMatchedRecHit2D> TkClonerImpl::operator()(SiStripMatchedRecHit2D const & hit, TrajectoryStateOnSurface const& tsos) const {
120  const GeomDet * det = hit.det();
121  const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (det);
122  LocalVector tkDir = (tsos.isValid() ? tsos.localDirection() :
123  det->surface().toLocal( det->position()-GlobalPoint(0,0,0)));
124 
125  const SiStripCluster& monoclust = hit.monoCluster();
126  const SiStripCluster& stereoclust = hit.stereoCluster();
127 
129  stripCPE->localParameters( monoclust, *gdet->monoDet(), tsos);
131  stripCPE->localParameters( stereoclust, *gdet->stereoDet(), gluedToStereo(tsos, gdet));
132 
133  SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
134  *gdet->monoDet(),
135  hit.monoClusterRef());
136  SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
137  *gdet->stereoDet(),
138  hit.stereoClusterRef());
139 
140  // return theMatcher->match(&monoHit,&stereoHit,gdet,tkDir,true);
141  std::unique_ptr<SiStripMatchedRecHit2D> temp = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir,false);
142  if(temp.get() == nullptr) {
143  temp = std::unique_ptr<SiStripMatchedRecHit2D>(hit.clone());
144  }
145  return temp;
146 }
147 
150  return TrackingRecHit::ConstRecHitPointer((*this)(hit,tsos));
151 }
152 
154  // std::cout << "cloning " << typeid(hit).name() << std::endl;
155  return TrackingRecHit::ConstRecHitPointer((*this)(hit,tsos));
156 }
157 
158 std::unique_ptr<ProjectedSiStripRecHit2D> TkClonerImpl::operator()(ProjectedSiStripRecHit2D const & hit, TrajectoryStateOnSurface const& tsos) const {
159  const SiStripCluster& clust = hit.stripCluster();
160  const GeomDetUnit * gdu = reinterpret_cast<const GeomDetUnit *>(hit.originalDet());
161  //if (!gdu) std::cout<<"no luck dude"<<std::endl;
163 
164  // project...
165  const GeomDet & det = *hit.det();
166  const BoundPlane& gluedPlane = det.surface();
167  const BoundPlane& hitPlane = gdu->surface();
168  LocalVector tkDir = (tsos.isValid() ? tsos.localDirection() :
169  det.surface().toLocal( det.position()-GlobalPoint(0,0,0)));
170 
171  auto delta = gluedPlane.localZ( hitPlane.position());
172  LocalVector ldir = tkDir;
173  LocalPoint lhitPos = gluedPlane.toLocal( hitPlane.toGlobal(lv.first));
174  LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.z();
175 
176  LocalVector hitXAxis = gluedPlane.toLocal( hitPlane.toGlobal( LocalVector(1.f,0,0)));
177  LocalError hitErr = lv.second;
178  if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
179  // the two planes are inverted, and the correlation element must change sign
180  hitErr = LocalError( hitErr.xx(), -hitErr.xy(), hitErr.yy());
181  }
182  LocalError rotatedError = hitErr.rotate( hitXAxis.x(), hitXAxis.y());
183  return std::unique_ptr<ProjectedSiStripRecHit2D>{new ProjectedSiStripRecHit2D(projectedHitPos, rotatedError, *hit.det(), *hit.originalDet(), hit.omniCluster())};
184 }
185 
186 
187 std::unique_ptr<ProjectedSiStripRecHit2D> TkClonerImpl::project(SiStripMatchedRecHit2D const & hit, bool mono, TrajectoryStateOnSurface const& tsos) const {
188  const GeomDet & det = *hit.det();
189  const GluedGeomDet & gdet = static_cast<const GluedGeomDet &> (det);
190  const GeomDetUnit * odet = mono ? gdet.monoDet() : gdet.stereoDet();
191  const BoundPlane& gluedPlane = det.surface();
192  const BoundPlane& hitPlane = odet->surface();
193 
194 
195  LocalVector tkDir = (tsos.isValid() ? tsos.localDirection() :
196  det.surface().toLocal( det.position()-GlobalPoint(0,0,0)));
197 
198  const SiStripCluster& monoclust = hit.monoCluster();
199  const SiStripCluster& stereoclust = hit.stereoCluster();
200 
202  if (tsos.isValid())
203  lv = mono ?
204  stripCPE->localParameters( monoclust, *odet, tsos) :
205  stripCPE->localParameters( stereoclust, *odet, gluedToStereo(tsos, &gdet));
206  else
207  lv = stripCPE->localParameters( mono ? monoclust : stereoclust, *odet);
208 
209 
210  auto delta = gluedPlane.localZ( hitPlane.position());
211  LocalVector ldir = tkDir;
212  LocalPoint lhitPos = gluedPlane.toLocal( hitPlane.toGlobal(lv.first));
213  LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.z();
214 
215  LocalVector hitXAxis = gluedPlane.toLocal( hitPlane.toGlobal( LocalVector(1.f,0,0)));
216  LocalError hitErr = lv.second;
217  if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
218  // the two planes are inverted, and the correlation element must change sign
219  hitErr = LocalError( hitErr.xx(), -hitErr.xy(), hitErr.yy());
220  }
221  LocalError rotatedError = hitErr.rotate( hitXAxis.x(), hitXAxis.y());
222  return std::unique_ptr<ProjectedSiStripRecHit2D>{
223  new ProjectedSiStripRecHit2D(projectedHitPos, rotatedError, det, *odet,
224  mono ? hit.monoClusterRef() : hit.stereoClusterRef() ) };
225 }
dbl * delta
Definition: mlp_gen.cc:36
float xx() const
Definition: LocalError.h:24
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
const LocalTrajectoryParameters & localParameters() const
SiStripCluster const & monoCluster() const
LocalVector localDirection() const
OmniClusterRef const & stereoClusterRef() const
virtual void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters &ltp) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const PixelClusterParameterEstimator * pixelCPE
Definition: TkClonerImpl.h:46
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
std::pair< LocalPoint, LocalError > LocalValues
virtual TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:57
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
virtual ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const =0
virtual LocalValues localParameters(const T &, const GeomDetUnit &) const =0
float xy() const
Definition: LocalError.h:25
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:48
const StripClusterParameterEstimator * stripCPE
Definition: TkClonerImpl.h:47
float yy() const
Definition: LocalError.h:26
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const GeomDet * det() const
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
OmniClusterRef const & omniCluster() const
const GeomDetUnit * originalDet() const
double f[11][100]
OmniClusterRef const & monoClusterRef() const
virtual std::unique_ptr< SiPixelRecHit > operator()(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:27
const GeomDetUnit * detUnit() const
const ClusterParameterEstimator< Phase2TrackerCluster1D > * phase2TrackerCPE
Definition: TkClonerImpl.h:49
const SiStripRecHitMatcher * theMatcher
Definition: TkClonerImpl.h:48
const GlobalTrajectoryParameters & globalParameters() const
SiStripCluster const & stripCluster() const
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
std::unique_ptr< SiStripMatchedRecHit2D > match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection, bool force=false) const
std::unique_ptr< ProjectedSiStripRecHit2D > project(SiStripMatchedRecHit2D const &hit, bool mono, TrajectoryStateOnSurface const &tsos) const
SiStripCluster const & stereoCluster() const
Pixel cluster – collection of neighboring pixels above threshold.
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
Phase2TrackerCluster1D const & phase2OTCluster() const
T x() const
Definition: PV3DBase.h:62
virtual SiStripMatchedRecHit2D * clone() const
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
Our base class.
Definition: SiPixelRecHit.h:23