CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoVertex/VertexPrimitives/src/BasicSingleVertexState.cc

Go to the documentation of this file.
00001 #include "RecoVertex/VertexPrimitives/interface/BasicSingleVertexState.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003 
00004 BasicSingleVertexState::BasicSingleVertexState()
00005   : thePos(GlobalPoint(0, 0, 0)), thePosAvailable(false),
00006     theErr(AlgebraicSymMatrix33()), theErrAvailable(false),
00007     theWeight(AlgebraicSymMatrix33()), theWeightAvailable(false),
00008     theWeightTimesPos(AlgebraicVector3()), theWeightTimesPosAvailable(false),
00009     valid(false), theWeightInMix(0.)
00010 {}
00011 
00012 
00013 BasicSingleVertexState::BasicSingleVertexState(const GlobalPoint & pos,
00014                              const GlobalError & posErr,
00015                              const double & weightInMix)
00016   : thePos(pos), thePosAvailable(true),
00017     theErr(posErr), theErrAvailable(true),
00018     theWeight(AlgebraicSymMatrix33()), theWeightAvailable(false),
00019     theWeightTimesPos(AlgebraicVector3()), theWeightTimesPosAvailable(false),
00020     valid(true), theWeightInMix(weightInMix)
00021 {}
00022 
00023 
00024 BasicSingleVertexState::BasicSingleVertexState(const GlobalPoint & pos,
00025                              const GlobalWeight & posWeight,
00026                              const double & weightInMix)
00027   : thePos(pos), thePosAvailable(true),
00028     theErr(AlgebraicSymMatrix33()), theErrAvailable(false),
00029     theWeight(posWeight), theWeightAvailable(true),
00030     theWeightTimesPos(AlgebraicVector3()), theWeightTimesPosAvailable(false),
00031     valid(true), theWeightInMix(weightInMix)
00032 {}
00033 
00034 
00035 BasicSingleVertexState::BasicSingleVertexState(const AlgebraicVector3 & weightTimesPosition,
00036                              const GlobalWeight & posWeight,
00037                              const double & weightInMix)
00038   : thePos(GlobalPoint(0, 0, 0)), thePosAvailable(false),
00039     theErr(AlgebraicSymMatrix33()), theErrAvailable(false),
00040     theWeight(posWeight), theWeightAvailable(true),
00041     theWeightTimesPos(weightTimesPosition), theWeightTimesPosAvailable(true),
00042     valid(true), theWeightInMix(weightInMix)
00043 {//std::cout <<"BasicSingleVertexState ctor\n";
00044 }
00045 
00046 GlobalPoint BasicSingleVertexState::position() const
00047 {
00048   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00049   if (!thePosAvailable) computePosition();
00050   return thePos;
00051 }
00052 
00053 
00054 GlobalError BasicSingleVertexState::error() const
00055 {
00056   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00057   if (!theErrAvailable) computeError();
00058   return theErr;
00059 }
00060 
00061 
00062 GlobalWeight BasicSingleVertexState::weight() const
00063 {
00064   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00065   if (!theWeightAvailable) computeWeight();
00066   return theWeight;
00067 }
00068 
00069 
00070 AlgebraicVector3 BasicSingleVertexState::weightTimesPosition() const
00071 {
00072   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00073   if (!theWeightTimesPosAvailable) computeWeightTimesPos();
00074   return theWeightTimesPos;
00075 }
00076 
00077 
00078 double BasicSingleVertexState::weightInMixture() const 
00079 {
00080   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00081   return theWeightInMix;
00082 }
00083 // RefCountedVertexSeed BasicSingleVertexState::seedWithoutTracks() const
00084 // {
00085 //   RefCountedVertexSeed v = new VertexSeed(position(), error());
00086 //   return v;
00087 // }
00088 
00089 
00090 
00091 void BasicSingleVertexState::computePosition() const
00092 {
00093   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00094   AlgebraicVector3 pos = error().matrix_new()*weightTimesPosition();
00095   thePos = GlobalPoint(pos[0], pos[1], pos[2]);
00096   thePosAvailable = true;
00097 }
00098 
00099 
00100 void BasicSingleVertexState::computeError() const
00101 {
00102   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00103   int ifail;
00104   theErr = weight().matrix().inverse(ifail);
00105   if (ifail != 0) throw VertexException("BasicSingleVertexState::could not invert weight matrix");
00106   theErrAvailable = true;
00107 }
00108 
00109 
00110 void BasicSingleVertexState::computeWeight() const
00111 {
00112   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00113   int ifail;
00114   theWeight = error().matrix().inverse(ifail);
00115   if (ifail != 0) throw VertexException("BasicSingleVertexState::could not invert error matrix");
00116   theWeightAvailable = true;
00117 }
00118 
00119 
00120 void BasicSingleVertexState::computeWeightTimesPos() const
00121 {
00122   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00123   AlgebraicVector3 pos; pos(0) = position().x();
00124   pos(1) = position().y(); pos(2) = position().z();
00125   theWeightTimesPos = weight().matrix_new()*pos;
00126   theWeightTimesPosAvailable = true;
00127 }
00128 
00129