File indexing completed on 2023-03-17 10:51:35
0001 #ifndef _TRACKER_LOCALTRAJECTORYPARAMETERS_H_
0002 #define _TRACKER_LOCALTRAJECTORYPARAMETERS_H_
0003
0004 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0005 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0006 #include "DataFormats/TrajectoryState/interface/TrackCharge.h"
0007 #include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
0008
0009 #include <cmath>
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 class LocalTrajectoryParameters {
0026 public:
0027
0028
0029 LocalTrajectoryParameters() {}
0030
0031
0032
0033
0034
0035
0036
0037
0038 LocalTrajectoryParameters(const AlgebraicVector5& v, float aPzSign, bool charged = true) {
0039 theQbp = v[0];
0040 theDxdz = v[1];
0041 theDydz = v[2];
0042 theX = v[3];
0043 theY = v[4];
0044 thePzSign = aPzSign;
0045 if (charged)
0046 theCharge = theQbp > 0 ? 1 : -1;
0047 else
0048 theCharge = 0;
0049 }
0050
0051
0052
0053
0054
0055
0056
0057
0058 LocalTrajectoryParameters(float aQbp, float aDxdz, float aDydz, float aX, float aY, float aPzSign, bool charged = true)
0059 : theDxdz(aDxdz), theDydz(aDydz), theX(aX), theY(aY), thePzSign(aPzSign > 0 ? 1 : -1) {
0060 if (charged) {
0061 theQbp = aQbp;
0062 theCharge = theQbp > 0 ? 1 : -1;
0063 } else {
0064 theQbp = aQbp;
0065 theCharge = 0;
0066 }
0067 }
0068
0069
0070 LocalTrajectoryParameters(const LocalPoint& pos, const LocalVector& p, TrackCharge charge)
0071 : theQbp(charge / p.mag()),
0072 theDxdz(p.x() / p.z()),
0073 theDydz(p.y() / p.z()),
0074 theX(pos.x()),
0075 theY(pos.y()),
0076 thePzSign(p.z() > 0. ? 1 : -1),
0077 theCharge(charge) {
0078 if (charge == 0)
0079 theQbp = 1.f / p.mag();
0080 }
0081
0082
0083
0084
0085 LocalPoint position() const { return LocalPoint(theX, theY); }
0086
0087
0088 LocalVector momentum() const {
0089 float op = std::abs(theQbp);
0090 if (op < 1.e-9f)
0091 op = 1.e-9f;
0092 float pz = float(thePzSign) / (op * std::sqrt(1.f + theDxdz * theDxdz + theDydz * theDydz));
0093 float px = pz * theDxdz;
0094 float py = pz * theDydz;
0095 return LocalVector(px, py, pz);
0096 }
0097
0098
0099 LocalVector direction() const {
0100 float dz = float(thePzSign) / std::sqrt(1.f + theDxdz * theDxdz + theDydz * theDydz);
0101 float dx = dz * theDxdz;
0102 float dy = dz * theDydz;
0103 return LocalVector(dx, dy, dz);
0104 }
0105
0106
0107 LocalVector directionNotNormalized() const { return LocalVector(theDxdz, theDydz, 1.f); }
0108
0109
0110 TrackCharge charge() const { return theCharge; }
0111
0112
0113 float signedInverseMomentum() const { return charge() == 0 ? 0.f : theQbp; }
0114
0115
0116
0117
0118
0119
0120 AlgebraicVector5 vector() const {
0121 AlgebraicVector5 v;
0122 v[0] = signedInverseMomentum();
0123 v[1] = theDxdz;
0124 v[2] = theDydz;
0125 v[3] = theX;
0126 v[4] = theY;
0127 return v;
0128 }
0129
0130
0131
0132
0133
0134
0135 AlgebraicVector5 mixedFormatVector() const {
0136 AlgebraicVector5 v;
0137 v[0] = theQbp;
0138 v[1] = theDxdz;
0139 v[2] = theDydz;
0140 v[3] = theX;
0141 v[4] = theY;
0142 return v;
0143 }
0144
0145
0146 float pzSign() const { return thePzSign; }
0147
0148
0149 bool updateP(float dP) {
0150 float p = 1.f / std::abs(theQbp);
0151 if ((p += dP) <= 0.f)
0152 return false;
0153 float newQbp = theQbp > 0. ? 1.f / p : -1.f / p;
0154 theQbp = newQbp;
0155 return true;
0156 }
0157
0158 float qbp() const { return theQbp; }
0159 float dxdz() const { return theDxdz; }
0160 float dydz() const { return theDydz; }
0161 float absdz() const { return 1.f / std::sqrt(1.f + theDxdz * theDxdz + theDydz * theDydz); }
0162
0163 private:
0164 float theQbp;
0165 float theDxdz;
0166 float theDydz;
0167 float theX;
0168 float theY;
0169
0170 short thePzSign;
0171
0172 short theCharge;
0173 };
0174
0175 #endif