CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

AdaptiveVertexFitter Class Reference

#include <AdaptiveVertexFitter.h>

Inheritance diagram for AdaptiveVertexFitter:
VertexFitter< 5 >

List of all members.

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
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)
virtual CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &beamSpot) const
virtual CachingVertex< 5 > vertex (const std::vector< reco::TransientTrack > &, const GlobalPoint &linPoint) const
virtual CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &, const reco::BeamSpot &spot) const
virtual CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &) 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 > &) const
virtual CachingVertex< 5 > vertex (const std::vector< RefCountedVertexTrack > &, const GlobalPoint &priorPos, const GlobalError &priorError) const
virtual ~AdaptiveVertexFitter ()

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_
int mctr_
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 98 of file AdaptiveVertexFitter.cc.

References setParameters().

Referenced by clone().

                                           :
    theNr(0),
    theLinP(linP.clone()), theUpdator( updator.clone()),
    theSmoother ( smoother.clone() ), theAssProbComputer( ann.clone() ),
    theComp ( crit.clone() ), theLinTrkFactory ( ltsf.clone() ),
    gsfIntermediarySmoothing_(false)
{
  setParameters();
}
AdaptiveVertexFitter::AdaptiveVertexFitter ( const AdaptiveVertexFitter original)

Definition at line 120 of file AdaptiveVertexFitter.cc.

                                                          :
    theMaxShift ( o.theMaxShift ), theMaxLPShift ( o.theMaxLPShift ),
    theMaxStep ( o.theMaxStep ), theWeightThreshold ( o.theWeightThreshold ),
    theNr ( o.theNr ),
    theLinP ( o.theLinP->clone() ), theUpdator ( o.theUpdator->clone() ),
    theSmoother ( o.theSmoother->clone() ),
    theAssProbComputer ( o.theAssProbComputer->clone() ),
    theComp ( o.theComp->clone() ),
    theLinTrkFactory ( o.theLinTrkFactory->clone() ),
    gsfIntermediarySmoothing_(o.gsfIntermediarySmoothing_)
{}
AdaptiveVertexFitter::~AdaptiveVertexFitter ( ) [virtual]

Definition at line 132 of file AdaptiveVertexFitter.cc.

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

{
  delete theLinP;
  delete theUpdator;
  delete theSmoother;
  delete theAssProbComputer;
  delete theComp;
  delete theLinTrkFactory;
}

Member Function Documentation

AdaptiveVertexFitter * AdaptiveVertexFitter::clone ( void  ) const [virtual]

Fit vertex out of a VertexSeed

Implements VertexFitter< 5 >.

Definition at line 372 of file AdaptiveVertexFitter.cc.

References AdaptiveVertexFitter().

Referenced by AdaptiveGsfVertexFitter::AdaptiveGsfVertexFitter().

{
  return new AdaptiveVertexFitter( * this );
}
CachingVertex<5> AdaptiveVertexFitter::fit ( const std::vector< RefCountedVertexTrack > &  tracks,
const VertexState priorSeed,
bool  withPrior 
) const [private]

perform the fit

double AdaptiveVertexFitter::getWeight ( float  chi2) const [private]

Definition at line 377 of file AdaptiveVertexFitter.cc.

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

Referenced by weightTracks().

{
  double weight = theAssProbComputer->weight(chi2);

  if ( weight > 1.0 )
  {
    LogWarning("RecoVertex/AdaptiveVertexFitter") << "Weight " << weight << " > 1.0!";
    weight=1.0;
  };

  if ( weight < 1e-20 )
  {
    // LogWarning("RecoVertex/AdaptiveVertexFitter") << "Weight " << weight << " < 0.0!";
    weight=1e-20;
  };
  return weight;
}
void AdaptiveVertexFitter::gsfIntermediarySmoothing ( bool  sm) [inline]
bool AdaptiveVertexFitter::gsfIntermediarySmoothing ( ) const [inline]

Definition at line 143 of file AdaptiveVertexFitter.h.

References gsfIntermediarySmoothing_.

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

Linearize tracks, for the first time in the iteration.

