CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 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())
 
 AdaptiveVertexFitter (const AdaptiveVertexFitter &original)
 
AdaptiveVertexFitterclone () const
 
void gsfIntermediarySmoothing (bool sm)
 
bool gsfIntermediarySmoothing () const
 
void setParameters (double maxshift=0.0001, double maxlpshift=0.1, unsigned maxstep=30, double weightthreshold=.001)
 
void setParameters (const edm::ParameterSet &)
 
void setWeightThreshold (float w)
 
virtual CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &) const
 
virtual CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &) const
 
virtual CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &, const reco::BeamSpot &spot) const
 
virtual CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &, const GlobalPoint &linPoint) const
 
virtual CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &, const GlobalPoint &priorPos, const GlobalError &priorError) const
 
virtual CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &beamSpot) const
 
virtual CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &, const GlobalPoint &priorPos, const GlobalError &priorError) const
 
virtual ~AdaptiveVertexFitter ()
 
- Public Member Functions inherited from VertexFitter< 5 >
virtual CachingVertex< N > vertex (const std::vector< typename CachingVertex< N >::RefCountedVertexTrack > &tracks) const =0
 
virtual CachingVertex< N > vertex (const std::vector< typename CachingVertex< N >::RefCountedVertexTrack > &tracks, const reco::BeamSpot &spot) const =0
 
virtual CachingVertex< N > vertex (const std::vector< typename CachingVertex< N >::RefCountedVertexTrack > &tracks, const GlobalPoint &priorPos, const GlobalError &priorError) 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
< RefCountedVertexTrack
linearizeTracks (const std::vector< reco::TransientTrack > &, const VertexState &) const
 
std::vector
< RefCountedVertexTrack
reLinearizeTracks (const std::vector< RefCountedVertexTrack > &tracks, const CachingVertex< 5 > &vertex) const
 
std::vector
< RefCountedVertexTrack
reWeightTracks (const std::vector< RefCountedLinearizedTrackState > &, const CachingVertex< 5 > &seed) const
 
std::vector
< RefCountedVertexTrack
reWeightTracks (const std::vector< RefCountedVertexTrack > &, const CachingVertex< 5 > &seed) const
 
std::vector
< RefCountedVertexTrack
weightTracks (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

Definition at line 34 of file AdaptiveVertexFitter.h.

Definition at line 33 of file AdaptiveVertexFitter.h.

Constructor & Destructor Documentation

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 92 of file AdaptiveVertexFitter.cc.

References setParameters().

Referenced by clone().

98  :
99  theNr(0),
100  theLinP(linP.clone()), theUpdator( updator.clone()),
101  theSmoother ( smoother.clone() ), theAssProbComputer( ann.clone() ),
102  theComp ( crit.clone() ), theLinTrkFactory ( ltsf.clone() ),
104 {
105  setParameters();
106 }
LinearizationPointFinder * theLinP
VertexUpdator< 5 > * theUpdator
virtual AnnealingSchedule * clone() const =0
virtual VertexSmoother * clone() const =0
virtual const AbstractLTSFactory * clone() const =0
VertexSmoother< 5 > * theSmoother
AnnealingSchedule * theAssProbComputer
void setParameters(double maxshift=0.0001, double maxlpshift=0.1, unsigned maxstep=30, double weightthreshold=.001)
virtual LinearizationPointFinder * clone() const =0
virtual VertexUpdator * clone() const =0
const AbstractLTSFactory< 5 > * theLinTrkFactory
VertexTrackCompatibilityEstimator< 5 > * theComp
AdaptiveVertexFitter::AdaptiveVertexFitter ( const AdaptiveVertexFitter original)

Definition at line 114 of file AdaptiveVertexFitter.cc.

114  :
115  theMaxShift ( o.theMaxShift ), theMaxLPShift ( o.theMaxLPShift ),
116  theMaxStep ( o.theMaxStep ), theWeightThreshold ( o.theWeightThreshold ),
117  theNr ( o.theNr ),
118  theLinP ( o.theLinP->clone() ), theUpdator ( o.theUpdator->clone() ),
119  theSmoother ( o.theSmoother->clone() ),
120  theAssProbComputer ( o.theAssProbComputer->clone() ),
121  theComp ( o.theComp->clone() ),
122  theLinTrkFactory ( o.theLinTrkFactory->clone() ),
123  gsfIntermediarySmoothing_(o.gsfIntermediarySmoothing_)
124 {}
LinearizationPointFinder * theLinP
VertexUpdator< 5 > * theUpdator
VertexSmoother< 5 > * theSmoother
AnnealingSchedule * theAssProbComputer
const AbstractLTSFactory< 5 > * theLinTrkFactory
VertexTrackCompatibilityEstimator< 5 > * theComp
AdaptiveVertexFitter::~AdaptiveVertexFitter ( )
virtual

Definition at line 126 of file AdaptiveVertexFitter.cc.

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

127 {
128  delete theLinP;
129  delete theUpdator;
130  delete theSmoother;
131  delete theAssProbComputer;
132  delete theComp;
133  delete theLinTrkFactory;
134 }
LinearizationPointFinder * theLinP
VertexUpdator< 5 > * theUpdator
VertexSmoother< 5 > * theSmoother
AnnealingSchedule * theAssProbComputer
const AbstractLTSFactory< 5 > * theLinTrkFactory
VertexTrackCompatibilityEstimator< 5 > * theComp

Member Function Documentation

AdaptiveVertexFitter * AdaptiveVertexFitter::clone ( void  ) const
virtual

Fit vertex out of a VertexSeed

Implements VertexFitter< 5 >.

Definition at line 361 of file AdaptiveVertexFitter.cc.

References AdaptiveVertexFitter().

Referenced by AdaptiveGsfVertexFitter::AdaptiveGsfVertexFitter().

362 {
363  return new AdaptiveVertexFitter( * this );
364 }
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())
CachingVertex< 5 > AdaptiveVertexFitter::fit ( const std::vector< RefCountedVertexTrack > &  tracks,
const VertexState priorSeed,
bool  withPrior 
) const
private

