CMS 3D CMS Logo

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 override
 
VertexUpdator< 5 > * clone () const override
 
 GsfVertexUpdator (bool limit=false, const GsfVertexMerger *merger=nullptr)
 
CachingVertex< 5 > remove (const CachingVertex< 5 > &oldVertex, const RefCountedVertexTrack track) const override
 
- 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< RefCountedLinearizedTrackStateLTC
 
typedef std::pair< VertexState, double > VertexChi2Pair
 
typedef std::pair< VertexState, WeightChi2PairVertexComponent
 
typedef std::vector< VertexStateVSC
 
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< GsfVertexMergertheMerger
 
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

◆ LTC

Definition at line 42 of file GsfVertexUpdator.h.

◆ RefCountedLinearizedTrackState

Definition at line 17 of file GsfVertexUpdator.h.

◆ RefCountedVertexTrack

Definition at line 16 of file GsfVertexUpdator.h.

◆ VertexChi2Pair

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

Definition at line 45 of file GsfVertexUpdator.h.

◆ VertexComponent

Definition at line 44 of file GsfVertexUpdator.h.

◆ VSC

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

Definition at line 41 of file GsfVertexUpdator.h.

◆ WeightChi2Pair

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

Definition at line 43 of file GsfVertexUpdator.h.

Constructor & Destructor Documentation

◆ GsfVertexUpdator()

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

Definition at line 6 of file GsfVertexUpdator.cc.

7  if (limitComponents)
8  theMerger = merger->clone();
9 }

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

Referenced by clone().

Member Function Documentation

◆ add()

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

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

Definition at line 11 of file GsfVertexUpdator.cc.

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

References KalmanVertexUpdator< N >::add(), assembleVertexComponents(), hltPixelTracks_cff::chi2, VertexState::components(), createNewComponent(), CachingVertex< N >::hasPrior(), kalmanVertexUpdator, limitComponents, GsfVertexMerger::merge(), CachingVertex< N >::priorError(), CachingVertex< N >::priorPosition(), theMerger, CachingVertex< N >::totalChiSquared(), HLT_2018_cff::track, CachingVertex< N >::tracks(), trackWeight(), CachingVertex< N >::vertexState(), VertexState::weight(), and VertexState::weightTimesPosition().

Referenced by counter.Counter::register(), and GsfVertexSmoother::smooth().

◆ assembleVertexComponents()

GsfVertexUpdator::VertexChi2Pair GsfVertexUpdator::assembleVertexComponents ( const std::vector< VertexComponent > &  newVertexComponents) const
private

Definition at line 121 of file GsfVertexUpdator.cc.

122  {
123  VSC vertexComponents;
124  vertexComponents.reserve(newVertexComponents.size());
125 
126  //renormalize weights
127  // cout << "assemble "<<newVertexComponents.size()<<endl;
128  double totalWeight = 0.;
129  double totalChi2 = 0.;
130 
131  for (std::vector<VertexComponent>::const_iterator iter = newVertexComponents.begin();
132  iter != newVertexComponents.end();
133  iter++) {
134  totalWeight += iter->second.first;
135  }
136  // cout << "totalWeight "<<totalWeight<<endl;
137  if (totalWeight < DBL_MIN) {
138  edm::LogWarning("GsfVertexUpdator") << "Updated Vertex has total weight of 0. "
139  << "The track is probably very far away.";
140  return VertexChi2Pair(VertexState(), 0.);
141  }
142 
143  for (std::vector<VertexComponent>::const_iterator iter = newVertexComponents.begin();
144  iter != newVertexComponents.end();
145  iter++) {
146  double weight = iter->second.first / totalWeight;
147  if (iter->second.first > DBL_MIN) {
148  vertexComponents.push_back(VertexState(iter->first.weightTimesPosition(), iter->first.weight(), weight));
149  totalChi2 += iter->second.second * weight;
150  }
151  }
152  // cout << "totalChi2 "<<totalChi2<<endl;
153  // cout << "vertexComponents "<<vertexComponents.size()<<endl;
154 
155  if (vertexComponents.empty()) {
156  edm::LogWarning("GsfVertexUpdator") << "No Vertex State left after reweighting.";
157  return VertexChi2Pair(VertexState(), 0.);
158  }
159 
160  return VertexChi2Pair(VertexState(new BasicMultiVertexState(vertexComponents)), totalChi2);
161 }

