Go to the documentation of this file.00001 #include "RecoVertex/GaussianSumVertexFit/interface/MultiVertexStateCombiner.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003
00004
00005 VertexState
00006 MultiVertexStateCombiner::combine(const VSC & theMixture) const
00007 {
00008
00009 if (theMixture.empty()) {
00010 throw VertexException
00011 ("MultiVertexStateCombiner:: VertexState container to collapse is empty");
00012 }
00013
00014 if (theMixture.size()==1) {
00015
00016 return VertexState(theMixture.front().position(), theMixture.front().error(), 1.0);
00017
00018
00019
00020
00021 }
00022
00023
00024 AlgebraicVector meanPosition(3,0);
00025 double weightSum = 0.;
00026 double vtxWeight;
00027 AlgebraicSymMatrix measCovar1(3,0), measCovar2(3,0);
00028 for (VSC::const_iterator mixtureIter1 = theMixture.begin();
00029 mixtureIter1 != theMixture.end(); mixtureIter1++ ) {
00030 vtxWeight = mixtureIter1->weightInMixture();
00031
00032 GlobalPoint vertexPosition = mixtureIter1->position();
00033 AlgebraicVector vertexCoord1(3);
00034 vertexCoord1[0] = vertexPosition.x();
00035 vertexCoord1[1] = vertexPosition.y();
00036 vertexCoord1[2] = vertexPosition.z();
00037
00038
00039 weightSum += vtxWeight;
00040 meanPosition += vtxWeight * vertexCoord1;
00041
00042 measCovar1 += vtxWeight * mixtureIter1->error().matrix();
00043 for (VSC::const_iterator mixtureIter2 = mixtureIter1+1;
00044 mixtureIter2 != theMixture.end(); mixtureIter2++ ) {
00045 GlobalPoint vertexPosition2 = mixtureIter2->position();
00046 AlgebraicVector vertexCoord2(3);
00047 vertexCoord2[0] = vertexPosition2.x();
00048 vertexCoord2[1] = vertexPosition2.y();
00049 vertexCoord2[2] = vertexPosition2.z();
00050 AlgebraicVector posDiff = vertexCoord1 - vertexCoord2;
00051 AlgebraicSymMatrix s(1,1);
00052 measCovar2 +=vtxWeight * mixtureIter2->weightInMixture() *
00053 s.similarity(posDiff.T().T());
00054 }
00055 }
00056 meanPosition /= weightSum;
00057 AlgebraicSymMatrix measCovar = measCovar1/weightSum + measCovar2/weightSum/weightSum;
00058
00059 GlobalPoint newPos(meanPosition[0], meanPosition[1], meanPosition[2]);
00060
00061
00062 return VertexState(newPos, GlobalError(measCovar), weightSum);
00063
00064
00065
00066
00067 }