Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:38

0001 #include "TrackingTools/GsfTracking/interface/TsosGaussianStateConversions.h"
0002 
0003 #include "TrackingTools/GsfTools/interface/SingleGaussianState.h"
0004 #include "TrackingTools/GsfTools/interface/BasicMultiTrajectoryState.h"
0005 
0006 using namespace SurfaceSideDefinition;
0007 
0008 namespace GaussianStateConversions {
0009 
0010   MultiGaussianState<5> multiGaussianStateFromTSOS(const TrajectoryStateOnSurface& tsos) {
0011     if (!tsos.isValid())
0012       return MultiGaussianState<5>();
0013 
0014     using SingleStatePtr = std::shared_ptr<SingleGaussianState<5>>;
0015     auto const& components = tsos.components();
0016     MultiGaussianState<5>::SingleStateContainer singleStates;
0017     singleStates.reserve(components.size());
0018     for (auto const& ic : components) {
0019       if (ic.isValid()) {
0020         auto sgs = std::make_shared<SingleGaussianState<5>>(
0021             ic.localParameters().vector(), ic.localError().matrix(), ic.weight());
0022         singleStates.push_back(sgs);
0023       }
0024     }
0025     return MultiGaussianState<5>(singleStates);
0026   }
0027 
0028   TrajectoryStateOnSurface tsosFromMultiGaussianState(const MultiGaussianState<5>& multiState,
0029                                                       const TrajectoryStateOnSurface& refTsos) {
0030     if (multiState.components().empty())
0031       return TrajectoryStateOnSurface();
0032     const Surface& surface = refTsos.surface();
0033     SurfaceSide side = refTsos.surfaceSide();
0034     const MagneticField* field = refTsos.magneticField();
0035     auto const& refTsos1 = refTsos.components().front();
0036     auto pzSign = refTsos1.localParameters().pzSign();
0037     bool charged = refTsos1.charge() != 0;
0038 
0039     auto const& singleStates = multiState.components();
0040     std::vector<TrajectoryStateOnSurface> components;
0041     components.reserve(singleStates.size());
0042     for (auto const& ic : singleStates) {
0043       components.emplace_back((*ic).weight(),
0044                               LocalTrajectoryParameters((*ic).mean(), pzSign, charged),
0045                               LocalTrajectoryError((*ic).covariance()),
0046                               surface,
0047                               field,
0048                               side);
0049     }
0050     return TrajectoryStateOnSurface((BasicTrajectoryState*)new BasicMultiTrajectoryState(components));
0051   }
0052 }  // namespace GaussianStateConversions