CMS 3D CMS Logo

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