File indexing completed on 2024-04-06 12:01:02
0001 #ifndef CommonTools_BaseParticlePropagator_RawParticle_h
0002 #define CommonTools_BaseParticlePropagator_RawParticle_h
0003
0004 #include "DataFormats/Math/interface/LorentzVector.h"
0005 #include "DataFormats/Math/interface/Vector3D.h"
0006
0007 #include "Math/GenVector/RotationX.h"
0008 #include "Math/GenVector/RotationY.h"
0009 #include "Math/GenVector/RotationZ.h"
0010 #include "Math/GenVector/Rotation3D.h"
0011 #include "Math/GenVector/AxisAngle.h"
0012 #include "Math/GenVector/Boost.h"
0013
0014 #include <string>
0015 #include <iosfwd>
0016
0017 #include <memory>
0018
0019
0020
0021
0022
0023
0024
0025 typedef math::XYZTLorentzVector XYZTLorentzVector;
0026 typedef math::XYZVector XYZVector;
0027
0028 class RawParticle;
0029
0030 namespace rawparticle {
0031
0032
0033
0034 RawParticle makeMuon(bool isParticle, const XYZTLorentzVector& p, const XYZTLorentzVector& xStart);
0035 }
0036
0037 class RawParticle {
0038 public:
0039 friend RawParticle rawparticle::makeMuon(bool, const XYZTLorentzVector&, const XYZTLorentzVector&);
0040 friend RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector& p, double mass, double charge);
0041 friend RawParticle unchecked_makeParticle(
0042 int id, const math::XYZTLorentzVector& p, const math::XYZTLorentzVector& xStart, double mass, double charge);
0043
0044 typedef ROOT::Math::AxisAngle Rotation;
0045 typedef ROOT::Math::Rotation3D Rotation3D;
0046 typedef ROOT::Math::RotationX RotationX;
0047 typedef ROOT::Math::RotationY RotationY;
0048 typedef ROOT::Math::RotationZ RotationZ;
0049 typedef ROOT::Math::Boost Boost;
0050
0051 RawParticle() = default;
0052
0053
0054
0055
0056 RawParticle(const XYZTLorentzVector& p);
0057
0058
0059
0060
0061 RawParticle(const XYZTLorentzVector& p, const XYZTLorentzVector& xStart, double charge = 0.);
0062
0063
0064
0065
0066 RawParticle(double px, double py, double pz, double e, double charge = 0.);
0067
0068
0069 RawParticle(const RawParticle& p) = default;
0070 RawParticle(RawParticle&& p) = default;
0071
0072
0073 RawParticle& operator=(const RawParticle& rhs) = default;
0074 RawParticle& operator=(RawParticle&& rhs) = default;
0075
0076 public:
0077
0078
0079
0080
0081 void setStatus(int istat);
0082
0083
0084 void setMass(float m);
0085
0086
0087 void setCharge(float q);
0088
0089
0090 void setT(const double t);
0091
0092
0093 void setVertex(const XYZTLorentzVector& vtx);
0094 void setVertex(double xv, double yv, double zv, double tv);
0095
0096
0097 void setMomentum(const XYZTLorentzVector& vtx);
0098 void setMomentum(double xv, double yv, double zv, double tv);
0099
0100 void SetPx(double);
0101 void SetPy(double);
0102 void SetPz(double);
0103 void SetE(double);
0104
0105
0106
0107
0108
0109
0110
0111 void boost(double bx, double by, double bz);
0112 void boost(const Boost& b);
0113
0114
0115
0116
0117
0118
0119
0120
0121 void rotate(double rphi, const XYZVector& raxis);
0122 void rotate(const Rotation& r);
0123 void rotate(const Rotation3D& r);
0124
0125
0126
0127
0128
0129
0130
0131 void rotateX(double rphi);
0132 void rotate(const RotationX& r);
0133
0134
0135
0136
0137
0138 void rotateY(double rphi);
0139 void rotate(const RotationY& r);
0140
0141
0142
0143
0144 void rotateZ(double rphi);
0145 void rotate(const RotationZ& r);
0146
0147
0148 void translate(const XYZVector& t);
0149
0150
0151
0152
0153
0154
0155
0156
0157 void chargeConjugate();
0158
0159 int pid() const;
0160
0161 int status() const;
0162
0163 double charge() const;
0164
0165 double mass() const;
0166
0167
0168
0169
0170 double eta() const;
0171
0172
0173 double cos2Theta() const;
0174 double cos2ThetaV() const;
0175
0176 double et() const;
0177
0178 double x() const;
0179 double X() const;
0180
0181 double y() const;
0182 double Y() const;
0183
0184 double z() const;
0185 double Z() const;
0186
0187 double t() const;
0188 double T() const;
0189
0190 double r() const;
0191 double R() const;
0192
0193 double r2() const;
0194 double R2() const;
0195
0196 const XYZTLorentzVector& vertex() const;
0197
0198 double px() const;
0199 double Px() const;
0200
0201 double py() const;
0202 double Py() const;
0203
0204 double pz() const;
0205 double Pz() const;
0206
0207 double e() const;
0208 double E() const;
0209
0210 double Pt() const;
0211 double pt() const;
0212
0213 double Perp2() const;
0214
0215 double mag() const;
0216
0217 double theta() const;
0218 double phi() const;
0219
0220 double M2() const;
0221
0222 const XYZTLorentzVector& momentum() const;
0223 XYZTLorentzVector& momentum();
0224
0225 XYZVector Vect() const;
0226
0227
0228
0229
0230
0231
0232 void printName() const;
0233
0234
0235
0236
0237
0238 void print() const;
0239
0240
0241
0242
0243
0244 int isUsed() const { return myUsed; }
0245
0246
0247
0248 void use() { myUsed = 1; }
0249
0250
0251
0252 void reUse() { myUsed = 0; }
0253
0254 private:
0255
0256
0257
0258 RawParticle(const int id, const XYZTLorentzVector& p, double mass, double charge);
0259
0260
0261
0262
0263 RawParticle(const int id, const XYZTLorentzVector& p, const XYZTLorentzVector& xStart, double mass, double charge);
0264
0265 private:
0266 XYZTLorentzVector myMomentum;
0267 XYZTLorentzVector myVertex;
0268 double myCharge = 0.;
0269 double myMass = 0.;
0270 int myId = 0;
0271 int myStatus = 99;
0272 int myUsed = 0;
0273 };
0274
0275 std::ostream& operator<<(std::ostream& o, const RawParticle& p);
0276
0277 inline int RawParticle::pid() const { return myId; }
0278 inline int RawParticle::status() const { return myStatus; }
0279 inline double RawParticle::eta() const { return -std::log(std::tan(this->theta() / 2.)); }
0280 inline double RawParticle::cos2Theta() const { return Pz() * Pz() / myMomentum.Vect().Mag2(); }
0281 inline double RawParticle::cos2ThetaV() const { return Z() * Z() / myVertex.Vect().Mag2(); }
0282 inline double RawParticle::x() const { return myVertex.Px(); }
0283 inline double RawParticle::y() const { return myVertex.Py(); }
0284 inline double RawParticle::z() const { return myVertex.Pz(); }
0285 inline double RawParticle::t() const { return myVertex.E(); }
0286 inline double RawParticle::X() const { return myVertex.Px(); }
0287 inline double RawParticle::Y() const { return myVertex.Py(); }
0288 inline double RawParticle::Z() const { return myVertex.Pz(); }
0289 inline double RawParticle::T() const { return myVertex.E(); }
0290 inline double RawParticle::R() const { return std::sqrt(R2()); }
0291 inline double RawParticle::R2() const { return myVertex.Perp2(); }
0292 inline double RawParticle::r() const { return std::sqrt(r2()); }
0293 inline double RawParticle::r2() const { return myVertex.Perp2(); }
0294 inline double RawParticle::charge() const { return myCharge; }
0295 inline double RawParticle::mass() const { return myMass; }
0296 inline double RawParticle::px() const { return myMomentum.px(); }
0297 inline double RawParticle::Px() const { return myMomentum.Px(); }
0298
0299 inline double RawParticle::py() const { return myMomentum.py(); }
0300 inline double RawParticle::Py() const { return myMomentum.Py(); }
0301
0302 inline double RawParticle::pz() const { return myMomentum.pz(); }
0303 inline double RawParticle::Pz() const { return myMomentum.Pz(); }
0304
0305 inline double RawParticle::e() const { return myMomentum.e(); }
0306 inline double RawParticle::E() const { return myMomentum.E(); }
0307
0308 inline double RawParticle::Pt() const { return myMomentum.Pt(); }
0309 inline double RawParticle::pt() const { return myMomentum.pt(); }
0310
0311 inline double RawParticle::Perp2() const { return myMomentum.Perp2(); }
0312
0313 inline double RawParticle::mag() const { return myMomentum.mag(); }
0314
0315 inline double RawParticle::theta() const { return myMomentum.theta(); }
0316 inline double RawParticle::phi() const { return myMomentum.phi(); }
0317
0318 inline double RawParticle::M2() const { return myMomentum.M2(); }
0319
0320 inline const XYZTLorentzVector& RawParticle::vertex() const { return myVertex; }
0321 inline const XYZTLorentzVector& RawParticle::momentum() const { return myMomentum; }
0322 inline XYZTLorentzVector& RawParticle::momentum() { return myMomentum; }
0323 inline XYZVector RawParticle::Vect() const { return myMomentum.Vect(); }
0324
0325 inline void RawParticle::setVertex(const XYZTLorentzVector& vtx) { myVertex = vtx; }
0326 inline void RawParticle::setVertex(double a, double b, double c, double d) { myVertex.SetXYZT(a, b, c, d); }
0327
0328 inline void RawParticle::setMomentum(const XYZTLorentzVector& p4) { myMomentum = p4; }
0329 inline void RawParticle::setMomentum(double a, double b, double c, double d) { myMomentum.SetXYZT(a, b, c, d); }
0330
0331 inline void RawParticle::SetPx(double px) { myMomentum.SetPx(px); }
0332 inline void RawParticle::SetPy(double py) { myMomentum.SetPy(py); }
0333 inline void RawParticle::SetPz(double pz) { myMomentum.SetPz(pz); }
0334 inline void RawParticle::SetE(double e) { myMomentum.SetE(e); }
0335
0336 inline void RawParticle::rotate(const RawParticle::Rotation3D& r) {
0337 XYZVector v(r(myMomentum.Vect()));
0338 setMomentum(v.X(), v.Y(), v.Z(), E());
0339 }
0340
0341 inline void RawParticle::rotate(const RawParticle::Rotation& r) {
0342 XYZVector v(r(myMomentum.Vect()));
0343 setMomentum(v.X(), v.Y(), v.Z(), E());
0344 }
0345
0346 inline void RawParticle::rotate(const RawParticle::RotationX& r) {
0347 XYZVector v(r(myMomentum.Vect()));
0348 setMomentum(v.X(), v.Y(), v.Z(), E());
0349 }
0350
0351 inline void RawParticle::rotate(const RawParticle::RotationY& r) {
0352 XYZVector v(r(myMomentum.Vect()));
0353 setMomentum(v.X(), v.Y(), v.Z(), E());
0354 }
0355
0356 inline void RawParticle::rotate(const RawParticle::RotationZ& r) {
0357 XYZVector v(r(myMomentum.Vect()));
0358 setMomentum(v.X(), v.Y(), v.Z(), E());
0359 }
0360
0361 inline void RawParticle::boost(const RawParticle::Boost& b) {
0362 XYZTLorentzVector p(b(momentum()));
0363 setMomentum(p.Px(), p.Py(), p.Pz(), p.E());
0364 }
0365
0366 inline void RawParticle::translate(const XYZVector& tr) {
0367 myVertex.SetXYZT(X() + tr.X(), Y() + tr.Y(), Z() + tr.Z(), T());
0368 }
0369
0370 #endif