References generateEDF::totalWeight, and mps_merge::weight.

Referenced by add().

◆ clone()

VertexUpdator<5>* GsfVertexUpdator::clone ( void  ) const
inlineoverridevirtual

Clone method

Implements VertexUpdator< 5 >.

Definition at line 38 of file GsfVertexUpdator.h.

38 { return new GsfVertexUpdator(*this); }

References GsfVertexUpdator().

◆ createNewComponent()

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 91 of file GsfVertexUpdator.cc.

94  {
95  if (abs(sign) != 1)
96  throw VertexException("GsfVertexUpdator::sign not equal to 1.");
97 
98  if (sign == -1)
99  throw VertexException("GsfVertexUpdator::sign of -1 not yet implemented.");
100 
101  // Weight of the component in the mixture (non-normalized)
102  double weightInMixture = theWeightCalculator.calculate(oldVertex, linTrack, 1.E9);
103  if (weightInMixture < 0.)
104  return VertexComponent(VertexState(), WeightChi2Pair(0., 0.));
105 
106  // position estimate of the component
107  VertexState newVertex = kalmanVertexUpdator.positionUpdate(oldVertex, linTrack, weight, sign);
108  if (!newVertex.isValid())
109  return VertexComponent(newVertex, WeightChi2Pair(0., 0.));
110 
111  //Chi**2 contribution of the component
112  std::pair<bool, double> chi2P = kalmanVertexUpdator.chi2Increment(oldVertex, newVertex, linTrack, weight);
113  if (!chi2P.first)
114  return VertexComponent(VertexState(), WeightChi2Pair(0., 0.));
115  // cout << "Update: "<<oldVertex.position()<<" "<<newVertex.position()<<" "<<chi2
116  // <<" "<<linTrack->weightInMixture()<<" "<<weightInMixture<<endl;
117 
118  return VertexComponent(newVertex, WeightChi2Pair(weightInMixture, chi2P.second));
119 }

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

Referenced by add().

◆ remove()

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

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

Definition at line 81 of file GsfVertexUpdator.cc.

81  {
82  throw VertexException("GsfVertexUpdator::Remove Methode not yet done");
83  // return CachingVertex<5>();
84 }

Member Data Documentation

◆ kalmanVertexUpdator

KalmanVertexUpdator<5> GsfVertexUpdator::kalmanVertexUpdator
private

Definition at line 56 of file GsfVertexUpdator.h.

Referenced by add(), and createNewComponent().

◆ limitComponents

bool GsfVertexUpdator::limitComponents
private

Definition at line 54 of file GsfVertexUpdator.h.

Referenced by add(), and GsfVertexUpdator().

◆ theMerger

DeepCopyPointerByClone<GsfVertexMerger> GsfVertexUpdator::theMerger
private

Definition at line 55 of file GsfVertexUpdator.h.

Referenced by add(), and GsfVertexUpdator().

◆ theWeightCalculator

GsfVertexWeightCalculator GsfVertexUpdator::theWeightCalculator
private

Definition at line 57 of file GsfVertexUpdator.h.

Referenced by createNewComponent().