std::vector<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.
std::vector<RefCountedVertexTrack> AdaptiveVertexFitter::reWeightTracks ( const std::vector< RefCountedVertexTrack > &  ,
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.

std::vector<RefCountedVertexTrack> AdaptiveVertexFitter::reWeightTracks ( const std::vector< RefCountedLinearizedTrackState > &  ,
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.

Referenced by SequentialVertexFitter< 5 >::reLinearizeTracks().

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

References theMaxLPShift, theMaxShift, theMaxStep, and theWeightThreshold.

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

{
  theMaxShift = maxshift;
  theMaxLPShift = maxlpshift;
  theMaxStep = maxstep;
  theWeightThreshold=weightthreshold;
}
void AdaptiveVertexFitter::setParameters ( const edm::ParameterSet s)

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

Definition at line 152 of file AdaptiveVertexFitter.cc.

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

{
    setParameters ( s.getParameter<double>("maxshift"),
                    s.getParameter<double>("maxlpshift"),
                    s.getParameter<int>("maxstep"),
                    s.getParameter<double>("weightthreshold") );
}
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 114 of file AdaptiveVertexFitter.cc.

References theWeightThreshold.

Referenced by AdaptiveVertexReconstructor::setupFitters().

virtual CachingVertex<5> AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  ,
const GlobalPoint linPoint 
) const [virtual]

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

Implements VertexFitter< 5 >.

virtual CachingVertex<5> AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  ,
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 >.

virtual CachingVertex<5> AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  ,
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.

virtual CachingVertex<5> AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  ) 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
virtual 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 >.

virtual CachingVertex<5> AdaptiveVertexFitter::vertex ( const std::vector< reco::TransientTrack > &  ) 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 >.

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

virtual CachingVertex<5> AdaptiveVertexFitter::vertex ( const std::vector< RefCountedVertexTrack > &  ,
const reco::BeamSpot spot 
) const [virtual]

Same as above, only now also with BeamSpot constraint.

vector< AdaptiveVertexFitter::RefCountedVertexTrack > AdaptiveVertexFitter::weightTracks ( const std::vector< RefCountedLinearizedTrackState > &  ,
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 451 of file AdaptiveVertexFitter.cc.

References AnnealingSchedule::currentTemp(), VertexTrackCompatibilityEstimator< N >::estimate(), mergeVDriftHistosByStation::file, getId(), getWeight(), i, m, AnnealingSchedule::resetAnnealing(), theAssProbComputer, theComp, theNr, VertexTrackFactory< N >::vertexTrack(), and AnnealingSchedule::weight().

Referenced by SequentialVertexFitter< 5 >::linearizeTracks().

{
  theNr++;
  CachingVertex<5> seedvtx ( seed, vector<RefCountedVertexTrack> (), 0. );
  theAssProbComputer->resetAnnealing();

  vector<RefCountedVertexTrack> finalTracks;
  VertexTrackFactory<5> vTrackFactory;
  #ifdef STORE_WEIGHTS
  iter++;
  #endif
  for(vector<RefCountedLinearizedTrackState>::const_iterator i
        = lTracks.begin(); i != lTracks.end(); i++)
  {

    double weight = 0.;
    pair<bool, double> chi2Res = theComp->estimate ( seedvtx, *i );
    if (!chi2Res.first) {
      // cout << "[AdaptiveVertexFitter] Aiee! " << endl;
      LogWarning ("AdaptiveVertexFitter" ) << "When weighting a track, chi2 calculation failed;"
                                           << " will add with w=0.";
    } else {
      weight = getWeight ( chi2Res.second );
    }
    RefCountedVertexTrack vTrData
       = vTrackFactory.vertexTrack(*i, seed, weight );
    #ifdef STORE_WEIGHTS
    map < string, dataharvester::MultiType > m;
    m["chi2"]=chi2;
    m["w"]=theAssProbComputer->weight(chi2);
    m["T"]=theAssProbComputer->currentTemp();
    m["n"]=iter;
    m["id"]=getId ( *i );
    m["pos"]="weight";
    dataharvester::Writer::file("w.txt").save ( m );
    #endif
    finalTracks.push_back(vTrData);
  }
  return finalTracks;
}

Member Data Documentation

Definition at line 215 of file AdaptiveVertexFitter.h.

Referenced by gsfIntermediarySmoothing().

int AdaptiveVertexFitter::mctr_ [mutable, private]

Definition at line 216 of file AdaptiveVertexFitter.h.

Definition at line 212 of file AdaptiveVertexFitter.h.

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

Definition at line 213 of file AdaptiveVertexFitter.h.

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

Definition at line 209 of file AdaptiveVertexFitter.h.

Referenced by ~AdaptiveVertexFitter().

Definition at line 204 of file AdaptiveVertexFitter.h.

Referenced by setParameters().

Definition at line 203 of file AdaptiveVertexFitter.h.

Referenced by setParameters().

Definition at line 205 of file AdaptiveVertexFitter.h.

Referenced by setParameters().

int AdaptiveVertexFitter::theNr [mutable, private]

Definition at line 207 of file AdaptiveVertexFitter.h.

Referenced by weightTracks().

Definition at line 211 of file AdaptiveVertexFitter.h.

Referenced by ~AdaptiveVertexFitter().

Definition at line 210 of file AdaptiveVertexFitter.h.

Referenced by ~AdaptiveVertexFitter().

Definition at line 206 of file AdaptiveVertexFitter.h.

Referenced by setParameters(), and setWeightThreshold().