Belle II Software development
TrackMatchLookUp Class Reference

Class to provide convenient methods to look up matching information between pattern recognition and Monte Carlo tracks. More...

#include <TrackMatchLookUp.h>

Public Types

enum class  MCToPRMatchInfo {
  c_undefined ,
  c_matched ,
  c_matchedWrongCharge ,
  c_merged ,
  c_mergedWrongCharge ,
  c_missing
}
 Matching categories for the Monte Carlo tracks. More...
 
enum class  PRToMCMatchInfo {
  c_undefined ,
  c_matched ,
  c_matchedWrongCharge ,
  c_clone ,
  c_cloneWrongCharge ,
  c_background ,
  c_ghost
}
 Matching categories for the pattern recognition tracks. More...
 

Public Member Functions

 TrackMatchLookUp (const std::string &mcRecoTrackStoreArrayName, const std::string &prRecoTrackStoreArrayName="")
 Constructor taking the names of the StoreArrays containing the Monte Carlo tracks and the pattern recognition tracks respectivelly.
 
const RecoTrackgetCorrectChargeMatchedMCRecoTrack (const RecoTrack &prRecoTrack) const
 Looks up the matched Monte Carlo track for the given pattern recognition track.
 
const RecoTrackgetWrongChargeMatchedMCRecoTrack (const RecoTrack &prRecoTrack) const
 Looks up the matched Monte Carlo track for the given pattern recognition track with the wrong charge.
 
const RecoTrackgetAnyChargeMatchedMCRecoTrack (const RecoTrack &prRecoTrack) const
 Check whether any matched MC RecoTracks for the given prRecoTrack, independent of whether both pattern and charge are matched correctly, or only the pattern is correct but the charge is wrong.
 
const RecoTrackgetCorrectChargeMatchedPRRecoTrack (const RecoTrack &mcRecoTrack) const
 Looks up the matched pattern recognition track for the given Monte Carlo track.
 
const RecoTrackgetWrongChargeMatchedPRRecoTrack (const RecoTrack &mcRecoTrack) const
 Looks up the matched pattern recognition track for the given Monte Carlo track.
 
const RecoTrackgetAnyChargeMatchedPRRecoTrack (const RecoTrack &mcRecoTrack) const
 Check whether any matched PR RecoTracks for the given mcRecoTrack, independent of whether both pattern and charge are matched correctly, or only the pattern is correct but the charge is wrong.
 
float getMatchedPurity (const RecoTrack &recoTrack) const
 Get the hit purity of the matched track.
 
float getMatchedEfficiency (const RecoTrack &recoTrack) const
 Get the hit efficiency of the matched track.
 
bool isChargeMatched (const RecoTrack &recoTrack) const
 Checks if the recoTrack charge is correctly assigned.
 
MCToPRMatchInfo getMCToPRMatchInfo (const RecoTrack &mcRecoTrack) const
 Gets the matching category of Monte Carlo 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 charge being matched.
 
bool isWrongChargeMatchedPRRecoTrack (const RecoTrack &prRecoTrack) const
 Checks, if the pattern recognition track was matched to a Monte Carlo track but with the wrong charge.
 
bool isAnyChargeMatchedPRRecoTrack (const RecoTrack &prRecoTrack) const
 Checks, if the pattern recognition track was matched to a Monte Carlo track, independent of whether the charge is matched.
 
bool isCorrectChargeClonePRRecoTrack (const RecoTrack &prRecoTrack) const
 Checks, if the pattern recognition track is a clone of an other pattern recognition track.
 
bool isWrongChargeClonePRRecoTrack (const RecoTrack &prRecoTrack) const
 Checks, if the pattern recognition track is a clone of an other pattern recognition track, but with the wrong charge.
 
bool isAnyChargeClonePRRecoTrack (const RecoTrack &prRecoTrack) const
 Checks, if the pattern recognition track is a clone of an other pattern recognition track, independent of whether the charge is correct.
 
bool isBackgroundPRRecoTrack (const RecoTrack &prRecoTrack) const
 Checks, if the pattern recognition track is mostly made from background hits.
 
bool isGhostPRRecoTrack (const RecoTrack &prRecoTrack) const
 Checks, if the pattern recognition track has contributions of different Monte Carlo tracks and/or background hits, such that a match is not possible.
 
PRToMCMatchInfo getPRToMCMatchInfo (const RecoTrack &prRecoTrack) const
 Gets the matching category of pattern recognition track.
 
bool isCorrectChargeMatchedMCRecoTrack (const RecoTrack &mcRecoTrack) const
 Checks, if the Monte Carlo Track was matched to a pattern recognition track based on the hit pattern and the correct charge.
 
bool isWrongChargeMatchedMCRecoTrack (const RecoTrack &mcRecoTrack) const
 Checks, if the Monte Carlo Track was matched to a pattern recognition track based on the hit pattern, but was assigned the wrong charge.
 
