CMS 3D CMS Logo

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

GsfVertexSmoother Class Reference

#include <GsfVertexSmoother.h>

Inheritance diagram for GsfVertexSmoother:
VertexSmoother< 5 >

List of all members.

Public Member Functions

virtual VertexSmoother< 5 > * clone () const
 GsfVertexSmoother (bool limit, const GsfVertexMerger *merger)
virtual CachingVertex< 5 > smooth (const CachingVertex< 5 > &vertex) const
const VertexUpdator< 5 > * vertexUpdator () const
virtual ~GsfVertexSmoother ()

Private Types

typedef VertexTrack
< 5 >::AlgebraicMatrix3M 
AlgebraicMatrix3M
typedef VertexTrack
< 5 >::AlgebraicSymMatrixOO 
AlgebraicSymMatrixOO
typedef std::vector
< RefCountedLinearizedTrackState
LTC
typedef VertexTrack
< 5 >::RefCountedLinearizedTrackState 
RefCountedLinearizedTrackState
typedef VertexTrack
< 5 >::RefCountedRefittedTrackState 
RefCountedRefittedTrackState
typedef CachingVertex
< 5 >::RefCountedVertexTrack 
RefCountedVertexTrack
typedef std::pair
< TrackWeightPair,
VtxTrkChi2Pair
RefittedTrackComponent
typedef std::pair
< RefCountedRefittedTrackState,
VtxTrkChi2Pair
TrackChi2Pair
typedef std::pair
< RefCountedRefittedTrackState,
double > 
TrackWeightPair
typedef std::vector< VertexStateVSC
typedef std::pair< double, double > VtxTrkChi2Pair

Private Member Functions

TrackChi2Pair assembleTrackComponents (const std::vector< RefittedTrackComponent > &trackComponents, const GlobalPoint &referencePosition) const
RefittedTrackComponent createNewComponent (const VertexState &oldVertex, const RefCountedLinearizedTrackState linTrack, float weight) const
VertexState meanVertex (const VertexState &vertexA, const VertexState &vertexB) const
double priorVertexChi2 (const VertexState priorVertex, const VertexState fittedVertex) const
TrackChi2Pair vertexAndTrackUpdate (const VertexState &oldVertex, const RefCountedVertexTrack track, const GlobalPoint &referencePosition) const

Private Attributes

KVFHelper< 5 > helper
KalmanVertexUpdator< 5 > kalmanVertexUpdator
bool limitComponents
KalmanSmoothedVertexChi2Estimator< 5 > smoothedChi2Estimator
DeepCopyPointerByClone
< GsfVertexMerger
theMerger
GsfVertexUpdator theUpdator
KalmanVertexTrackUpdator< 5 > theVertexTrackUpdator
VertexTrackFactory< 5 > theVTFactory
GsfVertexWeightCalculator theWeightCalculator

Detailed Description

The class which handles the track-refit and smoothed chi**2 calculations for the Gaussian Sum vertex fit. The track-to-track covariance matrix calculation is not yet done.

Definition at line 23 of file GsfVertexSmoother.h.


Member Typedef Documentation

Definition at line 66 of file GsfVertexSmoother.h.

Definition at line 67 of file GsfVertexSmoother.h.

Definition at line 70 of file GsfVertexSmoother.h.

Definition at line 64 of file GsfVertexSmoother.h.

Definition at line 65 of file GsfVertexSmoother.h.

Definition at line 63 of file GsfVertexSmoother.h.

Definition at line 74 of file GsfVertexSmoother.h.

Definition at line 73 of file GsfVertexSmoother.h.

Definition at line 72 of file GsfVertexSmoother.h.

typedef std::vector<VertexState> GsfVertexSmoother::VSC [private]

Definition at line 69 of file GsfVertexSmoother.h.

typedef std::pair<double, double> GsfVertexSmoother::VtxTrkChi2Pair [private]

Definition at line 71 of file GsfVertexSmoother.h.


Constructor & Destructor Documentation

GsfVertexSmoother::GsfVertexSmoother ( bool  limit,
const GsfVertexMerger merger 
)

The constructor

Parameters:
limitSpecifies whether the number of components of the vertex should be limited

Definition at line 6 of file GsfVertexSmoother.cc.

References GsfVertexMerger::clone(), limitComponents, and theMerger.

Referenced by clone().

virtual GsfVertexSmoother::~GsfVertexSmoother ( ) [inline, virtual]

Definition at line 35 of file GsfVertexSmoother.h.

{}

Member Function Documentation

