Belle II Software development
HitInHyperBox.h
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#pragma once
9
10#include <tracking/trackFindingCDC/hough/boxes/Box.h>
11#include <tracking/trackFindingCDC/hough/axes/StandardAxes.h>
12#include <tracking/trackingUtilities/numerics/Weight.h>
13#include <tracking/trackingUtilities/eventdata/hits/CDCRecoHit3D.h>
14#include <tracking/trackFindingCDC/hough/baseelements/SameSignChecker.h>
15
16#include <framework/gearbox/Unit.h>
17
18#include <cmath>
19
20namespace Belle2 {
25 namespace TrackFindingCDC {
26
53
54 public:
57
59 TrackingUtilities::Weight operator()(const TrackingUtilities::CDCRecoHit3D& recoHit,
60 const HoughBox* hyperBox)
61 {
62 const float lowerQ = *(hyperBox->getLowerBound<DiscreteQ>()); //DiscreteValue is based on std::vector<T>::const_iterator
63 const float upperQ = *(hyperBox->getUpperBound<DiscreteQ>());
64 const float deltaQ = 0.5 * (upperQ - lowerQ);
65
66 const float centerP = *(hyperBox->getCenter<1>()); //TODO getCenter(class T) is not implemented
67
68 const float centerZ0 = *(hyperBox->getCenter<2>());
69
70 const double perpS = recoHit.getArcLength2D();
71 const double recoZ = recoHit.getRecoZ();
72
73 const bool sameSign = SameSignChecker::sameSign(catZ(lowerQ, centerP, perpS) + centerZ0 - 100.0 * Unit::cm * deltaQ - recoZ,
74 catZ(upperQ, centerP, perpS) + centerZ0 + 100.0 * Unit::cm * deltaQ - recoZ); //100 is a reference - size of CDC in cm
75 if (not sameSign) {
76 return 1.0;
77 } else {
78 return NAN;
79 }
80 }
81
86 static bool compareDistances(const HoughBox& hyperBox, const TrackingUtilities::CDCRecoHit3D& lhsRecoHit,
87 const TrackingUtilities::CDCRecoHit3D& rhsRecoHit)
88 {
89 const float centerQ = *(hyperBox.getCenter<0>());
90 const float centerP = *(hyperBox.getCenter<1>());
91 const float centerZ0 = *(hyperBox.getCenter<2>());
92
93 const double lhsZ = lhsRecoHit.getRecoZ();
94 const double rhsZ = rhsRecoHit.getRecoZ();
95
96 const double lhsS = lhsRecoHit.getArcLength2D();
97 const double rhsS = rhsRecoHit.getArcLength2D();
98
99 const double lhsZDistance = catZ(centerQ, centerP, lhsS) + centerZ0 - lhsZ;
100 const double rhsZDistance = catZ(centerQ, centerP, rhsS) + centerZ0 - rhsZ;
101
102 return lhsZDistance < rhsZDistance;
103 }
104
105 private:
107 static double catZ(const double q, const double p, const double R)
108 {
109 //100 here is a reference - size of CDC in cm
110 return 100.0 * Unit::cm * q * (std::sqrt(1 - p * p) * std::cosh(R / (100.0 * Unit::cm) + std::asinh(p / std::sqrt(1 - p * p))) - 1);
111 }
112
113 public:
115 static float centerX(const HoughBox& hyperBox)
116 {
117 return *(hyperBox.getCenter<0>());
118 }
119
121 static float centerY(const HoughBox& hyperBox)
122 {
123 return *(hyperBox.getCenter<1>());
124 }
125
127 static float centerZ(const HoughBox& hyperBox)
128 {
129 return *(hyperBox.getCenter<2>());
130 }
131
133 static float deltaX(const HoughBox& hyperBox)
134 {
135 const float lowerQ = *(hyperBox.getLowerBound<DiscreteQ>()); //DiscreteValue is based on std::vector<T>::const_iterator
136 const float upperQ = *(hyperBox.getUpperBound<DiscreteQ>());
137 return 0.5 * (upperQ - lowerQ);
138 }
139
141 static const char* debugLine() { return "100.0 * [0] * (TMath::Sqrt(1 - [1] * [1]) * TMath::CosH(x / 100.0 + TMath::ASinH([1] / TMath::Sqrt(1 - [1] * [1]))) - 1) + [2]";}
142 };
143 }
145}
double R
typedef autogenerated by FFTW
The base class for all boxes.
Definition Box.h:33
An algorithm to check if a hit is contained in a hyperbolic cosine hough box.
static bool compareDistances(const HoughBox &hyperBox, const TrackingUtilities::CDCRecoHit3D &lhsRecoHit, const TrackingUtilities::CDCRecoHit3D &rhsRecoHit)
Compares distances from two hits to the track represented by the given box.
static float centerY(const HoughBox &hyperBox)
Returns center value of the box along second (P) axis.
static const char * debugLine()
ROOT expression of the track hypothesis.
static float deltaX(const HoughBox &hyperBox)
Returns half width of the box along first (Q) axis.
static float centerX(const HoughBox &hyperBox)
Returns center value of the box along first (Q) axis.
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCRecoHit3D &recoHit, const HoughBox *hyperBox)
Returns weight of the hit for the given hough box; in this algorithm - 1 if hit inside the box,...
Box< DiscreteQ, DiscreteP, DiscreteZ0 > HoughBox
Hough space is 3D with axes q, p, z0 as described above.
static float centerZ(const HoughBox &hyperBox)
Returns center value of the box along third (Z0) axis.
static double catZ(const double q, const double p, const double R)
Returns z(R) for the catenary with parameters q = E/p_t and p = p_z/E.
static bool sameSign(double n1, double n2)
Check if two values have the same sign.
Class representing a three dimensional reconstructed hit.
double getRecoZ() const
Getter for the z coordinate of the reconstructed position.
double getArcLength2D() const
Getter for the travel distance in the xy projection.
static const double cm
Standard units with the value = 1.
Definition Unit.h:47
Abstract base class for different kinds of events.