Belle II Software  release-05-01-25
HitInQuadraticBox.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun, Oliver Frost, Dmitrii Neverov *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit3D.h>
12 #include <tracking/trackFindingCDC/hough/boxes/PQBox.h>
13 #include <tracking/trackFindingCDC/hough/baseelements/SameSignChecker.h>
14 
15 namespace Belle2 {
20  namespace TrackFindingCDC {
21 
30  class HitInQuadraticBox {
31  public:
32 
34  using HoughBox = PQBox;
35 
40  Weight operator()(const CDCRecoHit3D& recoHit,
41  const HoughBox* pqBox)
42  {
43  float lowerP = pqBox->getLowerP();
44  float upperP = pqBox->getUpperP();
45 
46  float lowerQ = pqBox->getLowerQ();
47  float upperQ = pqBox->getUpperQ();
48 
49  float perpS = recoHit.getArcLength2D();
50  float reconstructedZ = recoHit.getRecoZ();
51 
52  float distLowerPLowerQ = (lowerP + 4 * lowerQ) * perpS - lowerQ / 25 * perpS * perpS - reconstructedZ;
53  float distUpperPLowerQ = (upperP + 4 * lowerQ) * perpS - lowerQ / 25 * perpS * perpS - reconstructedZ;
54  float distLowerPUpperQ = (lowerP + 4 * upperQ) * perpS - upperQ / 25 * perpS * perpS - reconstructedZ;
55  float distUpperPUpperQ = (upperP + 4 * upperQ) * perpS - upperQ / 25 * perpS * perpS - reconstructedZ;
56 
57  const bool sameSign = SameSignChecker::sameSign(distLowerPLowerQ, distUpperPLowerQ,
58  distLowerPUpperQ, distUpperPUpperQ);
59  if (not sameSign) {
60  return 1.0;
61  } else {
62  return NAN;
63  }
64  }
65 
70  static bool compareDistances(const HoughBox& pqBox, const CDCRecoHit3D& lhsRecoHit, const CDCRecoHit3D& rhsRecoHit)
71  {
72  const double pMean = (pqBox.getLowerP() + pqBox.getUpperP()) / 2.0;
73  const double qMean = (pqBox.getLowerQ() + pqBox.getUpperQ()) / 2.0;
74 
75  const double lhsZ = lhsRecoHit.getRecoZ();
76  const double rhsZ = rhsRecoHit.getRecoZ();
77 
78  const double lhsS = lhsRecoHit.getArcLength2D();
79  const double rhsS = rhsRecoHit.getArcLength2D();
80 
81  const double lhsZDistance = (pMean + 4 * qMean) * lhsS - qMean / 25 * lhsS * lhsS - lhsZ;
82  const double rhsZDistance = (pMean + 4 * qMean) * rhsS - qMean / 25 * rhsS * rhsS - rhsZ;
83 
84  return lhsZDistance < rhsZDistance;
85  }
86 
88  static const char* debugLine() { return "([0] + 4*[1])*x - [1] / 25 * x * x";}
89  };
90  }
92 }
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::HitInQuadraticBox::compareDistances
static bool compareDistances(const HoughBox &pqBox, const CDCRecoHit3D &lhsRecoHit, const CDCRecoHit3D &rhsRecoHit)
Compares distances from two hits to the track represented by the given box.
Definition: HitInQuadraticBox.h:78
Belle2::TrackFindingCDC::HitInQuadraticBox::debugLine
static const char * debugLine()
ROOT-compatible formula for z(s) = (p + 4q)*s - q/25 * s^2.
Definition: HitInQuadraticBox.h:96
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::HitInQuadraticBox::HoughBox
PQBox HoughBox
Use a PQBox.
Definition: HitInQuadraticBox.h:42
Belle2::TrackFindingCDC::HitInQuadraticBox::operator()
Weight operator()(const CDCRecoHit3D &recoHit, const HoughBox *pqBox)
Checks if the wire hit is contained in a p q hough space.
Definition: HitInQuadraticBox.h:48