perform the fit

Definition at line 502 of file AdaptiveVertexFitter.cc.

References VertexUpdator< N >::add(), AnnealingSchedule::anneal(), ExpressReco_HICollisions_FallBack::chi2, AnnealingSchedule::currentTemp(), VertexState::error(), dbtoweb::file, CastorDbASCIIIO::getId(), gsfIntermediarySmoothing_, i, AnnealingSchedule::isAnnealed(), CachingVertex< N >::isValid(), LogDebug, m, mag(), PV3DBase< T, PVType, FrameType >::perp(), VertexState::position(), CachingVertex< N >::position(), reLinearizeTracks(), AnnealingSchedule::resetAnnealing(), reWeightTracks(), VertexSmoother< N >::smooth(), ExpressReco_HICollisions_FallBack::step, theAssProbComputer, theMaxLPShift, theMaxShift, theMaxStep, theSmoother, theUpdator, theWeightThreshold, transverse(), AnnealingSchedule::weight(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by vertex().

505 {
507 
508  vector<RefCountedVertexTrack> initialTracks;
509  GlobalPoint priorVertexPosition = priorSeed.position();
510  GlobalError priorVertexError = priorSeed.error();
511 
512  CachingVertex<5> returnVertex( priorVertexPosition,priorVertexError,
513  initialTracks,0);
514  if (withPrior)
515  {
516  returnVertex = CachingVertex<5>(priorVertexPosition,priorVertexError,
517  priorVertexPosition,priorVertexError,initialTracks,0);
518  }
519 
520  // vector<RefCountedVertexTrack> globalVTracks = tracks;
521  // sort the tracks, according to distance to seed!
522  vector<RefCountedVertexTrack> globalVTracks ( tracks.size() );
523 
524  partial_sort_copy ( tracks.begin(), tracks.end(),
525  globalVTracks.begin(), globalVTracks.end(), DistanceToRefPoint ( priorSeed.position() ) );
526 
527  // main loop through all the VTracks
528  int lpStep = 0; int step = 0;
529 
530  CachingVertex<5> initialVertex = returnVertex;
531 
532  GlobalPoint newPosition = priorVertexPosition;
533  GlobalPoint previousPosition = newPosition;
534 
535  int ns_trks=0; // number of significant tracks.
536  // If we have only two significant tracks, we return an invalid vertex
537 
538  do {
539  ns_trks=0;
540  CachingVertex<5> fVertex = initialVertex;
541  if ((previousPosition - newPosition).transverse() > theMaxLPShift)
542  {
543  // relinearize and reweight.
544  // (reLinearizeTracks also reweights tracks)
545  if (gsfIntermediarySmoothing_) returnVertex = theSmoother->smooth(returnVertex);
546  globalVTracks = reLinearizeTracks( globalVTracks, returnVertex );
547  lpStep++;
548  } else if (step) {
549  // reweight, if it is not the first step
550  if (gsfIntermediarySmoothing_) returnVertex = theSmoother->smooth(returnVertex);
551  globalVTracks = reWeightTracks( globalVTracks, returnVertex );
552  }
553  // update sequentially the vertex estimate
554  CachingVertex<5> nVertex;
555  for(vector<RefCountedVertexTrack>::const_iterator i
556  = globalVTracks.begin(); i != globalVTracks.end(); i++)
557  {
558  if ((**i).weight() > 0.) nVertex = theUpdator->add( fVertex, *i );
559  else nVertex = fVertex;
560  if (nVertex.isValid()) {
561  if ( (**i).weight() >= theWeightThreshold )
562  {
563  ns_trks++;
564  };
565 
566  if ( fabs ( nVertex.position().z() ) > 10000. ||
567  nVertex.position().perp()>120.)
568  {
569  // were more than 100 m off!!
570  LogWarning ("AdaptiveVertexFitter" ) << "Help! Vertex candidate just took off to " << nVertex.position()
571  << "! Will discard this update!";
572 // //<< "track pt was " << (**i).linearizedTrack()->track().pt()
573 // << "track momentum was " << (**i).linearizedTrack()->track().initialFreeState().momentum()
574 // << "track position was " << (**i).linearizedTrack()->track().initialFreeState().position()
575 // << "track chi2 was " << (**i).linearizedTrack()->track().chi2()
576 // << "track ndof was " << (**i).linearizedTrack()->track().ndof()
577 // << "track w was " << (**i).weight()
578 // << "track schi2 was " << (**i).smoothedChi2();
579  } else {
580  fVertex = nVertex;
581  }
582  } else {
583  LogWarning("RecoVertex|AdaptiveVertexFitter")
584  << "The updator returned an invalid vertex when adding track "
585  << i-globalVTracks.begin()
586  << ".\n Your vertex might just have lost one good track.";
587  };
588  }
589  previousPosition = newPosition;
590  newPosition = fVertex.position();
591  returnVertex = fVertex;
593  step++;
594  if ( step >= theMaxStep ) break;
595 
596  } while (
597  // repeat as long as
598  // - vertex moved too much or
599  // - we're not yet annealed
600  ( ((previousPosition - newPosition).mag() > theMaxShift) ||
601  (!(theAssProbComputer->isAnnealed()) ) ) ) ;
602 
603  if ( theWeightThreshold > 0. && ns_trks < 2 && !withPrior )
604  {
605  LogDebug("AdaptiveVertexFitter")
606  << "fewer than two significant tracks (w>" << theWeightThreshold << ")."
607  << " Fitted vertex is invalid.";
608  return CachingVertex<5>(); // return invalid vertex
609  }
610 
611  #ifdef STORE_WEIGHTS
612  map < string, dataharvester::MultiType > m;
613  m["chi2"]=chi2;
614  m["w"]=theAssProbComputer->weight(chi2);
616  m["n"]=iter;
617  m["id"]=getId ( *i );
618  m["pos"]="final";
619  dataharvester::Writer::file("w.txt").save ( m );
620  #endif
621  return theSmoother->smooth( returnVertex );
622 }
#define LogDebug(id)
virtual bool isAnnealed() const =0
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:66
std::vector< RefCountedVertexTrack > reWeightTracks(const std::vector< RefCountedLinearizedTrackState > &, const CachingVertex< 5 > &seed) const
list file
Definition: dbtoweb.py:253
VertexUpdator< 5 > * theUpdator
T transverse() const
Another name for perp()
GlobalPoint position() const
Definition: VertexState.h:29
std::vector< RefCountedVertexTrack > reLinearizeTracks(const std::vector< RefCountedVertexTrack > &tracks, const CachingVertex< 5 > &vertex) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
virtual CachingVertex< N > add(const CachingVertex< N > &v, const typename CachingVertex< N >::RefCountedVertexTrack t) const =0
T z() const
Definition: PV3DBase.h:58
VertexSmoother< 5 > * theSmoother
AnnealingSchedule * theAssProbComputer
DetId getId(const std::vector< std::string > &items)
virtual double currentTemp() const =0
tuple tracks
Definition: testEve_cfg.py:39
virtual CachingVertex< N > smooth(const CachingVertex< N > &vertex) const =0
GlobalPoint position() const
bool isValid() const
Definition: CachingVertex.h:96
virtual void anneal()=0
virtual void resetAnnealing()=0
GlobalError error() const
Definition: VertexState.h:34
virtual double weight(double chi2) const =0
double AdaptiveVertexFitter::getWeight ( float  chi2) const
private

Definition at line 366 of file AdaptiveVertexFitter.cc.

References ExpressReco_HICollisions_FallBack::e, theAssProbComputer, AnnealingSchedule::weight(), and CommonMethods::weight().

Referenced by reWeightTracks(), and weightTracks().

367 {
369 
370  if ( weight > 1.0 )
371  {
372  LogWarning("RecoVertex/AdaptiveVertexFitter") << "Weight " << weight << " > 1.0!";
373  weight=1.0;
374  };
375 
376  if ( weight < 1e-20 )
377  {
378  // LogWarning("RecoVertex/AdaptiveVertexFitter") << "Weight " << weight << " < 0.0!";
379  weight=1e-20;
380  };
381  return weight;
382 }
AnnealingSchedule * theAssProbComputer
virtual double weight(double chi2) const =0
void AdaptiveVertexFitter::gsfIntermediarySmoothing ( bool  sm)
inline
bool AdaptiveVertexFitter::gsfIntermediarySmoothing ( ) const
inline

Definition at line 143 of file AdaptiveVertexFitter.h.

References gsfIntermediarySmoothing_.

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 306 of file AdaptiveVertexFitter.cc.

References ExpressReco_HICollisions_FallBack::e, cmsCodeRules.cppFunctionSkipper::exception, i, AbstractLTSFactory< N >::linearizedTrackState(), VertexState::position(), theLinTrkFactory, and weightTracks().

Referenced by vertex().

308 {
309  const GlobalPoint & linP ( seed.position() );
310  vector<RefCountedLinearizedTrackState> lTracks;
311  for(vector<reco::TransientTrack>::const_iterator i = tracks.begin();
312  i != tracks.end(); ++i )
313  {
314  try {
317  lTracks.push_back(lTrData);
318  } catch ( exception & e ) {
319  LogWarning("RecoVertex/AdaptiveVertexFitter")
320  << "Exception " << e.what() << " in ::linearizeTracks."
321  << "Your future vertex has just lost a track.";
322  };
323  }
324  return weightTracks(lTracks, seed );
325 }
int i
Definition: DBlmapReader.cc:9
virtual RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const =0
GlobalPoint position() const
Definition: VertexState.h:29
tuple tracks
Definition: testEve_cfg.py:39
ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
std::vector< RefCountedVertexTrack > weightTracks(const std::vector< RefCountedLinearizedTrackState > &, const VertexState &seed) const
const AbstractLTSFactory< 5 > * theLinTrkFactory
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 333 of file AdaptiveVertexFitter.cc.

References ExpressReco_HICollisions_FallBack::e, cmsCodeRules.cppFunctionSkipper::exception, i, AbstractLTSFactory< N >::linearizedTrackState(), VertexState::position(), reWeightTracks(), theLinTrkFactory, and CachingVertex< N >::vertexState().

Referenced by fit().

336 {
337  VertexState seed = vertex.vertexState();
338  GlobalPoint linP = seed.position();
339  vector<RefCountedLinearizedTrackState> lTracks;
340  for(vector<RefCountedVertexTrack>::const_iterator i = tracks.begin();
341  i != tracks.end(); i++)
342  {
343  try {
345  = theLinTrkFactory->linearizedTrackState( linP, (**i).linearizedTrack()->track() );
346  /*
347  RefCountedLinearizedTrackState lTrData =
348  (**i).linearizedTrack()->stateWithNewLinearizationPoint(linP);
349  */
350  lTracks.push_back(lTrData);
351  } catch ( exception & e ) {
352  LogWarning("RecoVertex/AdaptiveVertexFitter")
353  << "Exception " << e.what() << " in ::relinearizeTracks. "
354  << "Will not relinearize this track.";
355  lTracks.push_back ( (**i).linearizedTrack() );
356  };
357  };
358  return reWeightTracks(lTracks, vertex );
359 }
int i
Definition: DBlmapReader.cc:9
VertexState vertexState() const
Definition: CachingVertex.h:86
std::vector< RefCountedVertexTrack > reWeightTracks(const std::vector< RefCountedLinearizedTrackState > &, const CachingVertex< 5 > &seed) const
virtual RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const =0
GlobalPoint position() const
Definition: VertexState.h:29
tuple tracks
Definition: testEve_cfg.py:39
ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
const AbstractLTSFactory< 5 > * theLinTrkFactory
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 385 of file AdaptiveVertexFitter.cc.

References ExpressReco_HICollisions_FallBack::chi2, gather_cfg::cout, AnnealingSchedule::currentTemp(), VertexTrackCompatibilityEstimator< N >::estimate(), dbtoweb::file, CastorDbASCIIIO::getId(), getWeight(), i, m, CachingVertex< N >::position(), theAssProbComputer, theComp, theNr, CachingVertex< N >::vertexState(), VertexTrackFactory< N >::vertexTrack(), AnnealingSchedule::weight(), and CommonMethods::weight().

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

388 {
389  VertexState seed = vertex.vertexState();
390  theNr++;
391  // GlobalPoint pos = seed.position();
392 
393  vector<RefCountedVertexTrack> finalTracks;
394  VertexTrackFactory<5> vTrackFactory;
395  #ifdef STORE_WEIGHTS
396  iter++;
397  #endif
398  for(vector<RefCountedLinearizedTrackState>::const_iterator i
399  = lTracks.begin(); i != lTracks.end(); i++)
400  {
401  double weight=0.;
402  pair<bool, double> chi2Res = theComp->estimate ( vertex, *i );
403  if (!chi2Res.first) {
404  cout << "[AdaptiveVertexFitter] aie... vertex candidate is at " << vertex.position() << endl;
405  LogWarning("AdaptiveVertexFitter" ) << "When reweighting, chi2<0. Will add this track with w=0.";
406  // edm::LogWarning("AdaptiveVertexFitter" ) << "pt=" << (**i).track().pt();
407  }else {
408  weight = getWeight ( chi2Res.second );
409  }
410 
411  RefCountedVertexTrack vTrData
412  = vTrackFactory.vertexTrack(*i, seed, weight );
413 
414  #ifdef STORE_WEIGHTS
415  map < string, dataharvester::MultiType > m;
416  m["chi2"]=chi2;
417  m["w"]=theAssProbComputer->weight(chi2);
419  m["n"]=iter;
420  m["pos"]="reweight";
421  m["id"]=getId ( *i );
422  dataharvester::Writer::file("w.txt").save ( m );
423  #endif
424 
425  finalTracks.push_back(vTrData);
426  }
427  return finalTracks;
428 }
virtual BDpair estimate(const CachingVertex< N > &v, const RefCountedLinearizedTrackState track) const =0
int i
Definition: DBlmapReader.cc:9
VertexState vertexState() const
Definition: CachingVertex.h:86
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
list file
Definition: dbtoweb.py:253
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const
ReferenceCountingPointer< VertexTrack< 5 > > RefCountedVertexTrack
AnnealingSchedule * theAssProbComputer
DetId getId(const std::vector< std::string > &items)
virtual double currentTemp() const =0
double getWeight(float chi2) const
GlobalPoint position() const
tuple cout
Definition: gather_cfg.py:41
virtual double weight(double chi2) const =0
VertexTrackCompatibilityEstimator< 5 > * theComp
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 482 of file AdaptiveVertexFitter.cc.

References i, and reWeightTracks().

485 {
486  vector<RefCountedLinearizedTrackState> lTracks;
487  for(vector<RefCountedVertexTrack>::const_iterator i = tracks.begin();
488  i != tracks.end(); i++)
489  {
490  lTracks.push_back((**i).linearizedTrack());
491  }
492 
493  return reWeightTracks(lTracks, seed);
494 }
int i
Definition: DBlmapReader.cc:9
std::vector< RefCountedVertexTrack > reWeightTracks(const std::vector< RefCountedLinearizedTrackState > &, const CachingVertex< 5 > &seed) const
tuple tracks
Definition: testEve_cfg.py:39
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 136 of file AdaptiveVertexFitter.cc.

References theMaxLPShift, theMaxShift, theMaxStep, and theWeightThreshold.

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

138 {
139  theMaxShift = maxshift;
140  theMaxLPShift = maxlpshift;
141  theMaxStep = maxstep;
142  theWeightThreshold=weightthreshold;
143 }
void AdaptiveVertexFitter::setParameters ( const edm::ParameterSet s)

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

Definition at line 146 of file AdaptiveVertexFitter.cc.

References edm::ParameterSet::getParameter(), and setParameters().

147 {
148  setParameters ( s.getParameter<double>("maxshift"),
149  s.getParameter<double>("maxlpshift"),
150  s.getParameter<int>("maxstep"),
151  s.getParameter<double>("weightthreshold") );
152 }
T getParameter(std::string const &) const
void setParameters(double maxshift=0.0001, double maxlpshift=0.1, unsigned maxstep=30, double weightthreshold=.001)
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 108 of file AdaptiveVertexFitter.cc.

References theWeightThreshold.

Referenced by AdaptiveVertexReconstructor::setupFitters().

109 {
111 }
CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  tracks) const
virtual

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 155 of file AdaptiveVertexFitter.cc.

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

