Belle II Software  release-05-01-25
InPhi0CurvTanLBox.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/hough/axes/StandardAxes.h>
13 #include <tracking/trackFindingCDC/hough/boxes/Box.h>
14 #include <tracking/trackFindingCDC/topology/ILayer.h>
15 
16 namespace Belle2 {
21  namespace TrackFindingCDC {
22 
24  class InPhi0CurvTanLBox {
25 
26  public:
28  explicit InPhi0CurvTanLBox(float curlCurv)
29  : m_curlCurv(curlCurv)
30  {}
31 
32  public:
35 
36  public:
38  ESign getDistanceSign(const HoughBox& houghBox,
39  float x,
40  float y,
41  float l,
42  float dxdz,
43  float dydz,
44  ILayer iCLayer = -1) const
45  {
46  const std::array<DiscretePhi0, 2>& phi0Vec = houghBox.getBounds<DiscretePhi0>();
47  const std::array<DiscreteCurvWithArcLength2DCache, 2>& curv =
48  houghBox.getBounds<DiscreteCurvWithArcLength2DCache>();
49  const std::array<ContinuousTanL, 2>& tanL = houghBox.getBounds<ContinuousTanL>();
50 
51  float r2 = x * x + y * y;
52 
53  std::array<float, 2> xRot;
54  xRot[0] = x * phi0Vec[0]->x() + y * phi0Vec[0]->y();
55  xRot[1] = x * phi0Vec[1]->x() + y * phi0Vec[1]->y();
56 
57  std::array<float, 2> yRotPlusL;
58  yRotPlusL[0] = -x * phi0Vec[0]->y() + y * phi0Vec[0]->x() + l;
59  yRotPlusL[1] = -x * phi0Vec[1]->y() + y * phi0Vec[1]->x() + l;
60 
61  // std::array<float, 2> dxdzRot;
62  // dxdzRot[0] = dxdz * phi0Vec[0]->x() + dydz * phi0Vec[0]->y();
63  // dxdzRot[1] = dxdz * phi0Vec[1]->x() + dydz * phi0Vec[1]->y();
64 
65  std::array<float, 2> dydzRot;
66  dydzRot[0] = -dxdz * phi0Vec[0]->y() + dydz * phi0Vec[0]->x();
67  dydzRot[1] = -dxdz * phi0Vec[1]->y() + dydz * phi0Vec[1]->x();
68 
69  const bool onlyPositiveArm = 0 < m_curlCurv;
70  if (onlyPositiveArm) {
71  // Reject hit if it is on the inward going branch but the curvature suggest it is no curler
72  if ((xRot[0] < 0) and (xRot[1] < 0)) return ESign::c_Invalid;
73  }
74 
76  std::array<float, 2> s;
77  s[0] = curv[0]->getArcLength2D(iCLayer, (xRot[0] < 0) and (xRot[1] < 0));
78  s[1] = curv[1]->getArcLength2D(iCLayer, (xRot[0] < 0) and (xRot[1] < 0));
79 
80  std::array<float, 2> r2TimesHalfCurv;
81  r2 -= l * l;
82  r2TimesHalfCurv[0] = r2 * (static_cast<float>(*(curv[0])) / 2.0);
83  r2TimesHalfCurv[1] = r2 * (static_cast<float>(*(curv[1])) / 2.0);
84 
85  // std::array<float, 4> xRotCor;
86  // xRotCor[0b00] = xRot[0] + dxdzRot[0] * s[0] * static_cast<float>(tanL[0]);
87  // xRotCor[0b01] = xRot[0] + dxdzRot[0] * s[0] * static_cast<float>(tanL[1]);
88  // xRotCor[0b10] = xRot[1] + dxdzRot[1] * s[1] * static_cast<float>(tanL[0]);
89  // xRotCor[0b11] = xRot[1] + dxdzRot[1] * s[1] * static_cast<float>(tanL[1]);
90 
91  // const std::array<float, 4>& sCor = xRotCor;
92 
93  std::array<float, 4> z;
94  z[0b00] = s[0] * static_cast<float>(tanL[0]);
95  z[0b01] = s[1] * static_cast<float>(tanL[0]);
96  z[0b10] = s[0] * static_cast<float>(tanL[1]);
97  z[0b11] = s[1] * static_cast<float>(tanL[1]);
98 
99  // Using binary notation encoding lower and upper box bounds to fill the flat array.
100  std::array<float, 8> dist;
101  dist[0b000] = r2TimesHalfCurv[0] - yRotPlusL[0] - dydzRot[0] * z[0b00];
102  dist[0b001] = r2TimesHalfCurv[0] - yRotPlusL[1] - dydzRot[1] * z[0b00];
103  dist[0b010] = r2TimesHalfCurv[1] - yRotPlusL[0] - dydzRot[0] * z[0b01];
104  dist[0b011] = r2TimesHalfCurv[1] - yRotPlusL[1] - dydzRot[1] * z[0b01];
105 
106  dist[0b100] = r2TimesHalfCurv[0] - yRotPlusL[0] - dydzRot[0] * z[0b10];
107  dist[0b101] = r2TimesHalfCurv[0] - yRotPlusL[1] - dydzRot[1] * z[0b10];
108  dist[0b110] = r2TimesHalfCurv[1] - yRotPlusL[0] - dydzRot[0] * z[0b11];
109  dist[0b111] = r2TimesHalfCurv[1] - yRotPlusL[1] - dydzRot[1] * z[0b11];
110 
111  return ESignUtil::common(dist);
112  }
113 
114  private:
116  float m_curlCurv;
117  };
118  }
120 }
Belle2::TrackFindingCDC::Box
The base class for all boxes.
Definition: Box.h:43
Belle2::TrackFindingCDC::ESignUtil::common
static ESign common(ESign n1, ESign n2)
Check if two values have a common sign.
Definition: ESign.h:67
Belle2::TrackFindingCDC::DiscreteValue
Representation for a discrete position in an array of discrete positions.
Definition: DiscreteValue.h:33
Belle2::TrackFindingCDC::InPhi0CurvTanLBox::getDistanceSign
ESign getDistanceSign(const HoughBox &houghBox, float x, float y, float l, float dxdz, float dydz, ILayer iCLayer=-1) const
Function that gives the sign of the distance from an observed drift circle to the sweeped object.
Definition: InPhi0CurvTanLBox.h:46
Belle2::TrackFindingCDC::ESignUtil::ESign
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:37
Belle2::TrackFindingCDC::InPhi0CurvTanLBox::m_curlCurv
float m_curlCurv
Curler curvature - set to value greater zero to activate one arm exclusive finding.
Definition: InPhi0CurvTanLBox.h:124
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::InPhi0CurvTanLBox::InPhi0CurvTanLBox
InPhi0CurvTanLBox(float curlCurv)
Create a new box with the given curler curvature.
Definition: InPhi0CurvTanLBox.h:36
Belle2::TrackFindingCDC::ContinuousValue
Type to have values not based on discrete positions from an array.
Definition: ContinuousValue.h:31