bool isAnyChargeMatchedMCRecoTrack (const RecoTrack &mcRecoTrack) const
 Checks, if the Monte Carlo Track was matched to a pattern recognition track independent of the charge.
 
bool isCorrectChargeMergedMCRecoTrack (const RecoTrack &mcRecoTrack) const
 Checks, if the Monte Carlo Track has been merged into another pattern recognition track.
 
bool isWrongChargeMergedMCRecoTrack (const RecoTrack &mcRecoTrack) const
 Checks, if the Monte Carlo Track has been merged into another pattern recognition track and with the wrong charge.
 
bool isAnyChargeMergedMCRecoTrack (const RecoTrack &mcRecoTrack) const
 Checks, if the Monte Carlo Track has been merged into another pattern recognition track.
 
bool isMissingMCRecoTrack (const RecoTrack &mcRecoTrack) const
 Checks, if the Monte Carlo Track has no corresponding pattern recognition track.
 
const MCParticlegetRelatedMCParticle (const RecoTrack &recoTrack) const
 Looks for a relation of the given track to a Monte Carlo particle.
 
const TrackFitResultgetRelatedTrackFitResult (const RecoTrack &prRecoTrack, Const::ChargedStable chargedStable=Const::pion) const
 Looks up the TrackFitResult of a pattern recognition track.
 
const RecoTrackgetRelatedMCRecoTrack (const RecoTrack &prRecoTrack) const
 Looks for a related Monte Carlo track for the given pattern recognition track and return it if found.
 
const RecoTrackgetRelatedPRRecoTrack (const RecoTrack &mcRecoTrack) const
 Looks for a related pattern recognition track for the given Monte Carlo track and return it if found.
 
float getRelatedPurity (const RecoTrack &prRecoTrack) const
 Getter for the absolute value of the purity that is stored in the purity relation from pattern recognition tracks to Monte Carlo tracks.
 
float getRelatedEfficiency (const RecoTrack &mcRecoTrack) const
 Getter for the absolute value of the efficiency that is stored in the efficiency relation from Monte Carlo tracks to pattern recognition tracks.
 
const RecoTrackgetRelatedMCRecoTrack (const RecoTrack &prRecoTrack, float &purity) const
 Helper function looking for a related Monte Carlo track to the given pattern recognition track in the purity relation.
 
const RecoTrackgetRelatedPRRecoTrack (const RecoTrack &mcRecoTrack, float &efficiency) const
 Helper function looking for a related Monte Carlo track to the given pattern recognition track in the efficiency relation.
 
bool isMCRecoTrack (const RecoTrack &recoTrack) const
 Checks if the given track is in the Monte Carlo track StoreArray.
 
bool isPRRecoTrack (const RecoTrack &recoTrack) const
 Checks if the given track is in the pattern recognition StoreArray.
 
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.
 

Private Member Functions

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 information efficiency relation.
 
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 information purity relation.
 
const RecoTrackgetMCRecoTrackWithStatus (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 recognition track.
 
const RecoTrackgetPRRecoTrackWithStatus (const RecoTrack &mcRecoTrack, const MCToPRMatchInfo matchingStatus=MCToPRMatchInfo::c_matched) const
 Looks up the matched pattern recognition track with the MCToPRMatchInfo matchingStatus for the given Monte Carlo track.
 

Private Attributes

std::string m_mcTracksStoreArrayName
 Name of the StoreArray of Monte Carlo tracks.
 
std::string m_prTracksStoreArrayName
 Name of the StoreArray of Pattern recognition tracks.
 

Detailed Description

Class to provide convenient methods to look up matching information between pattern recognition and Monte Carlo tracks.

It provides a more user friendly look up interface into the relations that were generated by the MCTrackMatcherModule.

Instead of looking through the relations directly to find the matching information on your own the methods of this class exhibit a conceptual view on them.

This class is also accessible in python steering files.

Definition at line 33 of file TrackMatchLookUp.h.

Member Enumeration Documentation

◆ MCToPRMatchInfo

enum class MCToPRMatchInfo
strong

Matching categories for the Monte Carlo tracks.

c_undefined, //until the matcher module sets it c_matched, // hit pattern and charge are both correct c_matchedWrongCharge, // hit pattern is correct, but the charge is wrong c_merged, //a clone with the correct charge c_mergedWrongCharge, //a clone with the wrong charge c_missing

Definition at line 45 of file TrackMatchLookUp.h.

45{ c_undefined, c_matched, c_matchedWrongCharge, c_merged, c_mergedWrongCharge, c_missing };

◆ PRToMCMatchInfo

enum class PRToMCMatchInfo
strong

Matching categories for the pattern recognition tracks.

c_undefined, //until the matcher module sets it c_matched, // hit pattern and charge are both correct c_matchedWrongCharge, // hit pattern is correct, but the charge is wrong c_clone, //a clone with the correct charge c_cloneWrongCharge, //a clone with the wrong charge c_background, c_ghost

Definition at line 57 of file TrackMatchLookUp.h.

57{ c_undefined, c_matched, c_matchedWrongCharge, c_clone, c_cloneWrongCharge, c_background, c_ghost };

Constructor & Destructor Documentation

◆ TrackMatchLookUp()

TrackMatchLookUp ( const std::string &  mcRecoTrackStoreArrayName,
const std::string &  prRecoTrackStoreArrayName = "" 
)
explicit

Constructor taking the names of the StoreArrays containing the Monte Carlo tracks and the pattern recognition tracks respectivelly.

Only the name of StoreArray of the Monte Carlo reference tracks has to be given. The name of the StoreArray of the pattern recognition tracks to defaults to the standard name.

Definition at line 17 of file TrackMatchLookUp.cc.

19 : m_mcTracksStoreArrayName(DataStore::arrayName<RecoTrack>(mcRecoTrackStoreArrayName))
20 , m_prTracksStoreArrayName(DataStore::arrayName<RecoTrack>(prRecoTrackStoreArrayName))
21{
23 B2WARNING("Pattern recognition and Monte Carlo track StoreArray are the same.");
24 }
25}
std::string m_prTracksStoreArrayName
Name of the StoreArray of Pattern recognition tracks.
std::string m_mcTracksStoreArrayName
Name of the StoreArray of Monte Carlo tracks.

