CMS 3D CMS Logo

CandidateSimMuonMatcher.h
Go to the documentation of this file.
1 /*
2  * MuonCandidateMatcher.h
3  *
4  * Created on: Dec 14, 2020
5  * Author: kbunkow
6  */
7 
8 #ifndef L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_
9 #define L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_
10 
13 
15 // FRAMEWORK HEADERS
21 
24 
26 // DATA FORMATS HEADERS
32 
36 
38 // DETECTOR GEOMETRY HEADERS
41 
43 // PHYSICS TOOLS
46 
47 #include "TH1D.h"
48 
50 public:
51  enum class ResultType : short { propagationFailed = -1, notMatched = 0, matched = 1, duplicate = 2 };
52 
54 
56  pdgId = simTrack.type();
57  genPt = simTrack.momentum().pt();
58  genEta = simTrack.momentum().eta();
59  genPhi = simTrack.momentum().phi();
60  }
61 
67  }
68 
70  //bool propagationFailed = false;
71  double deltaPhi = 0;
72  double deltaEta = 0;
73 
74  double propagatedPhi = 0;
75  double propagatedEta = 0;
76 
77  double matchingLikelihood = 0;
78 
79  const l1t::RegionalMuonCand* muonCand = nullptr;
80  AlgoMuonPtr procMuon; //Processor gbCandidate
81 
82  //to avoid using simTrack or trackingParticle
83  double pdgId = 0;
84  double genPt = 0;
85  double genEta = 0;
86  double genPhi = 0;
87 
88  const SimTrack* simTrack = nullptr;
89  const SimVertex* simVertex = nullptr;
90 
92 };
93 
94 /*
95  * matches simMuons or tracking particles
96  */
98 public:
103 
104  ~CandidateSimMuonMatcher() override;
105 
106  void beginRun(edm::EventSetup const& eventSetup) override;
107 
108  void observeProcesorEmulation(unsigned int iProcessor,
109  l1t::tftype mtfType,
110  const std::shared_ptr<OMTFinput>&,
111  const AlgoMuons& algoCandidates,
112  const AlgoMuons& gbCandidates,
113  const std::vector<l1t::RegionalMuonCand>& candMuons) override;
114 
115  void observeEventBegin(const edm::Event& event) override;
116 
117  void observeEventEnd(const edm::Event& event,
118  std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) override;
119 
120  void endJob() override;
121 
122  //simplified ghost busting
123  //only candidates in the bx=0 are included
124  //ghost busts at the same time the mtfCands and the gbCandidates
125  //gbCandidates - all gbCandidates from all processors, should be one-to-one as the mtfCands,
126  //and the ghostBustedProcMuons are one-to-onr to the returned RegionalMuonCands
127  std::vector<const l1t::RegionalMuonCand*> ghostBust(const l1t::RegionalMuonCandBxCollection* mtfCands,
128  const AlgoMuons& gbCandidates,
129  AlgoMuons& ghostBustedProcMuons);
130 
132 
133  FreeTrajectoryState simTrackToFts(const TrackingParticle& trackingParticle);
134 
136 
138 
139  TrajectoryStateOnSurface propagate(const TrackingParticle& trackingParticle);
140 
141  //tsof should be the result of track propagation
143  const AlgoMuonPtr& procMuon,
144  const SimTrack& simTrack,
146 
148  const AlgoMuonPtr& procMuon,
149  const TrackingParticle& trackingParticle,
151 
152  std::vector<MatchingResult> cleanMatching(std::vector<MatchingResult> matchingResults,
153  std::vector<const l1t::RegionalMuonCand*>& muonCands,
154  AlgoMuons& ghostBustedProcMuons);
155 
156  std::vector<MatchingResult> match(std::vector<const l1t::RegionalMuonCand*>& muonCands,
157  AlgoMuons& ghostBustedProcMuons,
160  std::function<bool(const SimTrack&)> const& simTrackFilter);
161 
162  std::vector<MatchingResult> match(std::vector<const l1t::RegionalMuonCand*>& muonCands,
163  AlgoMuons& ghostBustedProcMuons,
165  std::function<bool(const TrackingParticle&)> const& simTrackFilter);
166 
167  //matching without any propagation, just checking basic geometrical agreement between simMuon and candidates
168  //problem with propagation is the it does not work for low pt muons (pt < ~3GeV)
169  //which is not good for dumping the data for the NN training. So for that purpose it is better to use the matchSimple
170  std::vector<MatchingResult> matchSimple(std::vector<const l1t::RegionalMuonCand*>& muonCands,
171  AlgoMuons& ghostBustedProcMuons,
174  std::function<bool(const SimTrack&)> const& simTrackFilter);
175 
176  std::vector<MatchingResult> getMatchingResults() { return matchingResults; }
177 
178 private:
180 
182 
184  std::vector<MatchingResult> matchingResults;
185 
188 
191 
192  TH1D* deltaPhiPropCandMean = nullptr;
193  TH1D* deltaPhiPropCandStdDev = nullptr;
194 
195  bool usePropagation = false;
196 };
197 
198 #endif /* L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_ */
const SimVertex * simVertex
MatchingResult match(const l1t::RegionalMuonCand *omtfCand, const AlgoMuonPtr &procMuon, const SimTrack &simTrack, TrajectoryStateOnSurface &tsof)
int pdgId() const
PDG ID.
Vector momentum() const
spatial momentum vector
edm::ESHandle< MagneticField > magField
TrajectoryStateOnSurface atStation2(const FreeTrajectoryState &ftsStart) const
const l1t::RegionalMuonCand * muonCand
void beginRun(edm::EventSetup const &eventSetup) override
TrajectoryStateOnSurface propagate(const SimTrack &simTrack, const edm::SimVertexContainer *simVertices)
CandidateSimMuonMatcher(const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig, const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > &magneticFieldEsToken, const edm::ESGetToken< Propagator, TrackingComponentsRecord > &propagatorEsToken)
void observeProcesorEmulation(unsigned int iProcessor, l1t::tftype mtfType, const std::shared_ptr< OMTFinput > &, const AlgoMuons &algoCandidates, const AlgoMuons &gbCandidates, const std::vector< l1t::RegionalMuonCand > &candMuons) override
const OMTFConfiguration * omtfConfig
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
const TrackingParticle * trackingParticle
std::vector< MatchingResult > cleanMatching(std::vector< MatchingResult > matchingResults, std::vector< const l1t::RegionalMuonCand *> &muonCands, AlgoMuons &ghostBustedProcMuons)
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
std::vector< MatchingResult > matchSimple(std::vector< const l1t::RegionalMuonCand *> &muonCands, AlgoMuons &ghostBustedProcMuons, const edm::SimTrackContainer *simTracks, const edm::SimVertexContainer *simVertices, std::function< bool(const SimTrack &)> const &simTrackFilter)
const edm::ESGetToken< Propagator, TrackingComponentsRecord > & propagatorEsToken
const edm::ParameterSet & edmCfg
MatchingResult(const SimTrack &simTrack)
FreeTrajectoryState simTrackToFts(const SimTrack &simTrack, const SimVertex &simVertex)
void observeEventBegin(const edm::Event &event) override
std::vector< MatchingResult > getMatchingResults()
std::vector< SimVertex > SimVertexContainer
edm::ESHandle< Propagator > propagator
std::vector< AlgoMuonPtr > AlgoMuons
Definition: AlgoMuon.h:176
MatchingResult(const TrackingParticle &trackingParticle)
Monte Carlo truth information used for tracking validation.
std::shared_ptr< AlgoMuon > AlgoMuonPtr
Definition: AlgoMuon.h:175
std::vector< TrackingParticle > TrackingParticleCollection
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
const SimTrack * simTrack
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > & magneticFieldEsToken
std::vector< MatchingResult > matchingResults
std::vector< SimTrack > SimTrackContainer
Definition: event.py:1
void observeEventEnd(const edm::Event &event, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates) override
std::vector< const l1t::RegionalMuonCand * > ghostBust(const l1t::RegionalMuonCandBxCollection *mtfCands, const AlgoMuons &gbCandidates, AlgoMuons &ghostBustedProcMuons)