CMS 3D CMS Logo

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

#include <AdaptiveVertexFitter.h>

Inheritance diagram for AdaptiveVertexFitter:
VertexFitter< 5 >

Public Types

typedef ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
 
typedef ReferenceCountingPointer< VertexTrack< 5 > > RefCountedVertexTrack
 

Public Member Functions

 AdaptiveVertexFitter (const AdaptiveVertexFitter &original)
 
 AdaptiveVertexFitter (const AnnealingSchedule &ann=GeometricAnnealing(), const LinearizationPointFinder &linP=DefaultLinearizationPointFinder(), const VertexUpdator< 5 > &updator=KalmanVertexUpdator< 5 >(), const VertexTrackCompatibilityEstimator< 5 > &estor=KalmanVertexTrackCompatibilityEstimator< 5 >(), const VertexSmoother< 5 > &smoother=DummyVertexSmoother< 5 >(), const AbstractLTSFactory< 5 > &ltsf=LinearizedTrackStateFactory())
 
AdaptiveVertexFitterclone () const override
 
bool gsfIntermediarySmoothing () const
 
void gsfIntermediarySmoothing (bool sm)
 
void setParameters (const edm::ParameterSet &)
 
void setParameters (double maxshift=0.0001, double maxlpshift=0.1, unsigned maxstep=30, double weightthreshold=.001)
 
void setWeightThreshold (float w)
 
CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &) const override
 
CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &, const GlobalPoint &linPoint) const override
 
CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &, const GlobalPoint &priorPos, const GlobalError &priorError) const override
 
CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &beamSpot) const override
 
CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &) const override
 
CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &, const GlobalPoint &priorPos, const GlobalError &priorError) const override
 
CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &, const reco::BeamSpot &spot) const override
 
 ~AdaptiveVertexFitter () override
 
- Public Member Functions inherited from VertexFitter< 5 >
virtual CachingVertex< Nvertex (const std::vector< typename CachingVertex< N >::RefCountedVertexTrack > &tracks) const=0
 
virtual CachingVertex< Nvertex (const std::vector< typename CachingVertex< N >::RefCountedVertexTrack > &tracks, const GlobalPoint &priorPos, const GlobalError &priorError) const=0
 
virtual CachingVertex< Nvertex (const std::vector< typename CachingVertex< N >::RefCountedVertexTrack > &tracks, const reco::BeamSpot &spot) const=0
 
 VertexFitter ()
 
virtual ~VertexFitter ()
 

Private Member Functions

CachingVertex< 5 > fit (const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
 
double getWeight (float chi2) const
 
std::vector< RefCountedVertexTracklinearizeTracks (const std::vector< reco::TransientTrack > &, const VertexState &) const
 
std::vector< RefCountedVertexTrackreLinearizeTracks (const std::vector< RefCountedVertexTrack > &tracks, const CachingVertex< 5 > &vertex) const
 
std::vector< RefCountedVertexTrackreWeightTracks (const std::vector< RefCountedLinearizedTrackState > &, const CachingVertex< 5 > &seed) const
 
std::vector< RefCountedVertexTrackreWeightTracks (const std::vector< RefCountedVertexTrack > &, const CachingVertex< 5 > &seed) const
 
std::vector< RefCountedVertexTrackweightTracks (const std::vector< RefCountedLinearizedTrackState > &, const VertexState &seed) const
 

Private Attributes

bool gsfIntermediarySmoothing_
 
AnnealingScheduletheAssProbComputer
 
VertexTrackCompatibilityEstimator< 5 > * theComp
 
LinearizationPointFindertheLinP
 
const AbstractLTSFactory< 5 > * theLinTrkFactory
 
double theMaxLPShift
 
double theMaxShift
 
int theMaxStep
 
int theNr
 
VertexSmoother< 5 > * theSmoother
 
VertexUpdator< 5 > * theUpdator
 
double theWeightThreshold
 

Detailed Description

An iterative reweighted fitter. Very robust, very adaptive.

See CMS Note 2007/008.

Exceptions VertexException( "Supplied fewer than two tracks" ) VertexException( "fewer than 2 significant tracks (w>threshold)" )

Definition at line 29 of file AdaptiveVertexFitter.h.

Member Typedef Documentation

◆ RefCountedLinearizedTrackState

Definition at line 32 of file AdaptiveVertexFitter.h.

◆ RefCountedVertexTrack

Definition at line 31 of file AdaptiveVertexFitter.h.

Constructor & Destructor Documentation

◆ AdaptiveVertexFitter() [1/2]

AdaptiveVertexFitter::AdaptiveVertexFitter ( const AnnealingSchedule ann = GeometricAnnealing(),
const LinearizationPointFinder linP = DefaultLinearizationPointFinder(),
const VertexUpdator< 5 > &  updator = KalmanVertexUpdator<5>(),
const VertexTrackCompatibilityEstimator< 5 > &  estor = KalmanVertexTrackCompatibilityEstimator<5>(),
const VertexSmoother< 5 > &  smoother = DummyVertexSmoother<5>(),
const AbstractLTSFactory< 5 > &  ltsf = LinearizedTrackStateFactory() 
)

Reimplemented constructors to use any kind of linearisation point finder, vertex updator and smoother. If no smoother is to be used, do not specify an instance for it.

Definition at line 102 of file AdaptiveVertexFitter.cc.

108  : theNr(0),
109  theLinP(linP.clone()),
110  theUpdator(updator.clone()),
111  theSmoother(smoother.clone()),
112  theAssProbComputer(ann.clone()),
113  theComp(crit.clone()),
114  theLinTrkFactory(ltsf.clone()),
116  setParameters();
117 }

References setParameters().

Referenced by clone().

