CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/RecoVertex/GaussianSumVertexFit/src/MultiVertexStateCombiner.cc

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 //     #ifndef CMS_NO_COMPLEX_RETURNS
00016       return VertexState(theMixture.front().position(), theMixture.front().error(), 1.0);
00017 //     #else
00018 //       VertexState theFinalVM(theMixture.front().position(), theMixture.front().error(), 1.0);
00019 //       return theFinalVM;
00020 //     #endif
00021   }
00022 
00023 
00024   AlgebraicVector3 meanPosition;
00025   double weightSum = 0.;
00026   AlgebraicSymMatrix33 measCovar1, measCovar2;
00027   for (VSC::const_iterator mixtureIter1 = theMixture.begin();
00028         mixtureIter1 != theMixture.end(); mixtureIter1++ ) {
00029     double vtxWeight = mixtureIter1->weightInMixture();
00030 
00031     GlobalPoint vertexPosition = mixtureIter1->position();
00032     AlgebraicVector3 vertexCoord1;
00033     vertexCoord1[0] = vertexPosition.x();
00034     vertexCoord1[1] = vertexPosition.y();
00035     vertexCoord1[2] = vertexPosition.z();
00036 
00037 //    AlgebraicVector position = mixtureIter1->position().vector(); //???
00038     weightSum += vtxWeight;
00039     meanPosition += vtxWeight * vertexCoord1;
00040 
00041     measCovar1 += vtxWeight * mixtureIter1->error().matrix();
00042     for (VSC::const_iterator mixtureIter2 = mixtureIter1+1;
00043         mixtureIter2 != theMixture.end(); mixtureIter2++ ) {
00044       GlobalPoint vertexPosition2 = mixtureIter2->position();
00045       AlgebraicVector3 vertexCoord2;
00046       vertexCoord2[0] = vertexPosition2.x();
00047       vertexCoord2[1] = vertexPosition2.y();
00048       vertexCoord2[2] = vertexPosition2.z();
00049       AlgebraicVector3 posDiff = vertexCoord1 - vertexCoord2;
00050       AlgebraicMatrix13 tmp; tmp.Place_in_row(posDiff,0,0);
00051       AlgebraicSymMatrix11 s = AlgebraicMatrixID(); 
00052       measCovar2 +=vtxWeight * mixtureIter2->weightInMixture() * ROOT::Math::SimilarityT(tmp,s);
00053     }
00054   }
00055   meanPosition /= weightSum;
00056   AlgebraicSymMatrix33 measCovar = measCovar1/weightSum + measCovar2/weightSum/weightSum;
00057 
00058   GlobalPoint newPos(meanPosition[0], meanPosition[1], meanPosition[2]);
00059 
00060 // #ifndef CMS_NO_COMPLEX_RETURNS
00061   return VertexState(newPos, GlobalError(measCovar), weightSum);
00062 // #else
00063 //   VertexState theFinalVS(newPos, GlobalError(measCovar), weightSum);
00064 //   return theFinalVS;
00065 // #endif
00066 }