CMS 3D CMS Logo

LocalTrajectoryParameters.h
Go to the documentation of this file.
1 #ifndef _TRACKER_LOCALTRAJECTORYPARAMETERS_H_
2 #define _TRACKER_LOCALTRAJECTORYPARAMETERS_H_
3 
8 
9 #include <cmath>
10 
26 public:
27 // construct
28 
30 
38  LocalTrajectoryParameters(const AlgebraicVector5& v, float aPzSign, bool charged = true) {
39  theQbp = v[0];
40  theDxdz = v[1];
41  theDydz = v[2];
42  theX = v[3];
43  theY = v[4];
44  thePzSign = aPzSign;
45  if ( charged )
46  theCharge = theQbp>0 ? 1 : -1;
47  else
48  theCharge = 0;
49  }
50 
51 
59  LocalTrajectoryParameters(float aQbp, float aDxdz, float aDydz,
60  float aX, float aY, float aPzSign, bool charged = true) :
61  theDxdz(aDxdz), theDydz(aDydz),
62  theX(aX), theY(aY), thePzSign(aPzSign>0 ? 1 : -1) {
63  if ( charged ) {
64  theQbp = aQbp;
65  theCharge = theQbp>0 ? 1 : -1;
66  }
67  else {
68  theQbp = aQbp;
69  theCharge = 0;
70  }
71  }
72 
76  theQbp( charge/p.mag()), theDxdz( p.x()/p.z()), theDydz( p.y()/p.z()),
77  theX( pos.x()), theY(pos.y()), thePzSign( p.z()>0. ? 1:-1), theCharge(charge) {
78  if ( charge==0 ) theQbp = 1.f/p.mag();
79  }
80 
81 // access
82 
84  LocalPoint position() const {
85  return LocalPoint(theX, theY);
86  }
87 
90  float op = std::abs(theQbp);
91  if ( op<1.e-9f ) op = 1.e-9f;
92  float pz = float(thePzSign)/(op*std::sqrt(1.f + theDxdz*theDxdz + theDydz*theDydz));
93  float px = pz*theDxdz;
94  float py = pz*theDydz;
95  return LocalVector(px, py, pz);
96  }
97 
101  float dx = dz*theDxdz;
102  float dy = dz*theDydz;
103  return LocalVector(dx, dy, dz);
104  }
105 
108  return LocalVector(theDxdz, theDydz, 1.f);
109  }
110 
111 
113  TrackCharge charge() const {return theCharge;}
114 
116  float signedInverseMomentum() const {
117  return charge()==0 ? 0.f : theQbp;
118  }
119 
127  v[0] = signedInverseMomentum();
128  v[1] = theDxdz;
129  v[2] = theDydz;
130  v[3] = theX;
131  v[4] = theY;
132  return v;
133  }
134 
142  v[0] = theQbp; // signed in case of charged particles, 1/p for neutrals
143  v[1] = theDxdz;
144  v[2] = theDydz;
145  v[3] = theX;
146  v[4] = theY;
147  return v;
148  }
149 
151  float pzSign() const {
152  return thePzSign;
153  }
154 
156  bool updateP(float dP) {
157  float p = 1.f/std::abs(theQbp);
158  if ((p += dP) <= 0.f) return false;
159  float newQbp = theQbp > 0. ? 1.f/p : -1.f/p;
160  theQbp = newQbp;
161  return true;
162  }
163 
164 
165  float qbp() const { return theQbp;}
166  float dxdz() const { return theDxdz;}
167  float dydz() const { return theDydz;}
168  float absdz() const { return 1.f/std::sqrt(1.f + theDxdz*theDxdz + theDydz*theDydz); }
169 
170 
171 private:
172  float theQbp;
173  float theDxdz;
174  float theDydz;
175  float theX;
176  float theY;
177 
178  short thePzSign;
179 
180  short theCharge;
181 
182 };
183 
184 #endif
LocalVector direction() const
Momentum vector unit in the local frame.
Local3DVector LocalVector
Definition: LocalVector.h:12
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
LocalPoint position() const
Local x and y position coordinates.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
float theQbp
q/p (charged) or 1/p (neutral)
LocalTrajectoryParameters(float aQbp, float aDxdz, float aDydz, float aX, float aY, float aPzSign, bool charged=true)
float signedInverseMomentum() const
Signed inverse momentum q/p (zero for neutrals).
AlgebraicVector5 vector() const
int TrackCharge
Definition: TrackCharge.h:4
T mag() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:18
LocalVector directionNotNormalized() const
Momentum vector unit in the local frame.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
LocalVector momentum() const
Momentum vector in the local frame.
LocalTrajectoryParameters(const LocalPoint &pos, const LocalVector &p, TrackCharge charge)
Constructor from local position, momentum and charge.
float theDxdz
tangent of direction in local x vs. z
ROOT::Math::SVector< double, 5 > AlgebraicVector5
LocalTrajectoryParameters(const AlgebraicVector5 &v, float aPzSign, bool charged=true)
float theDydz
tangent of direction in local y vs. z
AlgebraicVector5 mixedFormatVector() const
TrackCharge charge() const
Charge (-1, 0 or 1)
float pzSign() const
Sign of the z-component of the momentum in the local frame.
bool updateP(float dP)
Update of momentum by a scalar dP.