CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
AdaptiveVertexReconstructor Class Reference

#include <AdaptiveVertexReconstructor.h>

Inheritance diagram for AdaptiveVertexReconstructor:
VertexReconstructor

Public Member Functions

 AdaptiveVertexReconstructor (float primcut=2.0, float seccut=6.0, float minweight=0.5, bool smoothing=false)
 
 AdaptiveVertexReconstructor (const edm::ParameterSet &s)
 
AdaptiveVertexReconstructorclone () const override
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &v) const override
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &, const reco::BeamSpot &) const override
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &primaries, const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &) const override
 
 ~AdaptiveVertexReconstructor () override
 
- Public Member Functions inherited from VertexReconstructor
 VertexReconstructor ()
 
virtual ~VertexReconstructor ()
 

Private Member Functions

TransientVertex cleanUp (const TransientVertex &old) const
 
std::vector< TransientVertexcleanUpVertices (const std::vector< TransientVertex > &) const
 
void erase (const TransientVertex &newvtx, std::set< reco::TransientTrack > &remainingtrks, float w) const
 
void setupFitters (float primcut, float primT, float primr, float seccut, float secT, float secr, bool smoothing)
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &primaries, const std::vector< reco::TransientTrack > &trks, const reco::BeamSpot &, bool has_primaries, bool usespot) const
 

Private Attributes

float theMinWeight
 
AdaptiveVertexFitterthePrimaryFitter
 
AdaptiveVertexFittertheSecondaryFitter
 
float theWeightThreshold
 

Detailed Description

Definition at line 9 of file AdaptiveVertexReconstructor.h.

Constructor & Destructor Documentation

◆ AdaptiveVertexReconstructor() [1/2]

AdaptiveVertexReconstructor::AdaptiveVertexReconstructor ( float  primcut = 2.0,
float  seccut = 6.0,
float  minweight = 0.5,
bool  smoothing = false 
)

Definition at line 71 of file AdaptiveVertexReconstructor.cc.

References HLT_2023v11_cff::primcut, HLT_2023v11_cff::seccut, setupFitters(), and HLT_2023v11_cff::smoothing.

Referenced by clone().

72  : thePrimaryFitter(nullptr), theSecondaryFitter(nullptr), theMinWeight(min_weight), theWeightThreshold(0.001) {
73  setupFitters(primcut, 256., 0.25, seccut, 256., 0.25, smoothing);
74 }
void setupFitters(float primcut, float primT, float primr, float seccut, float secT, float secr, bool smoothing)
AdaptiveVertexFitter * theSecondaryFitter

◆ ~AdaptiveVertexReconstructor()

AdaptiveVertexReconstructor::~AdaptiveVertexReconstructor ( )
override

Definition at line 76 of file AdaptiveVertexReconstructor.cc.

References thePrimaryFitter, and theSecondaryFitter.

76  {
77  if (thePrimaryFitter)
78  delete thePrimaryFitter;
80  delete theSecondaryFitter;
81 }
AdaptiveVertexFitter * theSecondaryFitter

◆ AdaptiveVertexReconstructor() [2/2]

AdaptiveVertexReconstructor::AdaptiveVertexReconstructor ( const edm::ParameterSet s)

The ParameterSet should have the following defined: double primcut double seccut double minweight for descriptions see

Definition at line 120 of file AdaptiveVertexReconstructor.cc.

References MillePedeFileConverter_cfg::e, visualization-live-secondInstance_cfg::m, HLT_2023v11_cff::primcut, HLT_2023v11_cff::seccut, setupFitters(), HLT_2023v11_cff::smoothing, theMinWeight, and theWeightThreshold.

121  : thePrimaryFitter(nullptr), theSecondaryFitter(nullptr), theMinWeight(0.5), theWeightThreshold(0.001) {
122  float primcut = 2.0;
123  float seccut = 6.0;
124  bool smoothing = false;
125  // float primT = 4096.;
126  // float primr = 0.125;
127  float primT = 256.;
128  float primr = 0.25;
129  float secT = 256.;
130  float secr = 0.25;
131 
132  try {
133  primcut = m.getParameter<double>("primcut");
134  primT = m.getParameter<double>("primT");
135  primr = m.getParameter<double>("primr");
136  seccut = m.getParameter<double>("seccut");
137  secT = m.getParameter<double>("secT");
138  secr = m.getParameter<double>("secr");
139  theMinWeight = m.getParameter<double>("minweight");
140  theWeightThreshold = m.getParameter<double>("weightthreshold");
141  smoothing = m.getParameter<bool>("smoothing");
142  } catch (edm::Exception& e) {
143  edm::LogError("AdaptiveVertexReconstructor") << e.what();
144  }
145 
146  setupFitters(primcut, primT, primr, seccut, secT, secr, smoothing);
147 }
Log< level::Error, false > LogError
void setupFitters(float primcut, float primT, float primr, float seccut, float secT, float secr, bool smoothing)
AdaptiveVertexFitter * theSecondaryFitter

