CMS 3D CMS Logo

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

#include <GsfVertexUpdator.h>

Inheritance diagram for GsfVertexUpdator:
VertexUpdator< 5 >

Public Types

typedef VertexTrack
< 5 >::RefCountedLinearizedTrackState 
RefCountedLinearizedTrackState
 
typedef CachingVertex
< 5 >::RefCountedVertexTrack 
RefCountedVertexTrack
 
- Public Types inherited from VertexUpdator< 5 >
typedef CachingVertex< N >
::RefCountedVertexTrack 
RefCountedVertexTrack
 

Public Member Functions

CachingVertex< 5 > add (const CachingVertex< 5 > &oldVertex, const RefCountedVertexTrack track) const
 
VertexUpdator< 5 > * clone () const
 
 GsfVertexUpdator (bool limit=false, const GsfVertexMerger *merger=0)
 
CachingVertex< 5 > remove (const CachingVertex< 5 > &oldVertex, const RefCountedVertexTrack track) const
 
- Public Member Functions inherited from VertexUpdator< 5 >
virtual CachingVertex< Nadd (const CachingVertex< N > &v, const typename CachingVertex< N >::RefCountedVertexTrack t) const =0
 
virtual CachingVertex< Nremove (const CachingVertex< N > &v, const typename CachingVertex< N >::RefCountedVertexTrack t) const =0
 
 VertexUpdator ()
 
virtual ~VertexUpdator ()
 

Private Types

typedef std::vector
< RefCountedLinearizedTrackState
LTC
 
typedef std::pair< VertexState,
double > 
VertexChi2Pair
 
typedef std::pair< VertexState,
WeightChi2Pair
VertexComponent
 
typedef std::vector< VertexState > VSC
 
typedef std::pair< double, double > WeightChi2Pair
 

Private Member Functions

VertexChi2Pair assembleVertexComponents (const std::vector< VertexComponent > &newVertexComponents) const
 
VertexComponent createNewComponent (const VertexState &oldVertex, const RefCountedLinearizedTrackState linTrack, float weight, int sign) const
 

Private Attributes

KalmanVertexUpdator< 5 > kalmanVertexUpdator
 
bool limitComponents
 
DeepCopyPointerByClone
< GsfVertexMerger
theMerger
 
GsfVertexWeightCalculator theWeightCalculator
 

Detailed Description

Vertex updator for the Gaussian Sum vertex filter. (c.f. Th.Speer & R. Fruewirth, Comp.Phys.Comm 174, 935 (2006) )

Definition at line 14 of file GsfVertexUpdator.h.

Member Typedef Documentation

Definition at line 51 of file GsfVertexUpdator.h.

Definition at line 19 of file GsfVertexUpdator.h.

Definition at line 18 of file GsfVertexUpdator.h.

typedef std::pair<VertexState, double> GsfVertexUpdator::VertexChi2Pair
private

Definition at line 54 of file GsfVertexUpdator.h.

typedef std::pair<VertexState, WeightChi2Pair> GsfVertexUpdator::VertexComponent
private

Definition at line 53 of file GsfVertexUpdator.h.

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

Definition at line 50 of file GsfVertexUpdator.h.

typedef std::pair<double, double> GsfVertexUpdator::WeightChi2Pair
private

Definition at line 52 of file GsfVertexUpdator.h.

Constructor & Destructor Documentation

GsfVertexUpdator::GsfVertexUpdator ( bool  limit = false,
const GsfVertexMerger merger = 0 
)

Definition at line 6 of file GsfVertexUpdator.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

Member Function Documentation

CachingVertex< 5 > GsfVertexUpdator::add ( const CachingVertex< 5 > &  oldVertex,
const RefCountedVertexTrack  track 
) const

Method to add a track to an existing CachingVertex An invalid vertex is returned in case of problems during the update.

Definition at line 13 of file GsfVertexUpdator.cc.

References KalmanVertexUpdator< N >::add(), assembleVertexComponents(), createNewComponent(), CachingVertex< N >::hasPrior(), kalmanVertexUpdator, limitComponents, GsfVertexMerger::merge(), CachingVertex< N >::priorError(), CachingVertex< N >::priorPosition(), theMerger, CachingVertex< N >::totalChiSquared(), CachingVertex< N >::tracks(), and CachingVertex< N >::vertexState().

Referenced by GsfVertexSmoother::smooth().

