Belle II Software development
TrackMatchLookUp.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <mdst/dataobjects/MCParticle.h>
11#include <mdst/dataobjects/TrackFitResult.h>
12
13#include <tracking/dataobjects/RecoTrack.h>
14
15namespace Belle2 {
34
35 public:
45 enum class MCToPRMatchInfo { c_undefined, c_matched, c_matchedWrongCharge, c_merged, c_mergedWrongCharge, c_missing };
46
57 enum class PRToMCMatchInfo { c_undefined, c_matched, c_matchedWrongCharge, c_clone, c_cloneWrongCharge, c_background, c_ghost };
58
59 public:
68 explicit TrackMatchLookUp(const std::string& mcRecoTrackStoreArrayName,
69 const std::string& prRecoTrackStoreArrayName = "");
70
71 private:
77 const RecoTrack* prRecoTrack,
78 const float& efficiency) const;
79
85 const RecoTrack* mcRecoTrack,
86 const float& purity) const;
87
93 const RecoTrack* getMCRecoTrackWithStatus(const RecoTrack& prRecoTrack,
94 const PRToMCMatchInfo matchingStatus = PRToMCMatchInfo::c_matched) const;
95
101 const RecoTrack* getPRRecoTrackWithStatus(const RecoTrack& mcRecoTrack,
102 const MCToPRMatchInfo matchingStatus = MCToPRMatchInfo::c_matched) const;
103
104 public:
111 {
112 return getMCRecoTrackWithStatus(prRecoTrack, PRToMCMatchInfo::c_matched);
113 }
114
121 const RecoTrack* getWrongChargeMatchedMCRecoTrack(const RecoTrack& prRecoTrack) const
122 {
123 return getMCRecoTrackWithStatus(prRecoTrack, PRToMCMatchInfo::c_matchedWrongCharge);
124 }
125
131 const RecoTrack* getAnyChargeMatchedMCRecoTrack(const RecoTrack& prRecoTrack) const
132 {
133 const RecoTrack* anyMatchedRecoTrack = getMCRecoTrackWithStatus(prRecoTrack, PRToMCMatchInfo::c_matched);
134 if (anyMatchedRecoTrack == nullptr) {
135 anyMatchedRecoTrack = getMCRecoTrackWithStatus(prRecoTrack, PRToMCMatchInfo::c_matchedWrongCharge);
136 }
137 return anyMatchedRecoTrack;
138 }
139
146 {
147 return getPRRecoTrackWithStatus(mcRecoTrack, MCToPRMatchInfo::c_matched);
148 }
149
155 const RecoTrack* getWrongChargeMatchedPRRecoTrack(const RecoTrack& mcRecoTrack) const
156 {
157 return getPRRecoTrackWithStatus(mcRecoTrack, MCToPRMatchInfo::c_matchedWrongCharge);
158 }
159
165 const RecoTrack* getAnyChargeMatchedPRRecoTrack(const RecoTrack& mcRecoTrack) const
166 {
167 const RecoTrack* anyMatchedRecoTrack = getPRRecoTrackWithStatus(mcRecoTrack, MCToPRMatchInfo::c_matched);
168 if (anyMatchedRecoTrack == nullptr) {
169 anyMatchedRecoTrack = getPRRecoTrackWithStatus(mcRecoTrack, MCToPRMatchInfo::c_matchedWrongCharge);
170 }
171 return anyMatchedRecoTrack;
172 }
173
174 public:
183 float getMatchedPurity(const RecoTrack& recoTrack) const;
184
193 float getMatchedEfficiency(const RecoTrack& recoTrack) const;
194
195
202 bool isChargeMatched(const RecoTrack& recoTrack) const;
203
204 public:
209 {
210 float efficiency = NAN;
211 const RecoTrack* prRecoTrack = getRelatedPRRecoTrack(mcRecoTrack, efficiency);
212 return extractMCToPRMatchInfo(mcRecoTrack, prRecoTrack, efficiency);
213 }
214
219 bool isCorrectChargeMatchedPRRecoTrack(const RecoTrack& prRecoTrack) const
220 {
221 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_matched;
222 }
223
228 bool isWrongChargeMatchedPRRecoTrack(const RecoTrack& prRecoTrack) const
229 {
230 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_matchedWrongCharge;
231 }
232
237 bool isAnyChargeMatchedPRRecoTrack(const RecoTrack& prRecoTrack) const
238 {
239 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_matched or
240 getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_matchedWrongCharge;
241 }
242
246 bool isCorrectChargeClonePRRecoTrack(const RecoTrack& prRecoTrack) const
247 {
248 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_clone;
249 }
250
255 bool isWrongChargeClonePRRecoTrack(const RecoTrack& prRecoTrack) const
256 {
257 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_cloneWrongCharge;
258 }
259
264 bool isAnyChargeClonePRRecoTrack(const RecoTrack& prRecoTrack) const
265 {
266 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_clone or
267 getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_cloneWrongCharge;
268 }
269
273 bool isBackgroundPRRecoTrack(const RecoTrack& prRecoTrack) const
274 {
275 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_background;
276 }
277
282 bool isGhostPRRecoTrack(const RecoTrack& prRecoTrack) const
283 {
284 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_ghost;
285 }
286
287 public:
292 {
293 float purity = NAN;
294 const RecoTrack* mcRecoTrack = getRelatedMCRecoTrack(prRecoTrack, purity);
295 return extractPRToMCMatchInfo(prRecoTrack, mcRecoTrack, purity);
296 }
297
302 bool isCorrectChargeMatchedMCRecoTrack(const RecoTrack& mcRecoTrack) const
303 {
304 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_matched;
305 }
306
311 bool isWrongChargeMatchedMCRecoTrack(const RecoTrack& mcRecoTrack) const
312 {
313 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_matchedWrongCharge;
314 }
315
320 bool isAnyChargeMatchedMCRecoTrack(const RecoTrack& mcRecoTrack) const
321 {
322 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_matched or
323 getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_matchedWrongCharge;
324 }
325
329 bool isCorrectChargeMergedMCRecoTrack(const RecoTrack& mcRecoTrack) const
330 {
331 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_merged;
332 }
333
338 bool isWrongChargeMergedMCRecoTrack(const RecoTrack& mcRecoTrack) const
339 {
340 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_mergedWrongCharge;
341 }
342
346 bool isAnyChargeMergedMCRecoTrack(const RecoTrack& mcRecoTrack) const
347 {
348 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_merged or
349 getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_mergedWrongCharge;
350 }
351
355 bool isMissingMCRecoTrack(const RecoTrack& mcRecoTrack) const
356 {
357 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_missing;
358 }
359
360 public:
371 const MCParticle* getRelatedMCParticle(const RecoTrack& recoTrack) const;
372
385 const TrackFitResult*
386 getRelatedTrackFitResult(const RecoTrack& prRecoTrack,
387 Const::ChargedStable chargedStable = Const::pion) const;
388
393 const RecoTrack* getRelatedMCRecoTrack(const RecoTrack& prRecoTrack) const;
394
399 const RecoTrack* getRelatedPRRecoTrack(const RecoTrack& mcRecoTrack) const;
400
401 public:
413 float getRelatedPurity(const RecoTrack& prRecoTrack) const;
414
426 float getRelatedEfficiency(const RecoTrack& mcRecoTrack) const;
427
432 const RecoTrack* getRelatedMCRecoTrack(const RecoTrack& prRecoTrack, float& purity) const;
433
438 const RecoTrack* getRelatedPRRecoTrack(const RecoTrack& mcRecoTrack, float& efficiency) const;
439
440 public:
444 bool isMCRecoTrack(const RecoTrack& recoTrack) const;
445
449 bool isPRRecoTrack(const RecoTrack& recoTrack) const;
450
451 public:
455 const std::string& getMCTracksStoreArrayName() const
456 {
458 }
459
463 const std::string& getPRTracksStoreArrayName() const
464 {
466 }
467
468 private:
471
474 };
476}
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
Values of the result of a track fit with a given particle hypothesis.
Class to provide convenient methods to look up matching information between pattern recognition and M...
bool isAnyChargeMatchedMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track was matched to a pattern recognition track independent of the charge...
PRToMCMatchInfo extractPRToMCMatchInfo(const RecoTrack &prRecoTrack, const RecoTrack *mcRecoTrack, const float &purity) const
Helper function to assume the correct matching category for the pattern recognition tracks from the i...
const RecoTrack * getCorrectChargeMatchedMCRecoTrack(const RecoTrack &prRecoTrack) const
Looks up the matched Monte Carlo track for the given pattern recognition track.
bool isCorrectChargeClonePRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track is a clone of an other pattern recognition track.
bool isMissingMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track has no corresponding pattern recognition track.
float getMatchedPurity(const RecoTrack &recoTrack) const
Get the hit purity of the matched track.
const TrackFitResult * getRelatedTrackFitResult(const RecoTrack &prRecoTrack, Const::ChargedStable chargedStable=Const::pion) const
Looks up the TrackFitResult of a pattern recognition track.
const RecoTrack * getRelatedMCRecoTrack(const RecoTrack &prRecoTrack) const
Looks for a related Monte Carlo track for the given pattern recognition track and return it if found.
const RecoTrack * getWrongChargeMatchedMCRecoTrack(const RecoTrack &prRecoTrack) const
Looks up the matched Monte Carlo track for the given pattern recognition track with the wrong charge.
bool isWrongChargeMatchedPRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track was matched to a Monte Carlo track but with the wrong charge...
const RecoTrack * getAnyChargeMatchedMCRecoTrack(const RecoTrack &prRecoTrack) const
Check whether any matched MC RecoTracks for the given prRecoTrack, independent of whether both patter...
MCToPRMatchInfo
Matching categories for the Monte Carlo tracks.
float getRelatedPurity(const RecoTrack &prRecoTrack) const
Getter for the absolute value of the purity that is stored in the purity relation from pattern recogn...
bool isCorrectChargeMatchedMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track was matched to a pattern recognition track based on the hit pattern ...
bool isWrongChargeMergedMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track has been merged into another pattern recognition track and with the ...
const MCParticle * getRelatedMCParticle(const RecoTrack &recoTrack) const
Looks for a relation of the given track to a Monte Carlo particle.
bool isPRRecoTrack(const RecoTrack &recoTrack) const
Checks if the given track is in the pattern recognition StoreArray.
std::string m_prTracksStoreArrayName
Name of the StoreArray of Pattern recognition tracks.
bool isAnyChargeClonePRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track is a clone of an other pattern recognition track,...
const std::string & getMCTracksStoreArrayName() const
Getter for the name of the StoreArray of the Monte Carlo tracks.
bool isCorrectChargeMergedMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track has been merged into another pattern recognition track.
bool isCorrectChargeMatchedPRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track was matched to a Monte Carlo track with both hit pattern and...
PRToMCMatchInfo getPRToMCMatchInfo(const RecoTrack &prRecoTrack) const
Gets the matching category of pattern recognition track.
MCToPRMatchInfo getMCToPRMatchInfo(const RecoTrack &mcRecoTrack) const
Gets the matching category of Monte Carlo track.
bool isWrongChargeMatchedMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track was matched to a pattern recognition track based on the hit pattern,...
bool isChargeMatched(const RecoTrack &recoTrack) const
Checks if the recoTrack charge is correctly assigned.
const RecoTrack * getWrongChargeMatchedPRRecoTrack(const RecoTrack &mcRecoTrack) const
Looks up the matched pattern recognition track for the given Monte Carlo track.
bool isAnyChargeMergedMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track has been merged into another pattern recognition track.
const std::string & getPRTracksStoreArrayName() const
Getter for the name of the StoreArray of the pattern recognition tracks.
bool isWrongChargeClonePRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track is a clone of an other pattern recognition track,...
bool isBackgroundPRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track is mostly made from background hits.
bool isMCRecoTrack(const RecoTrack &recoTrack) const
Checks if the given track is in the Monte Carlo track StoreArray.
const RecoTrack * getAnyChargeMatchedPRRecoTrack(const RecoTrack &mcRecoTrack) const
Check whether any matched PR RecoTracks for the given mcRecoTrack, independent of whether both patter...
const RecoTrack * getMCRecoTrackWithStatus(const RecoTrack &prRecoTrack, const PRToMCMatchInfo matchingStatus=PRToMCMatchInfo::c_matched) const
Looks up the matched Monte Carlo track with the PRToMCMatchInfo matchingStatus for the given pattern ...
const RecoTrack * getPRRecoTrackWithStatus(const RecoTrack &mcRecoTrack, const MCToPRMatchInfo matchingStatus=MCToPRMatchInfo::c_matched) const
Looks up the matched pattern recognition track with the MCToPRMatchInfo matchingStatus for the given ...
std::string m_mcTracksStoreArrayName
Name of the StoreArray of Monte Carlo tracks.
const RecoTrack * getRelatedPRRecoTrack(const RecoTrack &mcRecoTrack) const
Looks for a related pattern recognition track for the given Monte Carlo track and return it if found.
const RecoTrack * getCorrectChargeMatchedPRRecoTrack(const RecoTrack &mcRecoTrack) const
Looks up the matched pattern recognition track for the given Monte Carlo track.
bool isAnyChargeMatchedPRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track was matched to a Monte Carlo track, independent of whether t...
float getMatchedEfficiency(const RecoTrack &recoTrack) const
Get the hit efficiency of the matched track.
float getRelatedEfficiency(const RecoTrack &mcRecoTrack) const
Getter for the absolute value of the efficiency that is stored in the efficiency relation from Monte ...
bool isGhostPRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track has contributions of different Monte Carlo tracks and/or bac...
MCToPRMatchInfo extractMCToPRMatchInfo(const RecoTrack &mcRecoTrack, const RecoTrack *prRecoTrack, const float &efficiency) const
Helper function to assume the correct matching category for the Monte Carlo tracks from the informati...
PRToMCMatchInfo
Matching categories for the pattern recognition tracks.
Abstract base class for different kinds of events.