Belle II Software  release-05-01-25
HitInHyperBox.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Dmitrii Neverov *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/hough/boxes/Box.h>
13 #include <tracking/trackFindingCDC/hough/axes/StandardAxes.h>
14 #include <tracking/trackFindingCDC/numerics/Weight.h>
15 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit3D.h>
16 #include <tracking/trackFindingCDC/hough/baseelements/SameSignChecker.h>
17 
18 #include <framework/gearbox/Unit.h>
19 
20 #include <cmath>
21 
22 namespace Belle2 {
27  namespace TrackFindingCDC {
28 
54  class HitInHyperBox {
55 
56  public:
58  using HoughBox = Box<DiscreteQ, DiscreteP, DiscreteZ0>;
59 
61  Weight operator()(const CDCRecoHit3D& recoHit,
62  const HoughBox* hyperBox)
63  {
64  const float lowerQ = *(hyperBox->getLowerBound<DiscreteQ>()); //DiscreteValue is based on std::vector<T>::const_iterator
65  const float upperQ = *(hyperBox->getUpperBound<DiscreteQ>());
66  const float deltaQ = 0.5 * (upperQ - lowerQ);
67 
68  const float centerP = *(hyperBox->getCenter<1>()); //TODO getCenter(class T) is not implemented
69 
70  const float centerZ0 = *(hyperBox->getCenter<2>());
71 
72  const double perpS = recoHit.getArcLength2D();
73  const double recoZ = recoHit.getRecoZ();
74 
75  const bool sameSign = SameSignChecker::sameSign(catZ(lowerQ, centerP, perpS) + centerZ0 - 100.0 * Unit::cm * deltaQ - recoZ,
76  catZ(upperQ, centerP, perpS) + centerZ0 + 100.0 * Unit::cm * deltaQ - recoZ); //100 is a reference - size of CDC in cm
77  if (not sameSign) {
78  return 1.0;
79  } else {
80  return NAN;
81  }
82  }
83 
88  static bool compareDistances(const HoughBox& hyperBox, const CDCRecoHit3D& lhsRecoHit, const CDCRecoHit3D& rhsRecoHit)
89  {
90  const float centerQ = *(hyperBox.getCenter<0>());
91  const float centerP = *(hyperBox.getCenter<1>());
92  const float centerZ0 = *(hyperBox.getCenter<2>());
93 
94  const double lhsZ = lhsRecoHit.getRecoZ();
95  const double rhsZ = rhsRecoHit.getRecoZ();
96 
97  const double lhsS = lhsRecoHit.getArcLength2D();
98  const double rhsS = rhsRecoHit.getArcLength2D();
99 
100  const double lhsZDistance = catZ(centerQ, centerP, lhsS) + centerZ0 - lhsZ;
101  const double rhsZDistance = catZ(centerQ, centerP, rhsS) + centerZ0 - rhsZ;
102 
103  return lhsZDistance < rhsZDistance;
104  }
105 
106  private:
108  static double catZ(const double q, const double p, const double R)
109  {
110  //100 here is a reference - size of CDC in cm
111  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);
112  }
113 
114  public:
116  static float centerX(const HoughBox& hyperBox)
117  {
118  return *(hyperBox.getCenter<0>());
119  }
120 
122  static float centerY(const HoughBox& hyperBox)
123  {
124  return *(hyperBox.getCenter<1>());
125  }
126 
128  static float centerZ(const HoughBox& hyperBox)
129  {
130  return *(hyperBox.getCenter<2>());
131  }
132 
134  static float deltaX(const HoughBox& hyperBox)
135  {
136  const float lowerQ = *(hyperBox.getLowerBound<DiscreteQ>()); //DiscreteValue is based on std::vector<T>::const_iterator
137  const float upperQ = *(hyperBox.getUpperBound<DiscreteQ>());
138  return 0.5 * (upperQ - lowerQ);
139  }
140 
142  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]";}
143  };
144  }
146 }
Belle2::TrackFindingCDC::Box
The base class for all boxes.
Definition: Box.h:43
Belle2::TrackFindingCDC::HitInHyperBox::catZ
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.
Definition: HitInHyperBox.h:116
Belle2::Unit::cm
static const double cm
Standard units with the value = 1.
Definition: Unit.h:57
Belle2::TrackFindingCDC::HitInHyperBox::deltaX
static float deltaX(const HoughBox &hyperBox)
Returns half width of the box along first (Q) axis.
Definition: HitInHyperBox.h:142
Belle2::TrackFindingCDC::HitInHyperBox::centerX
static float centerX(const HoughBox &hyperBox)
Returns center value of the box along first (Q) axis.
Definition: HitInHyperBox.h:124
Belle2::TrackFindingCDC::DiscreteValue
Representation for a discrete position in an array of discrete positions.
Definition: DiscreteValue.h:33
Belle2::TrackFindingCDC::SameSignChecker::sameSign
static bool sameSign(double n1, double n2)
Check if two values have the same sign.
Definition: SameSignChecker.h:34
Belle2::TrackFindingCDC::HitInHyperBox::HoughBox
Box< DiscreteQ, DiscreteP, DiscreteZ0 > HoughBox
Hough space is 3D with axes q, p, z0 as described above.
Definition: HitInHyperBox.h:66
Belle2::TrackFindingCDC::HitInHyperBox::centerY
static float centerY(const HoughBox &hyperBox)
Returns center value of the box along second (P) axis.
Definition: HitInHyperBox.h:130
Belle2::TrackFindingCDC::HitInHyperBox::debugLine
static const char * debugLine()
ROOT expression of the track hypothesis.
Definition: HitInHyperBox.h:150
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::HitInHyperBox::compareDistances
static bool compareDistances(const HoughBox &hyperBox, const CDCRecoHit3D &lhsRecoHit, const CDCRecoHit3D &rhsRecoHit)
Compares distances from two hits to the track represented by the given box.
Definition: HitInHyperBox.h:96
Belle2::TrackFindingCDC::HitInHyperBox::centerZ
static float centerZ(const HoughBox &hyperBox)
Returns center value of the box along third (Z0) axis.
Definition: HitInHyperBox.h:136
Belle2::TrackFindingCDC::HitInHyperBox::operator()
Weight operator()(const CDCRecoHit3D &recoHit, const HoughBox *hyperBox)
Returns weight of the hit for the given hough box; in this algorithm - 1 if hit inside the box,...
Definition: HitInHyperBox.h:69