Belle II Software  release-08-01-10
StandaloneCosmicsCollector Class Reference

Track finding algorithm class for linear tracks produced by cosmics in the VXD without magnetic field. More...

#include <StandaloneCosmicsCollector.h>

Collaboration diagram for StandaloneCosmicsCollector:

Public Member Functions

 StandaloneCosmicsCollector ()=default
 Constructor.
 
 ~StandaloneCosmicsCollector ()=default
 Destructor.
 
void setSortingMode (unsigned short index)
 Set sorting mode used in addSpacePoints. More...
 
void addSpacePoints (std::vector< StoreArray< SpacePoint >> SPs)
 Function to initialize the track finder anew for an event with its set of SpacePoints provided via their StoreArray. More...
 
bool doFit (double qualityCut, int maxRejected, int minSPs)
 Function to perform the actual line fit based on the StoreArray of SpacePoints provided. More...
 
std::pair< std::vector< double >, std::vector< double > > getResult ()
 Getter for the position and momentum seed resulting from the linear fit. More...
 
std::vector< const SpacePoint * > getSPTC ()
 Getter for the sorted list of SpacePoints used for the final fit which met the given requirements. More...
 
double getReducedChi2 ()
 Getter for the final reduced chi squared value obtained for the set of SpacePoints used for the last performed fit. More...
 

Private Member Functions

void addSpacePoint (const SpacePoint *SP)
 Adding single SpacePoint to the sorted member vector m_spacePoints, beginning with the SpacePoint with the smallest radius sqrt(x^2 + y^2). More...
 
bool doLineFit (int minSPs)
 Function performing the actual line fit via a principal component analysis methode yielding a direction vector based on the eigen vector corresponding to the largest eigenvalue and a seed position calculated as the mean of all given SpacePoints. More...
 
bool compareRads (const SpacePoint *a, const SpacePoint *b)
 Compare function used by addSpacePoint to sort the member vector of SpacePoints m_spacePoints by the radius calculated with x^2 + y^2. More...
 
void resortHits ()
 Function to resort the member vector of SpacePoints m_spacePoints based on the members m_start and m_direction obtained by the fit, so that the track candidate starts form the outermost hit and the following hits are sorted following the direction m_direction. More...
 
bool comparePars (const SpacePoint *a, const SpacePoint *b)
 Comparison function to compare two SpacePoints based on the distance between the start point of the fitted line m_start and their intersect with the fitted line. More...
 

Private Attributes

std::vector< const SpacePoint * > m_spacePoints
 Member vector of SpacePoints holding the SpacePoints considered for the track candidate.
 
unsigned short m_sortingMode = 1
 Storing identifier for sorting algorithm to be used for the function addSpacePoint. More...
 
double m_reducedChi2 = 10
 Member variable containing the reduced chi squared value of the current line fit. More...
 
std::pair< double, int > m_largestChi2 = std::pair<double, int>(0., 0)
 Pair containing the index of the vector m_spacePoints for the SpacePoint with the largest contribution to the chi2 value of the last fit and the respectiv contribution first: contribution to the total chi2 value of the last fit second: index of the SpacePoint with this largest contribution in the vector m_spacePoints.
 
std::vector< double > m_start {0., 0., 0.}
 Start point obtained by the last performed line fit.
 
std::vector< double > m_direction {0., 0., 0.}
 Direction of the line obtained by the last performed line fit.
 

Detailed Description

Track finding algorithm class for linear tracks produced by cosmics in the VXD without magnetic field.

The algorithm uses a simple principal component analysis approach to find a momentum and position seed assuming the presence of only the one track produced by the cosmic in the detector. SpacePoints produced by detector noise can be discarded by the TF by removing the biggest outlier until an adequate reduced chi squared value is reached. The track finder requires a minimal number of SpacePoints for a track, a reduced chi squared value below a given threshold, and the number of rejected SpacePoints to be below a given maximum.

Definition at line 33 of file StandaloneCosmicsCollector.h.

Member Function Documentation

◆ addSpacePoint()

void addSpacePoint ( const SpacePoint SP)
inlineprivate

Adding single SpacePoint to the sorted member vector m_spacePoints, beginning with the SpacePoint with the smallest radius sqrt(x^2 + y^2).

Parameters
SP

Definition at line 158 of file StandaloneCosmicsCollector.h.

159  {
160  auto forwardIt = std::lower_bound(m_spacePoints.begin(), m_spacePoints.end(), SP,
161  [this](const SpacePoint * lhs, const SpacePoint * rhs)
162  -> bool { return this->compareRads(lhs, rhs); });
163  m_spacePoints.insert(forwardIt, SP);
164  }
std::vector< const SpacePoint * > m_spacePoints
Member vector of SpacePoints holding the SpacePoints considered for the track candidate.

◆ addSpacePoints()

void addSpacePoints ( std::vector< StoreArray< SpacePoint >>  SPs)
inline

Function to initialize the track finder anew for an event with its set of SpacePoints provided via their StoreArray.

This also resets all internal variables for the new event.

Parameters
SPsStoreArray of SpacePoints of the event to be analyzed.

Definition at line 66 of file StandaloneCosmicsCollector.h.

