Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "RecoVertex/GaussianSumVertexFit/interface/VertexGaussianStateConversions.h"
0002 
0003 #include "RecoVertex/GaussianSumVertexFit/interface/BasicMultiVertexState.h"
0004 #include "TrackingTools/GsfTools/interface/SingleGaussianState.h"
0005 
0006 namespace GaussianStateConversions {
0007 
0008   MultiGaussianState<3> multiGaussianStateFromVertex(const VertexState aState) {
0009     typedef std::shared_ptr<SingleGaussianState<3> > SingleStatePtr;
0010     const std::vector<VertexState> components = aState.components();
0011     MultiGaussianState<3>::SingleStateContainer singleStates;
0012     singleStates.reserve(components.size());
0013     for (std::vector<VertexState>::const_iterator ic = components.begin(); ic != components.end(); ic++) {
0014       if (ic->isValid()) {
0015         GlobalPoint pos(ic->position());
0016         AlgebraicVector3 parameters;
0017         parameters(0) = pos.x();
0018         parameters(1) = pos.y();
0019         parameters(2) = pos.z();
0020         SingleStatePtr sgs(new SingleGaussianState<3>(parameters, ic->error().matrix(), ic->weightInMixture()));
0021         singleStates.push_back(sgs);
0022       }
0023     }
0024     return MultiGaussianState<3>(singleStates);
0025   }
0026 
0027   VertexState vertexFromMultiGaussianState(const MultiGaussianState<3>& multiState) {
0028     if (multiState.components().empty())
0029       return VertexState();
0030 
0031     const MultiGaussianState<3>::SingleStateContainer& singleStates = multiState.components();
0032     std::vector<VertexState> components;
0033     components.reserve(singleStates.size());
0034     for (MultiGaussianState<3>::SingleStateContainer::const_iterator ic = singleStates.begin();
0035          ic != singleStates.end();
0036          ic++) {
0037       const AlgebraicVector3& par = (**ic).mean();
0038       GlobalPoint position(par(0), par(1), par(2));
0039       const AlgebraicSymMatrix33& cov = (**ic).covariance();
0040       GlobalError error(cov(0, 0), cov(1, 0), cov(2, 0), cov(1, 1), cov(2, 1), cov(2, 2));
0041       components.push_back(VertexState(position, error, (**ic).weight()));
0042     }
0043     return VertexState(new BasicMultiVertexState(components));
0044   }
0045 }  // namespace GaussianStateConversions