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 
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)
Definition: weight.py:1
auto const & tracks
cannot be loose
fixed size matrix
math::XYZTLorentzVector sum
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38