Go to the documentation of this file.00001 #include "RecoVertex/GaussianSumVertexFit/interface/VertexGaussianStateConversions.h"
00002
00003 #include "RecoVertex/GaussianSumVertexFit/interface/BasicMultiVertexState.h"
00004 #include "TrackingTools/GsfTools/interface/SingleGaussianState.h"
00005 #include "DataFormats/CLHEP/interface/Migration.h"
00006 #include "boost/shared_ptr.hpp"
00007
00008 namespace GaussianStateConversions {
00009
00010 MultiGaussianState<3> multiGaussianStateFromVertex (const VertexState aState)
00011 {
00012 typedef boost::shared_ptr< SingleGaussianState<3> > SingleStatePtr;
00013 const std::vector<VertexState> components = aState.components();
00014 MultiGaussianState<3>::SingleStateContainer singleStates;
00015 singleStates.reserve(components.size());
00016 for ( std::vector<VertexState>::const_iterator ic=components.begin();
00017 ic!=components.end(); ic ++ ) {
00018 if ( ic->isValid() ) {
00019 GlobalPoint pos(ic->position());
00020 AlgebraicVector3 parameters;
00021 parameters(0) = pos.x(); parameters(1) = pos.y(); parameters(2) = pos.z();
00022 SingleStatePtr sgs(new SingleGaussianState<3>(parameters,
00023 ic->error().matrix_new(),
00024 ic->weightInMixture()));
00025 singleStates.push_back(sgs);
00026 }
00027 }
00028 return MultiGaussianState<3>(singleStates);
00029 }
00030
00031 VertexState vertexFromMultiGaussianState (const MultiGaussianState<3>& multiState)
00032 {
00033 if ( multiState.components().empty() ) return VertexState();
00034
00035 const MultiGaussianState<3>::SingleStateContainer& singleStates =
00036 multiState.components();
00037 std::vector<VertexState> components;
00038 components.reserve(singleStates.size());
00039 for ( MultiGaussianState<3>::SingleStateContainer::const_iterator ic=singleStates.begin();
00040 ic!=singleStates.end(); ic++ ) {
00041 const AlgebraicVector3& par = (**ic).mean();
00042 GlobalPoint position(par(0),par(1),par(2));
00043 const AlgebraicSymMatrix33& cov = (**ic).covariance();
00044 GlobalError error(cov(0,0),cov(1,0),cov(2,0),cov(1,1),cov(2,1),cov(2,2));
00045 components.push_back(VertexState(position,error,(**ic).weight()));
00046 }
00047 return VertexState(new BasicMultiVertexState(components));
00048 }
00049 }
00050