Member Function Documentation

◆ extractMCToPRMatchInfo()

TrackMatchLookUp::MCToPRMatchInfo extractMCToPRMatchInfo ( const RecoTrack mcRecoTrack,
const RecoTrack prRecoTrack,
const float &  efficiency 
) const
private

Helper function to assume the correct matching category for the Monte Carlo tracks from the information efficiency relation.

Definition at line 68 of file TrackMatchLookUp.cc.

71{
72 if (not prRecoTrack) return MCToPRMatchInfo::c_missing;
73 if (std::isnan(efficiency)) return MCToPRMatchInfo::c_undefined;
74 B2ASSERT("This RecoTrack isn't a MC RecoTrack as it is supposed to be.", isMCRecoTrack(mcRecoTrack));
75 B2ASSERT("This RecoTrack isn't a PR RecoTrack as it is supposed to be.", isPRRecoTrack(*prRecoTrack));
76
77 const RecoTrack* roundTripMCRecoTrack =
79
80 const bool wrongCharge = roundTripMCRecoTrack->getChargeSeed() != mcRecoTrack.getChargeSeed();
81
82 if (roundTripMCRecoTrack == &mcRecoTrack) {
83 if (wrongCharge) return MCToPRMatchInfo::c_matchedWrongCharge;
84 else return MCToPRMatchInfo::c_matched;
85 } else {
86 if (wrongCharge) return MCToPRMatchInfo::c_mergedWrongCharge;
87 else return MCToPRMatchInfo::c_merged;
88 }
89}
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:508
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
bool isPRRecoTrack(const RecoTrack &recoTrack) const
Checks if the given track is in the pattern recognition StoreArray.
bool isMCRecoTrack(const RecoTrack &recoTrack) const
Checks if the given track is in the Monte Carlo track StoreArray.

◆ extractPRToMCMatchInfo()

TrackMatchLookUp::PRToMCMatchInfo extractPRToMCMatchInfo ( const RecoTrack prRecoTrack,
const RecoTrack mcRecoTrack,
const float &  purity 
) const
private

Helper function to assume the correct matching category for the pattern recognition tracks from the information purity relation.

Definition at line 92 of file TrackMatchLookUp.cc.

95{
96 B2ASSERT("This RecoTrack isn't a PR RecoTrack as it is supposed to be.", isPRRecoTrack(prRecoTrack));
97 const RecoTrack::MatchingStatus matchingStatus = prRecoTrack.getMatchingStatus();
98
99 if (matchingStatus == RecoTrack::MatchingStatus::c_ghost) {
100 return PRToMCMatchInfo::c_ghost;
101 } else if (matchingStatus == RecoTrack::MatchingStatus::c_background) {
102 return PRToMCMatchInfo::c_background;
103 } else if (matchingStatus == RecoTrack::MatchingStatus::c_clone) {
104 if (not mcRecoTrack) B2WARNING("Clone with no related Monte Carlo RecoTrack");
105 return PRToMCMatchInfo::c_clone;
106 } else if (matchingStatus == RecoTrack::MatchingStatus::c_cloneWrongCharge) {
107 if (not mcRecoTrack) B2WARNING("Clone with no related Monte Carlo RecoTrack");
108 return PRToMCMatchInfo::c_cloneWrongCharge;
109 } else if (matchingStatus == RecoTrack::MatchingStatus::c_matched) {
110 if (not mcRecoTrack) B2WARNING("Match with no related Monte Carlo RecoTrack");
111 return PRToMCMatchInfo::c_matched;
112 } else if (matchingStatus == RecoTrack::MatchingStatus::c_matchedWrongCharge) {
113 if (not mcRecoTrack) B2WARNING("Match with no related Monte Carlo RecoTrack");
114 return PRToMCMatchInfo::c_matchedWrongCharge;
115 } else if (matchingStatus == RecoTrack::MatchingStatus::c_undefined) {
116 return PRToMCMatchInfo::c_undefined;
117 }
118 return PRToMCMatchInfo::c_undefined;
119}
MatchingStatus
Enum for the matching status of this reco track (set by the matching modules in the tracking package)...
Definition: RecoTrack.h:105
MatchingStatus getMatchingStatus() const
Return the matching status set by the TrackMatcher module.
Definition: RecoTrack.h:829