Referenced by NuclearVertexBuilder::FillVertexWithAdaptVtxFitter(), V0Fitter::fitAll(), PFDisplacedVertexFinder::fitVertexFromSeed(), PrimaryVertexAnalyzer4PU::getSimEvents(), InclusiveVertexFinder::produce(), TrackVertexArbitrator::produce(), AdaptiveGsfVertexFitter::vertex(), and AdaptiveVertexReconstructor::vertices().

156 {
157  if ( tracks.size() < 2 )
158  {
159  LogError("RecoVertex|AdaptiveVertexFitter")
160  << "Supplied fewer than two tracks. Vertex is invalid.";
161  return CachingVertex<5>(); // return invalid vertex
162  };
163  // Linearization Point
165  // Initial vertex seed, with a very large error matrix
166  VertexState lseed (linP, linPointError() );
167  vector<RefCountedVertexTrack> vtContainer = linearizeTracks(tracks, lseed);
168 
169  VertexState seed (linP, fitError() );
170  return fit(vtContainer, seed, false);
171 }
LinearizationPointFinder * theLinP
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
tuple tracks
Definition: testEve_cfg.py:39
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
std::vector< RefCountedVertexTrack > linearizeTracks(const std::vector< reco::TransientTrack > &, const VertexState &) const
CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  tracks) const
virtual

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 174 of file AdaptiveVertexFitter.cc.

