Belle II Software development
MCUtil Class Reference

Class bundling all helper functions for the MC information used in the PXD CKF. More...

#include <PXDMCUtil.h>

Public Member Functions

unsigned int getNumberOfCorrectPXDHits (const RecoTrack *mcRecoTrack, const std::vector< const SpacePoint * > &hits) const
 How many of the given space points are also in the MC track? Runs pxdHitIsCorrect on all of them.
 
bool allStatesCorrect (const std::vector< TrackFindingCDC::WithWeight< const CKFToPXDState * > > &states) const
 Are all hits related to the same MC track the seed is related to?
 
bool pxdHitIsCorrect (const RecoTrack *mcRecoTrack, const SpacePoint *spacePoint) const
 Returns true, of the space point is related to the mc track and if it is on the first half.
 
unsigned int getNumberOfCorrectHits (const RecoTrack *mcRecoTrack, const std::vector< const SpacePoint * > &hits) const
 How many of the given space points are also in the MC track? Runs hitIsCorrect on all of them.
 
bool allStatesCorrect (const std::vector< TrackFindingCDC::WithWeight< const CKFToSVDState * > > &states) const
 Are all hits related to the same MC track the seed is related to?
 
bool hitIsCorrect (const RecoTrack *mcRecoTrack, const SpacePoint *spacePoint) const
 Returns true, of the space point is related to the mc track and if it is on the first half.
 

Detailed Description

Class bundling all helper functions for the MC information used in the PXD CKF.

Class bundling all helper functions for the MC information used in the SVD CKF.

Definition at line 23 of file PXDMCUtil.h.

Member Function Documentation

◆ allStatesCorrect() [1/2]

bool allStatesCorrect ( const std::vector< TrackFindingCDC::WithWeight< const CKFToPXDState * > > &  states) const

Are all hits related to the same MC track the seed is related to?

Definition at line 75 of file PXDMCUtil.cc.

76{
77 const RecoTrack* seed = states.front()->getSeed();
78
79 B2ASSERT("Path without a seed?", seed);
80
81 if (states.size() <= 1) {
82 // just the seed? this can not be correct...
83 return false;
84 }
85
86 const std::string& seedTrackStoreArrayName = seed->getArrayName();
87
88 TrackMatchLookUp mcCDCMatchLookUp("MCRecoTracks", seedTrackStoreArrayName);
89 const RecoTrack* mcTrack = mcCDCMatchLookUp.getRelatedMCRecoTrack(*seed);
90
91 if (not mcTrack) {
92 // Track is a fake
93 B2DEBUG(29, "Seed is a fake");
94 return false;
95 }
96
97 std::vector<const SpacePoint*> spacePoints;
98 for (const CKFToPXDState* state : states) {
99 const SpacePoint* spacePoint = state->getHit();
100 if (spacePoint) {
101 spacePoints.push_back(spacePoint);
102 }
103 }
104
105 const unsigned int numberOfCorrectHits = getNumberOfCorrectPXDHits(mcTrack, spacePoints);
106
107 B2DEBUG(29, "Have found " << numberOfCorrectHits << " correct out of " << spacePoints.size() << " hits");
108 return numberOfCorrectHits == spacePoints.size();
109}
Specialized CKF State for extrapolating into the PXD.
Definition: CKFToPXDState.h:27
unsigned int getNumberOfCorrectPXDHits(const RecoTrack *mcRecoTrack, const std::vector< const SpacePoint * > &hits) const
How many of the given space points are also in the MC track? Runs pxdHitIsCorrect on all of them.
Definition: PXDMCUtil.cc:64
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
Class to provide convenient methods to look up matching information between pattern recognition and M...

◆ allStatesCorrect() [2/2]

bool allStatesCorrect ( const std::vector< TrackFindingCDC::WithWeight< const CKFToSVDState * > > &  states) const

Are all hits related to the same MC track the seed is related to?

Definition at line 76 of file SVDMCUtil.cc.