◆ AdaptiveVertexFitter() [2/2]

AdaptiveVertexFitter::AdaptiveVertexFitter ( const AdaptiveVertexFitter original)

Definition at line 121 of file AdaptiveVertexFitter.cc.

122  : theMaxShift(o.theMaxShift),
123  theMaxLPShift(o.theMaxLPShift),
124  theMaxStep(o.theMaxStep),
125  theWeightThreshold(o.theWeightThreshold),
126  theNr(o.theNr),
127  theLinP(o.theLinP->clone()),
128  theUpdator(o.theUpdator->clone()),
129  theSmoother(o.theSmoother->clone()),
130  theAssProbComputer(o.theAssProbComputer->clone()),
131  theComp(o.theComp->clone()),
132  theLinTrkFactory(o.theLinTrkFactory->clone()),
133  gsfIntermediarySmoothing_(o.gsfIntermediarySmoothing_) {}

◆ ~AdaptiveVertexFitter()

AdaptiveVertexFitter::~AdaptiveVertexFitter ( )
override

Definition at line 135 of file AdaptiveVertexFitter.cc.

135  {
136  delete theLinP;
137  delete theUpdator;
138  delete theSmoother;
139  delete theAssProbComputer;
140  delete theComp;
141  delete theLinTrkFactory;
142 }

References theAssProbComputer, theComp, theLinP, theLinTrkFactory, theSmoother, and theUpdator.

Member Function Documentation

◆ clone()

AdaptiveVertexFitter * AdaptiveVertexFitter::clone ( void  ) const
overridevirtual

Fit vertex out of a VertexSeed

Implements VertexFitter< 5 >.

Definition at line 327 of file AdaptiveVertexFitter.cc.

327 { return new AdaptiveVertexFitter(*this); }

References AdaptiveVertexFitter().

◆ fit()

CachingVertex< 5 > AdaptiveVertexFitter::fit ( const std::vector< RefCountedVertexTrack > &  tracks,
const VertexState priorSeed,
bool  withPrior 
) const
private

perform the fit

Definition at line 451 of file AdaptiveVertexFitter.cc.

453  {
454  // cout << "[AdaptiveVertexFit] fit with " << tracks.size() << endl;
456 
457  vector<RefCountedVertexTrack> initialTracks;
458  GlobalPoint priorVertexPosition = priorSeed.position();
459  GlobalError priorVertexError = priorSeed.error();
460 
461  CachingVertex<5> returnVertex(priorVertexPosition, priorVertexError, initialTracks, 0);
462  if (withPrior) {
463  returnVertex = CachingVertex<5>(
464  priorVertexPosition, priorVertexError, priorVertexPosition, priorVertexError, initialTracks, 0);
465  }
466 
467  std::vector<RefCountedVertexTrack> globalVTracks = tracks;
468  // sort the tracks, according to distance to seed!
469  sortByDistanceToRefPoint(globalVTracks, priorSeed.position());
470 
471  // main loop through all the VTracks
472  int lpStep = 0;
473  int step = 0;
474 
475  CachingVertex<5> initialVertex = returnVertex;
476 
477  GlobalPoint newPosition = priorVertexPosition;
478  GlobalPoint previousPosition = newPosition;
479 
480  int ns_trks = 0; // number of significant tracks.
481  // If we have only two significant tracks, we return an invalid vertex
482 
483  // cout << "[AdaptiveVertexFit] start " << tracks.size() << endl;
484  /*
485  for ( vector< RefCountedVertexTrack >::const_iterator
486  i=globalVTracks.begin(); i!=globalVTracks.end() ; ++i )
487  {
488  cout << " " << (**i).linearizedTrack()->track().initialFreeState().momentum() << endl;
489  }*/
490  do {
491  ns_trks = 0;
492  CachingVertex<5> fVertex = initialVertex;
493  // cout << "[AdaptiveVertexFit] step " << step << " at " << fVertex.position() << endl;
494  if ((previousPosition - newPosition).transverse() > theMaxLPShift) {
495  // relinearize and reweight.
496  // (reLinearizeTracks also reweights tracks)
497  // cout << "[AdaptiveVertexFit] relinearize at " << returnVertex.position() << endl;
499  returnVertex = theSmoother->smooth(returnVertex);
500  globalVTracks = reLinearizeTracks(globalVTracks, returnVertex);
501  lpStep++;
502  } else if (step) {
503  // reweight, if it is not the first step
504  // cout << "[AdaptiveVertexFit] reweight at " << returnVertex.position() << endl;
506  returnVertex = theSmoother->smooth(returnVertex);
507  globalVTracks = reWeightTracks(globalVTracks, returnVertex);
508  }
509  // cout << "[AdaptiveVertexFit] relinarized, reweighted" << endl;
510  // update sequentially the vertex estimate
512  for (vector<RefCountedVertexTrack>::const_iterator i = globalVTracks.begin(); i != globalVTracks.end(); i++) {
513  if ((**i).weight() > 0.)
514  nVertex = theUpdator->add(fVertex, *i);
515  else
516  nVertex = fVertex;
517  if (nVertex.isValid()) {
518  if ((**i).weight() >= theWeightThreshold)
519  ns_trks++;
520 
521  if (fabs(nVertex.position().z()) > 10000. || nVertex.position().perp() > 120.) {
522  // were more than 100 m off!!
523  LogInfo("AdaptiveVertexFitter")
524  << "Vertex candidate just took off to " << nVertex.position() << "! Will discard this update!";
525  // //<< "track pt was " << (**i).linearizedTrack()->track().pt()
526  // << "track momentum was " << (**i).linearizedTrack()->track().initialFreeState().momentum()
527  // << "track position was " << (**i).linearizedTrack()->track().initialFreeState().position()
528  // << "track chi2 was " << (**i).linearizedTrack()->track().chi2()
529  // << "track ndof was " << (**i).linearizedTrack()->track().ndof()
530  // << "track w was " << (**i).weight()
531  // << "track schi2 was " << (**i).smoothedChi2();
532  } else {
533  fVertex = nVertex;
534  }
535  } else {
536  LogInfo("RecoVertex/AdaptiveVertexFitter")
537  << "The updator returned an invalid vertex when adding track " << i - globalVTracks.begin()
538  << ".\n Your vertex might just have lost one good track.";
539  }
540  }
541  previousPosition = newPosition;
542  newPosition = fVertex.position();
543  returnVertex = fVertex;
545  step++;
546  if (step >= theMaxStep)
547  break;
548 
549  } while (
550  // repeat as long as
551  // - vertex moved too much or
552  // - we're not yet annealed
553  (((previousPosition - newPosition).mag() > theMaxShift) || (!(theAssProbComputer->isAnnealed()))));
554 
555  if (theWeightThreshold > 0. && ns_trks < 2 && !withPrior) {
556  LogDebug("AdaptiveVertexFitter") << "fewer than two significant tracks (w>" << theWeightThreshold << ")."
557  << " Fitted vertex is invalid.";
558  return CachingVertex<5>(); // return invalid vertex
559  }
560 
561 #ifdef STORE_WEIGHTS
562  map<string, dataharvester::MultiType> m;
563  m["chi2"] = chi2;
564  m["w"] = theAssProbComputer->weight(chi2);
565  m["T"] = theAssProbComputer->currentTemp();
566  m["n"] = iter;
567  m["id"] = getId(*i);
568  m["pos"] = "final";
569  dataharvester::Writer::file("w.txt").save(m);
570 #endif
571  // cout << "[AdaptiveVertexFit] /fit" << endl;
572  return theSmoother->smooth(returnVertex);
573 }