GsfVertexSmoother::TrackChi2Pair GsfVertexSmoother::assembleTrackComponents ( const std::vector< RefittedTrackComponent > &  trackComponents,
const GlobalPoint referencePosition 
) const [private]

This method assembles all the components of the refitted track into one refitted track state, normalizing the components. Also, it adds the chi2 track-components increments.

Definition at line 135 of file GsfVertexSmoother.cc.

Referenced by vertexAndTrackUpdate().

{

  //renormalize weights

  double totalWeight = 0.;
  double totalVtxChi2 = 0., totalTrkChi2 = 0.;

  for (std::vector<RefittedTrackComponent>::const_iterator iter = trackComponents.begin();
    iter != trackComponents.end(); ++iter ) {
    totalWeight += iter->first.second;
    totalVtxChi2 += iter->second.first  * iter->first.second ;
    totalTrkChi2 += iter->second.second * iter->first.second ;
  }

  totalVtxChi2 /= totalWeight ;
  totalTrkChi2 /= totalWeight ;

  std::vector<RefCountedRefittedTrackState> reWeightedRTSC;
  reWeightedRTSC.reserve(trackComponents.size());
  

  for (std::vector<RefittedTrackComponent>::const_iterator iter = trackComponents.begin();
    iter != trackComponents.end(); ++iter ) {
    if (iter->second.first!=0) {
      reWeightedRTSC.push_back(iter->first.first->stateWithNewWeight(iter->second.first/totalWeight));
    }
  }

  RefCountedRefittedTrackState finalRTS = 
    RefCountedRefittedTrackState(new MultiRefittedTS(reWeightedRTSC, referencePosition));
  return TrackChi2Pair(finalRTS, VtxTrkChi2Pair(totalVtxChi2, totalTrkChi2));
}
virtual VertexSmoother<5>* GsfVertexSmoother::clone ( void  ) const [inline, virtual]

Clone method

Implements VertexSmoother< 5 >.

Definition at line 56 of file GsfVertexSmoother.h.

References GsfVertexSmoother().

  {
    return new GsfVertexSmoother(* this);
  }
GsfVertexSmoother::RefittedTrackComponent GsfVertexSmoother::createNewComponent ( const VertexState oldVertex,
const RefCountedLinearizedTrackState  linTrack,
float  trackWeight 
) const [private]

This method does the smoothing of one track component with one vertex component. And the track-component-chi2 increment and weight of new component in mixture.

Definition at line 179 of file GsfVertexSmoother.cc.

References GsfVertexWeightCalculator::calculate(), helper, kalmanVertexUpdator, KalmanVertexUpdator< N >::positionUpdate(), theVertexTrackUpdator, theWeightCalculator, KVFHelper< N >::trackParameterChi2(), KalmanVertexTrackUpdator< N >::trackRefit(), and KVFHelper< N >::vertexChi2().

Referenced by vertexAndTrackUpdate().

{

  int sign =+1;

  // Weight of the component in the mixture (non-normalized)
  double weightInMixture = theWeightCalculator.calculate(oldVertex, linTrack, 1000000000.);

  // position estimate of the component
  VertexState newVertex = kalmanVertexUpdator.positionUpdate(oldVertex,
        linTrack, trackWeight, sign);

  KalmanVertexTrackUpdator<5>::trackMatrixPair thePair = 
        theVertexTrackUpdator.trackRefit(newVertex, linTrack, trackWeight);

  //Chi**2 contribution of the track component
  double vtxChi2 = helper.vertexChi2(oldVertex, newVertex);
  std::pair<bool, double> trkCi2 = helper.trackParameterChi2(linTrack, thePair.first);

  return RefittedTrackComponent(TrackWeightPair(thePair.first, weightInMixture), 
                        VtxTrkChi2Pair(vtxChi2, trkCi2.second));
}
VertexState GsfVertexSmoother::meanVertex ( const VertexState vertexA,
const VertexState vertexB 
) const [private]

Definition at line 205 of file GsfVertexSmoother.cc.

References VertexState::components().

Referenced by smooth().

