CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
16 TrackKinematics::TrackKinematics() : n(0), sumWeights(0) {}
17 
18 TrackKinematics::TrackKinematics(const std::vector<Track> &tracks) : n(0), sumWeights(0) {
19  for (std::vector<Track>::const_iterator iter = tracks.begin(); iter != tracks.end(); iter++)
20  add(*iter);
21 }
22 
24  for (TrackRefVector::const_iterator iter = tracks.begin(); iter != tracks.end(); iter++)
25  add(**iter);
26 }
27 
28 TrackKinematics::TrackKinematics(const std::vector<CandidatePtr> &tracks) : n(0), sumWeights(0) {
29  for (std::vector<CandidatePtr>::const_iterator iter = tracks.begin(); iter != tracks.end(); iter++)
30  add(*iter);
31 }
32 
34  for (CandidatePtrVector::const_iterator iter = tracks.begin(); iter != tracks.end(); iter++)
35  add(*iter);
36 }
37 
38 TrackKinematics::TrackKinematics(const Vertex &vertex) : n(0), sumWeights(0) {
39  bool hasRefittedTracks = vertex.hasRefittedTracks();
40  for (Vertex::trackRef_iterator iter = vertex.tracks_begin(); iter != vertex.tracks_end(); ++iter) {
41  if (hasRefittedTracks)
42  add(vertex.refittedTrack(*iter), vertex.trackWeight(*iter));
43  else
44  add(**iter, vertex.trackWeight(*iter));
45  }
46 }
47 
49  n += other.n;
50  sumWeights += other.sumWeights;
51  sum += other.sum;
52  weightedSum += other.weightedSum;
53 
54  return *this;
55 }
56 
57 void TrackKinematics::add(const Track &track, double weight) {
58  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
59 
60  vec.SetPx(track.px());
61  vec.SetPy(track.py());
62  vec.SetPz(track.pz());
63  vec.SetM(ParticleMasses::piPlus);
64 
65  n++;
66  sumWeights += weight;
67  sum += vec;
68  weightedSum += weight * vec;
69 }
70 
72  double weight = 1.0;
73 
74  n++;
75  sumWeights += weight;
76  sum += track->p4();
77  weightedSum += weight * track->p4();
78 }
const double piPlus
Definition: ParticleMasses.h:9
math::XYZTLorentzVector weightedSum
TrackKinematics & operator+=(const TrackKinematics &other)
void add(const reco::Track &track, double weight=1.0)
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
Definition: Vertex.h:181
auto const & tracks
cannot be loose
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:640
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
const_iterator begin() const
Definition: PtrVector.h:144
const_iterator end() const
Definition: PtrVector.h:146
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.h:110
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:96
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.h:108
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:646
Track refittedTrack(const TrackBaseRef &track) const
Definition: Vertex.cc:91
int weight
Definition: histoStyle.py:51
math::XYZTLorentzVector sum
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:38
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:643