Belle II Software  release-08-01-10
TOPSampleTimes.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 #include <TObject.h>
12 #include <vector>
13 #include <top/dbobjects/TOPASICPedestals.h>
14 
15 namespace Belle2 {
24  class TOPSampleTimes: public TObject {
25  public:
26 
30  enum EStatus {
31  c_Default = 0,
33  c_Unusable = 2
34  };
35 
39  enum {c_WindowSize = TOPASICPedestals::c_WindowSize,
40  c_TimeAxisSize = c_WindowSize * 4
41  };
42 
47  {}
48 
55  TOPSampleTimes(unsigned scrodID, unsigned channel, double syncTimeBase):
56  m_scrodID(scrodID), m_channel(channel)
57  {
58  setTimeAxis(syncTimeBase);
59  }
60 
65  {
66  }
67 
72  void setTimeAxis(double syncTimeBase);
73 
79  void setTimeAxis(const std::vector<double>& sampleTimes, double syncTimeBase);
80 
85  void setTimeError(double error) {m_timeError = error;}
86 
91 
96  unsigned getScrodID() const {return m_scrodID;}
97 
102  unsigned getChannel() const {return m_channel;}
103 
108  double getTimeRange() const {return m_timeAxis[c_TimeAxisSize];}
109 
114  std::vector<double> getTimeAxis() const;
115 
120  double getTimeError() const {return m_timeError;}
121 
131  double getFullTime(int window, double sample) const;
132 
142  double getTime(int window, double sample) const
143  {
144  return getFullTime(window, sample) - window * getTimeRange() / 4.0;
145  }
146 
157  double getDeltaTime(int window, double sample2, double sample1) const
158  {
159  return getFullTime(window, sample2) - getFullTime(window, sample1);
160  }
161 
169  double getTimeBin(int window, int sampleNumber) const;
170 
181  double getSample(int window, double time) const;
182 
187  bool isCalibrated() const {return m_calibrated == c_Calibrated;}
188 
193  bool isDefault() const {return m_calibrated == c_Default;}
194 
199  bool isUnusable() const {return m_calibrated == c_Unusable;}
200 
201  private:
202 
203  unsigned short m_scrodID = 0;
204  unsigned short m_channel = 0;
205  float m_timeAxis[c_TimeAxisSize + 1] = {0};
206  float m_timeError = 0;
211  };
212 
214 } // end namespace Belle2
215 
@ c_WindowSize
number of samples
Calibration constants of a singe ASIC channel: time axis (sample times)
unsigned short m_scrodID
scrod ID
ClassDef(TOPSampleTimes, 2)
ClassDef.
TOPSampleTimes(unsigned scrodID, unsigned channel, double syncTimeBase)
Useful constructor, sets equidistant time base (uncalibrated)
double getTimeError() const
Returns uncertainty on time base calibration incl.
unsigned short m_channel
hardware channel number within SCROD
bool isDefault() const
Returns calibration status.
float m_timeAxis[c_TimeAxisSize+1]
time axis + right border point
~TOPSampleTimes()
Destructor.
void setUnusable()
Switches calibration status to unusable to flag badly calibrated constant.
void setTimeError(double error)
Sets uncertainty on time base calibration incl.
EStatus
Calibration status values.
@ c_Calibrated
good calibrated value
@ c_Unusable
bad calibrated value
@ c_Default
uncalibrated default value
double getTimeRange() const
Returns time axis range (time interval corresponding to 4 asic windows)
unsigned getChannel() const
Returns hardware channel number.
unsigned getScrodID() const
Returns scrod ID.
EStatus m_calibrated
calibration status
bool isCalibrated() const
Returns calibration status.
double getDeltaTime(int window, double sample2, double sample1) const
Returns time difference between sample2 and sample1.
float m_timeError
uncertainty of time axis points incl.
double getTime(int window, double sample) const
Returns time w.r.t SSTin that corresponds to the window number.
bool isUnusable() const
Returns calibration status.
TOPSampleTimes()
Default constructor.
double getFullTime(int window, double sample) const
Returns time with respect to sample 0 of window 0.
double getTimeBin(int window, int sampleNumber) const
Returns time bin of a given sample number and window (e.g.
double getSample(int window, double time) const
Returns sample with respect to sample 0 of the specified ASIC window (inverse of getTime).
void setTimeAxis(double syncTimeBase)
Sets equidistant time axis (uncalibrated).
std::vector< double > getTimeAxis() const
Returns time axis (sample times)
Abstract base class for different kinds of events.