Belle II Software development
CurvBinsSpec Class Reference

Strategy to construct discrete curve points from discrete overlap specifications. More...

#include <CurvRep.h>

Public Member Functions

 CurvBinsSpec (double lowerBound, double upperBound, long nBins, int nOverlap, int nWidth)
 Constructs a specification for equally spaced discrete curvature values with discrete overlap specification.
 
DiscreteCurv::Array constructArray () const
 Construct the array of discrete curve positions.
 
DiscreteCurv::Array constructInvLinearArray () const
 Construct the array of discrete curve positions such that the inverse curvatures are distributed equally.
 
DiscreteCurv::Array constructLinearArray () const
 Construct the array of discrete curve positions such that the curvatures are distributed equally.
 
DiscreteCurvWithArcLength2DCache::Array constructCacheArray () const
 Construct the array of discrete curve positions including cache for the two dimensional arc length.
 
long getNPositions () const
 Getter for the number of bounds.
 
double getBinWidth () const
 Getter for the bin width in real curve to investigate the value that results from the discrete overlap specification.
 
double getOverlap () const
 Getter for the overlap in real curve to investigate the value that results from the discrete overlap specification.
 
int getNOverlap () const
 Getter for the overlap in discrete number of positions.
 

Private Attributes

double m_lowerBound
 Lower bound of the binning range.
 
double m_upperBound
 Upper bound of the binning range.
 
long m_nBins
 Number of accessible bins.
 
int m_nOverlap = 1
 Overlap of the leaves in curve counted in number of discrete values.
 
int m_nWidth = 3
 Width of the leaves at the maximal level in curve counted in number of discrete values.
 

Detailed Description

Strategy to construct discrete curve points from discrete overlap specifications.

Definition at line 23 of file CurvRep.h.

Constructor & Destructor Documentation

◆ CurvBinsSpec()

CurvBinsSpec ( double  lowerBound,
double  upperBound,
long  nBins,
int  nOverlap,
int  nWidth 
)

Constructs a specification for equally spaced discrete curvature values with discrete overlap specification.

Parameters
lowerBoundLower bound of the value range
upperBoundUpper bound of the value range
nBinsTotal number of final bins to be constructed
nWidthNumber of discrete values in each bin (counted semi open [start, stop)).
nOverlapNumber of discrete values that overlapping bins have in common (counted semi open [start, stop)).

Definition at line 15 of file CurvRep.cc.

16 : m_lowerBound(lowerBound)
17 , m_upperBound(upperBound)
18 , m_nBins(nBins)
19 , m_nOverlap(nOverlap)
20 , m_nWidth(nWidth)
21{
22 B2ASSERT("Overlap must be smaller than the width.", m_nWidth > m_nOverlap);
23 B2ASSERT("Upper curvature bound must be higher than the lower bound.", m_upperBound > m_lowerBound);
24}
int m_nOverlap
Overlap of the leaves in curve counted in number of discrete values.
Definition: CurvRep.h:84
double m_lowerBound
Lower bound of the binning range.
Definition: CurvRep.h:75
int m_nWidth
Width of the leaves at the maximal level in curve counted in number of discrete values.
Definition: CurvRep.h:87
double m_upperBound
Upper bound of the binning range.
Definition: CurvRep.h:78
long m_nBins
Number of accessible bins.
Definition: CurvRep.h:81

Member Function Documentation

◆ constructArray()

DiscreteCurv::Array constructArray ( ) const
inline

Construct the array of discrete curve positions.

Definition at line 40 of file CurvRep.h.

41 { return constructLinearArray(); }
DiscreteCurv::Array constructLinearArray() const
Construct the array of discrete curve positions such that the curvatures are distributed equally.
Definition: CurvRep.cc:26

◆ constructCacheArray()

DiscreteCurvWithArcLength2DCache::Array constructCacheArray ( ) const

Construct the array of discrete curve positions including cache for the two dimensional arc length.

Definition at line 76 of file CurvRep.cc.

77{
78 std::vector<float> discreteCurvs = constructArray();
79 std::vector<CurvWithArcLength2DCache> result;
80 result.reserve(discreteCurvs.size());
81 for (float curv : discreteCurvs) {
82 result.emplace_back(curv);
83 }
84 return result;
85}
DiscreteCurv::Array constructArray() const
Construct the array of discrete curve positions.
Definition: CurvRep.h:40

◆ constructInvLinearArray()

DiscreteCurv::Array constructInvLinearArray ( ) const

Construct the array of discrete curve positions such that the inverse curvatures are distributed equally.

Definition at line 41 of file CurvRep.cc.