77{
78 const RecoTrack* seed = states.front()->getSeed();
79
80 B2ASSERT("Path without a seed?", seed);
81
82 if (states.size() <= 1) {
83 // just the seed? this can not be correct...
84 return false;
85 }
86
87 const std::string& seedTrackStoreArrayName = seed->getArrayName();
88
89 TrackMatchLookUp mcCDCMatchLookUp("MCRecoTracks", seedTrackStoreArrayName);
90 const RecoTrack* mcTrack = mcCDCMatchLookUp.getRelatedMCRecoTrack(*seed);
91
92 if (not mcTrack) {
93 // Track is a fake
94 B2DEBUG(29, "Seed is a fake");
95 return false;
96 }
97
98 std::vector<const SpacePoint*> spacePoints;
99 for (const CKFToSVDState* state : states) {
100 const SpacePoint* spacePoint = state->getHit();
101 if (spacePoint) {
102 spacePoints.push_back(spacePoint);
103 }
104 }
105
106 const unsigned int numberOfCorrectHits = getNumberOfCorrectHits(mcTrack, spacePoints);
107
108 B2DEBUG(29, "Have found " << numberOfCorrectHits << " correct out of " << spacePoints.size() << " hits");
109 return numberOfCorrectHits == spacePoints.size();
110}
Specialized CKF State for extrapolating into the SVD.
Definition: CKFToSVDState.h:27
unsigned int getNumberOfCorrectHits(const RecoTrack *mcRecoTrack, const std::vector< const SpacePoint * > &hits) const
How many of the given space points are also in the MC track? Runs hitIsCorrect on all of them.
Definition: SVDMCUtil.cc:65

◆ getNumberOfCorrectHits()

unsigned int getNumberOfCorrectHits ( const RecoTrack mcRecoTrack,
const std::vector< const SpacePoint * > &  hits 
) const

How many of the given space points are also in the MC track? Runs hitIsCorrect on all of them.

Definition at line 65 of file SVDMCUtil.cc.

66{
67
68 const auto hitIsCorrectSpecialisation = [this, mcRecoTrack](const SpacePoint * spacePoint) {
69 return hitIsCorrect(mcRecoTrack, spacePoint);
70 };
71
72 const unsigned int numberOfCorrectHits = std::count_if(hits.begin(), hits.end(), hitIsCorrectSpecialisation);
73 return numberOfCorrectHits;
74}
bool hitIsCorrect(const RecoTrack *mcRecoTrack, const SpacePoint *spacePoint) const
Returns true, of the space point is related to the mc track and if it is on the first half.
Definition: SVDMCUtil.cc:20

◆ getNumberOfCorrectPXDHits()

unsigned int getNumberOfCorrectPXDHits ( const RecoTrack mcRecoTrack,
const std::vector< const SpacePoint * > &  hits 
) const

How many of the given space points are also in the MC track? Runs pxdHitIsCorrect on all of them.

Definition at line 64 of file PXDMCUtil.cc.

65{
66
67 const auto hitIsCorrectSpecialisation = [this, mcRecoTrack](const SpacePoint * spacePoint) {
68 return pxdHitIsCorrect(mcRecoTrack, spacePoint);
69 };
70
71 const unsigned int numberOfCorrectHits = std::count_if(hits.begin(), hits.end(), hitIsCorrectSpecialisation);
72 return numberOfCorrectHits;
73}
bool pxdHitIsCorrect(const RecoTrack *mcRecoTrack, const SpacePoint *spacePoint) const
Returns true, of the space point is related to the mc track and if it is on the first half.
Definition: PXDMCUtil.cc:19

◆ hitIsCorrect()

bool hitIsCorrect ( const RecoTrack mcRecoTrack,
const SpacePoint spacePoint 
) const

Returns true, of the space point is related to the mc track and if it is on the first half.

Definition at line 20 of file SVDMCUtil.cc.

