CMS 3D CMS Logo

TrackKinematics.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <vector>
3 
4 #include <Math/GenVector/PxPyPzE4D.h>
5 #include <Math/GenVector/PxPyPzM4D.h>
6 
11 
13 
14 using namespace reco;
15 
17  n(0), sumWeights(0)
18 {
19 }
20 
21 TrackKinematics::TrackKinematics(const std::vector<Track> &tracks) :
22  n(0), sumWeights(0)
23 {
24  for(std::vector<Track>::const_iterator iter = tracks.begin();
25  iter != tracks.end(); iter++)
26  add(*iter);
27 }
28 
30  n(0), sumWeights(0)
31 {
32  for(TrackRefVector::const_iterator iter = tracks.begin();
33  iter != tracks.end(); iter++)
34  add(**iter);
35 }
36 
37 TrackKinematics::TrackKinematics(const std::vector<CandidatePtr> &tracks) :
38  n(0), sumWeights(0)
39 {
40  for(std::vector<CandidatePtr>::const_iterator iter = tracks.begin();
41  iter != tracks.end(); iter++)
42  add(*iter);
43 }
44 
46  n(0), sumWeights(0)
47 {
48  for(CandidatePtrVector::const_iterator iter = tracks.begin();
49  iter != tracks.end(); iter++)
50  add(*iter);
51 }
52 
54  n(0), sumWeights(0)
55 {
56  bool hasRefittedTracks = vertex.hasRefittedTracks();
57  for(Vertex::trackRef_iterator iter = vertex.tracks_begin();
58  iter != vertex.tracks_end(); ++iter) {
59  if (hasRefittedTracks)
60  add(vertex.refittedTrack(*iter),
61  vertex.trackWeight(*iter));
62  else
63  add(**iter, vertex.trackWeight(*iter));
64  }
65 }
66 
68 {
69  n += other.n;
70  sumWeights += other.sumWeights;
71  sum += other.sum;
72  weightedSum += other.weightedSum;
73 
74  return *this;
75 }
76 
77 void TrackKinematics::add(const Track &track, double weight)
78 {
79  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
80 
81  vec.SetPx(track.px());
82  vec.SetPy(track.py());
83  vec.SetPz(track.pz());
84  vec.SetM(ParticleMasses::piPlus);
85 
86  n++;
87  sumWeights += weight;
88  sum += vec;
89  weightedSum += weight * vec;
90 }
91 
93 {
94  double weight = 1.0;
95 
96  n++;
97  sumWeights += weight;
98  sum += track->p4();
99  weightedSum += weight * track->p4();
100 }
const double piPlus
Definition: ParticleMasses.h:9
math::XYZTLorentzVector weightedSum
TrackKinematics & operator+=(const TrackKinematics &other)
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
void add(const reco::Track &track, double weight=1.0)
Track refittedTrack(const TrackBaseRef &track) const
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
Definition: Vertex.h:149
Definition: weight.py:1
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:666
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:253
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:248
const_iterator begin() const
Definition: PtrVector.h:129
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
const_iterator end() const
Definition: PtrVector.h:134
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:81
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:678
fixed size matrix
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
math::XYZTLorentzVector sum
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:672