CMS 3D CMS Logo

PVClusterComparer.cc
Go to the documentation of this file.
4 
5 #include "TMath.h"
6 
8  : track_pT_min_(2.5), track_pT_max_(10.), track_chi2_max_(9999999.), track_prob_min_(-1.) {
10 }
11 
13  double track_pt_max,
14  double track_chi2_max,
15  double track_prob_min)
16  : track_pT_min_(track_pt_min),
17  track_pT_max_(track_pt_max),
18  track_chi2_max_(track_chi2_max),
19  track_prob_min_(track_prob_min) {
21 }
22 
24  double sum = 0;
25  for (size_t i = 0; i < v.tracks().size(); ++i) {
26  double pt = v.tracks()[i]->pt();
27  if (pt < track_pT_min_)
28  continue; // Don't count tracks below track_pT_min_ (2.5 GeV)
29 
30  // RM : exclude badly reconstructed tracks from the sum
31  // if (track_prob_min_ >= 0. && track_prob_min_ <= 1.)
32  // if (TMath::Prob(v.tracks()[i]->chi2(),v.tracks()[i]->ndof()) < track_prob_min_) continue ;
33  if (track_prob_min_ >= 0. && track_prob_min_ <= 1.) {
34  size_t ndof = v.tracks()[i]->ndof();
35  if (ndof >= maxChi2_.size())
37  // cut on chi2 which corresponds to the configured probability
38  if (v.tracks()[i]->chi2() > maxChi2_[ndof])
39  continue;
40  }
41  if (v.tracks()[i]->normalizedChi2() > track_chi2_max_)
42  continue;
43  if (pt > track_pT_max_)
44  pt = track_pT_max_;
45  sum += pt * pt;
46  }
47  return sum;
48 }
49 
51  double sum = 0;
52  for (reco::Vertex::trackRef_iterator i = v.tracks_begin(), ie = v.tracks_end(); i != ie; ++i) {
53  double pt = (*i)->pt();
54  if (pt < track_pT_min_)
55  continue; // Don't count tracks below track_pT_min_ (2.5 GeV)
56 
57  // RM : exclude badly reconstructed tracks from the sum
58  // if (track_prob_min_ >= 0. && track_prob_min_ <= 1.)
59  // if (TMath::Prob((*i)->chi2(),(*i)->ndof()) < track_prob_min_) continue ;
60  if (track_prob_min_ >= 0. && track_prob_min_ <= 1.) {
61  unsigned int ndof = (*i)->ndof();
62  if (ndof >= maxChi2_.size())
64  // cut on chi2 which corresponds to the configured probability
65  if ((*i)->chi2() > maxChi2_[ndof])
66  continue;
67  }
68  if ((*i)->normalizedChi2() > track_chi2_max_)
69  continue;
70 
71  if (pt > track_pT_max_)
72  pt = track_pT_max_;
73  sum += pt * pt;
74  }
75  return sum;
76 }
77 
79  maxChi2_.clear();
80  maxChi2_.resize(20, 0.0);
81  if (track_prob_min_ >= 0. && track_prob_min_ <= 1.)
82  for (size_t ndof = 0; ndof < maxChi2_.size(); ++ndof)
83  // http://root.cern.ch/root/html/TMath.html#TMath:ChisquareQuantile
84  maxChi2_[ndof] = TMath::ChisquareQuantile(1 - track_prob_min_, ndof);
85 }
86 
88  size_t oldsize = maxChi2_.size();
89  // maxChi2_.resize(ndof+1);
90  for (size_t i = oldsize; i <= ndof; ++i) {
91  double chi2 = TMath::ChisquareQuantile(1 - track_prob_min_, i);
92  maxChi2_.push_back(chi2);
93  }
94 }
95 
97  return (pTSquaredSum(v1) > pTSquaredSum(v2));
98 }
100  return (pTSquaredSum(v1) > pTSquaredSum(v2));
101 }
const double track_pT_min_
std::vector< double > maxChi2_
double pTSquaredSum(const PVCluster &v)
Calculate sum of square of the pT&#39;s of the tracks in the vertex.
void updateChisquareQuantile(size_t ndof)
const double track_pT_max_
const double track_prob_min_
PVClusterComparer()
Constructor does nothing, no data members.
bool operator()(const PVCluster &v1, const PVCluster &v2)
Use this operator in a std::sort to sort them in decreasing sumPt.
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
const double track_chi2_max_