◆ getAnyChargeMatchedMCRecoTrack()

const RecoTrack * getAnyChargeMatchedMCRecoTrack ( const RecoTrack prRecoTrack) const
inline

Check whether any matched MC RecoTracks for the given prRecoTrack, independent of whether both pattern and charge are matched correctly, or only the pattern is correct but the charge is wrong.

If no match exists at all, a nullptr is returned.

Definition at line 131 of file TrackMatchLookUp.h.

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 }
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 ...

◆ getAnyChargeMatchedPRRecoTrack()

const RecoTrack * getAnyChargeMatchedPRRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Check whether any matched PR RecoTracks for the given mcRecoTrack, independent of whether both pattern and charge are matched correctly, or only the pattern is correct but the charge is wrong.

If no match exists at all, a nullptr is returned.

Definition at line 165 of file TrackMatchLookUp.h.

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 }
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 ...

◆ getCorrectChargeMatchedMCRecoTrack()

const RecoTrack * getCorrectChargeMatchedMCRecoTrack ( const RecoTrack prRecoTrack) const
inline

Looks up the matched Monte Carlo track for the given pattern recognition track.

If there is no match or the pattern recognition track is a clone, or the charge is wrong return nullptr.

Definition at line 110 of file TrackMatchLookUp.h.

111 {
112 return getMCRecoTrackWithStatus(prRecoTrack, PRToMCMatchInfo::c_matched);
113 }

◆ getCorrectChargeMatchedPRRecoTrack()

const RecoTrack * getCorrectChargeMatchedPRRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Looks up the matched pattern recognition track for the given Monte Carlo track.

If there is no match or the Monte Carlo track is a over-merged, or the charge is wrong return nullptr.

Definition at line 145 of file TrackMatchLookUp.h.

146 {
147 return getPRRecoTrackWithStatus(mcRecoTrack, MCToPRMatchInfo::c_matched);
148 }

◆ getMatchedEfficiency()

float getMatchedEfficiency ( const RecoTrack recoTrack) const

Get the hit efficiency of the matched track.

The given track can be both Monte Carlo track or pattern recognition track since the match is one to one relation. The returned efficiency is positive, hence the absolute value of the relation weight. If no exact match is assoziated with the track return NAN.

Definition at line 220 of file TrackMatchLookUp.cc.

221{
222 if (isPRRecoTrack(recoTrack)) {
223 const RecoTrack& prRecoTrack = recoTrack;
224 const RecoTrack* mcRecoTrack = getAnyChargeMatchedMCRecoTrack(prRecoTrack);
225 if (mcRecoTrack) {
226 return getRelatedEfficiency(*mcRecoTrack);
227 } else {
228 return NAN;
229 }
230
231 } else {
232 const RecoTrack& mcRecoTrack = recoTrack;
233 const RecoTrack* prRecoTrack = getAnyChargeMatchedPRRecoTrack(mcRecoTrack);
234 if (prRecoTrack) {
235 return getRelatedEfficiency(mcRecoTrack);
236 } else {
237 return NAN;
238 }
239 }
240}
const RecoTrack * getAnyChargeMatchedMCRecoTrack(const RecoTrack &prRecoTrack) const
Check whether any matched MC RecoTracks for the given prRecoTrack, independent of whether both patter...
const RecoTrack * getAnyChargeMatchedPRRecoTrack(const RecoTrack &mcRecoTrack) const
Check whether any matched PR RecoTracks for the given mcRecoTrack, independent of whether both patter...
float getRelatedEfficiency(const RecoTrack &mcRecoTrack) const
Getter for the absolute value of the efficiency that is stored in the efficiency relation from Monte ...

◆ getMatchedPurity()

float getMatchedPurity ( const RecoTrack recoTrack) const

Get the hit purity of the matched track.

The given track can be both Monte Carlo track or pattern recognition track since the match is one to one relation. The returned purity is positive, hence the absolute value of the relation weight. If no exact match is associated with the track return NAN.

Definition at line 197 of file TrackMatchLookUp.cc.

