CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoMuon/StandAloneTrackFinder/src/StandAloneMuonSmoother.cc

Go to the documentation of this file.
00001 
00012 #include "RecoMuon/StandAloneTrackFinder/interface/StandAloneMuonSmoother.h"
00013 
00014 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00015 
00016 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
00017 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
00018 #include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h"
00019 
00020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 
00023 using namespace edm;
00024 using namespace std;
00025 
00026 
00027 StandAloneMuonSmoother::StandAloneMuonSmoother(const ParameterSet& par, 
00028                                                const MuonServiceProxy* service):theService(service){
00029 
00030   // The max allowed chi2 to accept a rechit in the fit
00031   theMaxChi2 = par.getParameter<double>("MaxChi2");
00032   
00033   // The errors of the trajectory state are multiplied by nSigma 
00034   // to define acceptance of BoundPlane and maximalLocalDisplacement
00035   theNSigma = par.getParameter<double>("NumberOfSigma"); // default = 3.
00036   
00037   // The estimator: makes the decision wheter a measure is good or not
00038   // it isn't used by the updator which does the real fit. In fact, in principle,
00039   // a looser request onto the measure set can be requested 
00040   // (w.r.t. the request on the accept/reject measure in the fit)
00041   theEstimator = new Chi2MeasurementEstimator(theMaxChi2,theNSigma);
00042   
00043   theErrorRescaling = par.getParameter<double>("ErrorRescalingFactor");
00044   
00045   thePropagatorName = par.getParameter<string>("Propagator");
00046   
00047   theUpdator = new KFUpdator();
00048   
00049   // The Kalman smoother
00050   theSmoother = 0 ;
00051                 
00052 }
00053 
00054 StandAloneMuonSmoother::~StandAloneMuonSmoother(){
00055   if (theEstimator) delete theEstimator;
00056   if (theUpdator) delete theUpdator;
00057   if (theSmoother) delete theSmoother;
00058 }
00059 
00060 const Propagator* StandAloneMuonSmoother::propagator() const{ 
00061   return &*theService->propagator(thePropagatorName); 
00062 }
00063 
00064 void StandAloneMuonSmoother::renewTheSmoother(){
00065   if (theService->isTrackingComponentsRecordChanged()){
00066     if (theSmoother) delete theSmoother;
00067     theSmoother = new KFTrajectorySmoother(propagator(),
00068                                            updator(),
00069                                            estimator());
00070   }
00071   if (!theSmoother)
00072     theSmoother = new KFTrajectorySmoother(propagator(),
00073                                            updator(),
00074                                            estimator());
00075   
00076 }
00077 
00078 StandAloneMuonSmoother::SmoothingResult StandAloneMuonSmoother::smooth(const Trajectory& inputTrajectory){
00079   const string metname = "Muon|RecoMuon|StandAloneMuonSmoother";
00080   
00081   renewTheSmoother();
00082   
00083   vector<Trajectory> trajectoriesSM = smoother()->trajectories(inputTrajectory);
00084   
00085   if(!trajectoriesSM.size()){
00086     LogTrace(metname) << "No Track smoothed!";
00087     return SmoothingResult(false,inputTrajectory); 
00088   }
00089   
00090   Trajectory smoothed = trajectoriesSM.front(); 
00091   
00092   return SmoothingResult(true,smoothed); 
00093 }