Belle II Software  release-08-01-10
InPhi0CurvBox.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/perigee/Phi0Rep.h>
11 #include <tracking/trackFindingCDC/hough/perigee/CurvRep.h>
12 #include <tracking/trackFindingCDC/hough/boxes/Box.h>
13 #include <tracking/trackFindingCDC/topology/ILayer.h>
14 
15 #include <array>
16 #include <cmath>
17 
18 namespace Belle2 {
23  namespace TrackFindingCDC {
24 
26  class InPhi0CurvBox {
27 
28  public:
33  explicit InPhi0CurvBox(float curlCurv = NAN) : m_curlCurv(curlCurv) {}
34 
35  public:
38 
39  public:
48  ESign getDistanceSign(const HoughBox& houghBox,
49  float x,
50  float y,
51  float l,
52  float /*dxdz*/ = 0,
53  float /*dydz*/ = 0,
54  ILayer /*iCLayer*/ = -1) const
55  {
56  const std::array<DiscretePhi0, 2>& phi0Vec = houghBox.getBounds<DiscretePhi0>();
57  const std::array<DiscreteCurv, 2>& curv = houghBox.getBounds<DiscreteCurv>();
58 
59  std::array<float, 2> xRot;
60  xRot[0] = x * phi0Vec[0]->x() + y * phi0Vec[0]->y();
61  xRot[1] = x * phi0Vec[1]->x() + y * phi0Vec[1]->y();
62 
63  const bool isNonCurler = static_cast<float>(curv[1]) <= m_curlCurv and static_cast<float>(curv[0]) >= -m_curlCurv;
64  const bool onlyPositiveArm = isNonCurler;
65  if (onlyPositiveArm) {
66  // Reject hit if it is on the inward going branch but the curvature suggest it is no curler
67  if (xRot[0] < 0 and xRot[1] < 0) return ESign::c_Invalid;
68  }
69 
70  std::array<float, 2> yRotPlusL;
71  yRotPlusL[0] = -x * phi0Vec[0]->y() + y * phi0Vec[0]->x() + l;
72  yRotPlusL[1] = -x * phi0Vec[1]->y() + y * phi0Vec[1]->x() + l;
73 
74  const float r2 = x * x + y * y - l * l;
75  std::array<float, 2> r2TimesHalfCurv;
76  r2TimesHalfCurv[0] = r2 * (static_cast<float>(curv[0]) / 2.0);
77  r2TimesHalfCurv[1] = r2 * (static_cast<float>(curv[1]) / 2.0);
78 
79  // Using binary notation encoding lower and upper box bounds to fill the flat array.
80  std::array<float, 4> dist;
81 
82  dist[0b00] = r2TimesHalfCurv[0] - yRotPlusL[0];
83  dist[0b10] = r2TimesHalfCurv[0] - yRotPlusL[1];
84 
85  dist[0b01] = r2TimesHalfCurv[1] - yRotPlusL[0];
86  dist[0b11] = r2TimesHalfCurv[1] - yRotPlusL[1];
87 
88  return ESignUtil::common(dist);
89  }
90 
91  private:
93  float m_curlCurv;
94  };
95  }
97 }
The base class for all boxes.
Definition: Box.h:33
Representation for a discrete position in an array of discrete positions.
Definition: DiscreteValue.h:23
Checker if a position is contained in a family of curves over phi0 and curvature.
Definition: InPhi0CurvBox.h:26
InPhi0CurvBox(float curlCurv=NAN)
Constructor taking the curler curvature Curlers with high curvature than the curler curvature may obt...
Definition: InPhi0CurvBox.h:33
float m_curlCurv
Curler curvature - set to value greater zero to activate on arm exclusive finding.
Definition: InPhi0CurvBox.h:93
ESign getDistanceSign(const HoughBox &houghBox, float x, float y, float l, float=0, float=0, ILayer=-1) const
Function that gives the sign of the distance from an observed drift circle to the familiy of curves.
Definition: InPhi0CurvBox.h:48
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:27
static ESign common(ESign n1, ESign n2)
Check if two values have a common sign.
Definition: ESign.h:57
Abstract base class for different kinds of events.