Member Function Documentation

◆ cleanUp()

TransientVertex AdaptiveVertexReconstructor::cleanUp ( const TransientVertex old) const
private

Definition at line 11 of file AdaptiveVertexReconstructor.cc.

References TransientVertex::degreesOfFreedom(), TransientVertex::hasPrior(), TransientVertex::hasRefittedTracks(), mps_fire::i, HLT_2023v11_cff::minweight, TransientVertex::originalTracks(), TransientVertex::priorError(), TransientVertex::priorPosition(), TransientVertex::refittedTracks(), runTheMatrix::ret, TransientVertex::totalChiSquared(), TransientVertex::trackWeight(), hltEgammaHLTExtra_cfi::trks, and TransientVertex::vertexState().

Referenced by vertices().

11  {
12  vector<reco::TransientTrack> trks = old.originalTracks();
13  vector<reco::TransientTrack> newtrks;
15  static const float minweight = 1.e-8; // discard all tracks with lower weight
16  for (vector<reco::TransientTrack>::const_iterator i = trks.begin(); i != trks.end(); ++i) {
17  if (old.trackWeight(*i) > minweight) {
18  newtrks.push_back(*i);
19  mp[*i] = old.trackWeight(*i);
20  }
21  }
22 
24 
25  if (old.hasPrior()) {
26  VertexState priorstate(old.priorPosition(), old.priorError());
27  ret = TransientVertex(priorstate, old.vertexState(), newtrks, old.totalChiSquared(), old.degreesOfFreedom());
28  } else {
29  ret = TransientVertex(old.vertexState(), newtrks, old.totalChiSquared(), old.degreesOfFreedom());
30  }
31  ret.weightMap(mp); // set weight map
32 
33  if (old.hasRefittedTracks()) {
34  // we have refitted tracks -- copy them!
35  vector<reco::TransientTrack> newrfs;
36  vector<reco::TransientTrack> oldrfs = old.refittedTracks();
37  vector<reco::TransientTrack>::const_iterator origtrkiter = trks.begin();
38  for (vector<reco::TransientTrack>::const_iterator i = oldrfs.begin(); i != oldrfs.end(); ++i) {
39  if (old.trackWeight(*origtrkiter) > minweight) {
40  newrfs.push_back(*i);
41  }
42  origtrkiter++;
43  }
44  if (!newrfs.empty())
45  ret.refittedTracks(newrfs); // copy refitted tracks
46  }
47 
48  if (ret.refittedTracks().size() > ret.originalTracks().size()) {
49  edm::LogError("AdaptiveVertexReconstructor") << "More refitted tracks than original tracks!";
50  }
51 
52  return ret;
53 }
float totalChiSquared() const
ret
prodAgent to be discontinued
std::map< reco::TransientTrack, float > TransientTrackToFloatMap
Log< level::Error, false > LogError
float degreesOfFreedom() const
bool hasPrior() const
GlobalPoint priorPosition() const
VertexState const & vertexState() const
std::vector< reco::TransientTrack > const & originalTracks() const
GlobalError priorError() const
bool hasRefittedTracks() const
float trackWeight(const reco::TransientTrack &track) const
std::vector< reco::TransientTrack > const & refittedTracks() const

◆ cleanUpVertices()

vector< TransientVertex > AdaptiveVertexReconstructor::cleanUpVertices ( const std::vector< TransientVertex > &  old) const
private

cleanup reconstructed vertices. discard all with too few significant tracks.

Definition at line 235 of file AdaptiveVertexReconstructor.cc.

References mps_fire::i, runTheMatrix::ret, theWeightThreshold, and w().

Referenced by vertices().

235  {
236  vector<TransientVertex> ret;
237  for (vector<TransientVertex>::const_iterator i = old.begin(); i != old.end(); ++i) {
238  if (!(i->hasTrackWeight())) { // if we dont have track weights, we take the vtx
239  ret.push_back(*i);
240  continue;
241  }
242 
243  // maybe this should be replaced with asking for the ndf ...
244  // e.g. if ( ndf > - 1. )
245  int nsig = 0; // number of significant tracks.
247  for (TransientVertex::TransientTrackToFloatMap::const_iterator w = wm.begin(); w != wm.end(); ++w) {
248  if (w->second > theWeightThreshold)
249  nsig++;
250  }
251  if (nsig > 1)
252  ret.push_back(*i);
253  }
254 
255  return ret;
256 }
T w() const
ret
prodAgent to be discontinued
std::map< reco::TransientTrack, float > TransientTrackToFloatMap

◆ clone()

