Belle II Software development
CurvRep.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/hough/perigee/CurvRep.h>
9#include <tracking/trackFindingCDC/numerics/LookupTable.h>
10#include <framework/logging/Logger.h>
11
12using namespace Belle2;
13using namespace TrackFindingCDC;
14
15CurvBinsSpec::CurvBinsSpec(double lowerBound, double upperBound, long nBins, int nOverlap, int nWidth)
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}
25
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}
40
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}
75
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}
86
88{
89 assert(m_nWidth > m_nOverlap);
90 const long nPositions = (m_nWidth - m_nOverlap) * m_nBins + m_nOverlap + 1;
91 return nPositions;
92}
93
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}
108
110{
111 return getBinWidth() * m_nOverlap / m_nWidth;
112}
long getNPositions() const
Getter for the number of bounds.
Definition: CurvRep.cc:87
DiscreteCurv::Array constructArray() const
Constuct the array of discrete curv positions.
Definition: CurvRep.h:40
int m_nOverlap
Overlap of the leaves in curv counted in number of discrete values.
Definition: CurvRep.h:84
double m_lowerBound
Lower bound of the binning range.
Definition: CurvRep.h:75
DiscreteCurv::Array constructInvLinearArray() const
Constuct the array of discrete curv positions such that the inverse curvatures are distributed equall...
Definition: CurvRep.cc:41
int m_nWidth
Width of the leaves at the maximal level in curv counted in number of discrete values.
Definition: CurvRep.h:87
DiscreteCurv::Array constructLinearArray() const
Constuct the array of discrete curv positions such that the curvatures are distributed equally.
Definition: CurvRep.cc:26
CurvBinsSpec(double lowerBound, double upperBound, long nBins, int nOverlap, int nWidth)
Constructs a specification for equally spaced discrete curvature values with discrete overlap specifi...
Definition: CurvRep.cc:15
DiscreteCurvWithArcLength2DCache::Array constructCacheArray() const
Constuct the array of discrete curv positions including cache for the two dimensional arc length.
Definition: CurvRep.cc:76
double getBinWidth() const
Getter for the bin width in real curv to investigate the value that results from the discrete overlap...
Definition: CurvRep.cc:94
double m_upperBound
Upper bound of the binning range.
Definition: CurvRep.h:78
long m_nBins
Number of accessable bins.
Definition: CurvRep.h:81
double getOverlap() const
Getter for the overlap in real curv to investigate the value that results from the discrete overlap s...
Definition: CurvRep.cc:109
std::vector< T > Array
The type of the array which contains the underlying values.
Definition: DiscreteValue.h:55
Abstract base class for different kinds of events.