CMS 3D CMS Logo

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

VertexSmoother< 5 > * clone () const override
 
 GsfVertexSmoother (bool limit, const GsfVertexMerger *merger)
 
CachingVertex< 5 > smooth (const CachingVertex< 5 > &vertex) const override
 
const VertexUpdator< 5 > * vertexUpdator () const
 
 ~GsfVertexSmoother () override
 
- 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< RefCountedLinearizedTrackStateLTC
 
typedef VertexTrack< 5 >::RefCountedLinearizedTrackState RefCountedLinearizedTrackState
 
typedef VertexTrack< 5 >::RefCountedRefittedTrackState RefCountedRefittedTrackState
 
typedef CachingVertex< 5 >::RefCountedVertexTrack RefCountedVertexTrack
 
typedef std::pair< TrackWeightPair, VtxTrkChi2PairRefittedTrackComponent
 
typedef std::pair< RefCountedRefittedTrackState, VtxTrkChi2PairTrackChi2Pair
 
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< GsfVertexMergertheMerger
 
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 21 of file GsfVertexSmoother.h.

Member Typedef Documentation

◆ AlgebraicMatrix3M

Definition at line 57 of file GsfVertexSmoother.h.

◆ AlgebraicSymMatrixOO

Definition at line 58 of file GsfVertexSmoother.h.

◆ LTC

Definition at line 61 of file GsfVertexSmoother.h.

◆ RefCountedLinearizedTrackState

Definition at line 55 of file GsfVertexSmoother.h.

◆ RefCountedRefittedTrackState

Definition at line 56 of file GsfVertexSmoother.h.

◆ RefCountedVertexTrack

Definition at line 54 of file GsfVertexSmoother.h.

◆ RefittedTrackComponent

Definition at line 65 of file GsfVertexSmoother.h.

◆ TrackChi2Pair

Definition at line 64 of file GsfVertexSmoother.h.

◆ TrackWeightPair

Definition at line 63 of file GsfVertexSmoother.h.

◆ VSC

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

Definition at line 60 of file GsfVertexSmoother.h.

◆ VtxTrkChi2Pair

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

Definition at line 62 of file GsfVertexSmoother.h.

Constructor & Destructor Documentation

◆ GsfVertexSmoother()

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

7  if (limitComponents)
8  theMerger = merger->clone();
9 }
DeepCopyPointerByClone< GsfVertexMerger > theMerger
GsfVertexMerger * clone() const

◆ ~GsfVertexSmoother()

GsfVertexSmoother::~GsfVertexSmoother ( )
inlineoverride

Definition at line 31 of file GsfVertexSmoother.h.

31 {}

Member Function Documentation

◆ assembleTrackComponents()

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 124 of file GsfVertexSmoother.cc.

References generateEDF::totalWeight.

Referenced by vertexAndTrackUpdate().

126  {
127  //renormalize weights
128 
129  double totalWeight = 0.;
130  double totalVtxChi2 = 0., totalTrkChi2 = 0.;
131 
132  for (std::vector<RefittedTrackComponent>::const_iterator iter = trackComponents.begin();
133  iter != trackComponents.end();
134  ++iter) {
135  totalWeight += iter->first.second;
136  totalVtxChi2 += iter->second.first * iter->first.second;
137  totalTrkChi2 += iter->second.second * iter->first.second;
138  }
139 
140  totalVtxChi2 /= totalWeight;
141  totalTrkChi2 /= totalWeight;
142 
143  std::vector<RefCountedRefittedTrackState> reWeightedRTSC;
144  reWeightedRTSC.reserve(trackComponents.size());
145 
146  for (std::vector<RefittedTrackComponent>::const_iterator iter = trackComponents.begin();
147  iter != trackComponents.end();
148  ++iter) {
149  if (iter->second.first != 0) {
150  reWeightedRTSC.push_back(iter->first.first->stateWithNewWeight(iter->second.first / totalWeight));
151  }
152  }
153 
155  RefCountedRefittedTrackState(new MultiRefittedTS(reWeightedRTSC, referencePosition));
156  return TrackChi2Pair(finalRTS, VtxTrkChi2Pair(totalVtxChi2, totalTrkChi2));
157 }
VertexTrack< 5 >::RefCountedRefittedTrackState RefCountedRefittedTrackState
std::pair< double, double > VtxTrkChi2Pair
std::pair< RefCountedRefittedTrackState, VtxTrkChi2Pair > TrackChi2Pair