References fit().

175 {
176  if ( tracks.size() < 2 )
177  {
178  LogError("RecoVertex|AdaptiveVertexFitter")
179  << "Supplied fewer than two tracks. Vertex is invalid.";
180  return CachingVertex<5>(); // return invalid vertex
181  };
182  // Initial vertex seed, with a very small weight matrix
183  GlobalPoint linP = tracks[0]->linearizedTrack()->linearizationPoint();
184  VertexState seed (linP, fitError() );
185  return fit(tracks, seed, false);
186 }
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
tuple tracks
Definition: testEve_cfg.py:39
CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  tracks,
const reco::BeamSpot spot 
) const
virtual

Same as above, only now also with BeamSpot constraint.

Definition at line 189 of file AdaptiveVertexFitter.cc.

References fit().

190 {
191  if ( tracks.size() < 1 )
192  {
193  LogError("RecoVertex|AdaptiveVertexFitter")
194  << "Supplied no tracks. Vertex is invalid.";
195  return CachingVertex<5>(); // return invalid vertex
196  };
197  VertexState beamSpotState(spot);
198  return fit(tracks, beamSpotState, true );
199 }
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
tuple tracks
Definition: testEve_cfg.py:39
CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  tracks,
const GlobalPoint linPoint 
) const
virtual

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 207 of file AdaptiveVertexFitter.cc.

