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/trackingUtilities/numerics/LookupTable.h>
10#include <framework/logging/Logger.h>
11
12using namespace Belle2;
13using namespace TrackFindingCDC;
14using namespace TrackingUtilities;
15
16CurvBinsSpec::CurvBinsSpec(double lowerBound, double upperBound, long nBins, int nOverlap, int nWidth)
17 : m_lowerBound(lowerBound)
18 , m_upperBound(upperBound)
19 , m_nBins(nBins)
20 , m_nOverlap(nOverlap)
21 , m_nWidth(nWidth)
22{
23 B2ASSERT("Overlap must be smaller than the width.", m_nWidth > m_nOverlap);
24 B2ASSERT("Upper curvature bound must be higher than the lower bound.", m_upperBound > m_lowerBound);
25}
26
28{
29 const long nPositions = getNPositions();
30 if (m_lowerBound == 0) {
31 // Determining the lower bound such that the first bin is symmetric around zero
32 // This prevents some cut of effects if the hit happens to lean to
33 // the negative curvature spaces.
34 const double width = getBinWidth();
35 const double expandedLowerBound = -width / 2;
36 return linspace<float>(expandedLowerBound, m_upperBound, nPositions);
37 } else {
38 return linspace<float>(m_lowerBound, m_upperBound, nPositions);
39 }
40}
41
43{
44 const long nPositions = getNPositions();
45
46 long nCurlingCurvs = 3 * nPositions / 10;
47
48 std::vector<float> curlingCurvs = linspace<float>(1 / fabs(m_upperBound),
49 1 / fabs(m_lowerBound),
50 nCurlingCurvs + 1,
51 [](float f) {return 1 / f;});
52
53 std::sort(curlingCurvs.begin(), curlingCurvs.end());
54 float minWidthCurling = curlingCurvs[1] - curlingCurvs[0];
55
56
57 std::vector<float> nonCurlingCurvs = linspace<float>(-fabs(m_lowerBound),
58 fabs(m_lowerBound),
59 nPositions - nCurlingCurvs);
60
61 float widthNonCurling = nonCurlingCurvs[1] - nonCurlingCurvs[0];
62
63 B2INFO("Min Width curling" << minWidthCurling);
64 B2INFO("Width non curling" << widthNonCurling);
65 assert(minWidthCurling > widthNonCurling);
66
67 // ++ skips duplication of the identical curvature at m_lowerBound.
68 nonCurlingCurvs.insert(nonCurlingCurvs.end(), ++(curlingCurvs.begin()), curlingCurvs.end());
69 B2INFO(nonCurlingCurvs.size());
70 B2INFO(nPositions);
71
72 assert(nPositions == static_cast<long>(nonCurlingCurvs.size()));
73 assert(std::is_sorted(nonCurlingCurvs.begin(), nonCurlingCurvs.end()));
74 return nonCurlingCurvs;
75}
76
78{
79 std::vector<float> discreteCurvs = constructArray();
80 std::vector<CurvWithArcLength2DCache> result;
81 result.reserve(discreteCurvs.size());
82 for (float curv : discreteCurvs) {
83 result.emplace_back(curv);
84 }
85 return result;
86}
87
89{
90 assert(m_nWidth > m_nOverlap);
91 const long nPositions = (m_nWidth - m_nOverlap) * m_nBins + m_nOverlap + 1;
92 return nPositions;
93}
94
96{
97 const double overlapWidthRatio = static_cast<double>(m_nOverlap) / m_nWidth;
98 if (m_lowerBound == 0) {
99 // Determining the lower bound such that the first bin is symmetric around zero
100 // This prevents some cut of effects if the hit happens to lean to
101 // the negative curvature spaces.
102 const double width = m_upperBound / (m_nBins * (1 - overlapWidthRatio) + overlapWidthRatio - 0.5);
103 return width;
104 } else {
105 const double width = (m_upperBound - m_lowerBound) / (m_nBins * (1 - overlapWidthRatio) + overlapWidthRatio);
106 return width;
107 }
108}
109
111{
112 return getBinWidth() * m_nOverlap / m_nWidth;
113}
long getNPositions() const
Getter for the number of bounds.
Definition CurvRep.cc:88
DiscreteCurv::Array constructArray() const
Construct the array of discrete curve positions.
Definition CurvRep.h:40
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
DiscreteCurv::Array constructInvLinearArray() const
Construct the array of discrete curve positions such that the inverse curvatures are distributed equa...
Definition CurvRep.cc:42
int m_nWidth
Width of the leaves at the maximal level in curve counted in number of discrete values.
Definition CurvRep.h:87
DiscreteCurv::Array constructLinearArray() const
Construct the array of discrete curve positions such that the curvatures are distributed equally.
Definition CurvRep.cc:27
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:16
DiscreteCurvWithArcLength2DCache::Array constructCacheArray() const
Construct the array of discrete curve positions including cache for the two dimensional arc length.
Definition CurvRep.cc:77
double getBinWidth() const
Getter for the bin width in real curve to investigate the value that results from the discrete overla...
Definition CurvRep.cc:95
double m_upperBound
Upper bound of the binning range.
Definition CurvRep.h:78
long m_nBins
Number of accessible bins.
Definition CurvRep.h:81
double getOverlap() const
Getter for the overlap in real curve to investigate the value that results from the discrete overlap ...
Definition CurvRep.cc:110
Abstract base class for different kinds of events.