File indexing completed on 2024-04-06 12:03:49
0001 #ifndef Candidate_ParticleState_h
0002 #define Candidate_ParticleState_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "DataFormats/Math/interface/Point3D.h"
0014 #include "DataFormats/Math/interface/Vector3D.h"
0015 #include "DataFormats/Math/interface/PtEtaPhiMass.h"
0016 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0017 #include "DataFormats/Math/interface/LorentzVector.h"
0018 #include "Rtypes.h"
0019
0020 namespace reco {
0021
0022 class ParticleState {
0023 public:
0024
0025 typedef int Charge;
0026
0027 typedef math::XYZTLorentzVector LorentzVector;
0028
0029 typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
0030
0031 typedef math::XYZPoint Point;
0032
0033 typedef math::XYZVector Vector;
0034
0035 ParticleState() : vertex_(0, 0, 0), qx3_(0), pdgId_(0), status_(0) {}
0036
0037
0038 ParticleState(Charge q,
0039 const PtEtaPhiMass& p4,
0040 const Point& vertex = Point(0, 0, 0),
0041 int pdgId = 0,
0042 int status = 0,
0043 bool integerCharge = true)
0044 : vertex_(vertex),
0045 p4Polar_(p4.pt(), p4.eta(), p4.phi(), p4.mass()),
0046 p4Cartesian_(p4Polar_),
0047 qx3_(integerCharge ? q * 3 : q),
0048 pdgId_(pdgId),
0049 status_(status) {}
0050
0051
0052 ParticleState(Charge q,
0053 const LorentzVector& p4,
0054 const Point& vertex = Point(0, 0, 0),
0055 int pdgId = 0,
0056 int status = 0,
0057 bool integerCharge = true)
0058 : vertex_(vertex),
0059 p4Polar_(p4),
0060 p4Cartesian_(p4),
0061 qx3_(integerCharge ? q * 3 : q),
0062 pdgId_(pdgId),
0063 status_(status) {}
0064
0065
0066 ParticleState(Charge q,
0067 const PolarLorentzVector& p4,
0068 const Point& vertex = Point(0, 0, 0),
0069 int pdgId = 0,
0070 int status = 0,
0071 bool integerCharge = true)
0072 : vertex_(vertex),
0073 p4Polar_(p4),
0074 p4Cartesian_(p4),
0075 qx3_(integerCharge ? q * 3 : q),
0076 pdgId_(pdgId),
0077 status_(status) {}
0078
0079 ParticleState(Charge q,
0080 const GlobalVector& p3,
0081 float iEnergy,
0082 float imass,
0083 const Point& vertex = Point(0, 0, 0),
0084 int pdgId = 0,
0085 int status = 0,
0086 bool integerCharge = true)
0087 : vertex_(vertex),
0088 p4Polar_(p3.perp(), p3.eta(), p3.phi(), imass),
0089 p4Cartesian_(p3.x(), p3.y(), p3.z(), iEnergy),
0090 qx3_(integerCharge ? q * 3 : q),
0091 pdgId_(pdgId),
0092 status_(status) {}
0093
0094
0095 inline void setCartesian() { p4Cartesian_ = p4Polar_; }
0096
0097
0098 int charge() const { return qx3_ / 3; }
0099
0100 void setCharge(Charge q) { qx3_ = q * 3; }
0101
0102 int threeCharge() const { return qx3_; }
0103
0104 void setThreeCharge(Charge qx3) { qx3_ = qx3; }
0105
0106 const LorentzVector& p4() const { return p4Cartesian_; }
0107
0108 const PolarLorentzVector& polarP4() const { return p4Polar_; }
0109
0110 Vector momentum() const { return p4Cartesian_.Vect(); }
0111
0112
0113 Vector boostToCM() const { return p4Cartesian_.BoostToCM(); }
0114
0115 double p() const { return p4Cartesian_.P(); }
0116
0117 double energy() const { return p4Cartesian_.E(); }
0118
0119 double et() const { return (pt() <= 0) ? 0 : p4Cartesian_.Et(); }
0120
0121 double et2() const { return (pt() <= 0) ? 0 : p4Cartesian_.Et2(); }
0122
0123 double mass() const { return p4Polar_.mass(); }
0124
0125 double massSqr() const { return mass() * mass(); }
0126
0127 double mt() const { return p4Polar_.Mt(); }
0128
0129 double mtSqr() const { return p4Polar_.Mt2(); }
0130
0131 double px() const { return p4Cartesian_.Px(); }
0132
0133 double py() const { return p4Cartesian_.Py(); }
0134
0135 double pz() const { return p4Cartesian_.Pz(); }
0136
0137 double pt() const { return p4Polar_.pt(); }
0138
0139 double phi() const { return p4Polar_.phi(); }
0140
0141 double theta() const { return p4Cartesian_.Theta(); }
0142
0143 double eta() const { return p4Polar_.eta(); }
0144
0145 double rapidity() const { return p4Polar_.Rapidity(); }
0146
0147 double y() const { return rapidity(); }
0148
0149 void setP4(const LorentzVector& p4) {
0150 p4Cartesian_ = p4;
0151 p4Polar_ = p4;
0152 }
0153
0154 void setP4(const PolarLorentzVector& p4) {
0155 p4Polar_ = p4;
0156 p4Cartesian_ = p4;
0157 }
0158
0159 void setMass(double m) {
0160 p4Polar_.SetM(m);
0161 setCartesian();
0162 }
0163 void setPz(double pz) {
0164 p4Cartesian_.SetPz(pz);
0165 p4Polar_ = p4Cartesian_;
0166 }
0167
0168 const Point& vertex() const { return vertex_; }
0169
0170 double vx() const { return vertex_.X(); }
0171
0172 double vy() const { return vertex_.Y(); }
0173
0174 double vz() const { return vertex_.Z(); }
0175
0176 void setVertex(const Point& vertex) { vertex_ = vertex; }
0177
0178 int pdgId() const { return pdgId_; }
0179
0180 void setPdgId(int pdgId) { pdgId_ = pdgId; }
0181
0182 int status() const { return status_; }
0183
0184 void setStatus(int status) { status_ = status; }
0185
0186 void setLongLived() { status_ |= longLivedTag; }
0187
0188 bool longLived() const { return status_ & longLivedTag; }
0189
0190 void setMassConstraint() { status_ |= massConstraintTag; }
0191
0192 bool massConstraint() const { return status_ & massConstraintTag; }
0193
0194 private:
0195 static const unsigned int longLivedTag = 65536;
0196 static const unsigned int massConstraintTag = 131072;
0197
0198 private:
0199
0200 Point vertex_;
0201
0202
0203 PolarLorentzVector p4Polar_;
0204
0205 LorentzVector p4Cartesian_;
0206
0207
0208 Charge qx3_;
0209
0210
0211 int pdgId_;
0212
0213 int status_;
0214 };
0215
0216 }
0217
0218 #endif