Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:54

0001 #ifndef Candidate_ParticleState_h
0002 #define Candidate_ParticleState_h
0003 /** \class reco::ParticleState
0004  *
0005  * Base class describing a generic reconstructed particle
0006  * its main subclass is Candidate
0007  *
0008  * \author Luca Lista, INFN
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     /// electric charge type
0025     typedef int Charge;
0026     /// Lorentz vector
0027     typedef math::XYZTLorentzVector LorentzVector;
0028     /// Lorentz vector
0029     typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
0030     /// point in the space
0031     typedef math::XYZPoint Point;
0032     /// point in the space
0033     typedef math::XYZVector Vector;
0034     /// default constructor
0035     ParticleState() : vertex_(0, 0, 0), qx3_(0), pdgId_(0), status_(0) {}
0036 
0037     /// constructor from values
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     /// constructor from values
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     /// constructor from values
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     /// set internal cache
0095     inline void setCartesian() { p4Cartesian_ = p4Polar_; }
0096 
0097     /// electric charge
0098     int charge() const { return qx3_ / 3; }
0099     /// set electric charge
0100     void setCharge(Charge q) { qx3_ = q * 3; }
0101     /// electric charge
0102     int threeCharge() const { return qx3_; }
0103     /// set electric charge
0104     void setThreeCharge(Charge qx3) { qx3_ = qx3; }
0105     /// four-momentum Lorentz vector
0106     const LorentzVector& p4() const { return p4Cartesian_; }
0107     /// four-momentum Lorentz vector
0108     const PolarLorentzVector& polarP4() const { return p4Polar_; }
0109     /// spatial momentum vector
0110     Vector momentum() const { return p4Cartesian_.Vect(); }
0111     /// boost vector to boost a Lorentz vector
0112     /// to the particle center of mass system
0113     Vector boostToCM() const { return p4Cartesian_.BoostToCM(); }
0114     /// magnitude of momentum vector
0115     double p() const { return p4Cartesian_.P(); }
0116     /// energy
0117     double energy() const { return p4Cartesian_.E(); }
0118     /// transverse energy
0119     double et() const { return (pt() <= 0) ? 0 : p4Cartesian_.Et(); }
0120     /// transverse energy squared (use this for cuts)!
0121     double et2() const { return (pt() <= 0) ? 0 : p4Cartesian_.Et2(); }
0122     /// mass
0123     double mass() const { return p4Polar_.mass(); }
0124     /// mass squared
0125     double massSqr() const { return mass() * mass(); }
0126     /// transverse mass
0127     double mt() const { return p4Polar_.Mt(); }
0128     /// transverse mass squared
0129     double mtSqr() const { return p4Polar_.Mt2(); }
0130     /// x coordinate of momentum vector
0131     double px() const { return p4Cartesian_.Px(); }
0132     /// y coordinate of momentum vector
0133     double py() const { return p4Cartesian_.Py(); }
0134     /// z coordinate of momentum vector
0135     double pz() const { return p4Cartesian_.Pz(); }
0136     /// transverse momentum
0137     double pt() const { return p4Polar_.pt(); }
0138     /// momentum azimuthal angle
0139     double phi() const { return p4Polar_.phi(); }
0140     /// momentum polar angle
0141     double theta() const { return p4Cartesian_.Theta(); }
0142     /// momentum pseudorapidity
0143     double eta() const { return p4Polar_.eta(); }
0144     /// repidity
0145     double rapidity() const { return p4Polar_.Rapidity(); }
0146     /// repidity
0147     double y() const { return rapidity(); }
0148     /// set 4-momentum
0149     void setP4(const LorentzVector& p4) {
0150       p4Cartesian_ = p4;
0151       p4Polar_ = p4;
0152     }
0153     /// set 4-momentum
0154     void setP4(const PolarLorentzVector& p4) {
0155       p4Polar_ = p4;
0156       p4Cartesian_ = p4;
0157     }
0158     /// set particle mass
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     /// vertex position
0168     const Point& vertex() const { return vertex_; }
0169     /// x coordinate of vertex position
0170     double vx() const { return vertex_.X(); }
0171     /// y coordinate of vertex position
0172     double vy() const { return vertex_.Y(); }
0173     /// z coordinate of vertex position
0174     double vz() const { return vertex_.Z(); }
0175     /// set vertex
0176     void setVertex(const Point& vertex) { vertex_ = vertex; }
0177     /// PDG identifier
0178     int pdgId() const { return pdgId_; }
0179     // set PDG identifier
0180     void setPdgId(int pdgId) { pdgId_ = pdgId; }
0181     /// status word
0182     int status() const { return status_; }
0183     /// set status word
0184     void setStatus(int status) { status_ = status; }
0185     /// set long lived flag
0186     void setLongLived() { status_ |= longLivedTag; }
0187     /// is long lived?
0188     bool longLived() const { return status_ & longLivedTag; }
0189     /// set mass constraint flag
0190     void setMassConstraint() { status_ |= massConstraintTag; }
0191     /// do mass constraint?
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     /// vertex position
0200     Point vertex_;
0201 
0202     /// four-momentum Lorentz vector
0203     PolarLorentzVector p4Polar_;
0204     /// internal cache for p4
0205     LorentzVector p4Cartesian_;
0206 
0207     /// electric charge
0208     Charge qx3_;
0209 
0210     /// PDG identifier
0211     int pdgId_;
0212     /// status word
0213     int status_;
0214   };
0215 
0216 }  // namespace reco
0217 
0218 #endif