#include <GsfVertexSmoother.h>
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.
typedef VertexTrack<5>::AlgebraicMatrix3M GsfVertexSmoother::AlgebraicMatrix3M [private] |
Definition at line 66 of file GsfVertexSmoother.h.
typedef VertexTrack<5>::AlgebraicSymMatrixOO GsfVertexSmoother::AlgebraicSymMatrixOO [private] |
Definition at line 67 of file GsfVertexSmoother.h.
typedef std::vector<RefCountedLinearizedTrackState> GsfVertexSmoother::LTC [private] |
Definition at line 70 of file GsfVertexSmoother.h.
typedef VertexTrack<5>::RefCountedLinearizedTrackState GsfVertexSmoother::RefCountedLinearizedTrackState [private] |
Definition at line 64 of file GsfVertexSmoother.h.
typedef VertexTrack<5>::RefCountedRefittedTrackState GsfVertexSmoother::RefCountedRefittedTrackState [private] |
Definition at line 65 of file GsfVertexSmoother.h.
typedef CachingVertex<5>::RefCountedVertexTrack GsfVertexSmoother::RefCountedVertexTrack [private] |
Definition at line 63 of file GsfVertexSmoother.h.
typedef std::pair<TrackWeightPair, VtxTrkChi2Pair> GsfVertexSmoother::RefittedTrackComponent [private] |
Definition at line 74 of file GsfVertexSmoother.h.
typedef std::pair<RefCountedRefittedTrackState, VtxTrkChi2Pair> GsfVertexSmoother::TrackChi2Pair [private] |
Definition at line 73 of file GsfVertexSmoother.h.
typedef std::pair<RefCountedRefittedTrackState, double> GsfVertexSmoother::TrackWeightPair [private] |
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.
GsfVertexSmoother::GsfVertexSmoother | ( | bool | limit, |
const GsfVertexMerger * | merger | ||
) |
The constructor
limit | Specifies 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().
: limitComponents (limit) { if (limitComponents) theMerger = merger->clone(); }
virtual GsfVertexSmoother::~GsfVertexSmoother | ( | ) | [inline, virtual] |
Definition at line 35 of file GsfVertexSmoother.h.
{}
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.
priorVertex | The prior vertex state |
fittedVertex | The 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
vertex | is the final estimate of the vertex, as given by the last update. |
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(); AlgebraicSymMatrix33 we = ROOT::Math::SMatrixIdentity(); 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;}
KVFHelper<5> GsfVertexSmoother::helper [private] |
Definition at line 107 of file GsfVertexSmoother.h.
Referenced by createNewComponent(), and priorVertexChi2().
Definition at line 102 of file GsfVertexSmoother.h.
Referenced by createNewComponent().
bool GsfVertexSmoother::limitComponents [private] |
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().
VertexTrackFactory<5> GsfVertexSmoother::theVTFactory [private] |
Definition at line 106 of file GsfVertexSmoother.h.
Referenced by smooth().
Definition at line 105 of file GsfVertexSmoother.h.
Referenced by createNewComponent().