42{
43 const long nPositions = getNPositions();
44
45 long nCurlingCurvs = 3 * nPositions / 10;
46
47 std::vector<float> curlingCurvs = linspace<float>(1 / fabs(m_upperBound),
48 1 / fabs(m_lowerBound),
49 nCurlingCurvs + 1,
50 [](float f) {return 1 / f;});
51
52 std::sort(curlingCurvs.begin(), curlingCurvs.end());
53 float minWidthCurling = curlingCurvs[1] - curlingCurvs[0];
54
55
56 std::vector<float> nonCurlingCurvs = linspace<float>(-fabs(m_lowerBound),
57 fabs(m_lowerBound),
58 nPositions - nCurlingCurvs);
59
60 float widthNonCurling = nonCurlingCurvs[1] - nonCurlingCurvs[0];
61
62 B2INFO("Min Width curling" << minWidthCurling);
63 B2INFO("Width non curling" << widthNonCurling);
64 assert(minWidthCurling > widthNonCurling);
65
66 // ++ skips duplication of the identical curvature at m_lowerBound.
67 nonCurlingCurvs.insert(nonCurlingCurvs.end(), ++(curlingCurvs.begin()), curlingCurvs.end());
68 B2INFO(nonCurlingCurvs.size());
69 B2INFO(nPositions);
70
71 assert(nPositions == static_cast<long>(nonCurlingCurvs.size()));
72 assert(std::is_sorted(nonCurlingCurvs.begin(), nonCurlingCurvs.end()));
73 return nonCurlingCurvs;
74}
long getNPositions() const
Getter for the number of bounds.
Definition: CurvRep.cc:87

◆ constructLinearArray()

DiscreteCurv::Array constructLinearArray ( ) const

Construct the array of discrete curve positions such that the curvatures are distributed equally.

Definition at line 26 of file CurvRep.cc.

27{
28 const long nPositions = getNPositions();
29 if (m_lowerBound == 0) {
30 // Determining the lower bound such that the first bin is symmetric around zero
31 // This prevents some cut of effects if the hit happens to lean to
32 // the negative curvature spaces.
33 const double width = getBinWidth();
34 const double expandedLowerBound = -width / 2;
35 return linspace<float>(expandedLowerBound, m_upperBound, nPositions);
36 } else {
37 return linspace<float>(m_lowerBound, m_upperBound, nPositions);
38 }
39}
double getBinWidth() const
Getter for the bin width in real curve to investigate the value that results from the discrete overla...
Definition: CurvRep.cc:94

◆ getBinWidth()

double getBinWidth ( ) const

Getter for the bin width in real curve to investigate the value that results from the discrete overlap specification.

Definition at line 94 of file CurvRep.cc.

95{
96 const double overlapWidthRatio = static_cast<double>(m_nOverlap) / m_nWidth;
97 if (m_lowerBound == 0) {
98 // Determining the lower bound such that the first bin is symmetric around zero
99 // This prevents some cut of effects if the hit happens to lean to
100 // the negative curvature spaces.
101 const double width = m_upperBound / (m_nBins * (1 - overlapWidthRatio) + overlapWidthRatio - 0.5);
102 return width;
103 } else {
104 const double width = (m_upperBound - m_lowerBound) / (m_nBins * (1 - overlapWidthRatio) + overlapWidthRatio);
105 return width;
106 }
107}

◆ getNOverlap()

int getNOverlap ( ) const
inline

Getter for the overlap in discrete number of positions.

Definition at line 68 of file CurvRep.h.

69 {
70 return m_nOverlap;
71 }

◆ getNPositions()

long getNPositions ( ) const

Getter for the number of bounds.

Definition at line 87 of file CurvRep.cc.

88{
89 assert(m_nWidth > m_nOverlap);
90 const long nPositions = (m_nWidth - m_nOverlap) * m_nBins + m_nOverlap + 1;
91 return nPositions;
92}

◆ getOverlap()

double getOverlap ( ) const

Getter for the overlap in real curve to investigate the value that results from the discrete overlap specification.

Definition at line 109 of file CurvRep.cc.

110{
111 return getBinWidth() * m_nOverlap / m_nWidth;
112}

Member Data Documentation

◆ m_lowerBound

double m_lowerBound
private

Lower bound of the binning range.

Definition at line 75 of file CurvRep.h.

◆ m_nBins

long m_nBins
private

Number of accessible bins.

Definition at line 81 of file CurvRep.h.

◆ m_nOverlap

int m_nOverlap = 1
private

Overlap of the leaves in curve counted in number of discrete values.

Definition at line 84 of file CurvRep.h.

◆ m_nWidth

int m_nWidth = 3
private

Width of the leaves at the maximal level in curve counted in number of discrete values.

Definition at line 87 of file CurvRep.h.

◆ m_upperBound

double m_upperBound
private

Upper bound of the binning range.

Definition at line 78 of file CurvRep.h.


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