CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/MuonAnalysis/MuonAssociators/interface/MatcherUsingTracksAlgorithm.h

Go to the documentation of this file.
00001 #ifndef MuonAnalysis_MuonAssociators_MatcherUsingTracksAlgorithm_h
00002 #define MuonAnalysis_MuonAssociators_MatcherUsingTracksAlgorithm_h
00003 //
00004 // $Id: MatcherUsingTracksAlgorithm.h,v 1.8 2011/01/28 16:57:17 gpetrucc Exp $
00005 //
00006 
00016 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00017 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00018 
00019 #include "FWCore/Framework/interface/ESHandle.h"
00020 #include "FWCore/Framework/interface/EventSetup.h"
00021 #include "FWCore/Utilities/interface/InputTag.h"
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 
00024 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00025 #include "MagneticField/Engine/interface/MagneticField.h"
00026 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00027 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00028 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateClosestToPoint.h"
00029 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
00030 
00031 class MatcherUsingTracksAlgorithm {
00032     public:
00033         explicit MatcherUsingTracksAlgorithm(const edm::ParameterSet & iConfig);
00034         virtual ~MatcherUsingTracksAlgorithm() { }
00035 
00037         void init(const edm::EventSetup &iSetup) ;
00038 
00041         bool match(const reco::Candidate &c1, const reco::Candidate &c2, float &deltaR, float &deltaEta, float &deltaPhi, float &deltaLocalPos, float &deltaPtRel, float &chi2) const ;
00042 
00046         int match(const reco::Candidate &tk, const edm::View<reco::Candidate> &c2s, float &deltaR, float &deltaEta, float &deltaPhi, float &deltaLocalPos, float &deltaPtRel, float &chi2) const ;
00047 
00049         bool hasMetrics() const { return algo_ != ByTrackRef; }
00050 
00052         bool hasChi2() const { return useChi2_; }
00053 
00059         static double getChi2(const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)   ;
00060 
00065         static double getChi2(const FreeTrajectoryState &start, const TrajectoryStateClosestToPoint &other, bool diagonalOnly, bool useVertex) ;
00066 
00071         static double getChi2(const TrajectoryStateOnSurface &start, const TrajectoryStateOnSurface &other, bool diagonalOnly, bool usePosition) ;
00072 
00074         static void cropAndInvert(AlgebraicSymMatrix55 &cov, bool diagonalOnly, bool top3by3only) ;
00075     private:
00076         enum AlgoType   { ByTrackRef, ByDirectComparison, 
00077                           ByPropagatingSrc, ByPropagatingMatched,
00078                           ByPropagatingSrcTSCP, ByPropagatingMatchedTSCP }; // propagate closest to point
00079         enum WhichTrack { None, TrackerTk, MuonTk, GlobalTk };
00080         enum WhichState { AtVertex, Innermost, Outermost };
00081 
00082         AlgoType      algo_;
00083         WhichTrack    whichTrack1_, whichTrack2_;
00084         WhichState    whichState1_, whichState2_;
00085 
00086         // Preselection cuts on both sides
00087         StringCutObjectSelector<reco::Candidate,true> srcCut_, matchedCut_;
00088 
00089         // Matching cuts
00090         float maxLocalPosDiff_;
00091         float maxGlobalMomDeltaR_;
00092         float maxGlobalMomDeltaEta_;
00093         float maxGlobalMomDeltaPhi_;
00094         float maxGlobalDPtRel_;
00095         float maxChi2_;
00096         bool  requireSameCharge_;
00097         bool  useChi2_, chi2UseVertex_, chi2DiagonalOnly_, chi2FirstMomentum_;
00098         enum  SortBy { LocalPosDiff, GlobalMomDeltaR, GlobalMomDeltaEta, GlobalMomDeltaPhi, GlobalDPtRel, Chi2};
00099         SortBy sortBy_;
00100 
00101 
00102         //- Tools
00103         edm::ESHandle<MagneticField>          magfield_;
00104         edm::ESHandle<Propagator>             propagator_;
00105         edm::ESHandle<GlobalTrackingGeometry> geometry_;
00106 
00108         reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const ;
00109 
00111         FreeTrajectoryState    startingState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const ;
00112 
00114         TrajectoryStateOnSurface targetState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const ;
00115 
00118         bool matchWithPropagation(const FreeTrajectoryState &start, const FreeTrajectoryState &target, 
00119                 float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const ;
00120 
00123         bool matchWithPropagation(const FreeTrajectoryState &start, const TrajectoryStateOnSurface &target, 
00124                 float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const ;
00125 
00127         bool matchByDirectComparison(const FreeTrajectoryState &start, const FreeTrajectoryState &other, 
00128                 float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const ;
00129 
00131         void getConf(const edm::ParameterSet & iConfig, const std::string &whatFor, WhichTrack &whichTrack, WhichState &whichState) ;
00132    
00133 };
00134 
00135 
00136 #endif