21{
22 const auto isSameMCTrack = [&mcRecoTrack](const RecoTrack & clusterRecoTrack) {
23 return &clusterRecoTrack == mcRecoTrack;
24 };
25
26
27 const std::string& mcRecoTrackStoreArrayName = mcRecoTrack->getArrayName();
28
29 for (const SVDCluster& relatedCluster : spacePoint->getRelationsTo<SVDCluster>()) {
30 const auto& relatedMCTracksToCluster = relatedCluster.getRelationsTo<RecoTrack>(mcRecoTrackStoreArrayName);
31 if (not TrackFindingCDC::any(relatedMCTracksToCluster, isSameMCTrack)) {
32 return false;
33 }
34 }
35
36 // Test if these clusters are on the first half of the track
37 // For this, get the reco hit information of the related hit
38 const RecoHitInformation* recoHitInformationOfHit = mcRecoTrack->getRecoHitInformation(spacePoint->getRelatedTo<SVDCluster>());
39 B2ASSERT("Invalid MC information", recoHitInformationOfHit);
40
41 // then we also need the first exit out of this detector
42 const std::vector<RecoHitInformation*> recoHitInformationList = mcRecoTrack->getRecoHitInformations(true);
43 // For this, we get an iterator into the first entry (there must be at least one hit in this detector, so we are safe)
44 const auto& detector = recoHitInformationOfHit->getTrackingDetector();
45
46 const auto& itToFirstEntryInDetector = std::find_if(recoHitInformationList.begin(), recoHitInformationList.end(),
47 [detector](RecoHitInformation * hitInformation) {
48 return hitInformation->getTrackingDetector() == detector;
49 });
50 const auto& itToFirstEntryAfterDetector = std::find_if(itToFirstEntryInDetector, recoHitInformationList.end(),
51 [detector](RecoHitInformation * hitInformation) {
52 return hitInformation->getTrackingDetector() != detector;
53 });
54
55 if (itToFirstEntryAfterDetector == recoHitInformationList.end()) {
56 // This is a really strange case: it should actually not be possible to find such a hit. Better
57 // remove it.
58 return false;
59 }
60
61 const auto* firstHitAfterDetector = *itToFirstEntryAfterDetector;
62 return firstHitAfterDetector->getSortingParameter() >= recoHitInformationOfHit->getSortingParameter();
63}
This class stores additional information to every CDC/SVD/PXD hit stored in a RecoTrack.
RecoHitDetector getTrackingDetector() const
Get the detector this hit comes from.
unsigned int getSortingParameter() const
Get the sorting parameter.
RecoHitInformation * getRecoHitInformation(HitType *hit) const
Return the reco hit information for a generic hit from the storeArray.
Definition: RecoTrack.h:312
std::vector< RecoHitInformation * > getRecoHitInformations(bool getSorted=false) const
Return a list of all RecoHitInformations associated with the RecoTrack.
Definition: RecoTrack.cc:557
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:29

◆ pxdHitIsCorrect()

bool pxdHitIsCorrect ( const RecoTrack mcRecoTrack,
const SpacePoint spacePoint 
) const

Returns true, of the space point is related to the mc track and if it is on the first half.

Definition at line 19 of file PXDMCUtil.cc.

20{
21 const auto isSameMCTrack = [&mcRecoTrack](const RecoTrack & clusterRecoTrack) {
22 return &clusterRecoTrack == mcRecoTrack;
23 };
24
25
26 const std::string& mcRecoTrackStoreArrayName = mcRecoTrack->getArrayName();
27
28 for (const PXDCluster& relatedCluster : spacePoint->getRelationsTo<PXDCluster>()) {
29 const auto& relatedMCTracksToCluster = relatedCluster.getRelationsTo<RecoTrack>(mcRecoTrackStoreArrayName);
30 if (not TrackFindingCDC::any(relatedMCTracksToCluster, isSameMCTrack)) {
31 return false;
32 }
33 }
34
35 // Test if these clusters are on the first half of the track
36 // For this, get the reco hit information of the related hit
37 const RecoHitInformation* recoHitInformationOfHit = mcRecoTrack->getRecoHitInformation(spacePoint->getRelatedTo<PXDCluster>());
38 B2ASSERT("Invalid MC information", recoHitInformationOfHit);
39
40 // then we also need the first exit out of this detector
41 const std::vector<RecoHitInformation*> recoHitInformationList = mcRecoTrack->getRecoHitInformations(true);
42 // For this, we get an iterator into the first entry (there must be at least one hit in this detector, so we are safe)
43 const auto& detector = recoHitInformationOfHit->getTrackingDetector();
44
45 const auto& itToFirstEntryInDetector = std::find_if(recoHitInformationList.begin(), recoHitInformationList.end(),
46 [detector](RecoHitInformation * hitInformation) {
47 return hitInformation->getTrackingDetector() == detector;
48 });
49 const auto& itToFirstEntryAfterDetector = std::find_if(itToFirstEntryInDetector, recoHitInformationList.end(),
50 [detector](RecoHitInformation * hitInformation) {
51 return hitInformation->getTrackingDetector() != detector;
52 });
53
54 if (itToFirstEntryAfterDetector == recoHitInformationList.end()) {
55 // This is a really strange case: it should actually not be possible to find such a hit. Better
56 // remove it.
57 return false;
58 }
59
60 const auto* firstHitAfterDetector = *itToFirstEntryAfterDetector;
61 return firstHitAfterDetector->getSortingParameter() >= recoHitInformationOfHit->getSortingParameter();
62}
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30

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