References VertexUpdator< N >::add(), AnnealingSchedule::anneal(), hltPixelTracks_cff::chi2, AnnealingSchedule::currentTemp(), VertexState::error(), geometryDiff::file, getId(), gsfIntermediarySmoothing_, mps_fire::i, AnnealingSchedule::isAnnealed(), LogDebug, visualization-live-secondInstance_cfg::m, mag(), L1TEGammaOffline_cfi::nVertex, VertexState::position(), CachingVertex< N >::position(), reLinearizeTracks(), AnnealingSchedule::resetAnnealing(), reWeightTracks(), VertexSmoother< N >::smooth(), theAssProbComputer, theMaxLPShift, theMaxShift, theMaxStep, theSmoother, theUpdator, theWeightThreshold, tracks, and AnnealingSchedule::weight().

Referenced by trackingPlots.Iteration::modules(), and vertex().

◆ getWeight()

double AdaptiveVertexFitter::getWeight ( float  chi2) const
private

Definition at line 329 of file AdaptiveVertexFitter.cc.

329  {
331 
332  if (weight > 1.0) {
333  LogInfo("RecoVertex/AdaptiveVertexFitter") << "Weight " << weight << " > 1.0!";
334  weight = 1.0;
335  };
336 
337  if (weight < 1e-20) {
338  // LogInfo("RecoVertex/AdaptiveVertexFitter") << "Weight " << weight << " < 0.0!";
339  weight = 1e-20;
340  };
341  return weight;
342 }

References hltPixelTracks_cff::chi2, MillePedeFileConverter_cfg::e, theAssProbComputer, AnnealingSchedule::weight(), and mps_merge::weight.

Referenced by reWeightTracks(), and weightTracks().

◆ gsfIntermediarySmoothing() [1/2]

bool AdaptiveVertexFitter::gsfIntermediarySmoothing ( ) const
inline

Definition at line 137 of file AdaptiveVertexFitter.h.

137 { return gsfIntermediarySmoothing_; }

References gsfIntermediarySmoothing_.

◆ gsfIntermediarySmoothing() [2/2]

void AdaptiveVertexFitter::gsfIntermediarySmoothing ( bool  sm)
inline

◆ linearizeTracks()

vector< AdaptiveVertexFitter::RefCountedVertexTrack > AdaptiveVertexFitter::linearizeTracks ( const std::vector< reco::TransientTrack > &  tracks,
const VertexState seed 
) const
private

Linearize tracks, for the first time in the iteration.

Construct a container of VertexTrack from a set of reco::TransientTracks. As this is the first iteration of the adaptive fit, the initial error does not enter in the computation of the weights. This is to avoid that all tracks get the same weight when using a very large initial error matrix.

Definition at line 283 of file AdaptiveVertexFitter.cc.

284  {
285  const GlobalPoint& linP(seed.position());
286  vector<RefCountedLinearizedTrackState> lTracks;
287  for (vector<reco::TransientTrack>::const_iterator i = tracks.begin(); i != tracks.end(); ++i) {
288  try {
290  lTracks.push_back(lTrData);
291  } catch (exception& e) {
292  LogInfo("RecoVertex/AdaptiveVertexFitter") << "Exception " << e.what() << " in ::linearizeTracks."
293  << "Your future vertex has just lost a track.";
294  };
295  }
296  return weightTracks(lTracks, seed);
297 }

References MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, mps_fire::i, AbstractLTSFactory< N >::linearizedTrackState(), fileCollector::seed, theLinTrkFactory, tracks, and weightTracks().

Referenced by vertex().

◆ reLinearizeTracks()

vector< AdaptiveVertexFitter::RefCountedVertexTrack > AdaptiveVertexFitter::reLinearizeTracks ( const std::vector< RefCountedVertexTrack > &  tracks,
const CachingVertex< 5 > &  vertex 
) const
private

