Belle II Software  release-06-01-15
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 
15 namespace Belle2 {
34 
35  public:
39  enum class MCToPRMatchInfo { c_Invalid, c_Matched, c_Merged, c_Missing };
40 
44  enum class PRToMCMatchInfo { c_Invalid, c_Matched, c_Clone, c_Background, c_Ghost };
45 
46  public:
55  explicit TrackMatchLookUp(const std::string& mcRecoTrackStoreArrayName,
56  const std::string& prRecoTrackStoreArrayName = "");
57 
58  private:
64  const RecoTrack* prRecoTrack,
65  const float& efficiency) const;
66 
72  const RecoTrack* mcRecoTrack,
73  const float& purity) const;
74 
75  public:
80  const RecoTrack* getMatchedMCRecoTrack(const RecoTrack& prRecoTrack) const;
81 
86  const RecoTrack* getMatchedPRRecoTrack(const RecoTrack& mcRecoTrack) const;
87 
88  public:
97  float getMatchedPurity(const RecoTrack& recoTrack) const;
98 
107  float getMatchedEfficiency(const RecoTrack& recoTrack) const;
108 
109  public:
113  MCToPRMatchInfo getMCToPRMatchInfo(const RecoTrack& mcRecoTrack) const
114  {
115  float efficiency = NAN;
116  const RecoTrack* prRecoTrack = getRelatedPRRecoTrack(mcRecoTrack, efficiency);
117  return extractMCToPRMatchInfo(mcRecoTrack, prRecoTrack, efficiency);
118  }
119 
123  bool isMatchedPRRecoTrack(const RecoTrack& prRecoTrack) const
124  {
125  return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_Matched;
126  }
127 
131  bool isClonePRRecoTrack(const RecoTrack& prRecoTrack) const
132  {
133  return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_Clone;
134  }
135 
139  bool isBackgroundPRRecoTrack(const RecoTrack& prRecoTrack) const
140  {
141  return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_Background;
142  }
143 
148  bool isGhostPRRecoTrack(const RecoTrack& prRecoTrack) const
149  {
150  return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_Ghost;
151  }
152 
153  public:
157  PRToMCMatchInfo getPRToMCMatchInfo(const RecoTrack& prRecoTrack) const
158  {
159  float purity = NAN;
160  const RecoTrack* mcRecoTrack = getRelatedMCRecoTrack(prRecoTrack, purity);
161  return extractPRToMCMatchInfo(prRecoTrack, mcRecoTrack, purity);
162  }
163 
167  bool isMatchedMCRecoTrack(const RecoTrack& mcRecoTrack) const
168  {
169  return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_Matched;
170  }
171 
175  bool isMergedMCRecoTrack(const RecoTrack& mcRecoTrack) const
176  {
177  return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_Merged;
178  }
179 
183  bool isMissingMCRecoTrack(const RecoTrack& mcRecoTrack) const
184  {
185  return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_Missing;
186  }
187 
188  public:
199  const MCParticle* getRelatedMCParticle(const RecoTrack& recoTrack) const;
200 
213  const TrackFitResult*
214  getRelatedTrackFitResult(const RecoTrack& prRecoTrack,
215  Const::ChargedStable chargedStable = Const::pion) const;
216 
221  const RecoTrack* getRelatedMCRecoTrack(const RecoTrack& prRecoTrack) const;
222 
227  const RecoTrack* getRelatedPRRecoTrack(const RecoTrack& mcRecoTrack) const;
228 
229  public:
241  float getRelatedPurity(const RecoTrack& prRecoTrack) const;
242 
254  float getRelatedEfficiency(const RecoTrack& mcRecoTrack) const;
255 
260  const RecoTrack* getRelatedMCRecoTrack(const RecoTrack& prRecoTrack, float& purity) const;
261 
266  const RecoTrack* getRelatedPRRecoTrack(const RecoTrack& mcRecoTrack, float& efficiency) const;
267 
268  public:
272  bool isMCRecoTrack(const RecoTrack& recoTrack) const;
273 
277  bool isPRRecoTrack(const RecoTrack& recoTrack) const;
278 
279  public:
283  const std::string& getMCTracksStoreArrayName() const
284  {
286  }
287 
291  const std::string& getPRTracksStoreArrayName() const
292  {
294  }
295 
296  private:
299 
302  };
304 }
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:470
static const ChargedStable pion
charged pion particle
Definition: Const.h:542
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
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...
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...
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.
MCToPRMatchInfo
Matching categories for the Monte Carlo tracks.
bool isMergedMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track has been merged into another pattern recognition track.
float getRelatedPurity(const RecoTrack &prRecoTrack) const
Getter for the absolute value of the purity that is stored in the purity relation from pattern recogn...
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.
const RecoTrack * getMatchedMCRecoTrack(const RecoTrack &prRecoTrack) const
Looks up the matched Monte Carlo track for the given pattern recognition track.
PRToMCMatchInfo getPRToMCMatchInfo(const RecoTrack &prRecoTrack) const
Gets the matching category of pattern recognition track.
bool isClonePRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track is a clone of an other pattern recognition track.
MCToPRMatchInfo getMCToPRMatchInfo(const RecoTrack &mcRecoTrack) const
Gets the matching category of Monte Carlo track.
const std::string & getMCTracksStoreArrayName() const
Getter for the name of the StoreArray of the Monte Carlo tracks.
const std::string & getPRTracksStoreArrayName() const
Getter for the name of the StoreArray of the pattern recognition tracks.
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 * getMatchedPRRecoTrack(const RecoTrack &mcRecoTrack) const
Looks up the matched pattern recognition track for the given Monte Carlo track.
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.
TrackMatchLookUp(const std::string &mcRecoTrackStoreArrayName, const std::string &prRecoTrackStoreArrayName="")
Constructor taking the names of the StoreArrays containing the Monte Carlo tracks and the pattern rec...
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...
bool isMatchedMCRecoTrack(const RecoTrack &mcRecoTrack) const
Checks, if the Monte Carlo Track was matched to a pattern recognition track.
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.
bool isMatchedPRRecoTrack(const RecoTrack &prRecoTrack) const
Checks, if the pattern recognition track was matched to a Monte Carlo track.
Abstract base class for different kinds of events.