CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PVClusterComparer.cc
Go to the documentation of this file.
4 
5 #include "TMath.h"
6 
8  : track_pT_min_ ( 2.5)
9  , track_pT_max_ (10.)
10  , track_chi2_max_(9999999.)
11  , track_prob_min_(-1.)
12 {
14 }
15 
16 PVClusterComparer::PVClusterComparer(double track_pt_min, double track_pt_max, double track_chi2_max, double track_prob_min)
17  : track_pT_min_ (track_pt_min)
18  , track_pT_max_ (track_pt_max)
19  , track_chi2_max_(track_chi2_max)
20  , track_prob_min_(track_prob_min)
21 {
23 }
24 
26  double sum=0;
27  for (size_t i=0; i<v.tracks().size(); ++i) {
28 
29  double pt = v.tracks()[i]->pt();
30  if (pt < track_pT_min_) continue; // Don't count tracks below track_pT_min_ (2.5 GeV)
31 
32  // RM : exclude badly reconstructed tracks from the sum
33  // if (track_prob_min_ >= 0. && track_prob_min_ <= 1.)
34  // if (TMath::Prob(v.tracks()[i]->chi2(),v.tracks()[i]->ndof()) < track_prob_min_) continue ;
35  if (track_prob_min_ >= 0. && track_prob_min_ <= 1.) {
36  size_t ndof = v.tracks()[i]->ndof();
37  if (ndof >= maxChi2_.size())
39  // cut on chi2 which corresponds to the configured probability
40  if (v.tracks()[i]->chi2() > maxChi2_[ndof] ) continue ;
41  }
42  if (v.tracks()[i]->normalizedChi2() > track_chi2_max_) continue;
43  if (pt > track_pT_max_) pt = track_pT_max_;
44  sum += pt*pt;
45  }
46  return sum;
47 }
48 
50  double sum=0;
52  i!=ie; ++i) {
53 
54  double pt = (*i)->pt();
55  if (pt < track_pT_min_) 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] ) continue ;
66  }
67  if ((*i)->normalizedChi2() > track_chi2_max_) continue;
68 
69  if (pt > track_pT_max_) pt = track_pT_max_;
70  sum += pt*pt;
71  }
72  return sum;
73 }
74 
76  std::vector<double> maxChi2(20, 0.);
77  if (track_prob_min_ >= 0. && track_prob_min_ <= 1.)
78  for (size_t ndof = 0; ndof < maxChi2_.size(); ++ndof)
79  // http://root.cern.ch/root/html/TMath.html#TMath:ChisquareQuantile
80  maxChi2[ndof] = TMath::ChisquareQuantile(1- track_prob_min_, ndof);
81 
82  maxChi2_ = maxChi2;
83 
84 }
85 
87 
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 
96 
98  return ( pTSquaredSum(v1) > pTSquaredSum(v2) );
99 }
101  return ( pTSquaredSum(v1) > pTSquaredSum(v2) );
102 }
int i
Definition: DBlmapReader.cc:9
const double track_pT_min_
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
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_
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
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.
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
const double track_chi2_max_