AdaptiveVertexReconstructor* AdaptiveVertexReconstructor::clone ( void  ) const
inlineoverridevirtual

Implements VertexReconstructor.

Definition at line 42 of file AdaptiveVertexReconstructor.h.

References AdaptiveVertexReconstructor().

42 { return new AdaptiveVertexReconstructor(*this); }
AdaptiveVertexReconstructor(float primcut=2.0, float seccut=6.0, float minweight=0.5, bool smoothing=false)

◆ erase()

void AdaptiveVertexReconstructor::erase ( const TransientVertex newvtx,
std::set< reco::TransientTrack > &  remainingtrks,
float  w 
) const
private

contrary to what its name has you believe, ::erase removes all newvtx.originalTracks() above theMinWeight from remainingtrks.

Definition at line 55 of file AdaptiveVertexReconstructor.cc.

References mps_fire::i, TransientVertex::originalTracks(), TransientVertex::trackWeight(), and w().

Referenced by vertices().

57  {
58  /*
59  * Erase tracks that are in newvtx from remainingtrks
60  * But erase only if trackweight > w
61  */
62  const vector<reco::TransientTrack>& origtrks = newvtx.originalTracks();
63  for (vector<reco::TransientTrack>::const_iterator i = origtrks.begin(); i != origtrks.end(); ++i) {
64  double weight = newvtx.trackWeight(*i);
65  if (weight > w) {
66  remainingtrks.erase(*i);
67  };
68  };
69 }
T w() const
Definition: weight.py:1
std::vector< reco::TransientTrack > const & originalTracks() const
float trackWeight(const reco::TransientTrack &track) const

◆ setupFitters()

void AdaptiveVertexReconstructor::setupFitters ( float  primcut,
float  primT,
float  primr,
float  seccut,
float  secT,
float  secr,
bool  smoothing 
)
private

setup the vertex fitters.

Definition at line 83 of file AdaptiveVertexReconstructor.cc.

References HLT_2023v11_cff::primcut, HLT_2023v11_cff::seccut, AdaptiveVertexFitter::setWeightThreshold(), HLT_2023v11_cff::smoothing, thePrimaryFitter, theSecondaryFitter, and theWeightThreshold.

Referenced by AdaptiveVertexReconstructor().

84  {
85  VertexSmoother<5>* smoother;
86  if (smoothing) {
87  smoother = new KalmanVertexSmoother();
88  } else {
89  smoother = new DummyVertexSmoother<5>();
90  }
91 
92  if (thePrimaryFitter)
93  delete thePrimaryFitter;
95  delete theSecondaryFitter;
96 
97  /*
98  edm::LogError ("AdaptiveVertexReconstructor" )
99  << "Tini and r are hardcoded now!";
100  */
105  *smoother);
107  // if the primary fails, sth is wrong, so here we set a threshold on the weight.
112  *smoother);
114  // need to set it or else we have
115  // unwanted exceptions to deal with.
116  // cleanup can come later!
117  delete smoother;
118 }
AdaptiveVertexFitter * theSecondaryFitter

◆ vertices() [1/4]

vector< TransientVertex > AdaptiveVertexReconstructor::vertices ( const std::vector< reco::TransientTrack > &  ) const
overridevirtual

Reconstruct vertices

Implements VertexReconstructor.

Definition at line 160 of file AdaptiveVertexReconstructor.cc.

References pwdgSkimBPark_cfi::tracks.

Referenced by vertices().

160  {
161  return vertices(vector<reco::TransientTrack>(), tracks, reco::BeamSpot(), false, false);
162 }
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &v) const override

◆ vertices() [2/4]

vector< TransientVertex > AdaptiveVertexReconstructor::vertices ( const std::vector< reco::TransientTrack > &  t,
const reco::BeamSpot  
) const
overridevirtual

Reconstruct vertices, exploiting the beamspot constraint for the primary vertex

Reimplemented from VertexReconstructor.

Definition at line 149 of file AdaptiveVertexReconstructor.cc.

References alignCSCRings::s, submitPVValidationJobs::t, and vertices().

150  {
151  return vertices(vector<reco::TransientTrack>(), t, s, false, true);
152 }
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &v) const override

◆ vertices() [3/4]

vector< TransientVertex > AdaptiveVertexReconstructor::vertices ( const std::vector< reco::TransientTrack > &  primaries,
const std::vector< reco::TransientTrack > &  tracks,
const reco::BeamSpot spot 
) const
overridevirtual

Reconstruct vertices, but exploit the fact that you know that some tracks cannot come from a secondary vertex. primaries Tracks that cannot come from a secondary vertex (but can, in principle, be non-primaries, also). tracks These are the tracks that are of unknown origin. These tracks are subjected to pattern recognition. spot A beamspot constraint is mandatory in this method.

