Belle II Software  release-05-01-25
HitInZ0TanLambdaBox.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 *
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/Z0TanLambdaBox.h>
13 #include <tracking/trackFindingCDC/hough/baseelements/SameSignChecker.h>
14 
15 namespace Belle2 {
20  namespace TrackFindingCDC {
21 
27  class HitInZ0TanLambdaBox {
28  public:
29 
31  using HoughBox = Z0TanLambdaBox;
32 
37  Weight operator()(const CDCRecoHit3D& recoHit,
38  const HoughBox* z0TanLambdaBox)
39  {
40  float lowerZ0 = z0TanLambdaBox->getLowerZ0();
41  float upperZ0 = z0TanLambdaBox->getUpperZ0();
42 
43  float lowerTanLambda = z0TanLambdaBox->getLowerTanLambda();
44  float upperTanLambda = z0TanLambdaBox->getUpperTanLambda();
45 
46  float perpS = recoHit.getArcLength2D();
47  float reconstructedZ = recoHit.getRecoZ();
48 
49  float distLowerZ0LowerTanLambda = perpS * lowerTanLambda - reconstructedZ + lowerZ0;
50  float distUpperZ0LowerTanLambda = perpS * lowerTanLambda - reconstructedZ + upperZ0;
51  float distLowerZ0UpperTanLambda = perpS * upperTanLambda - reconstructedZ + lowerZ0;
52  float distUpperZ0UpperTanLambda = perpS * upperTanLambda - reconstructedZ + upperZ0;
53 
54  const bool sameSign = SameSignChecker::sameSign(distLowerZ0LowerTanLambda, distUpperZ0LowerTanLambda,
55  distLowerZ0UpperTanLambda, distUpperZ0UpperTanLambda);
56  if (not sameSign) {
57  return 1.0;
58  } else {
59  return NAN;
60  }
61  }
62 
67  static bool compareDistances(const HoughBox& z0TanLambdaBox, const CDCRecoHit3D& lhsRecoHit, const CDCRecoHit3D& rhsRecoHit)
68  {
69  const double z0Mean = (z0TanLambdaBox.getLowerZ0() + z0TanLambdaBox.getUpperZ0()) / 2.0;
70  const double tanLambdaMean = (z0TanLambdaBox.getLowerTanLambda() + z0TanLambdaBox.getUpperTanLambda()) / 2.0;
71 
72  const double lhsZ = lhsRecoHit.getRecoZ();
73  const double rhsZ = rhsRecoHit.getRecoZ();
74 
75  const double lhsS = lhsRecoHit.getArcLength2D();
76  const double rhsS = rhsRecoHit.getArcLength2D();
77 
78  const double lhsZDistance = lhsS * tanLambdaMean + z0Mean - lhsZ;
79  const double rhsZDistance = rhsS * tanLambdaMean + z0Mean - rhsZ;
80 
81  return lhsZDistance < rhsZDistance;
82  }
83 
85  static const char* debugLine() { return "[0] + [1] * x";}
86  };
87  }
89 }
Belle2::TrackFindingCDC::HitInZ0TanLambdaBox::HoughBox
Z0TanLambdaBox HoughBox
Use a Z0TanLambdaBox.
Definition: HitInZ0TanLambdaBox.h:39
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::HitInZ0TanLambdaBox::operator()
Weight operator()(const CDCRecoHit3D &recoHit, const HoughBox *z0TanLambdaBox)
Checks if the wire hit is contained in a z0 tan lambda hough space.
Definition: HitInZ0TanLambdaBox.h:45
Belle2::TrackFindingCDC::HitInZ0TanLambdaBox::debugLine
static const char * debugLine()
ROOT-compatible formula for z(s) = z0 + tanlambda * s.
Definition: HitInZ0TanLambdaBox.h:93
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::HitInZ0TanLambdaBox::compareDistances
static bool compareDistances(const HoughBox &z0TanLambdaBox, const CDCRecoHit3D &lhsRecoHit, const CDCRecoHit3D &rhsRecoHit)
Compares distances from two hits to the track represented by the given box.
Definition: HitInZ0TanLambdaBox.h:75