Construct new a container of VertexTrack with a new linearization point and vertex seed, from an existing set of VertexTrack, from which only the recTracks will be used.

Parameters
tracksThe original container of VertexTracks, from which the reco::TransientTracks will be extracted.
vertexThe seed to use for the VertexTracks. This position will also be used as the new linearization point.
Returns
The container of VertexTracks which are to be used in the next fit.

Construct new a container of VertexTrack with a new linearization point and vertex seed, from an existing set of VertexTrack, from which only the recTracks will be used.

Definition at line 304 of file AdaptiveVertexFitter.cc.

305  {
306  const VertexState& seed = vertex.vertexState();
307  GlobalPoint linP = seed.position();
308  vector<RefCountedLinearizedTrackState> lTracks;
309  for (vector<RefCountedVertexTrack>::const_iterator i = tracks.begin(); i != tracks.end(); i++) {
310  try {
312  theLinTrkFactory->linearizedTrackState(linP, (**i).linearizedTrack()->track());
313  /*
314  RefCountedLinearizedTrackState lTrData =
315  (**i).linearizedTrack()->stateWithNewLinearizationPoint(linP);
316  */
317  lTracks.push_back(lTrData);
318  } catch (exception& e) {
319  LogInfo("RecoVertex/AdaptiveVertexFitter") << "Exception " << e.what() << " in ::relinearizeTracks. "
320  << "Will not relinearize this track.";
321  lTracks.push_back((**i).linearizedTrack());
322  };
323  };
324  return reWeightTracks(lTracks, vertex);
325 }

References MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, mps_fire::i, AbstractLTSFactory< N >::linearizedTrackState(), reWeightTracks(), fileCollector::seed, theLinTrkFactory, tracks, vertex(), and CachingVertex< N >::vertexState().

Referenced by fit().

◆ reWeightTracks() [1/2]

vector< AdaptiveVertexFitter::RefCountedVertexTrack > AdaptiveVertexFitter::reWeightTracks ( const std::vector< RefCountedLinearizedTrackState > &  lTracks,
const CachingVertex< 5 > &  seed 
) const
private

Construct a new container of VertexTracks with new weights accounting for vertex error, from an existing set of LinearizedTracks.

Definition at line 344 of file AdaptiveVertexFitter.cc.

345  {
346  const VertexState& seed = vertex.vertexState();
347  // cout << "[AdaptiveVertexFitter] now reweight around " << seed.position() << endl;
348  theNr++;
349  // GlobalPoint pos = seed.position();
350 
351  vector<RefCountedVertexTrack> finalTracks;
352  VertexTrackFactory<5> vTrackFactory;
353 #ifdef STORE_WEIGHTS
354  iter++;
355 #endif
356  for (vector<RefCountedLinearizedTrackState>::const_iterator i = lTracks.begin(); i != lTracks.end(); i++) {
357  double weight = 0.;
358  // cout << "[AdaptiveVertexFitter] estimate " << endl;
359  pair<bool, double> chi2Res(false, 0.);
360  try {
361  chi2Res = theComp->estimate(vertex, *i, std::distance(lTracks.begin(), i));
362  } catch (exception const& e) {
363  };
364  // cout << "[AdaptiveVertexFitter] /estimate " << endl;
365  if (!chi2Res.first) {
366  // cout << "[AdaptiveVertexFitter] aie... vertex candidate is at " << vertex.position() << endl;
367  LogInfo("AdaptiveVertexFitter") << "When reweighting, chi2<0. Will add this track with w=0.";
368  // edm::LogInfo("AdaptiveVertexFitter" ) << "pt=" << (**i).track().pt();
369  } else {
370  weight = getWeight(chi2Res.second);
371  }
372 
373  RefCountedVertexTrack vTrData = vTrackFactory.vertexTrack(*i, seed, weight);
374 
375 #ifdef STORE_WEIGHTS
376  map<string, dataharvester::MultiType> m;
377  m["chi2"] = chi2;
378  m["w"] = theAssProbComputer->weight(chi2);
379  m["T"] = theAssProbComputer->currentTemp();
380  m["n"] = iter;
381  m["pos"] = "reweight";
382  m["id"] = getId(*i);
383  dataharvester::Writer::file("w.txt").save(m);
384 #endif
385 
386  finalTracks.push_back(vTrData);
387  }
388  sortByDistanceToRefPoint(finalTracks, vertex.position());
389  // cout << "[AdaptiveVertexFitter] /now reweight" << endl;
390  return finalTracks;
391 }

References hltPixelTracks_cff::chi2, AnnealingSchedule::currentTemp(), HLT_FULL_cff::distance, MillePedeFileConverter_cfg::e, VertexTrackCompatibilityEstimator< N >::estimate(), cppFunctionSkipper::exception, geometryDiff::file, getId(), getWeight(), mps_fire::i, visualization-live-secondInstance_cfg::m, CachingVertex< N >::position(), fileCollector::seed, theAssProbComputer, theComp, theNr, vertex(), CachingVertex< N >::vertexState(), VertexTrackFactory< N >::vertexTrack(), and AnnealingSchedule::weight().

Referenced by fit(), reLinearizeTracks(), and reWeightTracks().

◆ reWeightTracks() [2/2]

vector< AdaptiveVertexFitter::RefCountedVertexTrack > AdaptiveVertexFitter::reWeightTracks ( const std::vector< RefCountedVertexTrack > &  tracks,
const CachingVertex< 5 > &  seed 
) const
private

Construct new a container of VertexTracks with new weights accounting for vertex error, from an existing set of VertexTracks. From these the LinearizedTracks will be reused.