{
  std::vector<VertexState> vsCompA = vertexA.components();
  std::vector<VertexState> vsCompB = vertexB.components();
  std::vector<VertexState> finalVS;
  finalVS.reserve(vsCompA.size()*vsCompB.size());
  for (std::vector<VertexState>::iterator iA = vsCompA.begin(); iA!= vsCompA.end(); ++iA)
  {
    for (std::vector<VertexState>::iterator iB = vsCompB.begin(); iB!= vsCompB.end(); ++iB)
    {
      AlgebraicSymMatrix33 newWeight = iA->weight().matrix_new() +
                                     iB->weight().matrix_new();
      AlgebraicVector3 newWtP = iA->weightTimesPosition() +
                               iB->weightTimesPosition();
      double newWeightInMixture = iA->weightInMixture() *
                                  iB->weightInMixture();
      finalVS.push_back( VertexState(newWtP, newWeight, newWeightInMixture) );
    }
  }
  #ifndef CMS_NO_COMPLEX_RETURNS
    return VertexState(new BasicMultiVertexState(finalVS));
  #else
    VertexState theFinalVM(new BasicMultiVertexState(finalVS));
    return theFinalVM;
  #endif
}
double GsfVertexSmoother::priorVertexChi2 ( const VertexState  priorVertex,
const VertexState  fittedVertex 
) const [private]

Methode which calculates the chi**2 between the prior and the fitted vertex. This method takes into account multiple states.

Parameters:
priorVertexThe prior vertex state
fittedVertexThe fitted vertex state

Definition at line 234 of file GsfVertexSmoother.cc.

References VertexState::components(), helper, and KVFHelper< N >::vertexChi2().

Referenced by smooth().

{
  std::vector<VertexState> priorVertexComp  = priorVertex.components();
  std::vector<VertexState> fittedVertexComp = fittedVertex.components();
  double vetexChi2 = 0.;
  for (std::vector<VertexState>::iterator pvI = priorVertexComp.begin(); 
        pvI!= priorVertexComp.end(); ++pvI)
  {
    for (std::vector<VertexState>::iterator fvI = fittedVertexComp.begin(); 
        fvI!= fittedVertexComp.end(); ++fvI)
    {
      vetexChi2 += (pvI->weightInMixture())*(fvI->weightInMixture())*
                        helper.vertexChi2(*pvI, *fvI);
    }
  }
  return vetexChi2;
}
CachingVertex< 5 > GsfVertexSmoother::smooth ( const CachingVertex< 5 > &  vertex) const [virtual]

Methode which will refit the tracks with the vertex constraint and calculate the smoothed vertex chi**2

Parameters:
vertexis the final estimate of the vertex, as given by the last update.
Returns:
the final vertex estimate, with all the supplementary information

Definition at line 13 of file GsfVertexSmoother.cc.

References GsfVertexUpdator::add(), CachingVertex< N >::hasPrior(), i, limitComponents, meanVertex(), CachingVertex< N >::position(), priorVertexChi2(), CachingVertex< N >::priorVertexState(), theMerger, theUpdator, theVTFactory, CachingVertex< N >::tracks(), testEve_cfg::tracks, vertexAndTrackUpdate(), CachingVertex< N >::vertexState(), and VertexTrackFactory< N >::vertexTrack().