References fit(), and linearizeTracks().

209 {
210  if ( tracks.size() < 2 )
211  {
212  LogError("RecoVertex|AdaptiveVertexFitter")
213  << "Supplied fewer than two tracks. Vertex is invalid.";
214  return CachingVertex<5>(); // return invalid vertex
215  };
216  // Initial vertex seed, with a very large error matrix
217  VertexState seed (linPoint, linPointError() );
218  vector<RefCountedVertexTrack> vtContainer = linearizeTracks(tracks, seed);
219  VertexState fitseed (linPoint, fitError() );
220  return fit(vtContainer, fitseed, false);
221 }
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
tuple tracks
Definition: testEve_cfg.py:39
std::vector< RefCountedVertexTrack > linearizeTracks(const std::vector< reco::TransientTrack > &, const VertexState &) const
CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  tracks,
const GlobalPoint priorPos,
const GlobalError priorError 
) const
virtual

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 261 of file AdaptiveVertexFitter.cc.

References fit(), and linearizeTracks().

265 {
266  if ( tracks.size() < 1 )
267  {
268  LogError("RecoVertex|AdaptiveVertexFitter")
269  << "Supplied no tracks. Vertex is invalid.";
270  return CachingVertex<5>(); // return invalid vertex
271  };
272  VertexState seed (priorPos, priorError);
273  vector<RefCountedVertexTrack> vtContainer = linearizeTracks(tracks, seed);
274  return fit( vtContainer, seed, true );
275 }
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
tuple tracks
Definition: testEve_cfg.py:39
std::vector< RefCountedVertexTrack > linearizeTracks(const std::vector< reco::TransientTrack > &, const VertexState &) const
CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  tracks,
const reco::BeamSpot beamSpot 
) const
virtual

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 229 of file AdaptiveVertexFitter.cc.

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