198{
199
200 if (isMCRecoTrack(recoTrack)) {
201 const RecoTrack& mcRecoTrack = recoTrack;
202 const RecoTrack* prRecoTrack = getAnyChargeMatchedPRRecoTrack(mcRecoTrack);
203 if (prRecoTrack) {
204 return getRelatedPurity(*prRecoTrack);
205 } else {
206 return NAN;
207 }
208
209 } else {
210 const RecoTrack& prRecoTrack = recoTrack;
211 const RecoTrack* mcRecoTrack = getAnyChargeMatchedMCRecoTrack(prRecoTrack);
212 if (mcRecoTrack) {
213 return getRelatedPurity(prRecoTrack);
214 } else {
215 return NAN;
216 }
217 }
218}
float getRelatedPurity(const RecoTrack &prRecoTrack) const
Getter for the absolute value of the purity that is stored in the purity relation from pattern recogn...

◆ getMCRecoTrackWithStatus()

const RecoTrack * getMCRecoTrackWithStatus ( const RecoTrack prRecoTrack,
const PRToMCMatchInfo  matchingStatus = PRToMCMatchInfo::c_matched 
) const
private

Looks up the matched Monte Carlo track with the PRToMCMatchInfo matchingStatus for the given pattern recognition track.

If there is no match or the pattern recognition track is a clone return nullptr.

Definition at line 167 of file TrackMatchLookUp.cc.

169{
170 B2ASSERT("This RecoTrack isn't a PR RecoTrack as it is supposed to be.", isPRRecoTrack(prRecoTrack));
171
172 float purity = NAN;
173 const RecoTrack* mcRecoTrack = getRelatedMCRecoTrack(prRecoTrack, purity);
174
175 if (extractPRToMCMatchInfo(prRecoTrack, mcRecoTrack, purity) == matchingStatus) {
176 return mcRecoTrack;
177 } else {
178 return nullptr;
179 }
180}
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 * getRelatedMCRecoTrack(const RecoTrack &prRecoTrack) const
Looks for a related Monte Carlo track for the given pattern recognition track and return it if found.

◆ getMCToPRMatchInfo()

MCToPRMatchInfo getMCToPRMatchInfo ( const RecoTrack mcRecoTrack) const
inline

Gets the matching category of Monte Carlo track.

Definition at line 208 of file TrackMatchLookUp.h.

209 {
210 float efficiency = NAN;
211 const RecoTrack* prRecoTrack = getRelatedPRRecoTrack(mcRecoTrack, efficiency);
212 return extractMCToPRMatchInfo(mcRecoTrack, prRecoTrack, efficiency);
213 }
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.
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...

◆ getMCTracksStoreArrayName()

const std::string & getMCTracksStoreArrayName ( ) const
inline

Getter for the name of the StoreArray of the Monte Carlo tracks.

Definition at line 455 of file TrackMatchLookUp.h.

456 {
458 }

◆ getPRRecoTrackWithStatus()

const RecoTrack * getPRRecoTrackWithStatus ( const RecoTrack mcRecoTrack,
const MCToPRMatchInfo  matchingStatus = MCToPRMatchInfo::c_matched 
) const
private

Looks up the matched pattern recognition track with the MCToPRMatchInfo matchingStatus for the given Monte Carlo track.

If there is no match or the Monte Carlo track return nullptr.

Definition at line 182 of file TrackMatchLookUp.cc.

184{
185 B2ASSERT("This RecoTrack isn't a MC RecoTrack as it is supposed to be.", isMCRecoTrack(mcRecoTrack));
186
187 float efficiency = NAN;
188 const RecoTrack* prRecoTrack = getRelatedPRRecoTrack(mcRecoTrack, efficiency);
189
190 if (extractMCToPRMatchInfo(mcRecoTrack, prRecoTrack, efficiency) == matchingStatus) {
191 return prRecoTrack;
192 } else {
193 return nullptr;
194 }
195}

◆ getPRToMCMatchInfo()

PRToMCMatchInfo getPRToMCMatchInfo ( const RecoTrack prRecoTrack) const
inline

Gets the matching category of pattern recognition track.

Definition at line 291 of file TrackMatchLookUp.h.

292 {
293 float purity = NAN;
294 const RecoTrack* mcRecoTrack = getRelatedMCRecoTrack(prRecoTrack, purity);
295 return extractPRToMCMatchInfo(prRecoTrack, mcRecoTrack, purity);
296 }

◆ getPRTracksStoreArrayName()

const std::string & getPRTracksStoreArrayName ( ) const
inline

Getter for the name of the StoreArray of the pattern recognition tracks.

Definition at line 463 of file TrackMatchLookUp.h.

464 {
466 }

◆ getRelatedEfficiency()

float getRelatedEfficiency ( const RecoTrack mcRecoTrack) const

Getter for the absolute value of the efficiency that is stored in the efficiency relation from Monte Carlo tracks to pattern recognition tracks.

The efficiency relation on the DataStore encodes some information about the match category in the sign of the efficiency. However user code is always interested in the absolute value of the efficiency but may forget apply an absolute value. Since the matching category can be found by other methods of this class, we only provide the absolute value here.

