Belle II Software  release-05-02-19
TOPSampleTimes.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <TObject.h>
14 #include <vector>
15 #include <top/dbobjects/TOPASICPedestals.h>
16 
17 namespace Belle2 {
26  class TOPSampleTimes: public TObject {
27  public:
28 
32  enum EStatus {
33  c_Default = 0,
35  c_Unusable = 2
36  };
37 
41  enum {c_WindowSize = TOPASICPedestals::c_WindowSize,
42  c_TimeAxisSize = c_WindowSize * 4
43  };
44 
49  {}
50 
57  TOPSampleTimes(unsigned scrodID, unsigned channel, double syncTimeBase):
58  m_scrodID(scrodID), m_channel(channel)
59  {
60  setTimeAxis(syncTimeBase);
61  }
62 
67  {
68  }
69 
74  void setTimeAxis(double syncTimeBase);
75 
81  void setTimeAxis(const std::vector<double>& sampleTimes, double syncTimeBase);
82 
87  void setTimeError(double error) {m_timeError = error;}
88 
93 
98  unsigned getScrodID() const {return m_scrodID;}
99 
104  unsigned getChannel() const {return m_channel;}
105 
110  double getTimeRange() const {return m_timeAxis[c_TimeAxisSize];}
111 
116  std::vector<double> getTimeAxis() const;
117 
122  double getTimeError() const {return m_timeError;}
123 
133  double getFullTime(int window, double sample) const;
134 
144  double getTime(int window, double sample) const
145  {
146  return getFullTime(window, sample) - window * getTimeRange() / 4.0;
147  }
148 
159  double getDeltaTime(int window, double sample2, double sample1) const
160  {
161  return getFullTime(window, sample2) - getFullTime(window, sample1);
162  }
163 
171  double getTimeBin(int window, int sampleNumber) const;
172 
183  double getSample(int window, double time) const;
184 
189  bool isCalibrated() const {return m_calibrated == c_Calibrated;}
190 
195  bool isDefault() const {return m_calibrated == c_Default;}
196 
201  bool isUnusable() const {return m_calibrated == c_Unusable;}
202 
203  private:
204 
205  unsigned short m_scrodID = 0;
206  unsigned short m_channel = 0;
207  float m_timeAxis[c_TimeAxisSize + 1] = {0};
208  float m_timeError = 0;
213  };
214 
216 } // end namespace Belle2
217 
Belle2::TOPASICPedestals::c_WindowSize
@ c_WindowSize
number of samples
Definition: TOPASICPedestals.h:40
Belle2::TOPSampleTimes::isDefault
bool isDefault() const
Returns calibration status.
Definition: TOPSampleTimes.h:203
Belle2::TOPSampleTimes::getFullTime
double getFullTime(int window, double sample) const
Returns time with respect to sample 0 of window 0.
Definition: TOPSampleTimes.cc:60
Belle2::TOPSampleTimes::ClassDef
ClassDef(TOPSampleTimes, 2)
ClassDef.
Belle2::TOPSampleTimes::~TOPSampleTimes
~TOPSampleTimes()
Destructor.
Definition: TOPSampleTimes.h:74
Belle2::TOPSampleTimes::getTimeAxis
std::vector< double > getTimeAxis() const
Returns time axis (sample times)
Definition: TOPSampleTimes.cc:50
Belle2::TOPSampleTimes::getTime
double getTime(int window, double sample) const
Returns time w.r.t SSTin that corresponds to the window number.
Definition: TOPSampleTimes.h:152
Belle2::TOPSampleTimes::m_timeAxis
float m_timeAxis[c_TimeAxisSize+1]
time axis + right border point
Definition: TOPSampleTimes.h:215
Belle2::TOPSampleTimes::setUnusable
void setUnusable()
Switches calibration status to unusable to flag badly calibrated constant.
Definition: TOPSampleTimes.h:100
Belle2::TOPSampleTimes::m_scrodID
unsigned short m_scrodID
scrod ID
Definition: TOPSampleTimes.h:213
Belle2::TOPSampleTimes::m_timeError
float m_timeError
uncertainty of time axis points incl.
Definition: TOPSampleTimes.h:216
Belle2::TOPSampleTimes::c_Default
@ c_Default
uncalibrated default value
Definition: TOPSampleTimes.h:41
Belle2::TOPSampleTimes::TOPSampleTimes
TOPSampleTimes()
Default constructor.
Definition: TOPSampleTimes.h:56
Belle2::TOPSampleTimes::getTimeRange
double getTimeRange() const
Returns time axis range (time interval corresponding to 4 asic windows)
Definition: TOPSampleTimes.h:118
Belle2::TOPSampleTimes::getTimeError
double getTimeError() const
Returns uncertainty on time base calibration incl.
Definition: TOPSampleTimes.h:130
Belle2::TOPSampleTimes::c_Unusable
@ c_Unusable
bad calibrated value
Definition: TOPSampleTimes.h:43
Belle2::TOPSampleTimes::setTimeError
void setTimeError(double error)
Sets uncertainty on time base calibration incl.
Definition: TOPSampleTimes.h:95
Belle2::TOPSampleTimes::getSample
double getSample(int window, double time) const
Returns sample with respect to sample 0 of the specified ASIC window (inverse of getTime).
Definition: TOPSampleTimes.cc:82
Belle2::TOPSampleTimes
Calibration constants of a singe ASIC channel: time axis (sample times)
Definition: TOPSampleTimes.h:34
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOPSampleTimes::m_calibrated
EStatus m_calibrated
calibration status
Definition: TOPSampleTimes.h:217
Belle2::TOPSampleTimes::EStatus
EStatus
Calibration status values.
Definition: TOPSampleTimes.h:40
Belle2::TOPSampleTimes::isCalibrated
bool isCalibrated() const
Returns calibration status.
Definition: TOPSampleTimes.h:197
Belle2::TOPSampleTimes::m_channel
unsigned short m_channel
hardware channel number within SCROD
Definition: TOPSampleTimes.h:214
Belle2::TOPSampleTimes::c_Calibrated
@ c_Calibrated
good calibrated value
Definition: TOPSampleTimes.h:42
Belle2::TOPSampleTimes::setTimeAxis
void setTimeAxis(double syncTimeBase)
Sets equidistant time axis (uncalibrated).
Definition: TOPSampleTimes.cc:25
Belle2::TOPSampleTimes::getDeltaTime
double getDeltaTime(int window, double sample2, double sample1) const
Returns time difference between sample2 and sample1.
Definition: TOPSampleTimes.h:167
Belle2::TOPSampleTimes::isUnusable
bool isUnusable() const
Returns calibration status.
Definition: TOPSampleTimes.h:209
Belle2::TOPSampleTimes::getChannel
unsigned getChannel() const
Returns hardware channel number.
Definition: TOPSampleTimes.h:112
Belle2::TOPSampleTimes::getScrodID
unsigned getScrodID() const
Returns scrod ID.
Definition: TOPSampleTimes.h:106
Belle2::TOPSampleTimes::getTimeBin
double getTimeBin(int window, int sampleNumber) const
Returns time bin of a given sample number and window (e.g.
Definition: TOPSampleTimes.cc:106