15 {
16 
17  VSC prevVtxComponents = oldVertex.vertexState().components();
18 
19 // cout << "GsfVertexUpdator::Add new Track with "
20 // << track->linearizedTrack()->components().size() << " components to vertex of "
21 // << prevVtxComponents.size() << " components.\n";
22 
23  if (prevVtxComponents.empty()) {
24  throw VertexException
25  ("GsfVertexUpdator::(Previous) Vertex to update has no components");
26  }
27 
28  LTC ltComponents = track->linearizedTrack()->components();
29  if (ltComponents.empty()) {
30  throw VertexException
31  ("GsfVertexUpdator::Track to add to vertex has no components");
32  }
33 
34  if ((ltComponents.size()==1) && (prevVtxComponents.size()==1))
35  return kalmanVertexUpdator.add(oldVertex, track);
36 
37  float trackWeight = track->weight();
38 
39  std::vector<VertexComponent> newVertexComponents;
40  newVertexComponents.reserve(prevVtxComponents.size()*ltComponents.size());
41 
42 // for (LTC::iterator trackCompIter = ltComponents.begin();
43 // trackCompIter != ltComponents.end(); trackCompIter++ ) {
44 // cout <<(**trackCompIter).state().globalPosition()<<endl;
45 // }
46 
47  for (VSC::iterator vertexCompIter = prevVtxComponents.begin();
48  vertexCompIter != prevVtxComponents.end(); vertexCompIter++ ) {
49  for (LTC::iterator trackCompIter = ltComponents.begin();
50  trackCompIter != ltComponents.end(); trackCompIter++ ) {
51  newVertexComponents.push_back(
52  createNewComponent(*vertexCompIter, *trackCompIter, trackWeight, +1));
53  // return invalid vertex in case one of the updated vertex-components is invalid
54  if (!newVertexComponents.back().first.isValid()) return CachingVertex<5>();
55  }
56  }
57 // cout << "updator components: "<<newVertexComponents.size()<<endl;
58 
59  // Update tracks vector
60 
61  std::vector<RefCountedVertexTrack> newVertexTracks = oldVertex.tracks();
62  newVertexTracks.push_back(track);
63 // cout << "a \n ";
64 
65  // Assemble VertexStates and compute Chi**2
66 
67  VertexChi2Pair vertexChi2Pair = assembleVertexComponents(newVertexComponents);
68 // cout << "b \n ";
69  VertexState newVertexState = vertexChi2Pair.first;
70 // cout << "c \n ";
71  double chi2 = oldVertex.totalChiSquared() + vertexChi2Pair.second;
72 
73  // Merge:
74  if (limitComponents) newVertexState = theMerger->merge(newVertexState);
75 
76  if (oldVertex.hasPrior()) {
77  return CachingVertex<5>(oldVertex.priorPosition(), oldVertex.priorError(),
78  newVertexState.weightTimesPosition(),
79  newVertexState.weight(), newVertexTracks, chi2);
80  } else {
81  return CachingVertex<5>(newVertexState, newVertexTracks, chi2);
82  }
83 
84 
85 }
CachingVertex< 5 > merge(const CachingVertex< 5 > &vertex) const
Common base class.
std::vector< VertexState > VSC
VertexState const & vertexState() const
Definition: CachingVertex.h:85
KalmanVertexUpdator< 5 > kalmanVertexUpdator
GlobalError priorError() const
Definition: CachingVertex.h:94
std::vector< RefCountedVertexTrack > const & tracks() const
Definition: CachingVertex.h:91
float totalChiSquared() const
bool hasPrior() const
Definition: CachingVertex.h:95
VertexChi2Pair assembleVertexComponents(const std::vector< VertexComponent > &newVertexComponents) const
DeepCopyPointerByClone< GsfVertexMerger > theMerger
VertexComponent createNewComponent(const VertexState &oldVertex, const RefCountedLinearizedTrackState linTrack, float weight, int sign) const
std::pair< VertexState, double > VertexChi2Pair
CachingVertex< N > add(const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track) const
std::vector< RefCountedLinearizedTrackState > LTC
GlobalPoint priorPosition() const
Definition: CachingVertex.h:93
GsfVertexUpdator::VertexChi2Pair GsfVertexUpdator::assembleVertexComponents ( const std::vector< VertexComponent > &  newVertexComponents) const
private

Definition at line 134 of file GsfVertexUpdator.cc.

References getDQMSummary::iter, and histoStyle::weight.

Referenced by add().

136 {
137  VSC vertexComponents;
138  vertexComponents.reserve(newVertexComponents.size());
139 
140  //renormalize weights
141 // cout << "assemble "<<newVertexComponents.size()<<endl;
142  double totalWeight = 0.;
143  double totalChi2 = 0.;
144 
145  for (std::vector<VertexComponent>::const_iterator iter = newVertexComponents.begin();
146  iter != newVertexComponents.end(); iter ++) {
147  totalWeight += iter->second.first;
148  }
149 // cout << "totalWeight "<<totalWeight<<endl;
150  if (totalWeight<DBL_MIN) {
151  edm::LogWarning("GsfVertexUpdator") << "Updated Vertex has total weight of 0. "
152  <<"The track is probably very far away.";
153  return VertexChi2Pair( VertexState(), 0.);
154  }
155 
156  for (std::vector<VertexComponent>::const_iterator iter = newVertexComponents.begin();
157  iter != newVertexComponents.end(); iter ++) {
158  double weight = iter->second.first/totalWeight;
159  if (iter->second.first>DBL_MIN) {
160  vertexComponents.push_back(VertexState(iter->first.weightTimesPosition(),
161  iter->first.weight(), weight));
162  totalChi2 += iter->second.second * weight;
163  }
164  }
165 // cout << "totalChi2 "<<totalChi2<<endl;
166 // cout << "vertexComponents "<<vertexComponents.size()<<endl;
167 
168  if (vertexComponents.empty()){
169  edm::LogWarning("GsfVertexUpdator") << "No Vertex State left after reweighting.";
170  return VertexChi2Pair( VertexState(), 0.);
171  }
172 
173  return VertexChi2Pair( VertexState( new BasicMultiVertexState( vertexComponents)),
174  totalChi2);
175 }
std::vector< VertexState > VSC
std::pair< VertexState, double > VertexChi2Pair
int weight
Definition: histoStyle.py:50
VertexUpdator<5>* GsfVertexUpdator::clone ( void  ) const
inlinevirtual

