Belle II Software  release-08-01-10
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/trackFindingCDC/numerics/Weight.h>
13 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit3D.h>
14 #include <tracking/trackFindingCDC/hough/baseelements/SameSignChecker.h>
15 
16 #include <framework/gearbox/Unit.h>
17 
18 #include <cmath>
19 
20 namespace Belle2 {
25  namespace TrackFindingCDC {
26 
52  class HitInHyperBox {
53 
54  public:
57 
59  Weight operator()(const 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 CDCRecoHit3D& lhsRecoHit, const CDCRecoHit3D& rhsRecoHit)
87  {
88  const float centerQ = *(hyperBox.getCenter<0>());
89  const float centerP = *(hyperBox.getCenter<1>());
90  const float centerZ0 = *(hyperBox.getCenter<2>());
91 
92  const double lhsZ = lhsRecoHit.getRecoZ();
93  const double rhsZ = rhsRecoHit.getRecoZ();
94 
95  const double lhsS = lhsRecoHit.getArcLength2D();
96  const double rhsS = rhsRecoHit.getArcLength2D();
97 
98  const double lhsZDistance = catZ(centerQ, centerP, lhsS) + centerZ0 - lhsZ;
99  const double rhsZDistance = catZ(centerQ, centerP, rhsS) + centerZ0 - rhsZ;
100 
101  return lhsZDistance < rhsZDistance;
102  }
103 
104  private:
106  static double catZ(const double q, const double p, const double R)
107  {
108  //100 here is a reference - size of CDC in cm
109  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);
110  }
111 
112  public:
114  static float centerX(const HoughBox& hyperBox)
115  {
116  return *(hyperBox.getCenter<0>());
117  }
118 
120  static float centerY(const HoughBox& hyperBox)
121  {
122  return *(hyperBox.getCenter<1>());
123  }
124 
126  static float centerZ(const HoughBox& hyperBox)
127  {
128  return *(hyperBox.getCenter<2>());
129  }
130 
132  static float deltaX(const HoughBox& hyperBox)
133  {
134  const float lowerQ = *(hyperBox.getLowerBound<DiscreteQ>()); //DiscreteValue is based on std::vector<T>::const_iterator
135  const float upperQ = *(hyperBox.getUpperBound<DiscreteQ>());
136  return 0.5 * (upperQ - lowerQ);
137  }
138 
140  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]";}
141  };
142  }
144 }
double R
typedef autogenerated by FFTW
The base class for all boxes.
Definition: Box.h:33
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:52
double getRecoZ() const
Getter for the z coordinate of the reconstructed position.
Definition: CDCRecoHit3D.h:303
double getArcLength2D() const
Getter for the travel distance in the xy projection.
Definition: CDCRecoHit3D.h:370
Representation for a discrete position in an array of discrete positions.
Definition: DiscreteValue.h:23
An algorithm to check if a hit is contained in a hyperbolic cosine hough box.
Definition: HitInHyperBox.h:52
static float centerY(const HoughBox &hyperBox)
Returns center value of the box along second (P) axis.
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.
static float centerZ(const HoughBox &hyperBox)
Returns center value of the box along third (Z0) axis.
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:86
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:59
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 const char * debugLine()
ROOT expression of the track hypothesis.
static bool sameSign(double n1, double n2)
Check if two values have the same sign.
static const double cm
Standard units with the value = 1.
Definition: Unit.h:47
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.