CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
55  MatchingResult(const SimTrack& simTrack) : simTrack(&simTrack) {
56  pdgId = simTrack.type();
57  genPt = simTrack.momentum().pt();
58  genEta = simTrack.momentum().eta();
59  genPhi = simTrack.momentum().phi();
60  }
61 
62  MatchingResult(const TrackingParticle& trackingParticle) : trackingParticle(&trackingParticle) {
63  pdgId = trackingParticle.pdgId();
64  genPt = trackingParticle.pt();
65  genEta = trackingParticle.momentum().eta();
66  genPhi = trackingParticle.momentum().phi();
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;
90 };
91 
92 /*
93  * matches simMuons or tracking particles
94  */
96 public:
101 
102  ~CandidateSimMuonMatcher() override;
103 
104  void beginRun(edm::EventSetup const& eventSetup) override;
105 
106  void observeProcesorEmulation(unsigned int iProcessor,
107  l1t::tftype mtfType,
108  const std::shared_ptr<OMTFinput>&,
109  const AlgoMuons& algoCandidates,
110  const AlgoMuons& gbCandidates,
111  const std::vector<l1t::RegionalMuonCand>& candMuons) override;
112 
113  void observeEventBegin(const edm::Event& event) override;
114 
115  void observeEventEnd(const edm::Event& event,
116  std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) override;
117 
118  void endJob() override;
119 
120  //simplified ghost busting
121  //only candidates in the bx=0 are included
122  //ghost busts at the same time the mtfCands and the gbCandidates
123  //gbCandidates - all gbCandidates from all processors, should be one-to-one as the mtfCands,
124  //and the ghostBustedProcMuons are one-to-onr to the returned RegionalMuonCands
125  static std::vector<const l1t::RegionalMuonCand*> ghostBust(const l1t::RegionalMuonCandBxCollection* mtfCands,
126  const AlgoMuons& gbCandidates,
127  AlgoMuons& ghostBustedProcMuons);
128 
130 
131  FreeTrajectoryState simTrackToFts(const TrackingParticle& trackingParticle);
132 
134 
135  TrajectoryStateOnSurface propagate(const SimTrack& simTrack, const edm::SimVertexContainer* simVertices);
136 
137  TrajectoryStateOnSurface propagate(const TrackingParticle& trackingParticle);
138 
139  //tsof should be the result of track propagation
141  const AlgoMuonPtr& procMuon,
142  const SimTrack& simTrack,
144 
146  const AlgoMuonPtr& procMuon,
147  const TrackingParticle& trackingParticle,
149 
150  std::vector<MatchingResult> cleanMatching(std::vector<MatchingResult> matchingResults,
151  std::vector<const l1t::RegionalMuonCand*>& muonCands,
152  AlgoMuons& ghostBustedProcMuons);
153 
154  std::vector<MatchingResult> match(std::vector<const l1t::RegionalMuonCand*>& muonCands,
155  AlgoMuons& ghostBustedProcMuons,
156  const edm::SimTrackContainer* simTracks,
157  const edm::SimVertexContainer* simVertices,
158  std::function<bool(const SimTrack&)> const& simTrackFilter);
159 
160  std::vector<MatchingResult> match(std::vector<const l1t::RegionalMuonCand*>& muonCands,
161  AlgoMuons& ghostBustedProcMuons,
163  std::function<bool(const TrackingParticle&)> const& simTrackFilter);
164 
165  std::vector<MatchingResult> getMatchingResults() { return matchingResults; }
166 
167 private:
169 
171 
173  std::vector<MatchingResult> matchingResults;
174 
177 
180 
181  TH1D* deltaPhiPropCandMean = nullptr;
182  TH1D* deltaPhiPropCandStdDev = nullptr;
183 };
184 
185 #endif /* L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_ */
MatchingResult match(const l1t::RegionalMuonCand *omtfCand, const AlgoMuonPtr &procMuon, const SimTrack &simTrack, TrajectoryStateOnSurface &tsof)
std::vector< MatchingResult > cleanMatching(std::vector< MatchingResult > matchingResults, std::vector< const l1t::RegionalMuonCand * > &muonCands, AlgoMuons &ghostBustedProcMuons)
Vector momentum() const
spatial momentum vector
int pdgId() const
PDG ID.
edm::ESHandle< MagneticField > magField
const l1t::RegionalMuonCand * muonCand
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
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 TrackingParticle * trackingParticle
const edm::ESGetToken< Propagator, TrackingComponentsRecord > & propagatorEsToken
const edm::ParameterSet & edmCfg
MatchingResult(const SimTrack &simTrack)
string function
Definition: callgraph.py:50
FreeTrajectoryState simTrackToFts(const SimTrack &simTrack, const SimVertex &simVertex)
void observeEventBegin(const edm::Event &event) override
std::vector< MatchingResult > getMatchingResults()
TrajectoryStateOnSurface atStation2(FreeTrajectoryState ftsStart, float eta) const
std::vector< SimVertex > SimVertexContainer
edm::ESHandle< Propagator > propagator
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
std::vector< AlgoMuonPtr > AlgoMuons
Definition: AlgoMuon.h:102
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
MatchingResult(const TrackingParticle &trackingParticle)
Monte Carlo truth information used for tracking validation.
std::shared_ptr< AlgoMuon > AlgoMuonPtr
Definition: AlgoMuon.h:101
std::vector< TrackingParticle > TrackingParticleCollection
const SimTrack * simTrack
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > & magneticFieldEsToken
std::vector< MatchingResult > matchingResults
std::vector< SimTrack > SimTrackContainer
void observeEventEnd(const edm::Event &event, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates) override
static std::vector< const l1t::RegionalMuonCand * > ghostBust(const l1t::RegionalMuonCandBxCollection *mtfCands, const AlgoMuons &gbCandidates, AlgoMuons &ghostBustedProcMuons)