CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
VectorHit.cc
Go to the documentation of this file.
3 #include "CLHEP/Units/PhysicalConstants.h"
4 
6  const LocalPoint& posLower,
7  const LocalVector& dir,
8  const AlgebraicSymMatrix44& covMatrix,
9  const float chi2,
10  OmniClusterRef const& lower,
11  OmniClusterRef const& upper,
12  const float curvature,
13  const float curvatureError,
14  const float phi)
15  : BaseTrackerRecHit(idet, trackerHitRTTI::vector),
16  thePosition(posLower),
17  theDirection(dir),
18  theCovMatrix(covMatrix),
19  theChi2(chi2),
20  theLowerCluster(lower),
21  theUpperCluster(upper),
22  theCurvature(curvature),
23  theCurvatureError(curvatureError),
24  thePhi(phi) {}
25 
27  const VectorHit2D& vh2Dzx,
28  const VectorHit2D& vh2Dzy,
29  OmniClusterRef const& lower,
30  OmniClusterRef const& upper,
31  const float curvature,
32  const float curvatureError,
33  const float phi)
34  : BaseTrackerRecHit(idet, trackerHitRTTI::vector),
35  thePosition(LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.)),
36  theDirection(LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.)),
37  theLowerCluster(lower),
38  theUpperCluster(upper),
39  theCurvature(curvature),
40  theCurvatureError(curvatureError),
41  thePhi(phi) {
42  //building the cov matrix 4x4 starting from the 2x2
43  const AlgebraicSymMatrix22& covMatZX = vh2Dzx.covMatrix();
44  const AlgebraicSymMatrix22& covMatZY = vh2Dzy.covMatrix();
45 
47 
48  theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz)
49  theCovMatrix[1][1] = covMatZY[0][0]; // var(dy/dz)
50  theCovMatrix[2][2] = covMatZX[1][1]; // var(x)
51  theCovMatrix[3][3] = covMatZY[1][1]; // var(y)
52  theCovMatrix[0][2] = covMatZX[0][1]; // cov(dx/dz,x)
53  theCovMatrix[1][3] = covMatZY[0][1]; // cov(dy/dz,y)
54 
55  theChi2 = vh2Dzx.chi2() + vh2Dzy.chi2();
56 }
57 
58 bool VectorHit::sharesInput(const TrackingRecHit* other, SharedInputType what) const {
59  if (what == all && (geographicalId() != other->geographicalId()))
60  return false;
61 
62  if (!sameDetModule(*other))
63  return false;
64 
65  if (trackerHitRTTI::isVector(*other)) {
66  const VectorHit* otherVh = static_cast<const VectorHit*>(other);
67  return sharesClusters(*otherVh, what);
68  }
69 
70  if (what == all)
71  return false;
72 
73  // what about multi???
74  auto const& otherClus = reinterpret_cast<const BaseTrackerRecHit*>(other)->firstClusterRef();
75  return (otherClus == lowerClusterRef()) || (otherClus == upperClusterRef());
76 }
77 
78 bool VectorHit::sharesClusters(VectorHit const& other, SharedInputType what) const {
79  bool lower = this->lowerClusterRef() == other.lowerClusterRef();
80  bool upper = this->upperClusterRef() == other.upperClusterRef();
81 
82  return (what == TrackingRecHit::all) ? (lower && upper) : (upper || lower);
83 }
84 
86  AlgebraicVector4& pars = holder.params<theDimension>();
87  pars[0] = theDirection.x();
88  pars[1] = theDirection.y();
89  pars[2] = thePosition.x();
90  pars[3] = thePosition.y();
91 
92  holder.errors<theDimension>() = theCovMatrix;
93 
95  for (int i = 0; i < 4; ++i)
96  pf.index[i] = i + 1;
97 
99  holder.measuredErrors<theDimension>() = holder.tsosLocalErrors().Sub<AlgebraicSymMatrix44>(1, 1);
100 }
101 
103  const StackGeomDet* stackDet = static_cast<const StackGeomDet*>(det());
104  const PixelGeomDetUnit* geomDetLower = static_cast<const PixelGeomDetUnit*>(stackDet->lowerDet());
105  return phase2clusterGlobalPos(geomDetLower, lowerCluster());
106 }
107 
109  const StackGeomDet* stackDet = static_cast<const StackGeomDet*>(det());
110  const PixelGeomDetUnit* geomDetUpper = static_cast<const PixelGeomDetUnit*>(stackDet->upperDet());
111  return phase2clusterGlobalPos(geomDetUpper, upperCluster());
112 }
113 
115  const PixelTopology* topo = &geomDet->specificTopology();
116  float ix = cluster->center();
117  float iy = cluster->column() + 0.5f; // halfway the column
118  LocalPoint lp(topo->localX(ix), topo->localY(iy), 0); // x, y, z
119  Global3DPoint gp = geomDet->surface().toGlobal(lp);
120  return gp;
121 }
122 
124  const StackGeomDet* stackDet = static_cast<const StackGeomDet*>(det());
125  const PixelGeomDetUnit* geomDetLower = static_cast<const PixelGeomDetUnit*>(stackDet->lowerDet());
126  return phase2clusterGlobalPosErr(geomDetLower);
127 }
128 
130  const StackGeomDet* stackDet = static_cast<const StackGeomDet*>(det());
131  const PixelGeomDetUnit* geomDetUpper = static_cast<const PixelGeomDetUnit*>(stackDet->upperDet());
132  return phase2clusterGlobalPosErr(geomDetUpper);
133 }
134 
136  const PixelTopology* topo = &geomDet->specificTopology();
137  float pitchX = topo->pitch().first;
138  float pitchY = topo->pitch().second;
139  constexpr float invTwelve = 1. / 12;
140  LocalError le(pow(pitchX, 2) * invTwelve, 0, pow(pitchY, 2) * invTwelve); // e2_xx, e2_xy, e2_yy
141  GlobalError ge(ErrorFrameTransformer().transform(le, geomDet->surface()));
142  return ge;
143 }
144 
146  Local3DVector theLocalDelta =
148  Global3DVector g = det()->surface().toGlobal(theLocalDelta);
149  return g;
150 }
151 
153 
154 float VectorHit::theta() const { return globalDirection().theta(); }
155 
157  return magField * (CLHEP::c_light * 1e-5F) / theCurvature;
158  // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, using precise value from speed of light
159  // because curvature is a signed quantity this transverse momentum is also signed
160 }
161 float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta())); }
162 
164  return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
165 }
166 
168  return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
169 }
170 
172 
173 std::ostream& operator<<(std::ostream& os, const VectorHit& vh) {
174  os << " VectorHit create in the DetId#: " << vh.geographicalId() << "\n"
175  << " Vectorhit local position : " << vh.localPosition() << "\n"
176  << " Vectorhit local direction : " << vh.localDirection() << "\n"
177  << " Vectorhit global direction : " << vh.globalDirection() << "\n"
178  << " Lower cluster global position : " << vh.lowerGlobalPos() << "\n"
179  << " Upper cluster global position : " << vh.upperGlobalPos();
180 
181  return os;
182 }
183 
185 std::vector<const TrackingRecHit*> VectorHit::recHits() const { return {}; }
186 
188 std::vector<TrackingRecHit*> VectorHit::recHits() { return {}; }
SharedInputType
definition of equality via shared input
const GeomDetUnit * lowerDet() const
Definition: StackGeomDet.h:19
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
static Global3DPoint phase2clusterGlobalPos(const PixelGeomDetUnit *geomDet, ClusterRef cluster)
Definition: VectorHit.cc:114
Local3DVector LocalVector
Definition: LocalVector.h:12
virtual LocalVector localDirection() const
Definition: VectorHit.h:75
GlobalError lowerGlobalPosErr() const
Definition: VectorHit.cc:123
const auto & magField
GlobalError upperGlobalPosErr() const
Definition: VectorHit.cc:129
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T y() const
Definition: PV3DBase.h:60
OmniClusterRef const upperClusterRef() const
Definition: VectorHit.h:94
bool sharesInput(const TrackingRecHit *other, SharedInputType what) const override
Definition: VectorHit.cc:58
void getKfComponents4D(KfComponentsHolder &holder) const
Definition: VectorHit.cc:85
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
bool sameDetModule(TrackingRecHit const &hit) const
float transverseMomentum(float magField) const
Definition: VectorHit.cc:156
LocalPoint thePosition
Definition: VectorHit.h:127
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
LocalError localDirectionError() const
Definition: VectorHit.cc:167
T curvature(T InversePt, const MagneticField &field)
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: VectorHit.cc:185
static constexpr int theDimension
Definition: VectorHit.h:139
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
virtual float localX(float mpX) const =0
AlgebraicSymMatrix44 theCovMatrix
Definition: VectorHit.h:137
bool sharesClusters(VectorHit const &other, SharedInputType what) const
Definition: VectorHit.cc:78
AlgebraicROOTObject< D, D >::SymMatrix & measuredErrors()
ClusterRef upperCluster() const
Definition: VectorHit.h:92
const GeomDet * det() const
T z() const
Definition: PV3DBase.h:61
float momentum(float magField) const
Definition: VectorHit.cc:161
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > AlgebraicSymMatrix44
Global3DPoint upperGlobalPos() const
Definition: VectorHit.cc:108
static GlobalError phase2clusterGlobalPosErr(const PixelGeomDetUnit *geomDet)
Definition: VectorHit.cc:135
ROOT::Math::SVector< double, 4 > AlgebraicVector4
Global3DVector globalDirection() const
Definition: VectorHit.cc:152
const AlgebraicSymMatrix44 & covMatrix() const
Definition: VectorHit.cc:171
ClusterRef lowerCluster() const
&quot;lower&quot; is logical, not geometrically lower; in pixel-strip modules the &quot;lower&quot; is always a pixel ...
Definition: VectorHit.h:91
OmniClusterRef const lowerClusterRef() const
Definition: VectorHit.h:93
LocalError localPositionError() const override
Definition: VectorHit.cc:163
AlgebraicROOTObject< D >::Vector & params()
ValidHit vh
Definition: classes.h:14
AlgebraicROOTObject< D, D >::SymMatrix & errors()
ProjectMatrix< double, 5, D > & projFunc()
float theCurvature
Definition: VectorHit.h:142
LocalPoint localPosition() const override
Definition: VectorHit.h:74
virtual float localY(float mpY) const =0
const AlgebraicSymMatrix22 & covMatrix() const
Definition: VectorHit2D.h:24
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
const AlgebraicVector5 & tsosLocalParameters() const
VectorHit()
Definition: VectorHit.h:32
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
LocalVector theDirection
Definition: VectorHit.h:128
bool isVector(TrackingRecHit const &hit)
AlgebraicROOTObject< D >::Vector & measuredParams()
float theta() const
Definition: VectorHit.cc:154
const GeomDetUnit * upperDet() const
Definition: StackGeomDet.h:20
const Surface * surface() const final
float x
Global3DPoint lowerGlobalPos() const
Definition: VectorHit.cc:102
OmniClusterRef const & firstClusterRef() const override
Definition: VectorHit.h:107
float chi2() const
Definition: VectorHit2D.h:25
virtual std::pair< float, float > pitch() const =0
DetId geographicalId() const
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
float theChi2
Definition: VectorHit.h:138
T x() const
Definition: PV3DBase.h:59
const AlgebraicSymMatrix55 & tsosLocalErrors() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
Global3DVector globalDirectionVH() const
Definition: VectorHit.cc:145
unsigned transform(const HcalDetId &id, unsigned transformCode)