231 {
232  if ( tracks.size() < 1 )
233  {
234  LogError("RecoVertex|AdaptiveVertexFitter")
235  << "Supplied no tracks. Vertex is invalid.";
236  return CachingVertex<5>(); // return invalid vertex
237  };
238 
239  VertexState beamSpotState(beamSpot);
240  vector<RefCountedVertexTrack> vtContainer;
241 
242  if (tracks.size() > 1) {
243  // Linearization Point search if there are more than 1 track
245  VertexState lpState(linP, linPointError() );
246  vtContainer = linearizeTracks(tracks, lpState);
247  } else {
248  // otherwise take the beamspot position.
249  vtContainer = linearizeTracks(tracks, beamSpotState);
250  }
251 
252  return fit(vtContainer, beamSpotState, true);
253 }
LinearizationPointFinder * theLinP
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
tuple tracks
Definition: testEve_cfg.py:39
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
std::vector< RefCountedVertexTrack > linearizeTracks(const std::vector< reco::TransientTrack > &, const VertexState &) const
CachingVertex< 5 > AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  tracks,
const GlobalPoint priorPos,
const GlobalError priorError 
) const
virtual

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 282 of file AdaptiveVertexFitter.cc.

References fit().

286 {
287  if ( tracks.size() < 1 )
288  {
289  LogError("RecoVertex|AdaptiveVertexFitter")
290  << "Supplied no tracks. Vertex is invalid.";
291  return CachingVertex<5>(); // return invalid vertex
292  };
293  VertexState seed (priorPos, priorError);
294  return fit(tracks, seed, true);
295 }
CachingVertex< 5 > fit(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &priorSeed, bool withPrior) const
tuple tracks
Definition: testEve_cfg.py:39
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 431 of file AdaptiveVertexFitter.cc.

