Belle II Software  release-08-01-10
SelectionVariableHelper.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 
9 #pragma once
10 
11 namespace Belle2 {
20  template<class PointType, class DataType>
21  struct SelVarHelper {
22 
23 
29  static DataType s_MagneticFieldFactor; // = 1.5 * 0.00299710;
30 
31 
37  static void resetMagneticField(DataType magneticFieldStrength = 1.5) { SelVarHelper::s_MagneticFieldFactor = magneticFieldStrength * 0.00299710; }
38 
39 
41  static DataType calcPerp2(const PointType& aHit)
42  { return (aHit.X() * aHit.X() + aHit.Y() * aHit.Y()); }
43 
44 
46  static DataType calcPerp(const PointType& aHit) { return sqrt(calcPerp2(aHit)); }
47 
48 
50  static DataType calcMag2(const PointType& aHit)
51  { return (aHit.X() * aHit.X() + aHit.Y() * aHit.Y() + aHit.Z() * aHit.Z()); }
52 
53 
55  static DataType calcMag(const PointType& aHit) { return sqrt(calcMag2(aHit)); }
56 
57 
59  static DataType calcDot(const PointType& aHit, const PointType& bHit)
60  { return (aHit.X() * bHit.X() + aHit.Y() * bHit.Y() + aHit.Z() * bHit.Z()); }
61 
63  static DataType calcPt(DataType radius, DataType field = SelVarHelper::s_MagneticFieldFactor)
64  {
65  // TODO WARNING hardcoded value, is there a quasi-global value for such cases (this case, minimal accepted radius)
66  // if (fabs(radius) < 0.0000001) { throw (Circle_too_small() << radius << 0.0000001); }
67 
68  //WARNING: does not care for negative radius!!
69  return field * radius;
70  } // return unit: GeV/c
71 
72  };
73 
74  template<typename PointType, typename DataType> DataType SelVarHelper<PointType, DataType>::s_MagneticFieldFactor = 1.5 *
75  0.00299710;
76 
78 }
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
static DataType s_MagneticFieldFactor
is factor containing speed of light (c), the magnetic field (b) and the scaling factor s for conversi...
Abstract base class for different kinds of events.
contains a collection of functions and related stuff needed for SelectionVariables implementing 2-,...
static void resetMagneticField(DataType magneticFieldStrength=1.5)
Overrides standard-Setup for magnetic field.
static DataType calcDot(const PointType &aHit, const PointType &bHit)
returns scalar product of given two pointTypes.
static DataType calcPerp2(const PointType &aHit)
returns the perpendicular magnitude squared of given pointType.
static DataType calcMag2(const PointType &aHit)
returns the magnitude squared of given pointType.
static DataType calcPerp(const PointType &aHit)
returns the perpendicular magnitude of given pointType.
static DataType calcMag(const PointType &aHit)
returns the magnitude of given pointType.
static DataType calcPt(DataType radius, DataType field=SelVarHelper::s_MagneticFieldFactor)
calculates the estimation of the transverse momentum of given radius using defined strength of magnet...