CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/TrackingTools/GsfTracking/src/TsosGaussianStateConversions.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GsfTracking/interface/TsosGaussianStateConversions.h"
00002 
00003 #include "TrackingTools/GsfTools/interface/SingleGaussianState.h"
00004 #include "TrackingTools/GsfTools/interface/BasicMultiTrajectoryState.h"
00005 #include "boost/shared_ptr.hpp"
00006 
00007 using namespace SurfaceSideDefinition;
00008 
00009 namespace GaussianStateConversions {
00010 
00011   MultiGaussianState<5> multiGaussianStateFromTSOS (const TrajectoryStateOnSurface tsos)
00012   {
00013     if ( !tsos.isValid() )  return MultiGaussianState<5>();
00014 
00015     typedef boost::shared_ptr< SingleGaussianState<5> > SingleStatePtr;
00016     const std::vector<TrajectoryStateOnSurface>& components = tsos.components();
00017     MultiGaussianState<5>::SingleStateContainer singleStates;
00018     singleStates.reserve(components.size());
00019     for ( std::vector<TrajectoryStateOnSurface>::const_iterator ic=components.begin();
00020           ic!=components.end(); ic ++ ) {
00021       if ( ic->isValid() ) {
00022         SingleStatePtr sgs(new SingleGaussianState<5>(ic->localParameters().vector(),
00023                                                               ic->localError().matrix(),
00024                                                               ic->weight()));
00025         singleStates.push_back(sgs);
00026       }
00027     }
00028     return MultiGaussianState<5>(singleStates);
00029   }
00030 
00031   TrajectoryStateOnSurface tsosFromMultiGaussianState (const MultiGaussianState<5>& multiState,
00032                                                           const TrajectoryStateOnSurface refTsos)
00033   {
00034     if ( multiState.components().empty() )  return TrajectoryStateOnSurface();
00035     const Surface& surface = refTsos.surface();
00036     SurfaceSide side = refTsos.surfaceSide();
00037     const MagneticField* field = refTsos.magneticField();
00038     TrajectoryStateOnSurface refTsos1 = refTsos.components().front();
00039     double pzSign = refTsos1.localParameters().pzSign();
00040     bool charged = refTsos1.charge()!=0;
00041 
00042     const MultiGaussianState<5>::SingleStateContainer& singleStates = 
00043       multiState.components();
00044     std::vector<TrajectoryStateOnSurface> components;
00045     components.reserve(singleStates.size());
00046     for ( MultiGaussianState<5>::SingleStateContainer::const_iterator ic=singleStates.begin();
00047           ic!=singleStates.end(); ic++ ) {
00048       components.push_back(TrajectoryStateOnSurface(LocalTrajectoryParameters((**ic).mean(),
00049                                                                               pzSign,charged),
00050                                                     LocalTrajectoryError((**ic).covariance()),
00051                                                     surface,field,side,(**ic).weight()));
00052     }
00053     return TrajectoryStateOnSurface(new BasicMultiTrajectoryState(components));
00054   }
00055 }
00056