Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:45

0001 #ifndef RecoBTag_SecondaryVertex_TrackKinematics_h
0002 #define RecoBTag_SecondaryVertex_TrackKinematics_h
0003 
0004 #include <vector>
0005 
0006 #include "DataFormats/Math/interface/LorentzVector.h"
0007 #include "DataFormats/TrackReco/interface/Track.h"
0008 #include "DataFormats/Candidate/interface/Candidate.h"
0009 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0010 #include "DataFormats/VertexReco/interface/Vertex.h"
0011 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0012 #include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"
0013 
0014 namespace reco {
0015 
0016   class TrackKinematics {
0017   public:
0018     TrackKinematics();
0019     TrackKinematics(const std::vector<reco::Track> &tracks);
0020     TrackKinematics(const reco::TrackRefVector &tracks);
0021     TrackKinematics(const std::vector<reco::CandidatePtr> &tracks);
0022     TrackKinematics(const reco::CandidatePtrVector &tracks);
0023     TrackKinematics(const reco::Vertex &vertex);
0024     TrackKinematics(const reco::VertexCompositePtrCandidate &vertex)
0025         : n(vertex.numberOfSourceCandidatePtrs()),
0026           sumWeights(vertex.numberOfSourceCandidatePtrs()),
0027           sum(vertex.p4()),
0028           weightedSum(vertex.p4()) {}
0029 
0030     ~TrackKinematics() {}
0031 
0032     void add(const reco::Track &track, double weight = 1.0);
0033     void add(const reco::CandidatePtr &track);
0034 
0035     inline void add(const reco::TrackRef &track, double weight = 1.0) { return add(*track, weight); }
0036 
0037     TrackKinematics &operator+=(const TrackKinematics &other);
0038     inline TrackKinematics operator+(const TrackKinematics &other) {
0039       TrackKinematics copy = *this;
0040       copy += other;
0041       return copy;
0042     }
0043 
0044     inline unsigned int numberOfTracks() const { return n; }
0045     inline double sumOfWeights() const { return sumWeights; }
0046 
0047     inline const math::XYZTLorentzVector &vectorSum() const { return sum; }
0048     inline const math::XYZTLorentzVector &weightedVectorSum() const { return weightedSum; }
0049 
0050   private:
0051     unsigned int n;
0052     double sumWeights;
0053     math::XYZTLorentzVector sum;
0054     math::XYZTLorentzVector weightedSum;
0055   };
0056 
0057 }  // namespace reco
0058 
0059 #endif  // RecoBTag_SecondaryVertex_TrackKinematics_h