{

  std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
  int numberOfTracks = tracks.size();
  if (numberOfTracks<1) return vertex;

  // Initial vertex for ascending fit
  GlobalPoint priorVertexPosition = tracks[0]->linearizedTrack()->linearizationPoint();
  AlgebraicSymMatrix we(3,1);
  GlobalError priorVertexError(we*10000);

  std::vector<RefCountedVertexTrack> initialTracks;
  CachingVertex<5> fitVertex(priorVertexPosition,priorVertexError,initialTracks,0);
  //In case prior vertex was used.
  if (vertex.hasPrior()) {
    VertexState priorVertexState = vertex.priorVertexState();
    fitVertex = CachingVertex<5>(priorVertexState, priorVertexState,
                initialTracks,0);
  }

  // vertices from ascending fit
  std::vector<CachingVertex<5> > ascendingFittedVertices;
  ascendingFittedVertices.reserve(numberOfTracks);
  ascendingFittedVertices.push_back(fitVertex);

  // ascending fit
  for (std::vector<RefCountedVertexTrack>::const_iterator i = tracks.begin();
          i != (tracks.end()-1); ++i) {
    fitVertex = theUpdator.add(fitVertex,*i);
    if (limitComponents) fitVertex = theMerger->merge(fitVertex);
    ascendingFittedVertices.push_back(fitVertex);
  }

  // Initial vertex for descending fit
  priorVertexPosition = tracks[0]->linearizedTrack()->linearizationPoint();
  priorVertexError = GlobalError(we*10000);
  fitVertex = CachingVertex<5>(priorVertexPosition,priorVertexError,initialTracks,0);

  // vertices from descending fit
  std::vector<CachingVertex<5> > descendingFittedVertices;
  descendingFittedVertices.reserve(numberOfTracks);
  descendingFittedVertices.push_back(fitVertex);

  // descending fit
  for (std::vector<RefCountedVertexTrack>::const_iterator i = (tracks.end()-1);
          i != (tracks.begin()); --i) {
    fitVertex = theUpdator.add(fitVertex,*i);
    if (limitComponents) fitVertex = theMerger->merge(fitVertex);
    descendingFittedVertices.insert(descendingFittedVertices.begin(), fitVertex);
  }

  std::vector<RefCountedVertexTrack> newTracks;
  double smoothedChi2 = 0.;  // Smoothed chi2

  // Track refit
  for(std::vector<RefCountedVertexTrack>::const_iterator i = tracks.begin();
        i != tracks.end();i++)
  {
    int indexNumber = i-tracks.begin();
    //First, combine the vertices:
    VertexState meanedVertex = 
         meanVertex(ascendingFittedVertices[indexNumber].vertexState(), 
                    descendingFittedVertices[indexNumber].vertexState());
    if (limitComponents) meanedVertex = theMerger->merge(meanedVertex);
    // Add the vertex and smooth the track:
    TrackChi2Pair thePair = vertexAndTrackUpdate(meanedVertex, *i, vertex.position());
    smoothedChi2 += thePair.second.second;
    newTracks.push_back( theVTFactory.vertexTrack((**i).linearizedTrack(),
        vertex.vertexState(), thePair.first, thePair.second.second,
        AlgebraicSymMatrixOO(), (**i).weight()) );
  }

  if  (vertex.hasPrior()) {
    smoothedChi2 += priorVertexChi2(vertex.priorVertexState(), vertex.vertexState());
    return CachingVertex<5>(vertex.priorVertexState(), vertex.vertexState(),
                newTracks, smoothedChi2);
  } else {
    return CachingVertex<5>(vertex.vertexState(), newTracks, smoothedChi2);
  }
}
GsfVertexSmoother::TrackChi2Pair GsfVertexSmoother::vertexAndTrackUpdate ( const VertexState oldVertex,
const RefCountedVertexTrack  track,
const GlobalPoint referencePosition 
) const [private]

Definition at line 96 of file GsfVertexSmoother.cc.

References assembleTrackComponents(), VertexState::components(), and createNewComponent().

Referenced by smooth().

{

  VSC prevVtxComponents = oldVertex.components();

  if (prevVtxComponents.empty()) {
  throw VertexException
    ("GsfVertexSmoother::(Previous) Vertex to update has no components");
  }

  LTC ltComponents = track->linearizedTrack()->components();
  if (ltComponents.empty()) {
  throw VertexException
    ("GsfVertexSmoother::Track to add to vertex has no components");
  }
  float trackWeight = track->weight();

  std::vector<RefittedTrackComponent> newTrackComponents;
  newTrackComponents.reserve(prevVtxComponents.size()*ltComponents.size());

  for (VSC::iterator vertexCompIter = prevVtxComponents.begin();
        vertexCompIter != prevVtxComponents.end(); vertexCompIter++ ) {

    for (LTC::iterator trackCompIter = ltComponents.begin();
        trackCompIter != ltComponents.end(); trackCompIter++ ) {
      newTrackComponents.push_back
        (createNewComponent(*vertexCompIter, *trackCompIter, trackWeight));
    }
  }

  return assembleTrackComponents(newTrackComponents, referencePosition);
}
const VertexUpdator<5>* GsfVertexSmoother::vertexUpdator ( ) const [inline]

Access methods

Definition at line 50 of file GsfVertexSmoother.h.

References theUpdator.

  {return &theUpdator;}

Member Data Documentation

Definition at line 107 of file GsfVertexSmoother.h.

Referenced by createNewComponent(), and priorVertexChi2().

Definition at line 102 of file GsfVertexSmoother.h.

Referenced by createNewComponent().

Definition at line 99 of file GsfVertexSmoother.h.

Referenced by GsfVertexSmoother(), and smooth().

Definition at line 103 of file GsfVertexSmoother.h.

Definition at line 100 of file GsfVertexSmoother.h.

Referenced by GsfVertexSmoother(), and smooth().

Definition at line 101 of file GsfVertexSmoother.h.

Referenced by smooth(), and vertexUpdator().

Definition at line 104 of file GsfVertexSmoother.h.

Referenced by createNewComponent().

Definition at line 106 of file GsfVertexSmoother.h.

Referenced by smooth().

Definition at line 105 of file GsfVertexSmoother.h.

Referenced by createNewComponent().