◆ clone()

VertexSmoother<5>* GsfVertexSmoother::clone ( void  ) const
inlineoverridevirtual

Clone method

Implements VertexSmoother< 5 >.

Definition at line 51 of file GsfVertexSmoother.h.

References GsfVertexSmoother().

51 { return new GsfVertexSmoother(*this); }
GsfVertexSmoother(bool limit, const GsfVertexMerger *merger)

◆ createNewComponent()

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 164 of file GsfVertexSmoother.cc.

References GsfVertexWeightCalculator::calculate(), kalmanVertexUpdator, KalmanVertexUpdator< N >::positionUpdate(), Validation_hcalonly_cfi::sign, theVertexTrackUpdator, theWeightCalculator, KalmanVertexTrackUpdator< N >::trackRefit(), trackWeight(), and allConversions_cfi::vtxChi2.

Referenced by vertexAndTrackUpdate().

165  {
166  int sign = +1;
167 
168  // Weight of the component in the mixture (non-normalized)
169  double weightInMixture = theWeightCalculator.calculate(oldVertex, linTrack, 1000000000.);
170 
171  // position estimate of the component
172  VertexState newVertex = kalmanVertexUpdator.positionUpdate(oldVertex, linTrack, trackWeight, sign);
173 
175  theVertexTrackUpdator.trackRefit(newVertex, linTrack, trackWeight);
176 
177  //Chi**2 contribution of the track component
178  double vtxChi2 = helper.vertexChi2(oldVertex, newVertex);
179  std::pair<bool, double> trkCi2 = helper.trackParameterChi2(linTrack, thePair.first);
180 
181  return RefittedTrackComponent(TrackWeightPair(thePair.first, weightInMixture),
182  VtxTrkChi2Pair(vtxChi2, trkCi2.second));
183 }
double calculate(const VertexState &oldVertex, const RefCountedLinearizedTrackState track, double cov) const
Definition: helper.py:1
VertexState positionUpdate(const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
std::pair< double, double > VtxTrkChi2Pair
std::pair< RefCountedRefittedTrackState, double > TrackWeightPair
GsfVertexWeightCalculator theWeightCalculator
KalmanVertexUpdator< 5 > kalmanVertexUpdator
KalmanVertexTrackUpdator< 5 > theVertexTrackUpdator
std::pair< TrackWeightPair, VtxTrkChi2Pair > RefittedTrackComponent
trackMatrixPair trackRefit(const VertexState &vertex, RefCountedLinearizedTrackState linTrackState, float weight) const
float trackWeight(const reco::Vertex &sv, const reco::TransientTrack &track)

◆ meanVertex()

VertexState GsfVertexSmoother::meanVertex ( const VertexState vertexA,
const VertexState vertexB 
) const
private

Definition at line 185 of file GsfVertexSmoother.cc.

References VertexState::components().

Referenced by smooth().

185  {
186  std::vector<VertexState> vsCompA = vertexA.components();
187  std::vector<VertexState> vsCompB = vertexB.components();
188  std::vector<VertexState> finalVS;
189  finalVS.reserve(vsCompA.size() * vsCompB.size());
190  for (std::vector<VertexState>::iterator iA = vsCompA.begin(); iA != vsCompA.end(); ++iA) {
191  for (std::vector<VertexState>::iterator iB = vsCompB.begin(); iB != vsCompB.end(); ++iB) {
192  AlgebraicSymMatrix33 newWeight = iA->weight().matrix() + iB->weight().matrix();
193  AlgebraicVector3 newWtP = iA->weightTimesPosition() + iB->weightTimesPosition();
194  double newWeightInMixture = iA->weightInMixture() * iB->weightInMixture();
195  finalVS.push_back(VertexState(newWtP, newWeight, newWeightInMixture));
196  }
197  }
198 #ifndef CMS_NO_COMPLEX_RETURNS
199  return VertexState(new BasicMultiVertexState(finalVS));
200 #else
201  VertexState theFinalVM(new BasicMultiVertexState(finalVS));
202  return theFinalVM;
203 #endif
204 }
std::vector< VertexState > components() const
Definition: VertexState.h:90
ROOT::Math::SVector< double, 3 > AlgebraicVector3
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33

◆ priorVertexChi2()

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 206 of file GsfVertexSmoother.cc.

References VertexState::components().

Referenced by smooth().

206  {
207  std::vector<VertexState> priorVertexComp = priorVertex.components();
208  std::vector<VertexState> fittedVertexComp = fittedVertex.components();
209  double vetexChi2 = 0.;
210  for (std::vector<VertexState>::iterator pvI = priorVertexComp.begin(); pvI != priorVertexComp.end(); ++pvI) {
211  for (std::vector<VertexState>::iterator fvI = fittedVertexComp.begin(); fvI != fittedVertexComp.end(); ++fvI) {
212  vetexChi2 += (pvI->weightInMixture()) * (fvI->weightInMixture()) * helper.vertexChi2(*pvI, *fvI);
213  }
214  }
215  return vetexChi2;
216 }
Definition: helper.py:1
std::vector< VertexState > components() const
Definition: VertexState.h:90

◆ smooth()

CachingVertex< 5 > GsfVertexSmoother::smooth ( const CachingVertex< 5 > &  vertex) const
override

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 11 of file GsfVertexSmoother.cc.

References GsfVertexUpdator::add(), mps_fire::i, limitComponents, meanVertex(), GsfVertexMerger::merge(), priorVertexChi2(), theMerger, theUpdator, theVTFactory, DiMuonV_cfg::tracks, bphysicsOniaDQM_cfi::vertex, vertexAndTrackUpdate(), and VertexTrackFactory< N >::vertexTrack().

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

◆ vertexAndTrackUpdate()

GsfVertexSmoother::TrackChi2Pair GsfVertexSmoother::vertexAndTrackUpdate ( const VertexState oldVertex,
const RefCountedVertexTrack  track,
const GlobalPoint referencePosition 
) const
private

Definition at line 91 of file GsfVertexSmoother.cc.

References assembleTrackComponents(), VertexState::components(), createNewComponent(), HLT_2024v12_cff::track, and trackWeight().

Referenced by smooth().

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

◆ vertexUpdator()

const VertexUpdator<5>* GsfVertexSmoother::vertexUpdator ( ) const
inline

Access methods

Definition at line 46 of file GsfVertexSmoother.h.

References theUpdator.

46 { return &theUpdator; }
GsfVertexUpdator theUpdator

Member Data Documentation

◆ helper

KVFHelper<5> GsfVertexSmoother::helper
private

Definition at line 97 of file GsfVertexSmoother.h.

◆ kalmanVertexUpdator

KalmanVertexUpdator<5> GsfVertexSmoother::kalmanVertexUpdator
private

Definition at line 92 of file GsfVertexSmoother.h.

Referenced by createNewComponent().

◆ limitComponents

bool GsfVertexSmoother::limitComponents
private

Definition at line 89 of file GsfVertexSmoother.h.

Referenced by GsfVertexSmoother(), and smooth().

◆ smoothedChi2Estimator

KalmanSmoothedVertexChi2Estimator<5> GsfVertexSmoother::smoothedChi2Estimator
private

Definition at line 93 of file GsfVertexSmoother.h.

◆ theMerger

DeepCopyPointerByClone<GsfVertexMerger> GsfVertexSmoother::theMerger
private

Definition at line 90 of file GsfVertexSmoother.h.

Referenced by GsfVertexSmoother(), and smooth().

◆ theUpdator

GsfVertexUpdator GsfVertexSmoother::theUpdator
private

Definition at line 91 of file GsfVertexSmoother.h.

Referenced by smooth(), and vertexUpdator().

◆ theVertexTrackUpdator

KalmanVertexTrackUpdator<5> GsfVertexSmoother::theVertexTrackUpdator
private

Definition at line 94 of file GsfVertexSmoother.h.

Referenced by createNewComponent().

◆ theVTFactory

VertexTrackFactory<5> GsfVertexSmoother::theVTFactory
private

Definition at line 96 of file GsfVertexSmoother.h.

Referenced by smooth().

◆ theWeightCalculator

GsfVertexWeightCalculator GsfVertexSmoother::theWeightCalculator
private

Definition at line 95 of file GsfVertexSmoother.h.

Referenced by createNewComponent().