12 template <
unsigned int N>
17 (
"KalmanVertexUpdator::abs(sign) not equal to 1");
19 VertexState newVertexState = positionUpdate(oldVertex.
vertexState(),
20 track->linearizedTrack(),
weight, sign);
24 std::pair <bool, double> chi2P = chi2Increment(oldVertex.
vertexState(), newVertexState,
25 track->linearizedTrack() ,
weight );
28 chi1 +=sign * chi2P.second;
31 std::vector<RefCountedVertexTrack> newVertexTracks = oldVertex.
tracks();
34 newVertexTracks.push_back(track);
37 typename std::vector<RefCountedVertexTrack>::iterator pos
38 =
find(newVertexTracks.begin(), newVertexTracks.end(), track);
39 if (pos != newVertexTracks.end()) {
40 newVertexTracks.erase(pos);
42 std::cout<<
"KalmanVertexUpdator::Unable to find requested track in the current vertex"<<std::endl;
43 throw VertexException(
"KalmanVertexUpdator::Unable to find requested track in the current vertex");
49 newVertexState, newVertexTracks, chi1);
56 template <
unsigned int N>
60 float weight = track->weight();
61 return update(oldVertex,track,weight,+1);
64 template <
unsigned int N>
68 float weight = track->weight();
69 return update(oldVertex,track,weight,-1);
73 template <
unsigned int N>
77 const float weight,
int sign)
const
81 if (!linearizedTrack->isValid())
91 linearizedTrack->predictedStateWeight(error);
93 edm::LogWarning(
"KalmanVertexUpdator") <<
"predictedState error matrix inversion failed. An invalid vertex will be returned.";
106 edm::LogWarning(
"KalmanVertexUpdator") <<
"S matrix inversion failed. An invalid vertex will be returned.";
107 return VertexState();
111 ROOT::Math::Similarity(trackParametersWeight, ROOT::Math::Similarity(b,s));
116 + (weight * sign) * ROOT::Math::SimilarityT(a,gB);
122 + (weight * sign) * ( (ROOT::Math::Transpose(a) * gB) *
123 ( linearizedTrack->predictedStateParameters() - linearizedTrack->constantTerm()) );
127 VertexState newpos (newSwr,
GlobalWeight(newVertexWeight), 1.0);
136 template <
unsigned int N>
138 const VertexState & newVertexState,
143 GlobalPoint newVertexPosition = newVertexState.position();
145 if (!linearizedTrack->isValid())
146 return std::pair <bool, double> (
false, -1. );
149 newVertexPositionV(0) = newVertexPosition.
x();
150 newVertexPositionV(1) = newVertexPosition.
y();
151 newVertexPositionV(2) = newVertexPosition.
z();
157 linearizedTrack->predictedStateParameters();
160 linearizedTrack->predictedStateWeight(error);
162 edm::LogWarning(
"KalmanVertexUpdator") <<
"predictedState error matrix inversion failed. An invalid vertex will be returned.";
163 return std::pair <bool, double> (
false, -1.);
168 edm::LogWarning(
"KalmanVertexUpdator") <<
"S matrix inversion failed. An invalid vertex will be returned.";
169 return std::pair <bool, double> (
false, -1.);
174 AlgebraicVectorM newTrackMomentumP = s * ROOT::Math::Transpose(b) * trackParametersWeight * vv;
180 linearizedTrack->checkParameters(parameterResiduals);
182 double chi2 = weight * ROOT::Math::Similarity(parameterResiduals, trackParametersWeight);
185 chi2 += helper.vertexChi2(oldVertex, newVertexState);
187 return std::pair <bool, double> (
true, chi2);
std::pair< bool, double > chi2Increment(const VertexState &oldVertex, const VertexState &newVertexState, const RefCountedLinearizedTrackState linearizedTrack, float weight) const
ROOT::Math::SMatrix< double, N, N-2, ROOT::Math::MatRepStd< double, N, N-2 > > AlgebraicMatrixNM
VertexState const & vertexState() const
ROOT::Math::SVector< double, N > AlgebraicVectorN
ROOT::Math::SMatrix< double, N, 3, ROOT::Math::MatRepStd< double, N, 3 > > AlgebraicMatrixN3
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > AlgebraicSymMatrixNN
ROOT::Math::SMatrix< double, N-2, N-2, ROOT::Math::MatRepSym< double, N-2 > > AlgebraicSymMatrixMM
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< RefCountedVertexTrack > const & tracks() const
CachingVertex< N > remove(const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track) const
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
float totalChiSquared() const
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Abs< T >::type abs(const T &t)
VertexTrack< N >::RefCountedLinearizedTrackState RefCountedLinearizedTrackState
VertexState positionUpdate(const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
VertexState const & priorVertexState() const
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
CachingVertex< N > add(const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track) const
CachingVertex< N > update(const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track, float weight, int sign) const
ROOT::Math::SVector< double, N-2 > AlgebraicVectorM