CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "RecoVertex/GaussianSumVertexFit/interface/BasicMultiVertexState.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003 
00004 using namespace std;
00005 
00006 BasicMultiVertexState::
00007 BasicMultiVertexState(const vector<VertexState>& vsComp) :
00008   valid(true), theComponents(vsComp), theCombinedStateUp2Date( false) {}
00009 
00010 
00011 GlobalPoint BasicMultiVertexState::position() const
00012 {
00013   checkCombinedState();
00014   return theCombinedState.position();
00015 }
00016 
00017 
00018 GlobalError BasicMultiVertexState::error() const
00019 {
00020   checkCombinedState();
00021   return theCombinedState.error();
00022 }
00023 
00024 
00025 GlobalWeight BasicMultiVertexState::weight() const
00026 {
00027   checkCombinedState();
00028   return theCombinedState.weight();
00029 }
00030 
00031 
00032 AlgebraicVector3 BasicMultiVertexState::weightTimesPosition() const
00033 {
00034   checkCombinedState();
00035   return theCombinedState.weightTimesPosition();
00036 }
00037 
00038 
00039 // RefCountedVertexSeed BasicMultiVertexState::seedWithoutTracks() const
00040 // {
00041 //   checkCombinedState();
00042 //   return theCombinedState.seedWithoutTracks();
00043 // }
00044 
00045 double BasicMultiVertexState::weightInMixture() const {
00046   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00047   if (theComponents.empty()) {
00048     cout << "Asking for weight of empty MultiVertexState, returning zero!" << endl;
00049     throw VertexException("Asking for weight of empty MultiVertexState, returning zero!");
00050     return 0.;
00051   }
00052 
00053   double weight = 0.;
00054   for (vector<VertexState>::const_iterator it = theComponents.begin(); 
00055         it != theComponents.end(); it++) {
00056     weight += it->weightInMixture();
00057   }
00058   return weight;
00059 }
00060 
00061 void BasicMultiVertexState::checkCombinedState() const
00062 {
00063   if (!valid) throw VertexException("BasicSingleVertexState::invalid");
00064   if (theCombinedStateUp2Date) return;
00065 
00066   theCombinedState = theCombiner.combine(theComponents);
00067   theCombinedStateUp2Date = true;
00068 }
00069