CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/RecoBTag/SecondaryVertex/src/TrackKinematics.cc

Go to the documentation of this file.
00001 #include <cmath>
00002 #include <vector>
00003 
00004 #include <Math/GenVector/PxPyPzE4D.h>
00005 #include <Math/GenVector/PxPyPzM4D.h>
00006 
00007 #include "DataFormats/Math/interface/LorentzVector.h"
00008 #include "DataFormats/TrackReco/interface/Track.h"
00009 #include "DataFormats/VertexReco/interface/Vertex.h"
00010 
00011 #include "RecoBTag/SecondaryVertex/interface/ParticleMasses.h"
00012 #include "RecoBTag/SecondaryVertex/interface/TrackKinematics.h"
00013 
00014 using namespace reco;
00015 
00016 TrackKinematics::TrackKinematics() :
00017         n(0), sumWeights(0)
00018 {
00019 }
00020 
00021 TrackKinematics::TrackKinematics(const std::vector<Track> &tracks) :
00022         n(0), sumWeights(0)
00023 {
00024         for(std::vector<Track>::const_iterator iter = tracks.begin();
00025             iter != tracks.end(); iter++)
00026                 add(*iter);
00027 }
00028 
00029 TrackKinematics::TrackKinematics(const TrackRefVector &tracks) :
00030         n(0), sumWeights(0)
00031 {
00032         for(TrackRefVector::const_iterator iter = tracks.begin();
00033             iter != tracks.end(); iter++)
00034                 add(**iter);
00035 }
00036 
00037 TrackKinematics::TrackKinematics(const Vertex &vertex) :
00038         n(0), sumWeights(0)
00039 {
00040         bool hasRefittedTracks = vertex.hasRefittedTracks();
00041         for(Vertex::trackRef_iterator iter = vertex.tracks_begin();
00042             iter != vertex.tracks_end(); ++iter) {
00043                 if (hasRefittedTracks)
00044                         add(vertex.refittedTrack(*iter),
00045                             vertex.trackWeight(*iter));
00046                 else
00047                         add(**iter, vertex.trackWeight(*iter));
00048         }
00049 }
00050 
00051 TrackKinematics &TrackKinematics::operator += (const TrackKinematics &other)
00052 {
00053         n += other.n;
00054         sumWeights += other.sumWeights;
00055         sum += other.sum;
00056         weightedSum += other.weightedSum;
00057 
00058         return *this;
00059 }
00060 
00061 void TrackKinematics::add(const Track &track, double weight)
00062 {
00063         ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
00064 
00065         vec.SetPx(track.px());
00066         vec.SetPy(track.py());
00067         vec.SetPz(track.pz());
00068         vec.SetM(ParticleMasses::piPlus);
00069 
00070         n++;
00071         sumWeights += weight;
00072         sum += vec;
00073         weightedSum += weight * vec;
00074 }