Construct new a container of VertexTrack with new weights accounting for vertex error, from an existing set of VertexTracks. From these the LinearizedTracks will be reused.

Definition at line 437 of file AdaptiveVertexFitter.cc.

438  {
439  vector<RefCountedLinearizedTrackState> lTracks;
440  for (vector<RefCountedVertexTrack>::const_iterator i = tracks.begin(); i != tracks.end(); i++) {
441  lTracks.push_back((**i).linearizedTrack());
442  }
443 
444  return reWeightTracks(lTracks, seed);
445 }

References mps_fire::i, reWeightTracks(), fileCollector::seed, and tracks.

◆ setParameters() [1/2]

void AdaptiveVertexFitter::setParameters ( const edm::ParameterSet s)

Sets parameters. The following parameters are expected: maxshift, maxlpshift, maxstep, weightthreshold

Definition at line 151 of file AdaptiveVertexFitter.cc.

151  {
152  setParameters(s.getParameter<double>("maxshift"),
153  s.getParameter<double>("maxlpshift"),
154  s.getParameter<int>("maxstep"),
155  s.getParameter<double>("weightthreshold"));
156 }

References alignCSCRings::s, and setParameters().

◆ setParameters() [2/2]

void AdaptiveVertexFitter::setParameters ( double  maxshift = 0.0001,
double  maxlpshift = 0.1,
unsigned  maxstep = 30,
double  weightthreshold = .001 
)

Reads the configurable parameters.

Parameters
maxshiftif the vertex moves further than this (in cm), then we re-iterate.
maxlpshiftif the vertex moves further than this, then we re-linearize the tracks.
maxstepthat's the maximum of iterations that we allow for.
weightthresholdthat's the minimum track weight for a track to be considered "significant". If fewer than two tracks are significant, an exception is thrown.

Definition at line 144 of file AdaptiveVertexFitter.cc.

144  {
145  theMaxShift = maxshift;
146  theMaxLPShift = maxlpshift;
147  theMaxStep = maxstep;
149 }

References theMaxLPShift, theMaxShift, theMaxStep, theWeightThreshold, and HLT_FULL_cff::weightthreshold.

Referenced by AdaptiveGsfVertexFitter::AdaptiveGsfVertexFitter(), AdaptiveVertexFitter(), ConfigurableAdaptiveFitter::configure(), and setParameters().

◆ setWeightThreshold()

void AdaptiveVertexFitter::setWeightThreshold ( float  w)

Set the weight threshold should be used only to find (once) a good value FIXME this should disappear in the final version

Definition at line 119 of file AdaptiveVertexFitter.cc.

119 { theWeightThreshold = w; }

References theWeightThreshold, and w.

Referenced by PFTauPrimaryVertexProducerBase::produce(), and AdaptiveVertexReconstructor::setupFitters().

◆ vertex() [1/7]

CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  unstracks) const
overridevirtual

Method returning the fitted vertex, from a container of reco::TransientTracks. The linearization point will be searched with the given LP finder. No prior vertex position will be used in the vertex fit.

Returns
The fitted vertex

Implements VertexFitter< 5 >.

Definition at line 158 of file AdaptiveVertexFitter.cc.

158  {
159  if (unstracks.size() < 2) {
160  LogError("RecoVertex|AdaptiveVertexFitter") << "Supplied fewer than two tracks. Vertex is invalid.";
161  return CachingVertex<5>(); // return invalid vertex
162  };
163  vector<reco::TransientTrack> tracks = unstracks;
164  sortTracksByPt(tracks);
165  // Linearization Point
167  // Initial vertex seed, with a very large error matrix
168  VertexState lseed(linP, linPointError);
169  vector<RefCountedVertexTrack> vtContainer = linearizeTracks(tracks, lseed);
170 
171  VertexState seed(linP, fitError);
172  return fit(vtContainer, seed, false);
173 }

References fit(), LinearizationPointFinder::getLinearizationPoint(), linearizeTracks(), fileCollector::seed, theLinP, and tracks.

Referenced by SplitVertexResolution::analyze(), PrimaryVertexResolution::Plots::calculateAndFillResolution(), Tau.Tau::dxy(), V0Fitter::fitAll(), PFDisplacedVertexFinder::fitVertexFromSeed(), PFTauPrimaryVertexProducerBase::produce(), TemplatedInclusiveVertexFinder< InputContainer, VTX >::produce(), reLinearizeTracks(), reWeightTracks(), TrackVertexArbitration< VTX >::trackVertexArbitrator(), AdaptiveGsfVertexFitter::vertex(), and AdaptiveVertexReconstructor::vertices().

◆ vertex() [2/7]

CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  tracks,
const GlobalPoint linPoint 
) const
overridevirtual

Fit vertex out of a std::vector of reco::TransientTracks. Uses the specified linearization point.

Fit vertex out of a set of reco::TransientTracks. Uses the specified linearization point.

Implements VertexFitter< 5 >.

Definition at line 199 of file AdaptiveVertexFitter.cc.

200  {
201  if (tracks.size() < 2) {
202  LogError("RecoVertex|AdaptiveVertexFitter") << "Supplied fewer than two tracks. Vertex is invalid.";
203  return CachingVertex<5>(); // return invalid vertex
204  };
205  // Initial vertex seed, with a very large error matrix
206  VertexState seed(linPoint, linPointError);
207  vector<RefCountedVertexTrack> vtContainer = linearizeTracks(tracks, seed);
208  VertexState fitseed(linPoint, fitError);
209  return fit(vtContainer, fitseed, false);
210 }

References fit(), linearizeTracks(), fileCollector::seed, and tracks.

Referenced by Tau.Tau::dxy().

◆ vertex() [3/7]

CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  tracks,
const GlobalPoint priorPos,
const GlobalError priorError 
) const
overridevirtual

Fit vertex out of a set of reco::TransientTracks. Uses the position as both the linearization point AND as prior estimate of the vertex position. The error is used for the weight of the prior estimate.

Implements VertexFitter< 5 >.

Definition at line 247 of file AdaptiveVertexFitter.cc.

251 {
252  if (tracks.empty()) {
253  LogError("RecoVertex|AdaptiveVertexFitter") << "Supplied no tracks. Vertex is invalid.";
254  return CachingVertex<5>(); // return invalid vertex
255  };
256  VertexState seed(priorPos, priorError);
257  vector<RefCountedVertexTrack> vtContainer = linearizeTracks(tracks, seed);
258  return fit(vtContainer, seed, true);
259 }

References fit(), linearizeTracks(), fileCollector::seed, and tracks.

Referenced by Tau.Tau::dxy().

◆ vertex() [4/7]

CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  tracks,
const reco::BeamSpot beamSpot 
) const
overridevirtual

Fit vertex out of a set of TransientTracks. The specified BeamSpot will be used as priot, but NOT for the linearization. The specified LinearizationPointFinder will be used to find the linearization point.

Implements VertexFitter< 5 >.

Definition at line 216 of file AdaptiveVertexFitter.cc.

217  {
218  if (unstracks.empty()) {
219  LogError("RecoVertex|AdaptiveVertexFitter") << "Supplied no tracks. Vertex is invalid.";
220  return CachingVertex<5>(); // return invalid vertex
221  };
222 
223  VertexState beamSpotState(beamSpot);
224  vector<RefCountedVertexTrack> vtContainer;
225 
226  vector<reco::TransientTrack> tracks = unstracks;
227  sortTracksByPt(tracks);
228 
229  if (tracks.size() > 1) {
230  // Linearization Point search if there are more than 1 track
232  VertexState lpState(linP, linPointError);
233  vtContainer = linearizeTracks(tracks, lpState);
234  } else {
235  // otherwise take the beamspot position.
236  vtContainer = linearizeTracks(tracks, beamSpotState);
237  }
238 
239  return fit(vtContainer, beamSpotState, true);
240 }

References pwdgSkimBPark_cfi::beamSpot, fit(), LinearizationPointFinder::getLinearizationPoint(), linearizeTracks(), theLinP, and tracks.

Referenced by Tau.Tau::dxy().

◆ vertex() [5/7]

CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  tracks) const
override

Method returning the fitted vertex, from a container of VertexTracks. For the first loop, the LinearizedTrack contained in the VertexTracks will be used. If subsequent loops are needed, the new VertexTracks will be created with the last estimate of the vertex as linearization point. No prior vertex position will be used in the vertex fit.

Returns
The fitted vertex

Definition at line 175 of file AdaptiveVertexFitter.cc.

175  {
176  if (tracks.size() < 2) {
177  LogError("RecoVertex|AdaptiveVertexFitter") << "Supplied fewer than two tracks. Vertex is invalid.";
178  return CachingVertex<5>(); // return invalid vertex
179  };
180  // Initial vertex seed, with a very small weight matrix
181  GlobalPoint linP = tracks[0]->linearizedTrack()->linearizationPoint();
182  VertexState seed(linP, fitError);
183  return fit(tracks, seed, false);
184 }

References fit(), fileCollector::seed, and tracks.

Referenced by Tau.Tau::dxy().

◆ vertex() [6/7]

CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  tracks,
const GlobalPoint priorPos,
const GlobalError priorError 
) const
override

Fit vertex out of a set of VertexTracks Uses the position and error for the prior estimate of the vertex. This position is not used to relinearize the tracks.

Definition at line 265 of file AdaptiveVertexFitter.cc.

267  {
268  if (tracks.empty()) {
269  LogError("RecoVertex|AdaptiveVertexFitter") << "Supplied no tracks. Vertex is invalid.";
270  return CachingVertex<5>(); // return invalid vertex
271  };
272  VertexState seed(priorPos, priorError);
273  return fit(tracks, seed, true);
274 }

References fit(), fileCollector::seed, and tracks.

Referenced by Tau.Tau::dxy().

◆ vertex() [7/7]

CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  tracks,
const reco::BeamSpot spot 
) const
override

Same as above, only now also with BeamSpot constraint.

Definition at line 186 of file AdaptiveVertexFitter.cc.

187  {
188  if (tracks.empty()) {
189  LogError("RecoVertex|AdaptiveVertexFitter") << "Supplied no tracks. Vertex is invalid.";
190  return CachingVertex<5>(); // return invalid vertex
191  };
192  VertexState beamSpotState(spot);
193  return fit(tracks, beamSpotState, true);
194 }

References fit(), and tracks.

Referenced by Tau.Tau::dxy().

◆ weightTracks()

vector< AdaptiveVertexFitter::RefCountedVertexTrack > AdaptiveVertexFitter::weightTracks ( const std::vector< RefCountedLinearizedTrackState > &  lTracks,
const VertexState seed 
) const
private

Weight the tracks, for the first time, using KalmanChiSquare.

track weighting, as opposed to re-weighting, must always be done with a reset annealer!

Definition at line 393 of file AdaptiveVertexFitter.cc.

