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 (const edm::ParameterSet &s)
 
 AdaptiveVertexReconstructor (float primcut=2.0, float seccut=6.0, float minweight=0.5, bool smoothing=false)
 
AdaptiveVertexReconstructorclone () 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
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &v) 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.

72  : thePrimaryFitter(nullptr), theSecondaryFitter(nullptr), theMinWeight(min_weight), theWeightThreshold(0.001) {
73  setupFitters(primcut, 256., 0.25, seccut, 256., 0.25, smoothing);
74 }

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

Referenced by clone().

◆ ~AdaptiveVertexReconstructor()

AdaptiveVertexReconstructor::~AdaptiveVertexReconstructor ( )
override

Definition at line 76 of file AdaptiveVertexReconstructor.cc.

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

References thePrimaryFitter, and 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.

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 }

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

Member Function Documentation

◆ cleanUp()

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

Definition at line 11 of file AdaptiveVertexReconstructor.cc.

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 }

References TransientVertex::hasPrior(), TransientVertex::hasRefittedTracks(), mps_fire::i, HLT_FULL_cff::minweight, TransientVertex::originalTracks(), TransientVertex::priorError(), TransientVertex::priorPosition(), TransientVertex::refittedTracks(), runTheMatrix::ret, TransientVertex::trackWeight(), and TransientVertex::vertexState().

Referenced by vertices().

◆ 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.

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 }

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

Referenced by vertices().

◆ clone()

AdaptiveVertexReconstructor* AdaptiveVertexReconstructor::clone ( void  ) const
inlineoverridevirtual

Implements VertexReconstructor.

Definition at line 41 of file AdaptiveVertexReconstructor.h.

42 { return new AdaptiveVertexReconstructor(*this); }

References AdaptiveVertexReconstructor().

◆ 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.

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 }

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

Referenced by vertices().

◆ 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.

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 }

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

Referenced by AdaptiveVertexReconstructor().

