Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-14 23:41:50

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       //require states to be positive-definite
0044       if (double det = 0; (*ic).covariance().Det2(det) && det > 0) {
0045         components.emplace_back((*ic).weight(),
0046                                 LocalTrajectoryParameters((*ic).mean(), pzSign, charged),
0047                                 LocalTrajectoryError((*ic).covariance()),
0048                                 surface,
0049                                 field,
0050                                 side);
0051       }
0052     }
0053     return components.empty()
0054                ? TrajectoryStateOnSurface()
0055                : TrajectoryStateOnSurface((BasicTrajectoryState*)new BasicMultiTrajectoryState(components));
0056   }
0057 }  // namespace GaussianStateConversions