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 }
Vector3DBase< float, LocalTag >
GeomDet::position
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
TrajectoryStateOnSurface.h
TkClonerImpl::pixelCPE
const PixelClusterParameterEstimator * pixelCPE
Definition: TkClonerImpl.h:59
TkClonerImpl::makeShared
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:64
GeomDet
Definition: GeomDet.h:27
Phase2TrackerCluster1D
Definition: Phase2TrackerCluster1D.h:10
LocalError::xy
float xy() const
Definition: LocalError.h:23
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
PixelClusterParameterEstimator.h
SiPixelCluster.h
TrajectoryStateOnSurface::charge
TrackCharge charge() const
Definition: TrajectoryStateOnSurface.h:68
GluedGeomDet::monoDet
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:19
GluedGeomDet.h
SiStripRecHit2D
Definition: SiStripRecHit2D.h:7
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:28
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
TkClonerImpl::project
std::unique_ptr< ProjectedSiStripRecHit2D > project(SiStripMatchedRecHit2D const &hit, bool mono, TrajectoryStateOnSurface const &tsos) const
Definition: TkClonerImpl.cc:202
ProjectedSiStripRecHit2D
Definition: ProjectedSiStripRecHit2D.h:8
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
LocalError::xx
float xx() const
Definition: LocalError.h:22
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, LocalTag >
SiPixelRecHit.h
TkClonerImpl::theMatcher
const SiStripRecHitMatcher * theMatcher
Definition: TkClonerImpl.h:61
GluedGeomDet
Definition: GluedGeomDet.h:7
GlobalTrajectoryParameters::momentum
GlobalVector momentum() const
Definition: GlobalTrajectoryParameters.h:65
TrajectoryStateOnSurface::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: TrajectoryStateOnSurface.h:73
Phase2TrackerRecHit1D.h
SiStripCluster.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LocalError
Definition: LocalError.h:12
LocalError::rotate
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
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
TkCloner::tsos
TrackingRecHit TrajectoryStateOnSurface const &const tsos
Definition: TkCloner.h:18
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
TrackingRecHit::ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Definition: TrackingRecHit.h:25
ClusterParameterEstimator::localParameters
virtual LocalValues localParameters(const T &, const GeomDetUnit &) const =0
TkClonerImpl::stripCPE
const StripClusterParameterEstimator * stripCPE
Definition: TkClonerImpl.h:60
ProjectedSiStripRecHit2D.h
TkClonerImpl.h
StripClusterParameterEstimator::localParameters
virtual void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters &ltp) const
Definition: StripClusterParameterEstimator.h:32
SiStripRecHit1D
Definition: SiStripRecHit1D.h:8
SiStripRecHit1D.h
GluedGeomDet::stereoDet
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:20
VectorHit
Definition: VectorHit.h:28
GeomDet.h
SiStripRecHitMatcher.h
SiStripMatchedRecHit2D
Definition: SiStripMatchedRecHit2D.h:8
TkClonerImpl::operator()
std::unique_ptr< SiPixelRecHit > operator()(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:27
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
BoundPlane
PixelGeomDetUnit.h
TkClonerImpl::phase2TrackerCPE
const ClusterParameterEstimator< Phase2TrackerCluster1D > * phase2TrackerCPE
Definition: TkClonerImpl.h:62
PixelClusterParameterEstimator::getParameters
virtual ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const =0
StripClusterParameterEstimator.h
StripClusterParameterEstimator::LocalValues
std::pair< LocalPoint, LocalError > LocalValues
Definition: StripClusterParameterEstimator.h:27
TrajectoryStateOnSurface::globalParameters
const GlobalTrajectoryParameters & globalParameters() const
Definition: TrajectoryStateOnSurface.h:64
SiStripMatchedRecHit2D.h
SiStripCluster
Definition: SiStripCluster.h:8
TrackingRecHit::isValid
bool isValid() const
Definition: TrackingRecHit.h:141
SiStripRecHit2D.h
LocalError::yy
float yy() const
Definition: LocalError.h:24
hit
Definition: SiStripHitEffFromCalibTree.cc:88
Phase2TrackerRecHit1D
Definition: Phase2TrackerRecHit1D.h:10
VectorHit.h
SiStripRecHitMatcher::match
std::unique_ptr< SiStripMatchedRecHit2D > match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection, bool force) const
Definition: SiStripRecHitMatcher.cc:239