File indexing completed on 2024-04-06 12:29:08
0001 #include <memory>
0002 #include <vector>
0003
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0006 #include "DataFormats/GeometryVector/interface/VectorUtil.h"
0007 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
0008
0009 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0010
0011 #include "RecoVertex/GhostTrackFitter/interface/GhostTrack.h"
0012 #include "RecoVertex/GhostTrackFitter/interface/GhostTrackState.h"
0013 #include "RecoVertex/GhostTrackFitter/interface/GhostTrackPrediction.h"
0014
0015 #include "RecoVertex/GhostTrackFitter/interface/GhostTrackFitter.h"
0016
0017 #include "RecoVertex/GhostTrackFitter/interface/AnnealingGhostTrackFitter.h"
0018 #include "RecoVertex/GhostTrackFitter/interface/PositiveSideGhostTrackFitter.h"
0019 #include "RecoVertex/GhostTrackFitter/interface/KalmanGhostTrackUpdater.h"
0020
0021 using namespace reco;
0022
0023 GhostTrackFitter::GhostTrackFitter() {
0024 fitter = std::make_unique<AnnealingGhostTrackFitter>();
0025 updater = std::make_unique<KalmanGhostTrackUpdater>();
0026 }
0027
0028 GhostTrackFitter::~GhostTrackFitter() {}
0029
0030 GhostTrack GhostTrackFitter::fit(const GlobalPoint &priorPosition,
0031 const GlobalError &priorError,
0032 const GlobalVector &direction,
0033 double coneRadius,
0034 const std::vector<TransientTrack> &tracks) const {
0035 GhostTrackPrediction prior(priorPosition, priorError, direction, coneRadius);
0036 return fit(prior, priorPosition, tracks);
0037 }
0038
0039 GhostTrack GhostTrackFitter::fit(const GlobalPoint &priorPosition,
0040 const GlobalError &priorError,
0041 const GlobalVector &direction,
0042 const GlobalError &directionError,
0043 const std::vector<TransientTrack> &tracks) const {
0044 GhostTrackPrediction prior(priorPosition, priorError, direction, directionError);
0045 return fit(prior, priorPosition, tracks);
0046 }
0047
0048 GhostTrack GhostTrackFitter::fit(const GhostTrackPrediction &prior,
0049 const GlobalPoint &origin,
0050 const std::vector<TransientTrack> &tracks) const {
0051 double offset = prior.lambda(origin);
0052
0053 std::vector<GhostTrackState> states;
0054 for (std::vector<TransientTrack>::const_iterator iter = tracks.begin(); iter != tracks.end(); ++iter) {
0055 GhostTrackState state(*iter);
0056 state.linearize(prior, true, offset);
0057 states.push_back(state);
0058 }
0059
0060 PositiveSideGhostTrackFitter actualFitter(origin, *fitter);
0061 return fit(actualFitter, prior, states);
0062 }
0063
0064 GhostTrack GhostTrackFitter::fit(const GhostTrackPrediction &prior, const std::vector<TransientTrack> &tracks) const {
0065 std::vector<GhostTrackState> states;
0066 for (std::vector<TransientTrack>::const_iterator iter = tracks.begin(); iter != tracks.end(); ++iter) {
0067 GhostTrackState state(*iter);
0068 state.linearize(prior, true);
0069 states.push_back(state);
0070 }
0071
0072 return fit(*fitter, prior, states);
0073 }
0074
0075 GhostTrack GhostTrackFitter::fit(FitterImpl &fitterImpl,
0076 const GhostTrackPrediction &prior,
0077 const std::vector<GhostTrackState> &states_) const {
0078 std::vector<GhostTrackState> states = states_;
0079
0080 double ndof, chi2;
0081 GhostTrackPrediction pred = fitterImpl.fit(*updater, prior, states, ndof, chi2);
0082
0083 GhostTrack result(prior, pred, states, ndof, chi2);
0084
0085 return result;
0086 }