394  {
395  theNr++;
396  CachingVertex<5> seedvtx(seed, vector<RefCountedVertexTrack>(), 0.);
400 
401  vector<RefCountedVertexTrack> finalTracks;
402  VertexTrackFactory<5> vTrackFactory;
403 #ifdef STORE_WEIGHTS
404  iter++;
405 #endif
406  for (vector<RefCountedLinearizedTrackState>::const_iterator i = lTracks.begin(); i != lTracks.end(); i++) {
407  double weight = 0.;
408  pair<bool, double> chi2Res = theComp->estimate(seedvtx, *i, std::distance(lTracks.begin(), i));
409  if (!chi2Res.first) {
410  // cout << "[AdaptiveVertexFitter] Aiee! " << endl;
411  LogInfo("AdaptiveVertexFitter") << "When weighting a track, chi2 calculation failed;"
412  << " will add with w=0.";
413  } else {
414  weight = getWeight(chi2Res.second);
415  }
416  RefCountedVertexTrack vTrData = vTrackFactory.vertexTrack(*i, seed, weight);
417 #ifdef STORE_WEIGHTS
418  map<string, dataharvester::MultiType> m;
419  m["chi2"] = chi2;
420  m["w"] = theAssProbComputer->weight(chi2);
421  m["T"] = theAssProbComputer->currentTemp();
422  m["n"] = iter;
423  m["id"] = getId(*i);
424  m["pos"] = "weight";
425  dataharvester::Writer::file("w.txt").save(m);
426 #endif
427  finalTracks.push_back(vTrData);
428  }
429  return finalTracks;
430 }

References hltPixelTracks_cff::chi2, AnnealingSchedule::currentTemp(), HLT_FULL_cff::distance, VertexTrackCompatibilityEstimator< N >::estimate(), geometryDiff::file, getId(), getWeight(), mps_fire::i, visualization-live-secondInstance_cfg::m, AnnealingSchedule::resetAnnealing(), fileCollector::seed, theAssProbComputer, theComp, theNr, VertexTrackFactory< N >::vertexTrack(), and AnnealingSchedule::weight().

Referenced by linearizeTracks().

Member Data Documentation

◆ gsfIntermediarySmoothing_

bool AdaptiveVertexFitter::gsfIntermediarySmoothing_
private

Definition at line 203 of file AdaptiveVertexFitter.h.

Referenced by fit(), and gsfIntermediarySmoothing().

◆ theAssProbComputer

AnnealingSchedule* AdaptiveVertexFitter::theAssProbComputer
private

◆ theComp

VertexTrackCompatibilityEstimator<5>* AdaptiveVertexFitter::theComp
private

Definition at line 201 of file AdaptiveVertexFitter.h.

Referenced by reWeightTracks(), weightTracks(), and ~AdaptiveVertexFitter().

◆ theLinP

LinearizationPointFinder* AdaptiveVertexFitter::theLinP
private

Definition at line 197 of file AdaptiveVertexFitter.h.

Referenced by vertex(), and ~AdaptiveVertexFitter().

◆ theLinTrkFactory

const AbstractLTSFactory<5>* AdaptiveVertexFitter::theLinTrkFactory
private

◆ theMaxLPShift

double AdaptiveVertexFitter::theMaxLPShift
private

Definition at line 192 of file AdaptiveVertexFitter.h.

Referenced by fit(), and setParameters().

◆ theMaxShift

double AdaptiveVertexFitter::theMaxShift
private

Definition at line 191 of file AdaptiveVertexFitter.h.

Referenced by fit(), and setParameters().

◆ theMaxStep

int AdaptiveVertexFitter::theMaxStep
private

Definition at line 193 of file AdaptiveVertexFitter.h.

Referenced by fit(), and setParameters().

◆ theNr

int AdaptiveVertexFitter::theNr
mutableprivate

Definition at line 195 of file AdaptiveVertexFitter.h.

Referenced by reWeightTracks(), and weightTracks().

◆ theSmoother

VertexSmoother<5>* AdaptiveVertexFitter::theSmoother
private

Definition at line 199 of file AdaptiveVertexFitter.h.

Referenced by fit(), and ~AdaptiveVertexFitter().

◆ theUpdator

VertexUpdator<5>* AdaptiveVertexFitter::theUpdator
private

Definition at line 198 of file AdaptiveVertexFitter.h.

Referenced by fit(), and ~AdaptiveVertexFitter().

◆ theWeightThreshold

double AdaptiveVertexFitter::theWeightThreshold
private

Definition at line 194 of file AdaptiveVertexFitter.h.

Referenced by fit(), setParameters(), and setWeightThreshold().