Definition at line 159 of file TrackMatchLookUp.cc.

160{
161 B2ASSERT("This RecoTrack isn't a MC RecoTrack as it is supposed to be.", isMCRecoTrack(mcRecoTrack));
162 float efficiency = NAN;
163 getRelatedPRRecoTrack(mcRecoTrack, efficiency);
164 return std::fabs(efficiency);
165}

◆ getRelatedMCParticle()

const MCParticle * getRelatedMCParticle ( const RecoTrack recoTrack) const

Looks for a relation of the given track to a Monte Carlo particle.

Returns nullptr if not found.

Works for both pattern recognition and Monte Carlo tracks.

Whether clones have a related MCParticle depends on the settings of the MCTrackMatcher module that filled the relations.

Definition at line 121 of file TrackMatchLookUp.cc.

122{
123 return recoTrack.getRelatedTo<MCParticle>();
124}
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32

◆ getRelatedMCRecoTrack() [1/2]

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.

Return nullptr if not found.

Definition at line 126 of file TrackMatchLookUp.cc.

127{
128 B2ASSERT("This RecoTrack isn't a PR RecoTrack as it is supposed to be.", isPRRecoTrack(prRecoTrack));
129 return prRecoTrack.getRelatedTo<RecoTrack>(getMCTracksStoreArrayName());
130}
const std::string & getMCTracksStoreArrayName() const
Getter for the name of the StoreArray of the Monte Carlo tracks.

◆ getRelatedMCRecoTrack() [2/2]

const RecoTrack * getRelatedMCRecoTrack ( const RecoTrack prRecoTrack,
float &  purity 
) const

Helper function looking for a related Monte Carlo track to the given pattern recognition track in the purity relation.

Also returns to found purity as output parameter.

Definition at line 38 of file TrackMatchLookUp.cc.

39{
40 B2ASSERT("This RecoTrack isn't a PR RecoTrack as it is supposed to be.", isPRRecoTrack(prRecoTrack));
41 std::pair<RecoTrack*, float> mcRecoTrackAndWeight =
43 const RecoTrack* mcRecoTrack = mcRecoTrackAndWeight.first;
44 if (mcRecoTrack) {
45 purity = mcRecoTrackAndWeight.second;
46 } else {
47 purity = NAN;
48 }
49 return mcRecoTrack;
50}
std::pair< TO *, float > getRelatedToWithWeight(const std::string &name="", const std::string &namedRelation="") const
Get first related object & weight of relation pointing to an array.

◆ getRelatedPRRecoTrack() [1/2]

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.

Return nullptr if not found.

Definition at line 145 of file TrackMatchLookUp.cc.

146{
147 B2ASSERT("This RecoTrack isn't a MC RecoTrack as it is supposed to be.", isMCRecoTrack(mcRecoTrack));
148 return mcRecoTrack.getRelatedTo<RecoTrack>(getPRTracksStoreArrayName());
149}
const std::string & getPRTracksStoreArrayName() const
Getter for the name of the StoreArray of the pattern recognition tracks.

◆ getRelatedPRRecoTrack() [2/2]

const RecoTrack * getRelatedPRRecoTrack ( const RecoTrack mcRecoTrack,
float &  efficiency 
) const

Helper function looking for a related Monte Carlo track to the given pattern recognition track in the efficiency relation.

Also returns to found efficiency as output parameter.

Definition at line 53 of file TrackMatchLookUp.cc.

54{
55 B2ASSERT("This RecoTrack isn't a MC RecoTrack as it is supposed to be.", isMCRecoTrack(mcRecoTrack));
56 std::pair<RecoTrack*, float> prRecoTrackAndWeight =
58 const RecoTrack* prRecoTrack = prRecoTrackAndWeight.first;
59 if (prRecoTrack) {
60 efficiency = prRecoTrackAndWeight.second;
61 } else {
62 efficiency = NAN;
63 }
64 return prRecoTrack;
65}

◆ getRelatedPurity()

float getRelatedPurity ( const RecoTrack prRecoTrack) const

Getter for the absolute value of the purity that is stored in the purity relation from pattern recognition tracks to Monte Carlo tracks.

The purity relation on the DataStore encodes some information about the match category in the sign of the purity. However user code is always interested in the absolute value of the purity but may forget apply an absolute value. Since the matching category can be found by other methods of this class, we only provide the absolute value here.

Definition at line 151 of file TrackMatchLookUp.cc.

152{
153 B2ASSERT("This RecoTrack isn't a PR RecoTrack as it is supposed to be.", isPRRecoTrack(prRecoTrack));
154 float purity = NAN;
155 getRelatedMCRecoTrack(prRecoTrack, purity);
156 return std::fabs(purity);
157}

◆ getRelatedTrackFitResult()

