File indexing completed on 2024-05-15 04:21:50
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_
0009 #define L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_
0010
0011 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h"
0012 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h"
0013
0014
0015
0016 #include "FWCore/Framework/interface/ESHandle.h"
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "FWCore/Utilities/interface/InputTag.h"
0019 #include "FWCore/Utilities/interface/ESGetToken.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021
0022 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0023 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0024
0025
0026
0027 #include "DataFormats/Common/interface/Handle.h"
0028 #include "DataFormats/Common/interface/Ref.h"
0029 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
0030 #include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
0031 #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
0032
0033 #include "SimDataFormats/Track/interface/SimTrack.h"
0034 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0035 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0036
0037
0038
0039 #include "MagneticField/Engine/interface/MagneticField.h"
0040 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0041
0042
0043
0044 #include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
0045 #include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixStateInfo.h"
0046
0047 #include "TH1D.h"
0048
0049 class MatchingResult {
0050 public:
0051 enum class ResultType : short { propagationFailed = -1, notMatched = 0, matched = 1, duplicate = 2 };
0052
0053 MatchingResult() {}
0054
0055 MatchingResult(const SimTrack& simTrack) : simTrack(&simTrack) {
0056 pdgId = simTrack.type();
0057 genPt = simTrack.momentum().pt();
0058 genEta = simTrack.momentum().eta();
0059 genPhi = simTrack.momentum().phi();
0060 }
0061
0062 MatchingResult(const TrackingParticle& trackingParticle) : trackingParticle(&trackingParticle) {
0063 pdgId = trackingParticle.pdgId();
0064 genPt = trackingParticle.pt();
0065 genEta = trackingParticle.momentum().eta();
0066 genPhi = trackingParticle.momentum().phi();
0067 }
0068
0069 ResultType result = ResultType::notMatched;
0070
0071 double deltaPhi = 0;
0072 double deltaEta = 0;
0073
0074 double propagatedPhi = 0;
0075 double propagatedEta = 0;
0076
0077 double matchingLikelihood = 0;
0078
0079 const l1t::RegionalMuonCand* muonCand = nullptr;
0080 AlgoMuonPtr procMuon;
0081
0082
0083 double pdgId = 0;
0084 double genPt = 0;
0085 double genEta = 0;
0086 double genPhi = 0;
0087
0088 const SimTrack* simTrack = nullptr;
0089 const SimVertex* simVertex = nullptr;
0090
0091 const TrackingParticle* trackingParticle = nullptr;
0092 };
0093
0094
0095
0096
0097 class CandidateSimMuonMatcher : public IOMTFEmulationObserver {
0098 public:
0099 CandidateSimMuonMatcher(const edm::ParameterSet& edmCfg,
0100 const OMTFConfiguration* omtfConfig,
0101 const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord>& magneticFieldEsToken,
0102 const edm::ESGetToken<Propagator, TrackingComponentsRecord>& propagatorEsToken);
0103
0104 ~CandidateSimMuonMatcher() override;
0105
0106 void beginRun(edm::EventSetup const& eventSetup) override;
0107
0108 void observeProcesorEmulation(unsigned int iProcessor,
0109 l1t::tftype mtfType,
0110 const std::shared_ptr<OMTFinput>&,
0111 const AlgoMuons& algoCandidates,
0112 const AlgoMuons& gbCandidates,
0113 const std::vector<l1t::RegionalMuonCand>& candMuons) override;
0114
0115 void observeEventBegin(const edm::Event& event) override;
0116
0117 void observeEventEnd(const edm::Event& event,
0118 std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) override;
0119
0120 void endJob() override;
0121
0122
0123
0124
0125
0126
0127 std::vector<const l1t::RegionalMuonCand*> ghostBust(const l1t::RegionalMuonCandBxCollection* mtfCands,
0128 const AlgoMuons& gbCandidates,
0129 AlgoMuons& ghostBustedProcMuons);
0130
0131 FreeTrajectoryState simTrackToFts(const SimTrack& simTrack, const SimVertex& simVertex);
0132
0133 FreeTrajectoryState simTrackToFts(const TrackingParticle& trackingParticle);
0134
0135 TrajectoryStateOnSurface atStation2(const FreeTrajectoryState& ftsStart) const;
0136
0137 TrajectoryStateOnSurface propagate(const SimTrack& simTrack, const edm::SimVertexContainer* simVertices);
0138
0139 TrajectoryStateOnSurface propagate(const TrackingParticle& trackingParticle);
0140
0141
0142 MatchingResult match(const l1t::RegionalMuonCand* omtfCand,
0143 const AlgoMuonPtr& procMuon,
0144 const SimTrack& simTrack,
0145 TrajectoryStateOnSurface& tsof);
0146
0147 MatchingResult match(const l1t::RegionalMuonCand* omtfCand,
0148 const AlgoMuonPtr& procMuon,
0149 const TrackingParticle& trackingParticle,
0150 TrajectoryStateOnSurface& tsof);
0151
0152 std::vector<MatchingResult> cleanMatching(std::vector<MatchingResult> matchingResults,
0153 std::vector<const l1t::RegionalMuonCand*>& muonCands,
0154 AlgoMuons& ghostBustedProcMuons);
0155
0156 std::vector<MatchingResult> match(std::vector<const l1t::RegionalMuonCand*>& muonCands,
0157 AlgoMuons& ghostBustedProcMuons,
0158 const edm::SimTrackContainer* simTracks,
0159 const edm::SimVertexContainer* simVertices,
0160 std::function<bool(const SimTrack&)> const& simTrackFilter);
0161
0162 std::vector<MatchingResult> match(std::vector<const l1t::RegionalMuonCand*>& muonCands,
0163 AlgoMuons& ghostBustedProcMuons,
0164 const TrackingParticleCollection* trackingParticles,
0165 std::function<bool(const TrackingParticle&)> const& simTrackFilter);
0166
0167
0168
0169
0170 std::vector<MatchingResult> matchSimple(std::vector<const l1t::RegionalMuonCand*>& muonCands,
0171 AlgoMuons& ghostBustedProcMuons,
0172 const edm::SimTrackContainer* simTracks,
0173 const edm::SimVertexContainer* simVertices,
0174 std::function<bool(const SimTrack&)> const& simTrackFilter);
0175
0176 std::vector<MatchingResult> getMatchingResults() { return matchingResults; }
0177
0178 private:
0179 const OMTFConfiguration* omtfConfig;
0180
0181 const edm::ParameterSet& edmCfg;
0182
0183 AlgoMuons gbCandidates;
0184 std::vector<MatchingResult> matchingResults;
0185
0186 const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord>& magneticFieldEsToken;
0187 const edm::ESGetToken<Propagator, TrackingComponentsRecord>& propagatorEsToken;
0188
0189 edm::ESHandle<MagneticField> magField;
0190 edm::ESHandle<Propagator> propagator;
0191
0192 TH1D* deltaPhiPropCandMean = nullptr;
0193 TH1D* deltaPhiPropCandStdDev = nullptr;
0194
0195 bool usePropagation = false;
0196 };
0197
0198 #endif