Belle II Software  release-08-01-10
FlightTimeEstimator.cc
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 #include <tracking/trackFindingCDC/eventdata/utils/FlightTimeEstimator.h>
9 
10 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
11 
12 #include <tracking/trackFindingCDC/numerics/SpecialFunctions.h>
13 #include <tracking/trackFindingCDC/numerics/Angle.h>
14 
15 #include <framework/gearbox/Const.h>
16 
17 using namespace Belle2;
18 using namespace TrackFindingCDC;
19 
21 FlightTimeEstimator::instance(std::unique_ptr<FlightTimeEstimator> replacement)
22 {
23  static std::unique_ptr<FlightTimeEstimator> s_instance(new FlightTimeEstimator);
24  if (replacement) {
25  s_instance = std::move(replacement);
26  }
27  return *s_instance;
28 }
29 
30 namespace {
31  double getFirstPeriodAlphaFlightTime(double absAlpha)
32  {
33  return 1.0 / (sinc(absAlpha) * Const::speedOfLight);
34  }
35 }
36 
38  : m_firstPeriodAlphaFlightTimeFactor(getFirstPeriodAlphaFlightTime,
39  512,
40  0,
41  std::nextafter(M_PI, INFINITY))
42 {
43 }
44 
45 namespace {
46  double getHalfPeriodAlphaFlightTime(double absAlpha)
47  {
48  if (absAlpha > M_PI / 2.0) {
49  double reverseAlpha = AngleUtil::reversed(absAlpha);
50  return -1.0 / (sinc(reverseAlpha) * Const::speedOfLight);
51  } else {
52  return 1.0 / (sinc(absAlpha) * Const::speedOfLight);
53  }
54  }
55 }
56 
58  : m_triggerPoint(triggerPoint)
59  , m_halfPeriodAlphaFlightTimeFactor(getHalfPeriodAlphaFlightTime,
60  512,
61  0,
62  std::nextafter(M_PI, INFINITY))
63 {
64 }
static const double speedOfLight
[cm/ns]
Definition: Const.h:686
BeamEventFlightTimeEstimator()
Constructor also setting up the flight time lookup table.
CosmicRayFlightTimeEstimator(Vector3D triggerPoint=Vector3D(0, 0, 0))
Constructor also setting up the flight time lookup table.
Helper struct to provide consistent flight time estimation throughout the CDC track finding.
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
A three dimensional vector.
Definition: Vector3D.h:33
Abstract base class for different kinds of events.
static double reversed(const double angle)
Get the angle that point in the opposite direction.
Definition: Angle.h:54