Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:14

0001 /** \class StandAloneMuonSmoother
0002  * 
0003  *  Smooth a trajectory using the standard Kalman Filter smoother.
0004  *  This class contains the KFTrajectorySmoother and takes care
0005  *  to update the it whenever the propagator change.
0006  *
0007  *  \author R. Bellan - INFN Torino <riccardo.bellan@cern.ch>
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   // The max allowed chi2 to accept a rechit in the fit
0027   theMaxChi2 = par.getParameter<double>("MaxChi2");
0028 
0029   // The errors of the trajectory state are multiplied by nSigma
0030   // to define acceptance of BoundPlane and maximalLocalDisplacement
0031   theNSigma = par.getParameter<double>("NumberOfSigma");  // default = 3.
0032 
0033   // The estimator: makes the decision wheter a measure is good or not
0034   // it isn't used by the updator which does the real fit. In fact, in principle,
0035   // a looser request onto the measure set can be requested
0036   // (w.r.t. the request on the accept/reject measure in the fit)
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   // The Kalman smoother
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 }