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_2024v13_cff::primcut, HLT_2024v13_cff::seccut, setupFitters(), and HLT_2024v13_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_2024v13_cff::primcut, HLT_2024v13_cff::seccut, setupFitters(), HLT_2024v13_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_2024v13_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 233 of file AdaptiveVertexReconstructor.cc.

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

Referenced by vertices().

233  {
234  vector<TransientVertex> ret;
235  for (vector<TransientVertex>::const_iterator i = old.begin(); i != old.end(); ++i) {
236  if (!(i->hasTrackWeight())) { // if we dont have track weights, we take the vtx
237  ret.push_back(*i);
238  continue;
239  }
240 
241  // maybe this should be replaced with asking for the ndf ...
242  // e.g. if ( ndf > - 1. )
243  int nsig = 0; // number of significant tracks.
245  for (TransientVertex::TransientTrackToFloatMap::const_iterator w = wm.begin(); w != wm.end(); ++w) {
246  if (w->second > theWeightThreshold)
247  nsig++;
248  }
249  if (nsig > 1)
250  ret.push_back(*i);
251  }
252 
253  return ret;
254 }
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_2024v13_cff::primcut, HLT_2024v13_cff::seccut, AdaptiveVertexFitter::setWeightThreshold(), HLT_2024v13_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 DiMuonV_cfg::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, DiMuonV_cfg::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, MillePedeFileConverter_cfg::e, erase(), LogDebug, runTheMatrix::ret, alignCSCRings::s, theMinWeight, thePrimaryFitter, theSecondaryFitter, DiMuonV_cfg::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  unsigned int n_tracks = remainingtrks.size();
175 
176  // cout << "[AdaptiveVertexReconstructor] DEBUG ::vertices!!" << endl;
177  try {
178  while (remainingtrks.size() > 1) {
179  /*
180  cout << "[AdaptiveVertexReconstructor] next round: "
181  << remainingtrks.size() << endl;
182  */
184  if (ret.empty()) {
185  fitter = thePrimaryFitter;
186  };
187  vector<reco::TransientTrack> fittrks;
188  fittrks.reserve(remainingtrks.size());
189 
190  copy(remainingtrks.begin(), remainingtrks.end(), back_inserter(fittrks));
191 
192  TransientVertex tmpvtx;
193  if ((ret.empty()) && has_primaries) {
194  // add the primaries to the fitted tracks.
195  copy(primaries.begin(), primaries.end(), back_inserter(fittrks));
196  }
197  if ((ret.empty()) && usespot) {
198  tmpvtx = fitter->vertex(fittrks, s);
199  } else {
200  tmpvtx = fitter->vertex(fittrks);
201  }
202  TransientVertex newvtx = cleanUp(tmpvtx);
203  ret.push_back(newvtx);
204  erase(newvtx, remainingtrks, theMinWeight);
205  if (n_tracks == remainingtrks.size()) {
206  if (usespot) {
207  // try once more without beamspot constraint!
208  usespot = false;
209  LogDebug("AdaptiveVertexReconstructor") << "no tracks in vertex. trying again without beamspot constraint!";
210  continue;
211  }
212  LogDebug("AdaptiveVertexReconstructor")
213  << "all tracks (" << n_tracks << ") would be recycled for next fit. Trying with low threshold!";
214  erase(newvtx, remainingtrks, 1.e-5);
215  if (n_tracks == remainingtrks.size()) {
216  LogDebug("AdaptiveVertexReconstructor") << "low threshold didnt help! "
217  << "Discontinue procedure!";
218  break;
219  }
220  };
221 
222  // cout << "[AdaptiveVertexReconstructor] erased" << endl;
223  n_tracks = remainingtrks.size();
224  };
225  } catch (VertexException& v) {
226  // Will catch all (not enough significant tracks exceptions.
227  // in this case, the iteration can safely terminate.
228  };
229 
230  return cleanUpVertices(ret);
231 }
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