Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:34

0001 #include <cmath>
0002 #include <vector>
0003 
0004 #include <Math/GenVector/PxPyPzE4D.h>
0005 #include <Math/GenVector/PxPyPzM4D.h>
0006 
0007 #include "DataFormats/BTauReco/interface/ParticleMasses.h"
0008 #include "DataFormats/Math/interface/LorentzVector.h"
0009 #include "DataFormats/TrackReco/interface/Track.h"
0010 #include "DataFormats/VertexReco/interface/Vertex.h"
0011 
0012 #include "RecoBTag/SecondaryVertex/interface/TrackKinematics.h"
0013 
0014 using namespace reco;
0015 
0016 TrackKinematics::TrackKinematics() : n(0), sumWeights(0) {}
0017 
0018 TrackKinematics::TrackKinematics(const std::vector<Track> &tracks) : n(0), sumWeights(0) {
0019   for (std::vector<Track>::const_iterator iter = tracks.begin(); iter != tracks.end(); iter++)
0020     add(*iter);
0021 }
0022 
0023 TrackKinematics::TrackKinematics(const TrackRefVector &tracks) : n(0), sumWeights(0) {
0024   for (TrackRefVector::const_iterator iter = tracks.begin(); iter != tracks.end(); iter++)
0025     add(**iter);
0026 }
0027 
0028 TrackKinematics::TrackKinematics(const std::vector<CandidatePtr> &tracks) : n(0), sumWeights(0) {
0029   for (std::vector<CandidatePtr>::const_iterator iter = tracks.begin(); iter != tracks.end(); iter++)
0030     add(*iter);
0031 }
0032 
0033 TrackKinematics::TrackKinematics(const CandidatePtrVector &tracks) : n(0), sumWeights(0) {
0034   for (CandidatePtrVector::const_iterator iter = tracks.begin(); iter != tracks.end(); iter++)
0035     add(*iter);
0036 }
0037 
0038 TrackKinematics::TrackKinematics(const Vertex &vertex) : n(0), sumWeights(0) {
0039   bool hasRefittedTracks = vertex.hasRefittedTracks();
0040   for (Vertex::trackRef_iterator iter = vertex.tracks_begin(); iter != vertex.tracks_end(); ++iter) {
0041     if (hasRefittedTracks)
0042       add(vertex.refittedTrack(*iter), vertex.trackWeight(*iter));
0043     else
0044       add(**iter, vertex.trackWeight(*iter));
0045   }
0046 }
0047 
0048 TrackKinematics &TrackKinematics::operator+=(const TrackKinematics &other) {
0049   n += other.n;
0050   sumWeights += other.sumWeights;
0051   sum += other.sum;
0052   weightedSum += other.weightedSum;
0053 
0054   return *this;
0055 }
0056 
0057 void TrackKinematics::add(const Track &track, double weight) {
0058   ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
0059 
0060   vec.SetPx(track.px());
0061   vec.SetPy(track.py());
0062   vec.SetPz(track.pz());
0063   vec.SetM(ParticleMasses::piPlus);
0064 
0065   n++;
0066   sumWeights += weight;
0067   sum += vec;
0068   weightedSum += weight * vec;
0069 }
0070 
0071 void TrackKinematics::add(const CandidatePtr &track) {
0072   double weight = 1.0;
0073 
0074   n++;
0075   sumWeights += weight;
0076   sum += track->p4();
0077   weightedSum += weight * track->p4();
0078 }