VertexState::isValid
bool isValid() const
Make the ReferenceCountingProxy method to check validity public.
Definition: VertexState.h:93
VertexException
Common base class.
Definition: VertexException.h:12
GsfVertexMerger::clone
GsfVertexMerger * clone() const
Definition: GsfVertexMerger.h:24
CachingVertex< 5 >
mps_merge.weight
weight
Definition: mps_merge.py:88
generateEDF.totalWeight
totalWeight
Definition: generateEDF.py:688
GsfVertexUpdator::GsfVertexUpdator
GsfVertexUpdator(bool limit=false, const GsfVertexMerger *merger=nullptr)
Definition: GsfVertexUpdator.cc:6
CachingVertex::vertexState
const VertexState & vertexState() const
Definition: CachingVertex.h:137
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
CachingVertex::hasPrior
bool hasPrior() const
Definition: CachingVertex.h:153
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
GsfVertexUpdator::VertexChi2Pair
std::pair< VertexState, double > VertexChi2Pair
Definition: GsfVertexUpdator.h:45
KalmanVertexUpdator::add
CachingVertex< N > add(const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track) const override
Definition: KalmanVertexUpdator.cc:56
GsfVertexUpdator::WeightChi2Pair
std::pair< double, double > WeightChi2Pair
Definition: GsfVertexUpdator.h:43
GsfVertexUpdator::theMerger
DeepCopyPointerByClone< GsfVertexMerger > theMerger
Definition: GsfVertexUpdator.h:55
GsfVertexUpdator::LTC
std::vector< RefCountedLinearizedTrackState > LTC
Definition: GsfVertexUpdator.h:42
CachingVertex::priorPosition
GlobalPoint priorPosition() const
Definition: CachingVertex.h:149
GsfVertexUpdator::createNewComponent
VertexComponent createNewComponent(const VertexState &oldVertex, const RefCountedLinearizedTrackState linTrack, float weight, int sign) const
Definition: GsfVertexUpdator.cc:91
CachingVertex::totalChiSquared
float totalChiSquared() const
Definition: CachingVertex.h:159
BasicMultiVertexState
Definition: BasicMultiVertexState.h:12
edm::LogWarning
Definition: MessageLogger.h:141
GsfVertexUpdator::VSC
std::vector< VertexState > VSC
Definition: GsfVertexUpdator.h:41
KalmanVertexUpdator::chi2Increment
std::pair< bool, double > chi2Increment(const VertexState &oldVertex, const VertexState &newVertexState, const RefCountedLinearizedTrackState linearizedTrack, float weight) const
Definition: KalmanVertexUpdator.cc:129
GsfVertexUpdator::VertexComponent
std::pair< VertexState, WeightChi2Pair > VertexComponent
Definition: GsfVertexUpdator.h:44
VertexState::weight
GlobalWeight weight() const
Definition: VertexState.h:69
VertexState::components
std::vector< VertexState > components() const
Definition: VertexState.h:90
GsfVertexUpdator::kalmanVertexUpdator
KalmanVertexUpdator< 5 > kalmanVertexUpdator
Definition: GsfVertexUpdator.h:56
CachingVertex::tracks
std::vector< RefCountedVertexTrack > tracks() const
Definition: CachingVertex.h:147
KalmanVertexUpdator::positionUpdate
VertexState positionUpdate(const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
Definition: KalmanVertexUpdator.cc:70
VertexState::weightTimesPosition
AlgebraicVector3 weightTimesPosition() const
Definition: VertexState.h:77
GsfVertexUpdator::theWeightCalculator
GsfVertexWeightCalculator theWeightCalculator
Definition: GsfVertexUpdator.h:57
GsfVertexUpdator::assembleVertexComponents
VertexChi2Pair assembleVertexComponents(const std::vector< VertexComponent > &newVertexComponents) const
Definition: GsfVertexUpdator.cc:121
remoteMonitoring_LED_IterMethod_cfg.limit
limit
Definition: remoteMonitoring_LED_IterMethod_cfg.py:427
GsfVertexMerger::merge
CachingVertex< 5 > merge(const CachingVertex< 5 > &vertex) const
Definition: GsfVertexMerger.cc:47
VertexState
Definition: VertexState.h:13
CachingVertex::priorError
GlobalError priorError() const
Definition: CachingVertex.h:151
GsfVertexUpdator::limitComponents
bool limitComponents
Definition: GsfVertexUpdator.h:54
trackWeight
float trackWeight(const reco::Vertex &sv, const reco::TransientTrack &track)
Definition: TrackVertexArbitration.h:122
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GsfVertexWeightCalculator::calculate
double calculate(const VertexState &oldVertex, const RefCountedLinearizedTrackState track, double cov) const
Definition: GsfVertexWeightCalculator.cc:7
weight
Definition: weight.py:1