Reimplemented from VertexReconstructor.

Definition at line 154 of file AdaptiveVertexReconstructor.cc.

References alignCSCRings::s, pwdgSkimBPark_cfi::tracks, and vertices().

156  {
157  return vertices(primaries, tracks, s, true, true);
158 }
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &v) const override

◆ vertices() [4/4]

vector< TransientVertex > AdaptiveVertexReconstructor::vertices ( const std::vector< reco::TransientTrack > &  primaries,
const std::vector< reco::TransientTrack > &  trks,
const reco::BeamSpot s,
bool  has_primaries,
bool  usespot 
) const
private

the actual fit to avoid code duplication

Definition at line 164 of file AdaptiveVertexReconstructor.cc.

References cleanUp(), cleanUpVertices(), filterCSVwithJSON::copy, dqmiodatasetharvest::ctr, MillePedeFileConverter_cfg::e, erase(), LogDebug, runTheMatrix::ret, alignCSCRings::s, theMinWeight, thePrimaryFitter, theSecondaryFitter, pwdgSkimBPark_cfi::tracks, findQualityFiles::v, and AdaptiveVertexFitter::vertex().

168  {
169  vector<TransientVertex> ret;
170  set<reco::TransientTrack> remainingtrks;
171 
172  copy(tracks.begin(), tracks.end(), inserter(remainingtrks, remainingtrks.begin()));
173 
174  int ctr = 0;
175  unsigned int n_tracks = remainingtrks.size();
176 
177  // cout << "[AdaptiveVertexReconstructor] DEBUG ::vertices!!" << endl;
178  try {
179  while (remainingtrks.size() > 1) {
180  /*
181  cout << "[AdaptiveVertexReconstructor] next round: "
182  << remainingtrks.size() << endl;
183  */
184  ctr++;
186  if (ret.empty()) {
187  fitter = thePrimaryFitter;
188  };
189  vector<reco::TransientTrack> fittrks;
190  fittrks.reserve(remainingtrks.size());
191 
192  copy(remainingtrks.begin(), remainingtrks.end(), back_inserter(fittrks));
193 
194  TransientVertex tmpvtx;
195  if ((ret.empty()) && has_primaries) {
196  // add the primaries to the fitted tracks.
197  copy(primaries.begin(), primaries.end(), back_inserter(fittrks));
198  }
199  if ((ret.empty()) && usespot) {
200  tmpvtx = fitter->vertex(fittrks, s);
201  } else {
202  tmpvtx = fitter->vertex(fittrks);
203  }
204  TransientVertex newvtx = cleanUp(tmpvtx);
205  ret.push_back(newvtx);
206  erase(newvtx, remainingtrks, theMinWeight);
207  if (n_tracks == remainingtrks.size()) {
208  if (usespot) {
209  // try once more without beamspot constraint!
210  usespot = false;
211  LogDebug("AdaptiveVertexReconstructor") << "no tracks in vertex. trying again without beamspot constraint!";
212  continue;
213  }
214  LogDebug("AdaptiveVertexReconstructor")
215  << "all tracks (" << n_tracks << ") would be recycled for next fit. Trying with low threshold!";
216  erase(newvtx, remainingtrks, 1.e-5);
217  if (n_tracks == remainingtrks.size()) {
218  LogDebug("AdaptiveVertexReconstructor") << "low threshold didnt help! "
219  << "Discontinue procedure!";
220  break;
221  }
222  };
223 
224  // cout << "[AdaptiveVertexReconstructor] erased" << endl;
225  n_tracks = remainingtrks.size();
226  };
227  } catch (VertexException& v) {
228  // Will catch all (not enough significant tracks exceptions.
229  // in this case, the iteration can safely terminate.
230  };
231 
232  return cleanUpVertices(ret);
233 }
std::vector< TransientVertex > cleanUpVertices(const std::vector< TransientVertex > &) const
Common base class.
ret
prodAgent to be discontinued
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
AdaptiveVertexFitter * theSecondaryFitter
void erase(const TransientVertex &newvtx, std::set< reco::TransientTrack > &remainingtrks, float w) const
TransientVertex cleanUp(const TransientVertex &old) const
#define LogDebug(id)

Member Data Documentation

◆ theMinWeight

float AdaptiveVertexReconstructor::theMinWeight
private

Definition at line 77 of file AdaptiveVertexReconstructor.h.

Referenced by AdaptiveVertexReconstructor(), and vertices().

◆ thePrimaryFitter

AdaptiveVertexFitter* AdaptiveVertexReconstructor::thePrimaryFitter
private

◆ theSecondaryFitter

AdaptiveVertexFitter* AdaptiveVertexReconstructor::theSecondaryFitter
private

◆ theWeightThreshold

float AdaptiveVertexReconstructor::theWeightThreshold
private