References ExpressReco_HICollisions_FallBack::chi2, gather_cfg::cout, AnnealingSchedule::currentTemp(), VertexTrackCompatibilityEstimator< N >::estimate(), dbtoweb::file, CastorDbASCIIIO::getId(), getWeight(), i, m, AnnealingSchedule::resetAnnealing(), theAssProbComputer, theComp, theNr, VertexTrackFactory< N >::vertexTrack(), AnnealingSchedule::weight(), and CommonMethods::weight().

Referenced by linearizeTracks().

434 {
435  theNr++;
436  CachingVertex<5> seedvtx ( seed, vector<RefCountedVertexTrack> (), 0. );
440 
441  vector<RefCountedVertexTrack> finalTracks;
442  VertexTrackFactory<5> vTrackFactory;
443  #ifdef STORE_WEIGHTS
444  iter++;
445  #endif
446  for(vector<RefCountedLinearizedTrackState>::const_iterator i
447  = lTracks.begin(); i != lTracks.end(); i++)
448  {
449 
450  double weight = 0.;
451  pair<bool, double> chi2Res = theComp->estimate ( seedvtx, *i );
452  if (!chi2Res.first) {
453  cout << "[AdaptiveVertexFitter] Aiee! " << endl;
454  LogWarning ("AdaptiveVertexFitter" ) << "When weighting a track, chi2 calculation failed;"
455  << " will add with w=0.";
456  } else {
457  weight = getWeight ( chi2Res.second );
458  }
459  RefCountedVertexTrack vTrData
460  = vTrackFactory.vertexTrack(*i, seed, weight );
461  #ifdef STORE_WEIGHTS
462  map < string, dataharvester::MultiType > m;
463  m["chi2"]=chi2;
464  m["w"]=theAssProbComputer->weight(chi2);
466  m["n"]=iter;
467  m["id"]=getId ( *i );
468  m["pos"]="weight";
469  dataharvester::Writer::file("w.txt").save ( m );
470  #endif
471  finalTracks.push_back(vTrData);
472  }
473  return finalTracks;
474 }
virtual BDpair estimate(const CachingVertex< N > &v, const RefCountedLinearizedTrackState track) const =0
int i
Definition: DBlmapReader.cc:9
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
list file
Definition: dbtoweb.py:253
ReferenceCountingPointer< VertexTrack< 5 > > RefCountedVertexTrack
AnnealingSchedule * theAssProbComputer
DetId getId(const std::vector< std::string > &items)
virtual double currentTemp() const =0
double getWeight(float chi2) const
virtual void resetAnnealing()=0
tuple cout
Definition: gather_cfg.py:41
virtual double weight(double chi2) const =0
VertexTrackCompatibilityEstimator< 5 > * theComp