const TrackFitResult * getRelatedTrackFitResult ( const RecoTrack prRecoTrack,
Const::ChargedStable  chargedStable = Const::pion 
) const

Looks up the TrackFitResult of a pattern recognition track.

Return nullptr if there is no related track fit result.

The relations are setup to be from the Belle2::Track to the RecoTrack.

Then the TrackFitResults stored within the Belle2::Tracks are retrieved and the one selected particle hypothesises given via chargedStable is returned.

The default is the Pion fit.

Definition at line 132 of file TrackMatchLookUp.cc.

134{
135 B2ASSERT("This RecoTrack isn't a PR RecoTrack as it is supposed to be.", isPRRecoTrack(prRecoTrack));
136 Belle2::Track* b2track = prRecoTrack.getRelatedFrom<Belle2::Track>();
137 if (b2track) {
138 // Query the Belle2::Track for the selected fit hypothesis
139 return b2track->getTrackFitResult(chargedStable);
140 } else {
141 return nullptr;
142 }
143}
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Class that bundles various TrackFitResults.
Definition: Track.h:25
const TrackFitResult * getTrackFitResult(const Const::ChargedStable &chargedStable) const
Default Access to TrackFitResults.
Definition: Track.cc:30

◆ getWrongChargeMatchedMCRecoTrack()

const RecoTrack * getWrongChargeMatchedMCRecoTrack ( const RecoTrack prRecoTrack) const
inline

Looks up the matched Monte Carlo track for the given pattern recognition track with the wrong charge.

If there is no match or the pattern recognition track is a clone, or the charge is correct return nullptr.

Definition at line 121 of file TrackMatchLookUp.h.

122 {
123 return getMCRecoTrackWithStatus(prRecoTrack, PRToMCMatchInfo::c_matchedWrongCharge);
124 }

◆ getWrongChargeMatchedPRRecoTrack()

const RecoTrack * getWrongChargeMatchedPRRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Looks up the matched pattern recognition track for the given Monte Carlo track.

If there is no match or the Monte Carlo track is a over-merged or the charge is correct return nullptr.

Definition at line 155 of file TrackMatchLookUp.h.

156 {
157 return getPRRecoTrackWithStatus(mcRecoTrack, MCToPRMatchInfo::c_matchedWrongCharge);
158 }

◆ isAnyChargeClonePRRecoTrack()

bool isAnyChargeClonePRRecoTrack ( const RecoTrack prRecoTrack) const
inline

Checks, if the pattern recognition track is a clone of an other pattern recognition track, independent of whether the charge is correct.

Definition at line 264 of file TrackMatchLookUp.h.

265 {
266 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_clone or
267 getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_cloneWrongCharge;
268 }
PRToMCMatchInfo getPRToMCMatchInfo(const RecoTrack &prRecoTrack) const
Gets the matching category of pattern recognition track.

◆ isAnyChargeMatchedMCRecoTrack()

bool isAnyChargeMatchedMCRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Checks, if the Monte Carlo Track was matched to a pattern recognition track independent of the charge.

Definition at line 320 of file TrackMatchLookUp.h.

321 {
322 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_matched or
323 getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_matchedWrongCharge;
324 }
MCToPRMatchInfo getMCToPRMatchInfo(const RecoTrack &mcRecoTrack) const
Gets the matching category of Monte Carlo track.

◆ isAnyChargeMatchedPRRecoTrack()

bool isAnyChargeMatchedPRRecoTrack ( const RecoTrack prRecoTrack) const
inline

Checks, if the pattern recognition track was matched to a Monte Carlo track, independent of whether the charge is matched.

Definition at line 237 of file TrackMatchLookUp.h.

238 {
239 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_matched or
240 getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_matchedWrongCharge;
241 }

◆ isAnyChargeMergedMCRecoTrack()

bool isAnyChargeMergedMCRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Checks, if the Monte Carlo Track has been merged into another pattern recognition track.

Definition at line 346 of file TrackMatchLookUp.h.

347 {
348 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_merged or
349 getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_mergedWrongCharge;
350 }

◆ isBackgroundPRRecoTrack()

bool isBackgroundPRRecoTrack ( const RecoTrack prRecoTrack) const
inline

Checks, if the pattern recognition track is mostly made from background hits.

Definition at line 273 of file TrackMatchLookUp.h.

274 {
275 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_background;
276 }

◆ isChargeMatched()

bool isChargeMatched ( const RecoTrack recoTrack) const

Checks if the recoTrack charge is correctly assigned.

Returns NAN if the recoTrack is not matched. The given track can be both Monte Carlo track or pattern recognition track.

Definition at line 243 of file TrackMatchLookUp.cc.

244{
245 const MCParticle* mcParticle = getRelatedMCParticle(recoTrack);
246
247 if (mcParticle)
248 return (mcParticle->getCharge() == recoTrack.getChargeSeed());
249 else
250 return NAN;
251
252}
float getCharge() const
Return the particle charge defined in TDatabasePDG.
Definition: MCParticle.cc:36
const MCParticle * getRelatedMCParticle(const RecoTrack &recoTrack) const
Looks for a relation of the given track to a Monte Carlo particle.

