Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:07

0001 #include "RecoVertex/GaussianSumVertexFit/interface/BasicMultiVertexState.h"
0002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
0003 
0004 using namespace std;
0005 
0006 BasicMultiVertexState::BasicMultiVertexState(const vector<VertexState>& vsComp)
0007     : valid(true), theComponents(vsComp), theCombinedStateUp2Date(false) {}
0008 
0009 GlobalPoint BasicMultiVertexState::position() const {
0010   checkCombinedState();
0011   return theCombinedState.position();
0012 }
0013 
0014 double BasicMultiVertexState::time() const {
0015   checkCombinedState();
0016   return theCombinedState.time();
0017 }
0018 
0019 GlobalError BasicMultiVertexState::error() const {
0020   checkCombinedState();
0021   return theCombinedState.error();
0022 }
0023 
0024 double BasicMultiVertexState::timeError() const {
0025   checkCombinedState();
0026   return theCombinedState.timeError();
0027 }
0028 
0029 GlobalError BasicMultiVertexState::error4D() const {
0030   checkCombinedState();
0031   return theCombinedState.error4D();
0032 }
0033 
0034 GlobalWeight BasicMultiVertexState::weight() const {
0035   checkCombinedState();
0036   return theCombinedState.weight();
0037 }
0038 
0039 GlobalWeight BasicMultiVertexState::weight4D() const {
0040   checkCombinedState();
0041   return theCombinedState.weight4D();
0042 }
0043 
0044 AlgebraicVector3 BasicMultiVertexState::weightTimesPosition() const {
0045   checkCombinedState();
0046   return theCombinedState.weightTimesPosition();
0047 }
0048 
0049 AlgebraicVector4 BasicMultiVertexState::weightTimesPosition4D() const {
0050   checkCombinedState();
0051   return theCombinedState.weightTimesPosition4D();
0052 }
0053 
0054 // RefCountedVertexSeed BasicMultiVertexState::seedWithoutTracks() const
0055 // {
0056 //   checkCombinedState();
0057 //   return theCombinedState.seedWithoutTracks();
0058 // }
0059 
0060 double BasicMultiVertexState::weightInMixture() const {
0061   if (!valid)
0062     throw VertexException("BasicSingleVertexState::invalid");
0063   if (theComponents.empty()) {
0064     cout << "Asking for weight of empty MultiVertexState, returning zero!" << endl;
0065     throw VertexException("Asking for weight of empty MultiVertexState, returning zero!");
0066     return 0.;
0067   }
0068 
0069   double weight = 0.;
0070   for (vector<VertexState>::const_iterator it = theComponents.begin(); it != theComponents.end(); it++) {
0071     weight += it->weightInMixture();
0072   }
0073   return weight;
0074 }
0075 
0076 void BasicMultiVertexState::checkCombinedState() const {
0077   if (!valid)
0078     throw VertexException("BasicSingleVertexState::invalid");
0079   if (theCombinedStateUp2Date)
0080     return;
0081 
0082   theCombinedState = theCombiner.combine(theComponents);
0083   theCombinedStateUp2Date = true;
0084 }