File indexing completed on 2024-04-06 12:27:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "RecoMuon/StandAloneTrackFinder/interface/StandAloneMuonSmoother.h"
0011
0012 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0013
0014 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
0015 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
0016 #include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h"
0017
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020
0021 using namespace edm;
0022 using namespace std;
0023
0024 StandAloneMuonSmoother::StandAloneMuonSmoother(const ParameterSet& par, const MuonServiceProxy* service)
0025 : theService(service) {
0026
0027 theMaxChi2 = par.getParameter<double>("MaxChi2");
0028
0029
0030
0031 theNSigma = par.getParameter<double>("NumberOfSigma");
0032
0033
0034
0035
0036
0037 theEstimator = new Chi2MeasurementEstimator(theMaxChi2, theNSigma);
0038
0039 theErrorRescaling = par.getParameter<double>("ErrorRescalingFactor");
0040
0041 thePropagatorName = par.getParameter<string>("Propagator");
0042
0043 theUpdator = new KFUpdator();
0044
0045
0046 theSmoother = nullptr;
0047 }
0048
0049 StandAloneMuonSmoother::~StandAloneMuonSmoother() {
0050 if (theEstimator)
0051 delete theEstimator;
0052 if (theUpdator)
0053 delete theUpdator;
0054 if (theSmoother)
0055 delete theSmoother;
0056 }
0057
0058 const Propagator* StandAloneMuonSmoother::propagator() const { return &*theService->propagator(thePropagatorName); }
0059
0060 void StandAloneMuonSmoother::renewTheSmoother() {
0061 if (theService->isTrackingComponentsRecordChanged()) {
0062 if (theSmoother)
0063 delete theSmoother;
0064 theSmoother = new KFTrajectorySmoother(propagator(), updator(), estimator());
0065 }
0066 if (!theSmoother)
0067 theSmoother = new KFTrajectorySmoother(propagator(), updator(), estimator());
0068 }
0069
0070 StandAloneMuonSmoother::SmoothingResult StandAloneMuonSmoother::smooth(const Trajectory& inputTrajectory) {
0071 const string metname = "Muon|RecoMuon|StandAloneMuonSmoother";
0072
0073 renewTheSmoother();
0074
0075 vector<Trajectory> trajectoriesSM = smoother()->trajectories(inputTrajectory);
0076
0077 if (trajectoriesSM.empty()) {
0078 LogTrace(metname) << "No Track smoothed!";
0079 return SmoothingResult(false, inputTrajectory);
0080 }
0081
0082 Trajectory smoothed = trajectoriesSM.front();
0083
0084 return SmoothingResult(true, smoothed);
0085 }