test
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 
8 
11 
12 
15 
20 
21 #include<iostream>
22 #include <memory>
23 
24 std::unique_ptr<SiPixelRecHit> TkClonerImpl::operator()(SiPixelRecHit const & hit, TrajectoryStateOnSurface const& tsos) const {
25  const SiPixelCluster& clust = *hit.cluster();
26  auto && params = pixelCPE->getParameters( clust, *hit.detUnit(), tsos);
27  return std::unique_ptr<SiPixelRecHit>(new SiPixelRecHit(std::get<0>(params), std::get<1>(params), std::get<2>(params), *hit.det(), hit.cluster()));
28 }
29 
30 std::unique_ptr<SiStripRecHit2D> TkClonerImpl::operator()(SiStripRecHit2D const & hit, TrajectoryStateOnSurface const& tsos) const {
32  const SiStripCluster& clust = hit.stripCluster();
34  stripCPE->localParameters( clust, *hit.detUnit(), tsos);
35  return std::unique_ptr<SiStripRecHit2D>{new SiStripRecHit2D(lv.first, lv.second, *hit.det(), hit.omniCluster())};
36 }
37 
38 std::unique_ptr<SiStripRecHit1D> TkClonerImpl::operator()(SiStripRecHit1D const & hit, TrajectoryStateOnSurface const& tsos) const {
40  const SiStripCluster& clust = hit.stripCluster();
42  stripCPE->localParameters( clust, *hit.detUnit(), tsos);
43  LocalError le(lv.second.xx(),0.,std::numeric_limits<float>::max()); //Correct??
44  return std::unique_ptr<SiStripRecHit1D>{new SiStripRecHit1D(lv.first, le, *hit.det(), hit.omniCluster())};
45 }
46 
48  // std::cout << "cloning " << typeid(hit).name() << std::endl;
49  const SiPixelCluster& clust = *hit.cluster();
50  auto && params = pixelCPE->getParameters( clust, *hit.detUnit(), tsos);
51  return std::make_shared<SiPixelRecHit>(std::get<0>(params), std::get<1>(params), std::get<2>(params), *hit.det(), hit.cluster());
52 }
53 
55  // std::cout << "cloning " << typeid(hit).name() << std::endl;
57  const SiStripCluster& clust = hit.stripCluster();
59  stripCPE->localParameters( clust, *hit.detUnit(), tsos);
60  return std::make_shared<SiStripRecHit2D>(lv.first, lv.second, *hit.det(), hit.omniCluster());
61 }
62 
64  // std::cout << "cloning " << typeid(hit).name() << std::endl;
66  const SiStripCluster& clust = hit.stripCluster();
68  stripCPE->localParameters( clust, *hit.detUnit(), tsos);
69  LocalError le(lv.second.xx(),0.,std::numeric_limits<float>::max()); //Correct??
70  return std::make_shared<SiStripRecHit1D>(lv.first, le, *hit.det(), hit.omniCluster());
71 }
72 
73 
74 
75 namespace {
76 #undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj
77 #undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL
78 #ifdef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL
79 // Local lo Global lo Local
80  inline LocalTrajectoryParameters gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
81  const BoundPlane &stripPlane = gdet->stereoDet()->surface();
82  LocalPoint lp = stripPlane.toLocal(tsos.globalPosition());
83  LocalVector ld = stripPlane.toLocal(tsos.globalParameters().momentum());
84  return LocalTrajectoryParameters(lp,ld,tsos.charge());
85  }
86 #elif defined(RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj)
87  // A la RecHitProjector
88  inline LocalTrajectoryParameters gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
89  const BoundPlane &stripPlane = gdet->stereoDet()->surface();
90  double delta = stripPlane.localZ( tsos.globalPosition());
91  LocalVector ld = stripPlane.toLocal(tsos.globalParameters().momentum());
92  LocalPoint lp = stripPlane.toLocal(tsos.globalPosition()) - ld*delta/ld.z();
93  return LocalTrajectoryParameters(lp,ld,tsos.charge());
94  }
95 #else
96  // Dummy
97  inline const LocalTrajectoryParameters & gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
98  return tsos.localParameters();
99  }
100 #endif
101 }
102 
103 std::unique_ptr<SiStripMatchedRecHit2D> TkClonerImpl::operator()(SiStripMatchedRecHit2D const & hit, TrajectoryStateOnSurface const& tsos) const {
104  const GeomDet * det = hit.det();
105  const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (det);
106  LocalVector tkDir = (tsos.isValid() ? tsos.localDirection() :
107  det->surface().toLocal( det->position()-GlobalPoint(0,0,0)));
108 
109  const SiStripCluster& monoclust = hit.monoCluster();
110  const SiStripCluster& stereoclust = hit.stereoCluster();
111 
113  stripCPE->localParameters( monoclust, *gdet->monoDet(), tsos);
115  stripCPE->localParameters( stereoclust, *gdet->stereoDet(), gluedToStereo(tsos, gdet));
116 
117  SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
118  *gdet->monoDet(),
119  hit.monoClusterRef());
120  SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
121  *gdet->stereoDet(),
122  hit.stereoClusterRef());
123 
124  // return theMatcher->match(&monoHit,&stereoHit,gdet,tkDir,true);
125  std::unique_ptr<SiStripMatchedRecHit2D> temp = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir,false);
126  if(temp.get() == nullptr) {
127  temp = std::unique_ptr<SiStripMatchedRecHit2D>(hit.clone());
128  }
129  return temp;
130 }
131 
134  return TrackingRecHit::ConstRecHitPointer((*this)(hit,tsos));
135 }
136 
138  // std::cout << "cloning " << typeid(hit).name() << std::endl;
139  return TrackingRecHit::ConstRecHitPointer((*this)(hit,tsos));
140 }
141 
142 std::unique_ptr<ProjectedSiStripRecHit2D> TkClonerImpl::operator()(ProjectedSiStripRecHit2D const & hit, TrajectoryStateOnSurface const& tsos) const {
143  const SiStripCluster& clust = hit.stripCluster();
144  const GeomDetUnit * gdu = reinterpret_cast<const GeomDetUnit *>(hit.originalDet());
145  //if (!gdu) std::cout<<"no luck dude"<<std::endl;
147 
148  // project...
149  const GeomDet & det = *hit.det();
150  const BoundPlane& gluedPlane = det.surface();
151  const BoundPlane& hitPlane = gdu->surface();
152  LocalVector tkDir = (tsos.isValid() ? tsos.localDirection() :
153  det.surface().toLocal( det.position()-GlobalPoint(0,0,0)));
154 
155  auto delta = gluedPlane.localZ( hitPlane.position());
156  LocalVector ldir = tkDir;
157  LocalPoint lhitPos = gluedPlane.toLocal( hitPlane.toGlobal(lv.first));
158  LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.z();
159 
160  LocalVector hitXAxis = gluedPlane.toLocal( hitPlane.toGlobal( LocalVector(1.f,0,0)));
161  LocalError hitErr = lv.second;
162  if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
163  // the two planes are inverted, and the correlation element must change sign
164  hitErr = LocalError( hitErr.xx(), -hitErr.xy(), hitErr.yy());
165  }
166  LocalError rotatedError = hitErr.rotate( hitXAxis.x(), hitXAxis.y());
167  return std::unique_ptr<ProjectedSiStripRecHit2D>{new ProjectedSiStripRecHit2D(projectedHitPos, rotatedError, *hit.det(), *hit.originalDet(), hit.omniCluster())};
168 }
169 
170 
171 std::unique_ptr<ProjectedSiStripRecHit2D> TkClonerImpl::project(SiStripMatchedRecHit2D const & hit, bool mono, TrajectoryStateOnSurface const& tsos) const {
172  const GeomDet & det = *hit.det();
173  const GluedGeomDet & gdet = static_cast<const GluedGeomDet &> (det);
174  const GeomDetUnit * odet = mono ? gdet.monoDet() : gdet.stereoDet();
175  const BoundPlane& gluedPlane = det.surface();
176  const BoundPlane& hitPlane = odet->surface();
177 
178 
179  LocalVector tkDir = (tsos.isValid() ? tsos.localDirection() :
180  det.surface().toLocal( det.position()-GlobalPoint(0,0,0)));
181 
182  const SiStripCluster& monoclust = hit.monoCluster();
183  const SiStripCluster& stereoclust = hit.stereoCluster();
184 
186  if (tsos.isValid())
187  lv = mono ?
188  stripCPE->localParameters( monoclust, *odet, tsos) :
189  stripCPE->localParameters( stereoclust, *odet, gluedToStereo(tsos, &gdet));
190  else
191  lv = stripCPE->localParameters( mono ? monoclust : stereoclust, *odet);
192 
193 
194  auto delta = gluedPlane.localZ( hitPlane.position());
195  LocalVector ldir = tkDir;
196  LocalPoint lhitPos = gluedPlane.toLocal( hitPlane.toGlobal(lv.first));
197  LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.z();
198 
199  LocalVector hitXAxis = gluedPlane.toLocal( hitPlane.toGlobal( LocalVector(1.f,0,0)));
200  LocalError hitErr = lv.second;
201  if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
202  // the two planes are inverted, and the correlation element must change sign
203  hitErr = LocalError( hitErr.xx(), -hitErr.xy(), hitErr.yy());
204  }
205  LocalError rotatedError = hitErr.rotate( hitXAxis.x(), hitXAxis.y());
206  return std::unique_ptr<ProjectedSiStripRecHit2D>{
207  new ProjectedSiStripRecHit2D(projectedHitPos, rotatedError, det, *odet,
208  mono ? hit.monoClusterRef() : hit.stereoClusterRef() ) };
209 }
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:40
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:47
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
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:41
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:24
const GeomDetUnit * detUnit() const
const SiStripRecHitMatcher * theMatcher
Definition: TkClonerImpl.h:42
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
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