AdaptiveVertexFitter::reLinearizeTracks
std::vector< RefCountedVertexTrack > reLinearizeTracks(const std::vector< RefCountedVertexTrack > &tracks, const CachingVertex< 5 > &vertex) const
Definition: AdaptiveVertexFitter.cc:304
VertexTrackCompatibilityEstimator::estimate
virtual BDpair estimate(const CachingVertex< N > &v, const RefCountedLinearizedTrackState track, unsigned int hint=UINT_MAX) const =0
mps_fire.i
i
Definition: mps_fire.py:428
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
VertexUpdator::add
virtual CachingVertex< N > add(const CachingVertex< N > &v, const typename CachingVertex< N >::RefCountedVertexTrack t) const =0
step
step
Definition: StallMonitor.cc:94
CachingVertex< 5 >
mps_merge.weight
weight
Definition: mps_merge.py:88
AnnealingSchedule::isAnnealed
virtual bool isAnnealed() const =0
CachingVertex::vertexState
const VertexState & vertexState() const
Definition: CachingVertex.h:137
AdaptiveVertexFitter::RefCountedVertexTrack
ReferenceCountingPointer< VertexTrack< 5 > > RefCountedVertexTrack
Definition: AdaptiveVertexFitter.h:31
AdaptiveVertexFitter::theLinTrkFactory
const AbstractLTSFactory< 5 > * theLinTrkFactory
Definition: AdaptiveVertexFitter.h:202
AnnealingSchedule::clone
virtual AnnealingSchedule * clone() const =0
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
AdaptiveVertexFitter::vertex
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
Definition: AdaptiveVertexFitter.cc:158
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
AbstractLTSFactory::linearizedTrackState
virtual RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const =0
fileCollector.seed
seed
Definition: fileCollector.py:127
alignCSCRings.s
s
Definition: alignCSCRings.py:92
AdaptiveVertexFitter::reWeightTracks
std::vector< RefCountedVertexTrack > reWeightTracks(const std::vector< RefCountedLinearizedTrackState > &, const CachingVertex< 5 > &seed) const
Definition: AdaptiveVertexFitter.cc:344
w
const double w
Definition: UKUtility.cc:23
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
AdaptiveVertexFitter::AdaptiveVertexFitter
AdaptiveVertexFitter(const AnnealingSchedule &ann=GeometricAnnealing(), const LinearizationPointFinder &linP=DefaultLinearizationPointFinder(), const VertexUpdator< 5 > &updator=KalmanVertexUpdator< 5 >(), const VertexTrackCompatibilityEstimator< 5 > &estor=KalmanVertexTrackCompatibilityEstimator< 5 >(), const VertexSmoother< 5 > &smoother=DummyVertexSmoother< 5 >(), const AbstractLTSFactory< 5 > &ltsf=LinearizedTrackStateFactory())
Definition: AdaptiveVertexFitter.cc:102
VertexState::error
GlobalError error() const
Definition: VertexState.h:64
AdaptiveVertexFitter::setParameters
void setParameters(double maxshift=0.0001, double maxlpshift=0.1, unsigned maxstep=30, double weightthreshold=.001)
Definition: AdaptiveVertexFitter.cc:144
AdaptiveVertexFitter::theUpdator
VertexUpdator< 5 > * theUpdator
Definition: AdaptiveVertexFitter.h:198
Point3DBase< float, GlobalTag >
AdaptiveVertexFitter::theSmoother
VertexSmoother< 5 > * theSmoother
Definition: AdaptiveVertexFitter.h:199
AdaptiveVertexFitter::theMaxLPShift
double theMaxLPShift
Definition: AdaptiveVertexFitter.h:192
AnnealingSchedule::currentTemp
virtual double currentTemp() const =0
geometryDiff.file
file
Definition: geometryDiff.py:13
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
HLT_FULL_cff.updator
updator
Definition: HLT_FULL_cff.py:123
VertexSmoother::smooth
virtual CachingVertex< N > smooth(const CachingVertex< N > &vertex) const =0
AdaptiveVertexFitter::RefCountedLinearizedTrackState
ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
Definition: AdaptiveVertexFitter.h:32
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
VertexTrackFactory< 5 >
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
CachingVertex::position
GlobalPoint position() const
Definition: CachingVertex.cc:308
AdaptiveVertexFitter::theMaxShift
double theMaxShift
Definition: AdaptiveVertexFitter.h:191
VertexSmoother::clone
virtual VertexSmoother * clone() const =0
AdaptiveVertexFitter::linearizeTracks
std::vector< RefCountedVertexTrack > linearizeTracks(const std::vector< reco::TransientTrack > &, const VertexState &) const
Definition: AdaptiveVertexFitter.cc:283
GlobalErrorBase< double, ErrorMatrixTag >
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AdaptiveVertexFitter::weightTracks
std::vector< RefCountedVertexTrack > weightTracks(const std::vector< RefCountedLinearizedTrackState > &, const VertexState &seed) const
Definition: AdaptiveVertexFitter.cc:393
HLT_FULL_cff.weightthreshold
weightthreshold
Definition: HLT_FULL_cff.py:52056
LinearizationPointFinder::clone
virtual LinearizationPointFinder * clone() const =0
VertexTrackFactory::vertexTrack
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
Definition: VertexTrackFactory.h:27
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
AnnealingSchedule::weight
virtual double weight(double chi2) const =0
AbstractLTSFactory::clone
virtual const AbstractLTSFactory * clone() const =0
VertexState
Definition: VertexState.h:13
AnnealingSchedule::anneal
virtual void anneal()=0
AdaptiveVertexFitter::theAssProbComputer
AnnealingSchedule * theAssProbComputer
Definition: AdaptiveVertexFitter.h:200
LinearizationPointFinder::getLinearizationPoint
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
VertexState::position
GlobalPoint position() const
Definition: VertexState.h:62
L1TEGammaOffline_cfi.nVertex
nVertex
Definition: L1TEGammaOffline_cfi.py:60
AdaptiveVertexFitter::theComp
VertexTrackCompatibilityEstimator< 5 > * theComp
Definition: AdaptiveVertexFitter.h:201
AdaptiveVertexFitter::theWeightThreshold
double theWeightThreshold
Definition: AdaptiveVertexFitter.h:194
AdaptiveVertexFitter::theMaxStep
int theMaxStep
Definition: AdaptiveVertexFitter.h:193
getId
static unsigned int getId()
Definition: DQMStoreStats.h:129
AnnealingSchedule::resetAnnealing
virtual void resetAnnealing()=0
AdaptiveVertexFitter::getWeight
double getWeight(float chi2) const
Definition: AdaptiveVertexFitter.cc:329
AdaptiveVertexFitter::gsfIntermediarySmoothing_
bool gsfIntermediarySmoothing_
Definition: AdaptiveVertexFitter.h:203
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7746
weight
Definition: weight.py:1
AdaptiveVertexFitter::fit
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
Definition: AdaptiveVertexFitter.cc:451
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
AdaptiveVertexFitter::theLinP
LinearizationPointFinder * theLinP
Definition: AdaptiveVertexFitter.h:197
AdaptiveVertexFitter::theNr
int theNr
Definition: AdaptiveVertexFitter.h:195