CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
GsfVertexSmoother Class Reference

#include <GsfVertexSmoother.h>

Inheritance diagram for GsfVertexSmoother:
VertexSmoother< 5 >

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 ()
 
- Public Member Functions inherited from VertexSmoother< 5 >
virtual CachingVertex< Nsmooth (const CachingVertex< N > &vertex) const =0
 
 VertexSmoother ()
 
virtual ~VertexSmoother ()
 

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().

6  :
8 {
9  if (limitComponents) theMerger = merger->clone();
10 }
GsfVertexMerger * clone() const
DeepCopyPointerByClone< GsfVertexMerger > theMerger
virtual GsfVertexSmoother::~GsfVertexSmoother ( )
inlinevirtual

Definition at line 35 of file GsfVertexSmoother.h.

35 {}

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().

139 {
140 
141  //renormalize weights
142 
143  double totalWeight = 0.;
144  double totalVtxChi2 = 0., totalTrkChi2 = 0.;
145 
146  for (std::vector<RefittedTrackComponent>::const_iterator iter = trackComponents.begin();
147  iter != trackComponents.end(); ++iter ) {
148  totalWeight += iter->first.second;
149  totalVtxChi2 += iter->second.first * iter->first.second ;
150  totalTrkChi2 += iter->second.second * iter->first.second ;
151  }
152 
153  totalVtxChi2 /= totalWeight ;
154  totalTrkChi2 /= totalWeight ;
155 
156  std::vector<RefCountedRefittedTrackState> reWeightedRTSC;
157  reWeightedRTSC.reserve(trackComponents.size());
158 
159 
160  for (std::vector<RefittedTrackComponent>::const_iterator iter = trackComponents.begin();
161  iter != trackComponents.end(); ++iter ) {
162  if (iter->second.first!=0) {
163  reWeightedRTSC.push_back(iter->first.first->stateWithNewWeight(iter->second.first/totalWeight));
164  }
165  }
166 
167  RefCountedRefittedTrackState finalRTS =
168  RefCountedRefittedTrackState(new MultiRefittedTS(reWeightedRTSC, referencePosition));
169  return TrackChi2Pair(finalRTS, VtxTrkChi2Pair(totalVtxChi2, totalTrkChi2));
170 }
VertexTrack< 5 >::RefCountedRefittedTrackState RefCountedRefittedTrackState
std::pair< double, double > VtxTrkChi2Pair
std::pair< RefCountedRefittedTrackState, VtxTrkChi2Pair > TrackChi2Pair
virtual VertexSmoother<5>* GsfVertexSmoother::clone ( void  ) const
inlinevirtual

Clone method

Implements VertexSmoother< 5 >.

Definition at line 56 of file GsfVertexSmoother.h.

References GsfVertexSmoother().

57  {
58  return new GsfVertexSmoother(* this);
59  }
GsfVertexSmoother(bool limit, const GsfVertexMerger *merger)
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(), jetcorrextractor::sign(), theVertexTrackUpdator, theWeightCalculator, KVFHelper< N >::trackParameterChi2(), KalmanVertexTrackUpdator< N >::trackRefit(), and KVFHelper< N >::vertexChi2().

Referenced by vertexAndTrackUpdate().

