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