File indexing completed on 2024-04-06 12:31:31
0001 #include "TrackingTools/GsfTracking/interface/GsfMultiStateUpdator.h"
0002 #include "TrackingTools/GsfTools/interface/GetComponents.h"
0003 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
0004 #include "TrackingTools/PatternTools/interface/MeasurementExtractor.h"
0005 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0006 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
0007 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0008 #include "TrackingTools/GsfTools/interface/BasicMultiTrajectoryState.h"
0009 #include "TrackingTools/GsfTracking/interface/PosteriorWeightsCalculator.h"
0010 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateAssembler.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012
0013 TrajectoryStateOnSurface GsfMultiStateUpdator::update(const TrajectoryStateOnSurface& tsos,
0014 const TrackingRecHit& aRecHit) const {
0015 if (!tsos.isValid()) {
0016 edm::LogError("GsfMultiStateUpdator") << "Trying to update trajectory state with invalid TSOS! ";
0017 return TrajectoryStateOnSurface();
0018 }
0019
0020 GetComponents comps(tsos);
0021 auto const& predictedComponents = comps();
0022 if (predictedComponents.empty()) {
0023 edm::LogError("GsfMultiStateUpdator") << "Trying to update trajectory state with zero components! ";
0024 return TrajectoryStateOnSurface();
0025 }
0026
0027 auto&& weights = PosteriorWeightsCalculator(predictedComponents).weights(aRecHit);
0028 if (weights.empty()) {
0029 edm::LogError("GsfMultiStateUpdator") << " no weights could be retreived. invalid updated state !.";
0030 return TrajectoryStateOnSurface();
0031 }
0032
0033 MultiTrajectoryStateAssembler result;
0034
0035 int i = 0;
0036 for (auto const& tsosI : predictedComponents) {
0037 TrajectoryStateOnSurface updatedTSOS = KFUpdator().update(tsosI, aRecHit);
0038
0039 if (double det;
0040 updatedTSOS.isValid() && updatedTSOS.localError().valid() && updatedTSOS.localError().posDef() &&
0041 (det = 0., updatedTSOS.curvilinearError().matrix().Sub<AlgebraicSymMatrix22>(0, 0).Det(det) && det > 0) &&
0042 (det = 0., updatedTSOS.curvilinearError().matrix().Sub<AlgebraicSymMatrix33>(0, 0).Det(det) && det > 0) &&
0043 (det = 0., updatedTSOS.curvilinearError().matrix().Sub<AlgebraicSymMatrix44>(0, 0).Det(det) && det > 0) &&
0044 (det = 0., updatedTSOS.curvilinearError().matrix().Det2(det) && det > 0)) {
0045 result.addState(TrajectoryStateOnSurface(weights[i],
0046 updatedTSOS.localParameters(),
0047 updatedTSOS.localError(),
0048 updatedTSOS.surface(),
0049 &(tsos.globalParameters().magneticField()),
0050 tsosI.surfaceSide()));
0051 } else {
0052 edm::LogError("GsfMultiStateUpdator") << "KF updated state " << i << " is invalid. skipping.";
0053 }
0054 ++i;
0055 }
0056
0057 return result.combinedState();
0058 }