Belle II Software development
SPTCSelectorXBestPerFamily Class Reference

Algorithm to collect the x best TrackCandidates per family based on a VXD Quality estimator method output. More...

#include <SPTCSelectorXBestPerFamily.h>

Public Member Functions

 SPTCSelectorXBestPerFamily (unsigned short xBest=5, const std::string &estimationMethod=std::string("tripletFit"))
 Constructor for the selection of the x best candidates for each family based on the quality index.
 
 ~SPTCSelectorXBestPerFamily ()=default
 Destructor.
 
void prepareSelector (unsigned short nFamilies)
 Preparation of Best Candidate Selector by resetting the vectors.
 
void testNewSPTC (SpacePointTrackCand &sptc)
 Test new SPTC if it is better than the least best of the current x best SPTCs of its respective family.
 
std::vector< SpacePointTrackCandreturnSelection () const
 Return vector containing the best SPTCs; maximal m_xBest per family.
 
void setMagneticFieldForQE (double bFieldZ)
 Setting magnetic field for the quality estimator.
 

Private Attributes

std::unique_ptr< QualityEstimatorBasem_estimator
 Pointer to the Quality Estimator used to evaluate the SPTCs to find the best.
 
std::vector< std::multiset< SpacePointTrackCand > > m_bestPaths
 Vector containing one vector of the best SPTCs per family.
 
std::vector< short > m_familyToIndex
 Map of family number to respective index for m_bestPaths.
 
unsigned short m_currentIndex = 0
 Counter for current index used for m_familyToIndex.
 
unsigned short m_xBest
 Number of allowed best SPTCs per family.
 

Detailed Description

Algorithm to collect the x best TrackCandidates per family based on a VXD Quality estimator method output.

Definition at line 29 of file SPTCSelectorXBestPerFamily.h.

Constructor & Destructor Documentation

◆ SPTCSelectorXBestPerFamily()

SPTCSelectorXBestPerFamily ( unsigned short  xBest = 5,
const std::string &  estimationMethod = std::string("tripletFit") 
)
inline

Constructor for the selection of the x best candidates for each family based on the quality index.

Parameters
xBestMaximal number of best candidates to be stored per family.
estimationMethodQuality estimator to be used.

Definition at line 38 of file SPTCSelectorXBestPerFamily.h.

38 :
39 m_xBest(xBest)
40 {
41 if (estimationMethod == "tripletFit") {
42 m_estimator = std::make_unique<QualityEstimatorTripletFit>();
43 } else if (estimationMethod == "circleFit") {
44 m_estimator = std::make_unique<QualityEstimatorCircleFit>();
45 } else if (estimationMethod == "helixFit") {
46 m_estimator = std::make_unique<QualityEstimatorRiemannHelixFit>();
47 } else if (estimationMethod == "random") {
48 m_estimator = std::make_unique<QualityEstimatorRandom>();
49 }
50 B2ASSERT("QualityEstimator could not be initialized with method: " << estimationMethod, m_estimator);
51 };
unsigned short m_xBest
Number of allowed best SPTCs per family.
std::unique_ptr< QualityEstimatorBase > m_estimator
Pointer to the Quality Estimator used to evaluate the SPTCs to find the best.

Member Function Documentation

◆ prepareSelector()

void prepareSelector ( unsigned short  nFamilies)
inline

Preparation of Best Candidate Selector by resetting the vectors.

To be executed at the beginning of a new event after the families are defined to reset the respective vectors and set them up under consideration of the number of families in the event.

Parameters
nFamiliesNumber of families in the event.

Definition at line 61 of file SPTCSelectorXBestPerFamily.h.

62 {
63 m_bestPaths.clear();
64 m_familyToIndex.clear();
65 m_bestPaths.reserve(nFamilies);
66 m_familyToIndex.resize(nFamilies, -1);
67
69 }
std::vector< short > m_familyToIndex
Map of family number to respective index for m_bestPaths.
unsigned short m_currentIndex
Counter for current index used for m_familyToIndex.
std::vector< std::multiset< SpacePointTrackCand > > m_bestPaths
Vector containing one vector of the best SPTCs per family.

