CMS 3D CMS Logo

Vertex.cc
Go to the documentation of this file.
2 #include <Math/GenVector/PxPyPzE4D.h>
3 #include <Math/GenVector/PxPyPzM4D.h>
4 
5 using namespace reco;
6 using namespace std;
7 
8 Vertex::Vertex(const Point& p, const Error& err, double chi2, double ndof, size_t size)
9  : chi2_(chi2), ndof_(ndof), position_(p), time_(0.) {
10  tracks_.reserve(size);
11  index idx = 0;
12  for (index i = 0; i < dimension4D; ++i) {
13  for (index j = 0; j <= i; ++j) {
14  if (i == dimension || j == dimension) {
15  covariance_[idx++] = 0.0;
16  } else {
17  covariance_[idx++] = err(i, j);
18  }
19  }
20  }
21  validity_ = true;
22 }
23 
24 Vertex::Vertex(const Point& p, const Error4D& err, double time, double chi2, double ndof, size_t size)
25  : chi2_(chi2), ndof_(ndof), position_(p), time_(time) {
26  tracks_.reserve(size4D);
27  index idx = 0;
28  for (index i = 0; i < dimension4D; ++i)
29  for (index j = 0; j <= i; ++j)
30  covariance_[idx++] = err(i, j);
31  validity_ = true;
32 }
33 
34 Vertex::Vertex(const Point& p, const Error& err) : chi2_(0.0), ndof_(0), position_(p), time_(0.) {
35  index idx = 0;
36  for (index i = 0; i < dimension4D; ++i) {
37  for (index j = 0; j <= i; ++j) {
38  if (i == dimension || j == dimension) {
39  covariance_[idx++] = 0.0;
40  } else {
41  covariance_[idx++] = err(i, j);
42  }
43  }
44  }
45  validity_ = true;
46 }
47 
48 Vertex::Vertex(const Point& p, const Error4D& err, double time) : chi2_(0.0), ndof_(0), position_(p), time_(time) {
49  index idx = 0;
50  for (index i = 0; i < dimension + 1; ++i)
51  for (index j = 0; j <= i; ++j)
52  covariance_[idx++] = err(i, j);
53  validity_ = true;
54 }
55 
56 void Vertex::fill(Error& err) const {
57  Error4D temp;
58  fill(temp);
59  err = temp.Sub<Error>(0, 0);
60 }
61 
62 void Vertex::fill(Error4D& err) const {
63  index idx = 0;
64  for (index i = 0; i < dimension4D; ++i)
65  for (index j = 0; j <= i; ++j)
66  err(i, j) = covariance_[idx++];
67 }
68 
69 size_t Vertex::tracksSize() const { return weights_.size(); }
70 
72 
74  // if ( !(tracks_.size() ) ) createTracks();
75  return tracks_.end();
76  // return weights_.keys().end();
77 }
78 
79 void Vertex::add(const TrackBaseRef& r, float w) {
80  tracks_.push_back(r);
81  weights_.push_back(w * 255);
82 }
83 
84 void Vertex::add(const TrackBaseRef& r, const Track& refTrack, float w) {
85  tracks_.push_back(r);
86  refittedTracks_.push_back(refTrack);
87  weights_.push_back(w * 255);
88 }
89 
91  weights_.clear();
92  tracks_.clear();
93  refittedTracks_.clear();
94 }
95 
96 TrackBaseRef Vertex::originalTrack(const Track& refTrack) const {
97  if (refittedTracks_.empty())
98  throw cms::Exception("Vertex") << "No refitted tracks stored in vertex\n";
99  std::vector<Track>::const_iterator it = find_if(refittedTracks_.begin(), refittedTracks_.end(), TrackEqual(refTrack));
100  if (it == refittedTracks_.end())
101  throw cms::Exception("Vertex") << "Refitted track not found in list\n";
102  size_t pos = it - refittedTracks_.begin();
103  return tracks_[pos];
104 }
105 
107  if (refittedTracks_.empty())
108  throw cms::Exception("Vertex") << "No refitted tracks stored in vertex\n";
110  if (it == tracks_end())
111  throw cms::Exception("Vertex") << "Track not found in list\n";
112  size_t pos = it - tracks_begin();
113  return refittedTracks_[pos];
114 }
115 
117 
120  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
121 
122  if (hasRefittedTracks()) {
123  for (std::vector<Track>::const_iterator iter = refittedTracks_.begin(); iter != refittedTracks_.end(); ++iter) {
124  if (trackWeight(originalTrack(*iter)) >= minWeight) {
125  vec.SetPx(iter->px());
126  vec.SetPy(iter->py());
127  vec.SetPz(iter->pz());
128  vec.SetM(mass);
129  sum += vec;
130  }
131  }
132  } else {
133  for (std::vector<reco::TrackBaseRef>::const_iterator iter = tracks_begin(); iter != tracks_end(); iter++) {
134  if (trackWeight(*iter) >= minWeight) {
135  vec.SetPx((*iter)->px());
136  vec.SetPy((*iter)->py());
137  vec.SetPz((*iter)->pz());
138  vec.SetM(mass);
139  sum += vec;
140  }
141  }
142  }
143  return sum;
144 }
145 
146 unsigned int Vertex::nTracks(float minWeight) const {
147  int n = 0;
148  if (hasRefittedTracks()) {
149  for (std::vector<Track>::const_iterator iter = refittedTracks_.begin(); iter != refittedTracks_.end(); ++iter)
150  if (trackWeight(originalTrack(*iter)) >= minWeight)
151  n++;
152  } else {
153  for (std::vector<reco::TrackBaseRef>::const_iterator iter = tracks_begin(); iter != tracks_end(); iter++)
154  if (trackWeight(*iter) >= minWeight)
155  n++;
156  }
157  return n;
158 }
reco::Vertex::trackRef_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
reco::Vertex::dimension4D
Definition: Vertex.h:42
reco::Vertex::originalTrack
TrackBaseRef originalTrack(const Track &refTrack) const
Definition: Vertex.cc:96
reco::Vertex::dimension
Definition: Vertex.h:42
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
reco::Vertex::refittedTrack
Track refittedTrack(const TrackBaseRef &track) const
Definition: Vertex.cc:106
pos
Definition: PixelAliasList.h:18
reco::TrackBaseRef
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
reco::Vertex::idx
index idx(index i, index j) const
position index
Definition: Vertex.h:219
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::Vertex::validity_
bool validity_
tells wether the vertex is really valid.
Definition: Vertex.h:215
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
fftjetcommon_cfi.minWeight
minWeight
Definition: fftjetcommon_cfi.py:213
reco::Vertex::TrackEqual
Definition: Vertex.h:191
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::Ref< TrackCollection >
ndof
Definition: HIMultiTrackSelector.h:49
reco::Vertex::tracks_
std::vector< TrackBaseRef > tracks_
reference to tracks
Definition: Vertex.h:210
w
const double w
Definition: UKUtility.cc:23
reco::Vertex::tracks_end
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:73
reco::Vertex::add
void add(const TrackBaseRef &r, float w=1.0)
add a reference to a Track
Definition: Vertex.cc:79
reco::Track
Definition: Track.h:27
reco::Vertex::size4D
Definition: Vertex.h:52
reco::Vertex::hasRefittedTracks
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
Definition: Vertex.h:168
Vertex.h
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
reco::Vertex::p4
math::XYZTLorentzVectorD p4(float mass=0.13957018, float minWeight=0.5) const
Returns the four momentum of the sum of the tracks, assuming the given mass for the decay products.
Definition: Vertex.cc:118
reco::Vertex::refittedTracks_
std::vector< Track > refittedTracks_
The vector of refitted tracks.
Definition: Vertex.h:212
reco::Vertex::tracks_begin
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:71
reco::Vertex::tracksSize
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:69
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
alignCSCRings.r
r
Definition: alignCSCRings.py:93
reco::Vertex::trackWeight
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:85
std
Definition: JetResolutionObject.h:76
reco::Vertex::fill
void fill(CovarianceMatrix &v) const
fill SMatrix
Exception
Definition: hltDiff.cc:246
reco::Vertex::Vertex
Vertex()
Definition: Vertex.h:58
reco::Vertex::covariance_
float covariance_[size4D]
covariance matrix (4x4) as vector
Definition: Vertex.h:208
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
reco::Vertex::size
Definition: Vertex.h:52
edm::RefToBase< reco::Track >
reco::Vertex::nTracks
unsigned int nTracks(float minWeight=0.5) const
Returns the number of tracks in the vertex with weight above minWeight.
Definition: Vertex.cc:146
cms::Exception
Definition: Exception.h:70
reco::Vertex::removeTracks
void removeTracks()
Definition: Vertex.cc:90
reco::Vertex::index
unsigned int index
index type
Definition: Vertex.h:54
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ntuplemaker.time
time
Definition: ntuplemaker.py:310
reco::Vertex::Error4D
math::Error< dimension4D >::type Error4D
covariance error matrix (4x4)
Definition: Vertex.h:48
reco::Vertex::weights_
std::vector< uint8_t > weights_
Definition: Vertex.h:213
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443