◆ comparePars()

bool comparePars ( const SpacePoint a,
const SpacePoint b 
)
inlineprivate

Comparison function to compare two SpacePoints based on the distance between the start point of the fitted line m_start and their intersect with the fitted line.

Parameters
aleft hand side SpacePoint
bright hand side SpacePoint
Returns
boolean true if a is closer to the start of the fitted line than b

Definition at line 318 of file StandaloneCosmicsCollector.h.

◆ compareRads()

bool compareRads ( const SpacePoint a,
const SpacePoint b 
)
inlineprivate

Compare function used by addSpacePoint to sort the member vector of SpacePoints m_spacePoints by the radius calculated with x^2 + y^2.

The square root is omitted, as it does not matter for the comparison.

Parameters
aleft hand side SpacePoint
bright hand side SpacePoint
Returns
true if radius of a smaller than radius of b

Definition at line 270 of file StandaloneCosmicsCollector.h.

◆ doFit()

bool doFit ( double  qualityCut,
int  maxRejected,
int  minSPs 
)
inline

Function to perform the actual line fit based on the StoreArray of SpacePoints provided.

The fit performs a principal component analysis based on the provided 3D-points, refitting the SpacePoints again with the worst Point removed, if the given qualityCut on the reduced chi squared value is not reached. This is done until the requirement is met, or a maximal number of rejected SpacePoints (maxRejected) is reached. Furthermore the fitting is aborted, if not a minimal number of SpacePoints (minSPs) is provided. The function returns true, if a track candidate fulfilling these requirements is found.

Parameters
qualityCut
maxRejected
minSPs
Returns
boolean true, if a sufficient track candidate is found, else false.

Definition at line 92 of file StandaloneCosmicsCollector.h.

◆ doLineFit()

bool doLineFit ( int  minSPs)
inlineprivate

Function performing the actual line fit via a principal component analysis methode yielding a direction vector based on the eigen vector corresponding to the largest eigenvalue and a seed position calculated as the mean of all given SpacePoints.

The function sets the member m_reducedChi2 which is calculated based on the distance of all given points to the fitted line. The final value is divided by the number of SPs in the track candidate, yielding a reduced chi2. If the provided SpacePoints are less than a given minimal length the fit will be aborted returning false. If enough SpacePoints are provided, the function returns true independent from the value of the calculated reduced chi2.

Parameters
minSPs
Returns
boolean

Definition at line 179 of file StandaloneCosmicsCollector.h.

◆ getReducedChi2()

double getReducedChi2 ( )
inline

Getter for the final reduced chi squared value obtained for the set of SpacePoints used for the last performed fit.

Returns
double chi square value for the last fit performed for the event.

Definition at line 145 of file StandaloneCosmicsCollector.h.

◆ getResult()

std::pair<std::vector<double>, std::vector<double> > getResult ( )
inline

Getter for the position and momentum seed resulting from the linear fit.

The momentum is rather only a vector giving the direction of the straight fit with a sufficiently large magnitude. The position seed is set to be the outermost SpacePoint with the direction seed pointing towards the next inner hit. If the fit does not meet the given requirements, the result of the last try for this event is returned. If the event does not have the required minimal number of SpacePoints, vectors with zeros are returned.

Returns
pair of vectors of double. First is position seed, second the direction/momentum seed.

Definition at line 122 of file StandaloneCosmicsCollector.h.

◆ getSPTC()

std::vector<const SpacePoint*> getSPTC ( )
inline

Getter for the sorted list of SpacePoints used for the final fit which met the given requirements.

The SpacePoints are sorted, starting at the position seed and towards the direction obtained by the final fit. If the fit did not meet the requirements, the last set which was used for the current event is returned.

Returns
vector of sorted SpacePoints used for the final fit.

Definition at line 134 of file StandaloneCosmicsCollector.h.

◆ resortHits()

void resortHits ( )
inlineprivate

Function to resort the member vector of SpacePoints m_spacePoints based on the members m_start and m_direction obtained by the fit, so that the track candidate starts form the outermost hit and the following hits are sorted following the direction m_direction.

This sorting is done using the comparison function comparePars.

Definition at line 297 of file StandaloneCosmicsCollector.h.

◆ setSortingMode()

void setSortingMode ( unsigned short  index)
inline

Set sorting mode used in addSpacePoints.

One can choose to sort 1: by radius 2: by x-coordinate 3: by y-coordinate by calling this function with the respective index. If the function is not used, the default set at the declaration of m_sortingMode is used.

Definition at line 51 of file StandaloneCosmicsCollector.h.

Member Data Documentation

◆ m_reducedChi2

double m_reducedChi2 = 10
private

Member variable containing the reduced chi squared value of the current line fit.

The value is obtained by dividing the actual chi2 value by the number of SPs in the track candidate. Is reset to 10 in addSpacePoints.

Definition at line 350 of file StandaloneCosmicsCollector.h.

◆ m_sortingMode

unsigned short m_sortingMode = 1
private

Storing identifier for sorting algorithm to be used for the function addSpacePoint.

1: by radius (default) 2: by x-value 3: by y-value

Definition at line 344 of file StandaloneCosmicsCollector.h.


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