◆ returnSelection()

std::vector< SpacePointTrackCand > returnSelection ( ) const
inline

Return vector containing the best SPTCs; maximal m_xBest per family.

Returns
One vector containing the best SPTC candidates for the whole event.

Definition at line 103 of file SPTCSelectorXBestPerFamily.h.

104 {
105 std::vector<SpacePointTrackCand> jointBestPaths;
106 jointBestPaths.reserve(std::accumulate(m_bestPaths.begin(), m_bestPaths.end(), 0,
107 [](int a, auto b) { return a + b.size(); }));
108
109 for (auto&& set : m_bestPaths) {
110 jointBestPaths.insert(jointBestPaths.end(), set.begin(), set.end());
111 }
112
113 return jointBestPaths;
114 }

◆ setMagneticFieldForQE()

void setMagneticFieldForQE ( double  bFieldZ)
inline

Setting magnetic field for the quality estimator.

Parameters
bFieldZMagnetic Field value to be used for the Quality Estimation.

Definition at line 119 of file SPTCSelectorXBestPerFamily.h.

120 {
121 m_estimator->setMagneticFieldStrength(bFieldZ);
122 }

◆ testNewSPTC()

void testNewSPTC ( SpacePointTrackCand sptc)
inline

Test new SPTC if it is better than the least best of the current x best SPTCs of its respective family.

If so, the least best is thrown out, and the new is added to the sorted x best SPTC multiset of the family. If the maximal number of best SPTCs is not reached for the family, yet, the SPTC is just added at the right place.

Parameters
sptcSpacePointTrackCandidate to be evaluated for adding.

Definition at line 76 of file SPTCSelectorXBestPerFamily.h.

77 {
78 sptc.setQualityIndicator(m_estimator->estimateQuality(sptc.getSortedHits()));
79 short family = sptc.getFamily();
80
81 if (m_familyToIndex.at(family) == -1) {
82 m_bestPaths.emplace_back(std::multiset<SpacePointTrackCand> { sptc });
85 return;
86 }
87
88 auto& currentSet = m_bestPaths.at(m_familyToIndex[family]);
89
90 if (currentSet.size() == m_xBest) {
91 std::multiset<SpacePointTrackCand>::iterator iter = currentSet.begin();
92 if (sptc.getQualityIndicator() < iter->getQualityIndicator()) {
93 return;
94 }
95 currentSet.erase(iter);
96 }
97 currentSet.emplace_hint(currentSet.cbegin(), sptc);
98 }

Member Data Documentation

◆ m_bestPaths

std::vector<std::multiset<SpacePointTrackCand> > m_bestPaths
private

Vector containing one vector of the best SPTCs per family.

Definition at line 130 of file SPTCSelectorXBestPerFamily.h.

◆ m_currentIndex

unsigned short m_currentIndex = 0
private

Counter for current index used for m_familyToIndex.

The counter is increased each time a family is seen for the first time and thus a new entry for this family is added to m_familyToIndex.

Definition at line 137 of file SPTCSelectorXBestPerFamily.h.

◆ m_estimator

std::unique_ptr<QualityEstimatorBase> m_estimator
private

Pointer to the Quality Estimator used to evaluate the SPTCs to find the best.

Definition at line 127 of file SPTCSelectorXBestPerFamily.h.

◆ m_familyToIndex

std::vector<short> m_familyToIndex
private

Map of family number to respective index for m_bestPaths.

Definition at line 133 of file SPTCSelectorXBestPerFamily.h.

◆ m_xBest

unsigned short m_xBest
private

Number of allowed best SPTCs per family.

Definition at line 140 of file SPTCSelectorXBestPerFamily.h.


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