Member Data Documentation

bool AdaptiveVertexFitter::gsfIntermediarySmoothing_
private

Definition at line 215 of file AdaptiveVertexFitter.h.

Referenced by fit(), and gsfIntermediarySmoothing().

AnnealingSchedule* AdaptiveVertexFitter::theAssProbComputer
private
VertexTrackCompatibilityEstimator<5>* AdaptiveVertexFitter::theComp
private

Definition at line 213 of file AdaptiveVertexFitter.h.

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

LinearizationPointFinder* AdaptiveVertexFitter::theLinP
private

Definition at line 209 of file AdaptiveVertexFitter.h.

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

const AbstractLTSFactory<5>* AdaptiveVertexFitter::theLinTrkFactory
private
double AdaptiveVertexFitter::theMaxLPShift
private

Definition at line 204 of file AdaptiveVertexFitter.h.

Referenced by fit(), and setParameters().

double AdaptiveVertexFitter::theMaxShift
private

Definition at line 203 of file AdaptiveVertexFitter.h.

Referenced by fit(), and setParameters().

int AdaptiveVertexFitter::theMaxStep
private

Definition at line 205 of file AdaptiveVertexFitter.h.

Referenced by fit(), and setParameters().

int AdaptiveVertexFitter::theNr
mutableprivate

Definition at line 207 of file AdaptiveVertexFitter.h.

Referenced by reWeightTracks(), and weightTracks().

VertexSmoother<5>* AdaptiveVertexFitter::theSmoother
private

Definition at line 211 of file AdaptiveVertexFitter.h.

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

VertexUpdator<5>* AdaptiveVertexFitter::theUpdator
private

Definition at line 210 of file AdaptiveVertexFitter.h.

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

double AdaptiveVertexFitter::theWeightThreshold
private

Definition at line 206 of file AdaptiveVertexFitter.h.

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