◆ vertices() [1/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.

150  {
151  return vertices(vector<reco::TransientTrack>(), t, s, false, true);
152 }

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

◆ vertices() [2/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. \paramname primaries Tracks that cannot come from a secondary vertex (but can, in principle, be non-primaries, also). \paramname tracks These are the tracks that are of unknown origin. These tracks are subjected to pattern recognition. \paramname spot A beamspot constraint is mandatory in this method.

Reimplemented from VertexReconstructor.

Definition at line 154 of file AdaptiveVertexReconstructor.cc.

156  {
157  return vertices(primaries, tracks, s, true, true);
158 }

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

◆ vertices() [3/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.

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 }

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

◆ vertices() [4/4]

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

Reconstruct vertices

Implements VertexReconstructor.

Definition at line 160 of file AdaptiveVertexReconstructor.cc.

160  {
161  return vertices(vector<reco::TransientTrack>(), tracks, reco::BeamSpot(), false, false);
162 }

References PDWG_EXOHSCP_cff::tracks.

Referenced by vertices().

Member Data Documentation

◆ theMinWeight

float AdaptiveVertexReconstructor::theMinWeight
private

Definition at line 76 of file AdaptiveVertexReconstructor.h.

Referenced by AdaptiveVertexReconstructor(), and vertices().

◆ thePrimaryFitter

AdaptiveVertexFitter* AdaptiveVertexReconstructor::thePrimaryFitter
private

◆ theSecondaryFitter

AdaptiveVertexFitter* AdaptiveVertexReconstructor::theSecondaryFitter
private

◆ theWeightThreshold

float AdaptiveVertexReconstructor::theWeightThreshold
private
DummyVertexSmoother
Definition: DummyVertexSmoother.h:11
AdaptiveVertexFitter
Definition: AdaptiveVertexFitter.h:29
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
TransientVertex::hasRefittedTracks
bool hasRefittedTracks() const
Definition: TransientVertex.h:206
KalmanVertexUpdator< 5 >
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:428
TransientVertex::refittedTracks
std::vector< reco::TransientTrack > const & refittedTracks() const
Definition: TransientVertex.h:211
TransientVertex::hasPrior
bool hasPrior() const
Definition: TransientVertex.h:181
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
TransientVertex::priorError
GlobalError priorError() const
Definition: TransientVertex.h:174
VertexException
Common base class.
Definition: VertexException.h:12
HLT_FULL_cff.minweight
minweight
Definition: HLT_FULL_cff.py:51988
AdaptiveVertexReconstructor::theWeightThreshold
float theWeightThreshold
Definition: AdaptiveVertexReconstructor.h:78
findQualityFiles.v
v
Definition: findQualityFiles.py:179
AdaptiveVertexFitter::vertex
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
Definition: AdaptiveVertexFitter.cc:158
edm::Exception
Definition: EDMException.h:77
HLT_FULL_cff.primcut
primcut
Definition: HLT_FULL_cff.py:51922
alignCSCRings.s
s
Definition: alignCSCRings.py:92
TransientVertex::vertexState
VertexState const & vertexState() const
Definition: TransientVertex.h:168
TransientVertex::priorPosition
GlobalPoint priorPosition() const
Definition: TransientVertex.h:173
w
const double w
Definition: UKUtility.cc:23
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
KalmanVertexTrackCompatibilityEstimator
Definition: KalmanVertexTrackCompatibilityEstimator.h:24
reco::BeamSpot
Definition: BeamSpot.h:21
AdaptiveVertexReconstructor::thePrimaryFitter
AdaptiveVertexFitter * thePrimaryFitter
Definition: AdaptiveVertexReconstructor.h:72
KalmanVertexSmoother
Definition: KalmanVertexSmoother.h:6
TransientVertex::TransientTrackToFloatMap
std::map< reco::TransientTrack, float > TransientTrackToFloatMap
Definition: TransientVertex.h:21
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
dqmiodatasetharvest.ctr
ctr
Definition: dqmiodatasetharvest.py:191
GeometricAnnealing
Definition: GeometricAnnealing.h:7
AdaptiveVertexFitter::setWeightThreshold
void setWeightThreshold(float w)
Definition: AdaptiveVertexFitter.cc:119
TransientVertex
Definition: TransientVertex.h:18
AdaptiveVertexReconstructor::theMinWeight
float theMinWeight
Definition: AdaptiveVertexReconstructor.h:76
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DefaultLinearizationPointFinder
Definition: DefaultLinearizationPointFinder.h:13
AdaptiveVertexReconstructor::cleanUp
TransientVertex cleanUp(const TransientVertex &old) const
Definition: AdaptiveVertexReconstructor.cc:11
HLT_FULL_cff.smoothing
smoothing
Definition: HLT_FULL_cff.py:51925
AdaptiveVertexReconstructor::setupFitters
void setupFitters(float primcut, float primT, float primr, float seccut, float secT, float secr, bool smoothing)
Definition: AdaptiveVertexReconstructor.cc:83
TransientVertex::trackWeight
float trackWeight(const reco::TransientTrack &track) const
Definition: TransientVertex.cc:241
AdaptiveVertexReconstructor::theSecondaryFitter
AdaptiveVertexFitter * theSecondaryFitter
Definition: AdaptiveVertexReconstructor.h:73
VertexState
Definition: VertexState.h:13
TransientVertex::originalTracks
std::vector< reco::TransientTrack > const & originalTracks() const
Definition: TransientVertex.h:200
AdaptiveVertexReconstructor::erase
void erase(const TransientVertex &newvtx, std::set< reco::TransientTrack > &remainingtrks, float w) const
Definition: AdaptiveVertexReconstructor.cc:55
AdaptiveVertexReconstructor::AdaptiveVertexReconstructor
AdaptiveVertexReconstructor(float primcut=2.0, float seccut=6.0, float minweight=0.5, bool smoothing=false)
Definition: AdaptiveVertexReconstructor.cc:71
AdaptiveVertexReconstructor::vertices
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &v) const override
Definition: AdaptiveVertexReconstructor.cc:160
AdaptiveVertexReconstructor::cleanUpVertices
std::vector< TransientVertex > cleanUpVertices(const std::vector< TransientVertex > &) const
Definition: AdaptiveVertexReconstructor.cc:235
HLT_FULL_cff.seccut
seccut
Definition: HLT_FULL_cff.py:51923
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
weight
Definition: weight.py:1
VertexSmoother< 5 >
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37