◆ isCorrectChargeClonePRRecoTrack()

bool isCorrectChargeClonePRRecoTrack ( const RecoTrack prRecoTrack) const
inline

Checks, if the pattern recognition track is a clone of an other pattern recognition track.

Definition at line 246 of file TrackMatchLookUp.h.

247 {
248 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_clone;
249 }

◆ isCorrectChargeMatchedMCRecoTrack()

bool isCorrectChargeMatchedMCRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Checks, if the Monte Carlo Track was matched to a pattern recognition track based on the hit pattern and the correct charge.

Definition at line 302 of file TrackMatchLookUp.h.

303 {
304 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_matched;
305 }

◆ isCorrectChargeMatchedPRRecoTrack()

bool isCorrectChargeMatchedPRRecoTrack ( const RecoTrack prRecoTrack) const
inline

Checks, if the pattern recognition track was matched to a Monte Carlo track with both hit pattern and charge being matched.

Definition at line 219 of file TrackMatchLookUp.h.

220 {
221 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_matched;
222 }

◆ isCorrectChargeMergedMCRecoTrack()

bool isCorrectChargeMergedMCRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Checks, if the Monte Carlo Track has been merged into another pattern recognition track.

Definition at line 329 of file TrackMatchLookUp.h.

330 {
331 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_merged;
332 }

◆ isGhostPRRecoTrack()

bool isGhostPRRecoTrack ( const RecoTrack prRecoTrack) const
inline

Checks, if the pattern recognition track has contributions of different Monte Carlo tracks and/or background hits, such that a match is not possible.

Definition at line 282 of file TrackMatchLookUp.h.

283 {
284 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_ghost;
285 }

◆ isMCRecoTrack()

bool isMCRecoTrack ( const RecoTrack recoTrack) const

Checks if the given track is in the Monte Carlo track StoreArray.

Definition at line 27 of file TrackMatchLookUp.cc.

28{
29 return recoTrack.getArrayName() == getMCTracksStoreArrayName();
30}
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.

◆ isMissingMCRecoTrack()

bool isMissingMCRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Checks, if the Monte Carlo Track has no corresponding pattern recognition track.

Definition at line 355 of file TrackMatchLookUp.h.

356 {
357 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_missing;
358 }

◆ isPRRecoTrack()

bool isPRRecoTrack ( const RecoTrack recoTrack) const

Checks if the given track is in the pattern recognition StoreArray.

Definition at line 32 of file TrackMatchLookUp.cc.

33{
34 return recoTrack.getArrayName() == getPRTracksStoreArrayName();
35}

◆ isWrongChargeClonePRRecoTrack()

bool isWrongChargeClonePRRecoTrack ( const RecoTrack prRecoTrack) const
inline

Checks, if the pattern recognition track is a clone of an other pattern recognition track, but with the wrong charge.

Definition at line 255 of file TrackMatchLookUp.h.

256 {
257 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_cloneWrongCharge;
258 }

◆ isWrongChargeMatchedMCRecoTrack()

bool isWrongChargeMatchedMCRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Checks, if the Monte Carlo Track was matched to a pattern recognition track based on the hit pattern, but was assigned the wrong charge.

Definition at line 311 of file TrackMatchLookUp.h.

312 {
313 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_matchedWrongCharge;
314 }

◆ isWrongChargeMatchedPRRecoTrack()

bool isWrongChargeMatchedPRRecoTrack ( const RecoTrack prRecoTrack) const
inline

Checks, if the pattern recognition track was matched to a Monte Carlo track but with the wrong charge.

Definition at line 228 of file TrackMatchLookUp.h.

229 {
230 return getPRToMCMatchInfo(prRecoTrack) == PRToMCMatchInfo::c_matchedWrongCharge;
231 }

◆ isWrongChargeMergedMCRecoTrack()

bool isWrongChargeMergedMCRecoTrack ( const RecoTrack mcRecoTrack) const
inline

Checks, if the Monte Carlo Track has been merged into another pattern recognition track and with the wrong charge.

Definition at line 338 of file TrackMatchLookUp.h.

339 {
340 return getMCToPRMatchInfo(mcRecoTrack) == MCToPRMatchInfo::c_mergedWrongCharge;
341 }

Member Data Documentation

◆ m_mcTracksStoreArrayName

std::string m_mcTracksStoreArrayName
private

Name of the StoreArray of Monte Carlo tracks.

Definition at line 470 of file TrackMatchLookUp.h.

◆ m_prTracksStoreArrayName

std::string m_prTracksStoreArrayName
private

Name of the StoreArray of Pattern recognition tracks.

Definition at line 473 of file TrackMatchLookUp.h.


The documentation for this class was generated from the following files: