CMS 3D CMS Logo

ConfigurableTrimmedVertexFinder.cc
Go to the documentation of this file.
3 
4 using namespace reco;
5 
7  const VertexUpdator<5>* vu,
9  : theClusterFinder(vf, vu, ve),
10  theVtxFitProbCut(0.01),
11  theTrackCompatibilityToPV(0.05),
12  theTrackCompatibilityToSV(0.01),
13  theMaxNbOfVertices(0) {
14  // default pt cut is 1.5 GeV
15  theFilter.setPtCut(1.5);
16 }
17 
19  theFilter.setPtCut(s.getParameter<double>("ptCut"));
20  theTrackCompatibilityToPV = s.getParameter<double>("trackCompatibilityToPVcut");
21  theTrackCompatibilityToSV = s.getParameter<double>("trackCompatibilityToSVcut");
22  theVtxFitProbCut = s.getParameter<double>("vtxFitProbCut");
23  theMaxNbOfVertices = s.getParameter<int>("maxNbOfVertices");
24 }
25 
26 std::vector<TransientVertex> ConfigurableTrimmedVertexFinder::vertices(const std::vector<TransientTrack>& tracks) const {
27  std::vector<TransientTrack> remaining;
28 
29  return vertices(tracks, remaining, reco::BeamSpot(), false);
30 }
31 
32 std::vector<TransientVertex> ConfigurableTrimmedVertexFinder::vertices(const std::vector<TransientTrack>& tracks,
33  const reco::BeamSpot& spot) const {
34  std::vector<TransientTrack> remaining;
35  return vertices(tracks, remaining, spot, true);
36 }
37 
38 std::vector<TransientVertex> ConfigurableTrimmedVertexFinder::vertices(const std::vector<TransientTrack>& tracks,
39  std::vector<TransientTrack>& unused,
40  const reco::BeamSpot& spot,
41  bool use_spot) const {
44 
45  std::vector<TransientTrack> filtered;
46  for (std::vector<TransientTrack>::const_iterator it = tracks.begin(); it != tracks.end(); it++) {
47  if (theFilter(*it)) {
48  filtered.push_back(*it);
49  } else {
50  unused.push_back(*it);
51  }
52  }
53 
54  std::vector<TransientVertex> all = vertexCandidates(filtered, unused, spot, use_spot);
55 
57 
58  std::vector<TransientVertex> sel = clean(all);
59 
61 
62  return sel;
63 }
64 
65 std::vector<TransientVertex> ConfigurableTrimmedVertexFinder::vertexCandidates(const std::vector<TransientTrack>& tracks,
66  std::vector<TransientTrack>& unused,
67  const reco::BeamSpot& spot,
68  bool use_spot) const {
69  std::vector<TransientVertex> cand;
70 
71  std::vector<TransientTrack> remain = tracks;
72 
73  while (true) {
74  float tkCompCut = (cand.empty() ? theTrackCompatibilityToPV : theTrackCompatibilityToSV);
75 
76  // std::cout << "PVR:compat cut " << tkCompCut << std::endl;
78  // std::cout << "PVCF:compat cut after setting "
79  // << theClusterFinder.trackCompatibilityCut() << std::endl;
80 
81  std::vector<TransientVertex> newVertices;
82  if (cand.empty() && use_spot) {
83  newVertices = theClusterFinder.vertices(remain, spot);
84  } else {
85  newVertices = theClusterFinder.vertices(remain);
86  }
87  if (newVertices.empty())
88  break;
89 
90  analyseClusterFinder(newVertices, remain);
91 
92  for (std::vector<TransientVertex>::const_iterator iv = newVertices.begin(); iv != newVertices.end(); iv++) {
93  if (iv->originalTracks().size() > 1) {
94  cand.push_back(*iv);
95  } else {
96  // candidate has too few tracks - get them back into the vector
97  for (std::vector<TransientTrack>::const_iterator trk = iv->originalTracks().begin();
98  trk != iv->originalTracks().end();
99  ++trk) {
100  unused.push_back(*trk);
101  }
102  }
103  }
104 
105  // when max number of vertices reached, stop
106  if (theMaxNbOfVertices != 0) {
107  if (cand.size() >= (unsigned int)theMaxNbOfVertices)
108  break;
109  }
110  }
111 
112  for (std::vector<TransientTrack>::const_iterator it = remain.begin(); it != remain.end(); it++) {
113  unused.push_back(*it);
114  }
115 
116  return cand;
117 }
118 
119 std::vector<TransientVertex> ConfigurableTrimmedVertexFinder::clean(
120  const std::vector<TransientVertex>& candidates) const {
121  std::vector<TransientVertex> sel;
122  for (std::vector<TransientVertex>::const_iterator i = candidates.begin(); i != candidates.end(); i++) {
123  if (ChiSquaredProbability((*i).totalChiSquared(), (*i).degreesOfFreedom()) > theVtxFitProbCut) {
124  sel.push_back(*i);
125  }
126  }
127 
128  return sel;
129 }
std::vector< TransientVertex > clean(const std::vector< TransientVertex > &candidates) const
int32_t *__restrict__ iv
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
virtual void analyseFoundVertices(const std::vector< TransientVertex > &vts) const
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks) const override
virtual void analyseVertexCandidates(const std::vector< TransientVertex > &vts) const
static const TGPicture * filtered(bool iBackgroundIsBlack)
std::vector< TransientVertex > vertexCandidates(const std::vector< reco::TransientTrack > &tracks, std::vector< reco::TransientTrack > &unused, const reco::BeamSpot &spot, bool use_spot) const
float ChiSquaredProbability(double chiSquared, double nrDOF)
void setTrackCompatibilityCut(float cut)
ConfigurableTrimmedVertexFinder(const VertexFitter< 5 > *vf, const VertexUpdator< 5 > *vu, const VertexTrackCompatibilityEstimator< 5 > *ve)
virtual void analyseInputTracks(const std::vector< reco::TransientTrack > &tracks) const
void setParameters(const edm::ParameterSet &)
fixed size matrix
virtual void analyseClusterFinder(const std::vector< TransientVertex > &vts, const std::vector< reco::TransientTrack > &remain) const
std::vector< TransientVertex > vertices(std::vector< reco::TransientTrack > &remain) const
void setPtCut(double ptCut)
virtual void resetEvent(const std::vector< reco::TransientTrack > &tracks) const