CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
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 {
33  iter != tracks.end(); iter++)
34  add(**iter);
35 }
36 
38  n(0), sumWeights(0)
39 {
40  bool hasRefittedTracks = vertex.hasRefittedTracks();
42  iter != vertex.tracks_end(); ++iter) {
43  if (hasRefittedTracks)
44  add(vertex.refittedTrack(*iter),
45  vertex.trackWeight(*iter));
46  else
47  add(**iter, vertex.trackWeight(*iter));
48  }
49 }
50 
52 {
53  n += other.n;
54  sumWeights += other.sumWeights;
55  sum += other.sum;
56  weightedSum += other.weightedSum;
57 
58  return *this;
59 }
60 
61 void TrackKinematics::add(const Track &track, double weight)
62 {
63  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
64 
65  vec.SetPx(track.px());
66  vec.SetPy(track.py());
67  vec.SetPz(track.pz());
68  vec.SetM(ParticleMasses::piPlus);
69 
70  n++;
71  sumWeights += weight;
72  sum += vec;
73  weightedSum += weight * vec;
74 }
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:44
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:134
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:580
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:592
tuple tracks
Definition: testEve_cfg.py:39
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
int weight
Definition: histoStyle.py:50
math::XYZTLorentzVector sum
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:586