File indexing completed on 2024-04-06 12:22:47
0001 #ifndef MuonAnalysis_MuonAssociators_MatcherUsingTracksAlgorithm_h
0002 #define MuonAnalysis_MuonAssociators_MatcherUsingTracksAlgorithm_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0015 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0016
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018 #include "FWCore/Framework/interface/EventSetup.h"
0019 #include "FWCore/Framework/interface/ConsumesCollector.h"
0020 #include "FWCore/Utilities/interface/InputTag.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022
0023 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0024 #include "MagneticField/Engine/interface/MagneticField.h"
0025 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0026 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0027 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateClosestToPoint.h"
0028 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0029
0030 class IdealMagneticFieldRecord;
0031 class TrackingComponentsRecord;
0032 class GlobalTrackingGeometryRecord;
0033
0034 class MatcherUsingTracksAlgorithm {
0035 public:
0036 explicit MatcherUsingTracksAlgorithm(const edm::ParameterSet &iConfig, edm::ConsumesCollector);
0037 virtual ~MatcherUsingTracksAlgorithm() {}
0038
0039
0040 void init(const edm::EventSetup &iSetup);
0041
0042
0043
0044 bool match(const reco::Candidate &c1,
0045 const reco::Candidate &c2,
0046 float &deltaR,
0047 float &deltaEta,
0048 float &deltaPhi,
0049 float &deltaLocalPos,
0050 float &deltaPtRel,
0051 float &chi2) const;
0052
0053
0054
0055
0056 int match(const reco::Candidate &tk,
0057 const edm::View<reco::Candidate> &c2s,
0058 float &deltaR,
0059 float &deltaEta,
0060 float &deltaPhi,
0061 float &deltaLocalPos,
0062 float &deltaPtRel,
0063 float &chi2) const;
0064
0065
0066 bool hasMetrics() const { return algo_ != ByTrackRef; }
0067
0068
0069 bool hasChi2() const { return useChi2_; }
0070
0071
0072
0073
0074
0075
0076 static double getChi2(const FreeTrajectoryState &start,
0077 const FreeTrajectoryState &other,
0078 bool diagonalOnly,
0079 bool useVertex,
0080 bool useFirstMomentum);
0081
0082
0083
0084
0085
0086 static double getChi2(const FreeTrajectoryState &start,
0087 const TrajectoryStateClosestToPoint &other,
0088 bool diagonalOnly,
0089 bool useVertex);
0090
0091
0092
0093
0094
0095 static double getChi2(const TrajectoryStateOnSurface &start,
0096 const TrajectoryStateOnSurface &other,
0097 bool diagonalOnly,
0098 bool usePosition);
0099
0100
0101 static void cropAndInvert(AlgebraicSymMatrix55 &cov, bool diagonalOnly, bool top3by3only);
0102
0103 private:
0104 enum AlgoType {
0105 ByTrackRef,
0106 ByDirectComparison,
0107 ByPropagatingSrc,
0108 ByPropagatingMatched,
0109 ByPropagatingSrcTSCP,
0110 ByPropagatingMatchedTSCP
0111 };
0112 enum WhichTrack { None, TrackerTk, MuonTk, GlobalTk };
0113 enum WhichState { AtVertex, Innermost, Outermost };
0114
0115 AlgoType algo_;
0116 WhichTrack whichTrack1_, whichTrack2_;
0117 WhichState whichState1_, whichState2_;
0118
0119
0120 StringCutObjectSelector<reco::Candidate, true> srcCut_, matchedCut_;
0121
0122
0123 float maxLocalPosDiff_;
0124 float maxGlobalMomDeltaR_;
0125 float maxGlobalMomDeltaEta_;
0126 float maxGlobalMomDeltaPhi_;
0127 float maxGlobalDPtRel_;
0128 float maxChi2_;
0129 bool requireSameCharge_;
0130 bool useChi2_, chi2UseVertex_, chi2DiagonalOnly_, chi2FirstMomentum_;
0131 enum SortBy { LocalPosDiff, GlobalMomDeltaR, GlobalMomDeltaEta, GlobalMomDeltaPhi, GlobalDPtRel, Chi2 };
0132 SortBy sortBy_;
0133
0134
0135 edm::ESHandle<MagneticField> magfield_;
0136 edm::ESHandle<Propagator> propagator_;
0137 edm::ESHandle<GlobalTrackingGeometry> geometry_;
0138
0139 edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magfieldToken_;
0140 edm::ESGetToken<Propagator, TrackingComponentsRecord> propagatorToken_;
0141 edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> geometryToken_;
0142
0143
0144 reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const;
0145
0146
0147 FreeTrajectoryState startingState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const;
0148
0149
0150 TrajectoryStateOnSurface targetState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const;
0151
0152
0153
0154 bool matchWithPropagation(const FreeTrajectoryState &start,
0155 const FreeTrajectoryState &target,
0156 float &lastDeltaR,
0157 float &lastDeltaEta,
0158 float &lastDeltaPhi,
0159 float &lastDeltaLocalPos,
0160 float &lastGlobalDPtRel,
0161 float &lastChi2) const;
0162
0163
0164
0165 bool matchWithPropagation(const FreeTrajectoryState &start,
0166 const TrajectoryStateOnSurface &target,
0167 float &lastDeltaR,
0168 float &lastDeltaEta,
0169 float &lastDeltaPhi,
0170 float &lastDeltaLocalPos,
0171 float &lastGlobalDPtRel,
0172 float &lastChi2) const;
0173
0174
0175 bool matchByDirectComparison(const FreeTrajectoryState &start,
0176 const FreeTrajectoryState &other,
0177 float &lastDeltaR,
0178 float &lastDeltaEta,
0179 float &lastDeltaPhi,
0180 float &lastDeltaLocalPos,
0181 float &lastGlobalDPtRel,
0182 float &lastChi2) const;
0183
0184
0185 void getConf(const edm::ParameterSet &iConfig,
0186 const std::string &whatFor,
0187 WhichTrack &whichTrack,
0188 WhichState &whichState);
0189 };
0190
0191 #endif