CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MultiVertexStateCombiner.cc
Go to the documentation of this file.
3 
4 
6 MultiVertexStateCombiner::combine(const VSC & theMixture) const
7 {
8 
9  if (theMixture.empty()) {
10  throw VertexException
11  ("MultiVertexStateCombiner:: VertexState container to collapse is empty");
12  }
13 
14  if (theMixture.size()==1) {
15 // #ifndef CMS_NO_COMPLEX_RETURNS
16  return VertexState(theMixture.front().position(), theMixture.front().error(), 1.0);
17 // #else
18 // VertexState theFinalVM(theMixture.front().position(), theMixture.front().error(), 1.0);
19 // return theFinalVM;
20 // #endif
21  }
22 
23 
24  AlgebraicVector3 meanPosition;
25  double weightSum = 0.;
26  AlgebraicSymMatrix33 measCovar1, measCovar2;
27  for (VSC::const_iterator mixtureIter1 = theMixture.begin();
28  mixtureIter1 != theMixture.end(); mixtureIter1++ ) {
29  double vtxWeight = mixtureIter1->weightInMixture();
30 
31  GlobalPoint vertexPosition = mixtureIter1->position();
32  AlgebraicVector3 vertexCoord1;
33  vertexCoord1[0] = vertexPosition.x();
34  vertexCoord1[1] = vertexPosition.y();
35  vertexCoord1[2] = vertexPosition.z();
36 
37 // AlgebraicVector position = mixtureIter1->position().vector(); //???
38  weightSum += vtxWeight;
39  meanPosition += vtxWeight * vertexCoord1;
40 
41  measCovar1 += vtxWeight * mixtureIter1->error().matrix();
42  for (VSC::const_iterator mixtureIter2 = mixtureIter1+1;
43  mixtureIter2 != theMixture.end(); mixtureIter2++ ) {
44  GlobalPoint vertexPosition2 = mixtureIter2->position();
45  AlgebraicVector3 vertexCoord2;
46  vertexCoord2[0] = vertexPosition2.x();
47  vertexCoord2[1] = vertexPosition2.y();
48  vertexCoord2[2] = vertexPosition2.z();
49  AlgebraicVector3 posDiff = vertexCoord1 - vertexCoord2;
50  AlgebraicMatrix13 tmp; tmp.Place_in_row(posDiff,0,0);
52  measCovar2 +=vtxWeight * mixtureIter2->weightInMixture() * ROOT::Math::SimilarityT(tmp,s);
53  }
54  }
55  meanPosition /= weightSum;
56  AlgebraicSymMatrix33 measCovar = measCovar1/weightSum + measCovar2/weightSum/weightSum;
57 
58  GlobalPoint newPos(meanPosition[0], meanPosition[1], meanPosition[2]);
59 
60 // #ifndef CMS_NO_COMPLEX_RETURNS
61  return VertexState(newPos, GlobalError(measCovar), weightSum);
62 // #else
63 // VertexState theFinalVS(newPos, GlobalError(measCovar), weightSum);
64 // return theFinalVS;
65 // #endif
66 }
VertexState combine(const VSC &theMixture) const
Common base class.
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
T y() const
Definition: PV3DBase.h:63
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
T z() const
Definition: PV3DBase.h:64
std::vector< VertexState > VSC
ROOT::Math::SMatrix< double, 1, 3, ROOT::Math::MatRepStd< double, 1, 3 > > AlgebraicMatrix13
ROOT::Math::SVector< double, 3 > AlgebraicVector3
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
T x() const
Definition: PV3DBase.h:62
ROOT::Math::SMatrix< double, 1, 1, ROOT::Math::MatRepSym< double, 1 > > AlgebraicSymMatrix11