181 {
182 
183  int sign =+1;
184 
185  // Weight of the component in the mixture (non-normalized)
186  double weightInMixture = theWeightCalculator.calculate(oldVertex, linTrack, 1000000000.);
187 
188  // position estimate of the component
189  VertexState newVertex = kalmanVertexUpdator.positionUpdate(oldVertex,
190  linTrack, trackWeight, sign);
191 
193  theVertexTrackUpdator.trackRefit(newVertex, linTrack, trackWeight);
194 
195  //Chi**2 contribution of the track component
196  double vtxChi2 = helper.vertexChi2(oldVertex, newVertex);
197  std::pair<bool, double> trkCi2 = helper.trackParameterChi2(linTrack, thePair.first);
198 
199  return RefittedTrackComponent(TrackWeightPair(thePair.first, weightInMixture),
200  VtxTrkChi2Pair(vtxChi2, trkCi2.second));
201 }
double sign(double x)
std::pair< double, double > VtxTrkChi2Pair
KVFHelper< 5 > helper
std::pair< RefCountedRefittedTrackState, double > TrackWeightPair
double vertexChi2(const VertexState &vertexA, const VertexState &VertexB) const
Definition: KVFHelper.cc:13
GsfVertexWeightCalculator theWeightCalculator
KalmanVertexUpdator< 5 > kalmanVertexUpdator
BDpair trackParameterChi2(const RefCountedLinearizedTrackState linTrack, const RefCountedRefittedTrackState refittedTrackState) const
Definition: KVFHelper.cc:46
KalmanVertexTrackUpdator< 5 > theVertexTrackUpdator
double calculate(const VertexState &oldVertex, const RefCountedLinearizedTrackState track, double cov) const
std::pair< TrackWeightPair, VtxTrkChi2Pair > RefittedTrackComponent
VertexState positionUpdate(const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
float trackWeight(const reco::Vertex &sv, const reco::TransientTrack &track)
trackMatrixPair trackRefit(const VertexState &vertex, RefCountedLinearizedTrackState linTrackState, float weight) const
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().

207 {
208  std::vector<VertexState> vsCompA = vertexA.components();
209  std::vector<VertexState> vsCompB = vertexB.components();
210  std::vector<VertexState> finalVS;
211  finalVS.reserve(vsCompA.size()*vsCompB.size());
212  for (std::vector<VertexState>::iterator iA = vsCompA.begin(); iA!= vsCompA.end(); ++iA)
213  {
214  for (std::vector<VertexState>::iterator iB = vsCompB.begin(); iB!= vsCompB.end(); ++iB)
215  {
216  AlgebraicSymMatrix33 newWeight = iA->weight().matrix_new() +
217  iB->weight().matrix_new();
218  AlgebraicVector3 newWtP = iA->weightTimesPosition() +
219  iB->weightTimesPosition();
220  double newWeightInMixture = iA->weightInMixture() *
221  iB->weightInMixture();
222  finalVS.push_back( VertexState(newWtP, newWeight, newWeightInMixture) );
223  }
224  }
225  #ifndef CMS_NO_COMPLEX_RETURNS
226  return VertexState(new BasicMultiVertexState(finalVS));
227  #else
228  VertexState theFinalVM(new BasicMultiVertexState(finalVS));
229  return theFinalVM;
230  #endif
231 }
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
ROOT::Math::SVector< double, 3 > AlgebraicVector3
std::vector< VertexState > components() const
Definition: VertexState.h:82
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().

236 {
237  std::vector<VertexState> priorVertexComp = priorVertex.components();
238  std::vector<VertexState> fittedVertexComp = fittedVertex.components();
239  double vetexChi2 = 0.;
240  for (std::vector<VertexState>::iterator pvI = priorVertexComp.begin();
241  pvI!= priorVertexComp.end(); ++pvI)
242  {
243  for (std::vector<VertexState>::iterator fvI = fittedVertexComp.begin();
244  fvI!= fittedVertexComp.end(); ++fvI)
245  {
246  vetexChi2 += (pvI->weightInMixture())*(fvI->weightInMixture())*
247  helper.vertexChi2(*pvI, *fvI);
248  }
249  }
250  return vetexChi2;
251 }
KVFHelper< 5 > helper
double vertexChi2(const VertexState &vertexA, const VertexState &VertexB) const
Definition: KVFHelper.cc:13
std::vector< VertexState > components() const
Definition: VertexState.h:82
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(), GsfVertexMerger::merge(), CachingVertex< N >::position(), priorVertexChi2(), CachingVertex< N >::priorVertexState(), theMerger, theUpdator, theVTFactory, testEve_cfg::tracks, CachingVertex< N >::tracks(), vertexAndTrackUpdate(), CachingVertex< N >::vertexState(), and VertexTrackFactory< N >::vertexTrack().

14 {
15 
16  std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
17  int numberOfTracks = tracks.size();
18  if (numberOfTracks<1) return vertex;
19 
20  // Initial vertex for ascending fit
21  GlobalPoint priorVertexPosition = tracks[0]->linearizedTrack()->linearizationPoint();
22  AlgebraicSymMatrix33 we = ROOT::Math::SMatrixIdentity();
23  GlobalError priorVertexError(we*10000);
24 
25  std::vector<RefCountedVertexTrack> initialTracks;
26  CachingVertex<5> fitVertex(priorVertexPosition,priorVertexError,initialTracks,0);
27  //In case prior vertex was used.
28  if (vertex.hasPrior()) {
29  VertexState priorVertexState = vertex.priorVertexState();
30  fitVertex = CachingVertex<5>(priorVertexState, priorVertexState,
31  initialTracks,0);
32  }
33 
34  // vertices from ascending fit
35  std::vector<CachingVertex<5> > ascendingFittedVertices;
36  ascendingFittedVertices.reserve(numberOfTracks);
37  ascendingFittedVertices.push_back(fitVertex);
38 
39  // ascending fit
40  for (std::vector<RefCountedVertexTrack>::const_iterator i = tracks.begin();
41  i != (tracks.end()-1); ++i) {
42  fitVertex = theUpdator.add(fitVertex,*i);
43  if (limitComponents) fitVertex = theMerger->merge(fitVertex);
44  ascendingFittedVertices.push_back(fitVertex);
45  }
46 
47  // Initial vertex for descending fit
48  priorVertexPosition = tracks[0]->linearizedTrack()->linearizationPoint();
49  priorVertexError = GlobalError(we*10000);
50  fitVertex = CachingVertex<5>(priorVertexPosition,priorVertexError,initialTracks,0);
51 
52  // vertices from descending fit
53  std::vector<CachingVertex<5> > descendingFittedVertices;
54  descendingFittedVertices.reserve(numberOfTracks);
55  descendingFittedVertices.push_back(fitVertex);
56 
57  // descending fit
58  for (std::vector<RefCountedVertexTrack>::const_iterator i = (tracks.end()-1);
59  i != (tracks.begin()); --i) {
60  fitVertex = theUpdator.add(fitVertex,*i);
61  if (limitComponents) fitVertex = theMerger->merge(fitVertex);
62  descendingFittedVertices.insert(descendingFittedVertices.begin(), fitVertex);
63  }
64 
65  std::vector<RefCountedVertexTrack> newTracks;
66  double smoothedChi2 = 0.; // Smoothed chi2
67 
68  // Track refit
69  for(std::vector<RefCountedVertexTrack>::const_iterator i = tracks.begin();
70  i != tracks.end();i++)
71  {
72  int indexNumber = i-tracks.begin();
73  //First, combine the vertices:
74  VertexState meanedVertex =
75  meanVertex(ascendingFittedVertices[indexNumber].vertexState(),
76  descendingFittedVertices[indexNumber].vertexState());
77  if (limitComponents) meanedVertex = theMerger->merge(meanedVertex);
78  // Add the vertex and smooth the track:
79  TrackChi2Pair thePair = vertexAndTrackUpdate(meanedVertex, *i, vertex.position());
80  smoothedChi2 += thePair.second.second;
81  newTracks.push_back( theVTFactory.vertexTrack((**i).linearizedTrack(),
82  vertex.vertexState(), thePair.first, thePair.second.second,
83  AlgebraicSymMatrixOO(), (**i).weight()) );
84  }
85 
86  if (vertex.hasPrior()) {
87  smoothedChi2 += priorVertexChi2(vertex.priorVertexState(), vertex.vertexState());
88  return CachingVertex<5>(vertex.priorVertexState(), vertex.vertexState(),
89  newTracks, smoothedChi2);
90  } else {
91  return CachingVertex<5>(vertex.vertexState(), newTracks, smoothedChi2);
92  }
93 }
VertexTrackFactory< 5 > theVTFactory
int i
Definition: DBlmapReader.cc:9
TrackChi2Pair vertexAndTrackUpdate(const VertexState &oldVertex, const RefCountedVertexTrack track, const GlobalPoint &referencePosition) const
CachingVertex< 5 > merge(const CachingVertex< 5 > &vertex) const
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
VertexState const & vertexState() const
Definition: CachingVertex.h:85
GsfVertexUpdator theUpdator
std::vector< RefCountedVertexTrack > const & tracks() const
Definition: CachingVertex.h:91
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:12
std::pair< RefCountedRefittedTrackState, VtxTrkChi2Pair > TrackChi2Pair
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
bool hasPrior() const
Definition: CachingVertex.h:95
VertexState meanVertex(const VertexState &vertexA, const VertexState &vertexB) const
VertexState const & priorVertexState() const
Definition: CachingVertex.h:86
tuple tracks
Definition: testEve_cfg.py:39
GlobalPoint position() const
DeepCopyPointerByClone< GsfVertexMerger > theMerger
CachingVertex< 5 > add(const CachingVertex< 5 > &oldVertex, const RefCountedVertexTrack track) const
double priorVertexChi2(const VertexState priorVertex, const VertexState fittedVertex) const
VertexTrack< 5 >::AlgebraicSymMatrixOO AlgebraicSymMatrixOO
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(), createNewComponent(), and trackWeight().

Referenced by smooth().

98 {
99 
100  VSC prevVtxComponents = oldVertex.components();
101 
102  if (prevVtxComponents.empty()) {
103  throw VertexException
104  ("GsfVertexSmoother::(Previous) Vertex to update has no components");
105  }
106 
107  LTC ltComponents = track->linearizedTrack()->components();
108  if (ltComponents.empty()) {
109  throw VertexException
110  ("GsfVertexSmoother::Track to add to vertex has no components");
111  }
112  float trackWeight = track->weight();
113 
114  std::vector<RefittedTrackComponent> newTrackComponents;
115  newTrackComponents.reserve(prevVtxComponents.size()*ltComponents.size());
116 
117  for (VSC::iterator vertexCompIter = prevVtxComponents.begin();
118  vertexCompIter != prevVtxComponents.end(); vertexCompIter++ ) {
119 
120  for (LTC::iterator trackCompIter = ltComponents.begin();
121  trackCompIter != ltComponents.end(); trackCompIter++ ) {
122  newTrackComponents.push_back
123  (createNewComponent(*vertexCompIter, *trackCompIter, trackWeight));
124  }
125  }
126 
127  return assembleTrackComponents(newTrackComponents, referencePosition);
128 }
std::vector< RefCountedLinearizedTrackState > LTC
Common base class.
TrackChi2Pair assembleTrackComponents(const std::vector< RefittedTrackComponent > &trackComponents, const GlobalPoint &referencePosition) const
std::vector< VertexState > components() const
Definition: VertexState.h:82
std::vector< VertexState > VSC
RefittedTrackComponent createNewComponent(const VertexState &oldVertex, const RefCountedLinearizedTrackState linTrack, float weight) const
float trackWeight(const reco::Vertex &sv, const reco::TransientTrack &track)
const VertexUpdator<5>* GsfVertexSmoother::vertexUpdator ( ) const
inline

Access methods

Definition at line 50 of file GsfVertexSmoother.h.

References theUpdator.

51  {return &theUpdator;}
GsfVertexUpdator theUpdator

Member Data Documentation

KVFHelper<5> GsfVertexSmoother::helper
private

Definition at line 107 of file GsfVertexSmoother.h.

Referenced by createNewComponent(), and priorVertexChi2().

KalmanVertexUpdator<5> GsfVertexSmoother::kalmanVertexUpdator
private

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().

KalmanSmoothedVertexChi2Estimator<5> GsfVertexSmoother::smoothedChi2Estimator
private

Definition at line 103 of file GsfVertexSmoother.h.

DeepCopyPointerByClone<GsfVertexMerger> GsfVertexSmoother::theMerger
private

Definition at line 100 of file GsfVertexSmoother.h.

Referenced by GsfVertexSmoother(), and smooth().

GsfVertexUpdator GsfVertexSmoother::theUpdator
private

Definition at line 101 of file GsfVertexSmoother.h.

Referenced by smooth(), and vertexUpdator().

KalmanVertexTrackUpdator<5> GsfVertexSmoother::theVertexTrackUpdator
private

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().

GsfVertexWeightCalculator GsfVertexSmoother::theWeightCalculator
private

Definition at line 105 of file GsfVertexSmoother.h.

Referenced by createNewComponent().