Clone method

Implements VertexUpdator< 5 >.

Definition at line 42 of file GsfVertexUpdator.h.

References GsfVertexUpdator().

43  {
44  return new GsfVertexUpdator(* this);
45  }
GsfVertexUpdator(bool limit=false, const GsfVertexMerger *merger=0)
GsfVertexUpdator::VertexComponent GsfVertexUpdator::createNewComponent ( const VertexState &  oldVertex,
const RefCountedLinearizedTrackState  linTrack,
float  weight,
int  sign 
) const
private

Where one component of the previous vertex gets updated with one component of the track.

Definition at line 104 of file GsfVertexUpdator.cc.

References funct::abs(), GsfVertexWeightCalculator::calculate(), KalmanVertexUpdator< N >::chi2Increment(), kalmanVertexUpdator, KalmanVertexUpdator< N >::positionUpdate(), and theWeightCalculator.

Referenced by add().

106 {
107 
108  if(abs(sign) != 1)
109  throw VertexException ("GsfVertexUpdator::sign not equal to 1.");
110 
111  if(sign == -1)
112  throw VertexException("GsfVertexUpdator::sign of -1 not yet implemented.");
113 
114 
115  // Weight of the component in the mixture (non-normalized)
116  double weightInMixture = theWeightCalculator.calculate(oldVertex, linTrack, 1.E9);
117  if (weightInMixture < 0.) return VertexComponent(VertexState(), WeightChi2Pair(0.,0.));
118 
119  // position estimate of the component
120  VertexState newVertex = kalmanVertexUpdator.positionUpdate(oldVertex,
121  linTrack, weight, sign);
122  if (!newVertex.isValid()) return VertexComponent(newVertex, WeightChi2Pair(0.,0.));
123 
124  //Chi**2 contribution of the component
125  std::pair <bool, double> chi2P = kalmanVertexUpdator.chi2Increment(oldVertex, newVertex,
126  linTrack, weight);
127  if (!chi2P.first) return VertexComponent(VertexState(), WeightChi2Pair(0.,0.));
128 // cout << "Update: "<<oldVertex.position()<<" "<<newVertex.position()<<" "<<chi2
129 // <<" "<<linTrack->weightInMixture()<<" "<<weightInMixture<<endl;
130 
131  return VertexComponent(newVertex, WeightChi2Pair(weightInMixture, chi2P.second));
132 }
std::pair< bool, double > chi2Increment(const VertexState &oldVertex, const VertexState &newVertexState, const RefCountedLinearizedTrackState linearizedTrack, float weight) const
GsfVertexWeightCalculator theWeightCalculator
Common base class.
double sign(double x)
KalmanVertexUpdator< 5 > kalmanVertexUpdator
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double calculate(const VertexState &oldVertex, const RefCountedLinearizedTrackState track, double cov) const
VertexState positionUpdate(const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
std::pair< double, double > WeightChi2Pair
int weight
Definition: histoStyle.py:50
std::pair< VertexState, WeightChi2Pair > VertexComponent
CachingVertex< 5 > GsfVertexUpdator::remove ( const CachingVertex< 5 > &  oldVertex,
const RefCountedVertexTrack  track 
) const

Method removing already used VertexTrack from existing CachingVertex This method is not yet implemented.

Definition at line 90 of file GsfVertexUpdator.cc.

92 {
93  throw VertexException("GsfVertexUpdator::Remove Methode not yet done");
94 // return CachingVertex<5>();
95 }
Common base class.

Member Data Documentation

KalmanVertexUpdator<5> GsfVertexUpdator::kalmanVertexUpdator
private

Definition at line 64 of file GsfVertexUpdator.h.

Referenced by add(), and createNewComponent().

bool GsfVertexUpdator::limitComponents
private

Definition at line 62 of file GsfVertexUpdator.h.

Referenced by add(), and GsfVertexUpdator().

DeepCopyPointerByClone<GsfVertexMerger> GsfVertexUpdator::theMerger
private

Definition at line 63 of file GsfVertexUpdator.h.

Referenced by add(), and GsfVertexUpdator().

GsfVertexWeightCalculator GsfVertexUpdator::theWeightCalculator
private

Definition at line 65 of file GsfVertexUpdator.h.

Referenced by createNewComponent().