Belle II Software  release-05-02-19
SVDHitTimeSelectionFunction.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Giulia Casarosa *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <TObject.h>
14 
15 #include <cmath>
16 #include <vector>
17 
18 namespace Belle2 {
25  class SVDHitTimeSelectionFunction : public TObject {
26 
27  public:
28 
30  typedef bool (SVDHitTimeSelectionFunction::*selFunction)(double, double, double, double) const;
31 
33  bool isInTime(double svdTime, double svdTimeError = 0, double t0 = 0 , double t0Error = 0) const
34  {
36  return (this->*f)(svdTime, svdTimeError, t0, t0Error) ;
37  }
38 
40  bool areClustersInTime(double uTime, double vTime) const
41  {
42  if (abs(uTime - vTime) > m_maxUVTimeDifference)
43  return false;
44  return true;
45  }
46  float m_maxUVTimeDifference = 100;
50  {
51  // The m_implementations vector is static.
52  // We have to initialize it just once.
53  if (m_implementations.size() == 0) {
57  }
58 
59  m_current = 0; //firstVersion is the default //m_implementations.size() - 1;
60  m_deltaT = 100; //ns
61  m_nSigma = 100;
62  m_tMin = -999; //ns
63  };
64 
66  // SVDHitTimeSelectionFunction(const Belle2::SVDHitTimeSelectionFunction& a);
67 
68  //implementation: function version
70  void setFunctionID(int user_current) {m_current = user_current;}
72  int getFunctionID() const {return m_current;}
73 
74  //implementation firstVersion, setters and getters
76  void setMinTime(double tMin) { m_tMin = tMin; }
78  float getMinTime() const { return m_tMin; };
79 
80  //implementation secondVersion, setters and getters
82  void setDeltaTime(double deltaT) { m_deltaT = deltaT; }
84  float getDeltaTime() const { return m_deltaT; };
85 
86  //implementation thirdVersion, setters and getters
88  void setNsigma(double nSigma) { m_nSigma = nSigma; }
90  float getNsigma() const { return m_nSigma; };
91 
92  //max U-V time difference
94  void setMaxUVTimeDifference(double timeDiff) { m_maxUVTimeDifference = timeDiff; }
97  private:
98 
102  bool firstVersion(double svdTime, double /* svdTimeError */, double /* t0 */, double /* t0Error */) const
103  {
104  return svdTime > m_tMin;
105  };
106  double m_tMin;
109  bool secondVersion(double svdTime, double /* svdTimeError */, double t0, double /* t0Error */) const
110  {
111  return fabs(svdTime - t0) < m_deltaT;
112  };
113  double m_deltaT;
117  bool thirdVersion(double svdTime, double svdTimeError, double t0, double t0Error) const
118  {
119  float err2 = svdTimeError * svdTimeError + t0Error * t0Error;
120  return (svdTime - t0) * (svdTime - t0) < m_nSigma * m_nSigma * err2;
121  };
122  double m_nSigma;
126  int m_current;
128  static std::vector < selFunction > m_implementations;
129 
130 
131  ClassDef(SVDHitTimeSelectionFunction, 3)
132  };
133 
135 }
Belle2::SVDHitTimeSelectionFunction::setFunctionID
void setFunctionID(int user_current)
copy constructor
Definition: SVDHitTimeSelectionFunction.h:78
Belle2::SVDHitTimeSelectionFunction::m_current
int m_current
current function ID
Definition: SVDHitTimeSelectionFunction.h:134
Belle2::SVDHitTimeSelectionFunction::getMinTime
float getMinTime() const
returns the minimum cluster time
Definition: SVDHitTimeSelectionFunction.h:86
Belle2::SVDHitTimeSelectionFunction::getDeltaTime
float getDeltaTime() const
returns the minimum time distnace wrt t0
Definition: SVDHitTimeSelectionFunction.h:92
Belle2::SVDHitTimeSelectionFunction::areClustersInTime
bool areClustersInTime(double uTime, double vTime) const
returns whether the uCluster time is compatible with the vClsuter time
Definition: SVDHitTimeSelectionFunction.h:48
Belle2::SVDHitTimeSelectionFunction::selFunction
bool(SVDHitTimeSelectionFunction::* selFunction)(double, double, double, double) const
typedef of the output calibration function
Definition: SVDHitTimeSelectionFunction.h:38
Belle2::SVDHitTimeSelectionFunction::firstVersion
bool firstVersion(double svdTime, double, double, double) const
function parameters & implementations
Definition: SVDHitTimeSelectionFunction.h:110
Belle2::SVDHitTimeSelectionFunction::setDeltaTime
void setDeltaTime(double deltaT)
set the minimum time distance wrt t0
Definition: SVDHitTimeSelectionFunction.h:90
Belle2::SVDHitTimeSelectionFunction::setMaxUVTimeDifference
void setMaxUVTimeDifference(double timeDiff)
set m_maxUVTimeDifference
Definition: SVDHitTimeSelectionFunction.h:102
Belle2::SVDHitTimeSelectionFunction::m_deltaT
double m_deltaT
minimum time distance wrt t0
Definition: SVDHitTimeSelectionFunction.h:120
Belle2::SVDHitTimeSelectionFunction::thirdVersion
bool thirdVersion(double svdTime, double svdTimeError, double t0, double t0Error) const
THIRD VERSION, ID = 2: isOnTime if |t - t0|< nSigma*sigma.
Definition: SVDHitTimeSelectionFunction.h:125
Belle2::SVDHitTimeSelectionFunction::getMaxUVTimeDifference
float getMaxUVTimeDifference() const
get m_maxUVTimeDifference
Definition: SVDHitTimeSelectionFunction.h:104
Belle2::SVDHitTimeSelectionFunction::m_nSigma
double m_nSigma
number of Sigma
Definition: SVDHitTimeSelectionFunction.h:129
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDHitTimeSelectionFunction
class to contain the cut on svd hit time at SP creation step
Definition: SVDHitTimeSelectionFunction.h:33
Belle2::SVDHitTimeSelectionFunction::setMinTime
void setMinTime(double tMin)
set the minimum cluster time
Definition: SVDHitTimeSelectionFunction.h:84
Belle2::SVDHitTimeSelectionFunction::SVDHitTimeSelectionFunction
SVDHitTimeSelectionFunction()
constructor
Definition: SVDHitTimeSelectionFunction.h:57
Belle2::SVDHitTimeSelectionFunction::getNsigma
float getNsigma() const
returns the minimum cluster time
Definition: SVDHitTimeSelectionFunction.h:98
Belle2::SVDHitTimeSelectionFunction::m_implementations
static std::vector< selFunction > m_implementations
vector of fuctions, we use the m_current
Definition: SVDHitTimeSelectionFunction.h:136
Belle2::SVDHitTimeSelectionFunction::m_tMin
double m_tMin
minimum cluster time
Definition: SVDHitTimeSelectionFunction.h:113
Belle2::SVDHitTimeSelectionFunction::isInTime
bool isInTime(double svdTime, double svdTimeError=0, double t0=0, double t0Error=0) const
returns whether the hit came on time or not
Definition: SVDHitTimeSelectionFunction.h:41
Belle2::SVDHitTimeSelectionFunction::m_maxUVTimeDifference
float m_maxUVTimeDifference
max time difference of U and V clusters
Definition: SVDHitTimeSelectionFunction.h:54
Belle2::SVDHitTimeSelectionFunction::secondVersion
bool secondVersion(double svdTime, double, double t0, double) const
SECOND VERSION, ID = 1: isOnTime if |t - t0|< deltaT.
Definition: SVDHitTimeSelectionFunction.h:117
Belle2::SVDHitTimeSelectionFunction::setNsigma
void setNsigma(double nSigma)
set the nSigma
Definition: SVDHitTimeSelectionFunction.h:96
Belle2::SVDHitTimeSelectionFunction::getFunctionID
int getFunctionID() const
get the function ID (function version)
Definition: SVDHitTimeSelectionFunction.h:80