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 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 (theComponents.empty()) { 00047 cout << "Asking for weight of empty MultiVertexState, returning zero!" << endl; 00048 throw VertexException("Asking for weight of empty MultiVertexState, returning zero!"); 00049 return 0.; 00050 } 00051 00052 double weight = 0.; 00053 for (vector<VertexState>::const_iterator it = theComponents.begin(); 00054 it != theComponents.end(); it++) { 00055 weight += it->weightInMixture(); 00056 } 00057 return weight; 00058 } 00059 00060 void BasicMultiVertexState::checkCombinedState() const 00061 { 00062 if (theCombinedStateUp2Date) return; 00063 00064 theCombinedState = theCombiner.combine(theComponents); 00065 theCombinedStateUp2Date = true; 00066 } 00067