Belle II Software development
SVDClusterTime Class Referenceabstract

Abstract Class representing the SVD cluster time. More...

#include <SVDClusterTime.h>

Inheritance diagram for SVDClusterTime:
SVDCoG3Time SVDCoG6Time SVDELS3Time

Public Member Functions

 SVDClusterTime ()
 Constructor to create an empty Cluster Time Object by default returns the calibrated time.
 
void setReturnRawClusterTime ()
 set to return the raw cluster time instead of the calibrated one
 
void setTriggerBin (const int triggerBin)
 set the trigger bin
 
virtual void computeClusterTime (Belle2::SVD::RawCluster &rawCluster, double &time, double &timeError, int &firstFrame)=0
 computes the cluster time, timeError and FirstFrame
 
virtual ~SVDClusterTime ()
 virtual destructor
 
void applyCoG6Time (const Belle2::SVD::RawCluster &rawCluster, double &time, double &timeError, int &firstFrame)
 CoG6 Time Algorithm.
 
void applyCoG3Time (const Belle2::SVD::RawCluster &rawCluster, double &time, double &timeError, int &firstFrame)
 CoG3 Time Algorithm.
 
void applyELS3Time (const Belle2::SVD::RawCluster &rawCluster, double &time, double &timeError, int &firstFrame)
 ELS3 Time Algorithm.
 

Protected Attributes

SVDPulseShapeCalibrations m_PulseShapeCal
 SVDPulseShaper calibration wrapper.
 
SVDCoGTimeCalibrations m_CoG6TimeCal
 CoG6 time calibration wrapper.
 
SVD3SampleCoGTimeCalibrations m_CoG3TimeCal
 CoG3 time calibration wrapper.
 
SVD3SampleELSTimeCalibrations m_ELS3TimeCal
 ELS3 time calibration wrapper.
 
DBObjPtr< HardwareClockSettingsm_hwClock
 Hardware Clocks.
 
double m_apvClockPeriod = 1. / m_hwClock->getClockFrequency(Const::EDetector::SVD, "sampling")
 APV clock period.
 
int m_triggerBin = std::numeric_limits<int>::quiet_NaN()
 trigger bin
 
bool m_returnRawClusterTime = false
 to be used for time calibration
 

Detailed Description

Abstract Class representing the SVD cluster time.

Definition at line 26 of file SVDClusterTime.h.

Constructor & Destructor Documentation

◆ SVDClusterTime()

SVDClusterTime ( )
inline

Constructor to create an empty Cluster Time Object by default returns the calibrated time.

Definition at line 34 of file SVDClusterTime.h.

34{m_returnRawClusterTime = false;};

◆ ~SVDClusterTime()

virtual ~SVDClusterTime ( )
inlinevirtual

virtual destructor

Definition at line 57 of file SVDClusterTime.h.

57{};

Member Function Documentation

◆ applyCoG3Time()

void applyCoG3Time ( const Belle2::SVD::RawCluster & rawCluster,
double & time,
double & timeError,
int & firstFrame )

CoG3 Time Algorithm.

Definition at line 78 of file SVDClusterTime.cc.

79 {
80 //take the MaxSum 3 samples
81 SVDMaxSumAlgorithm maxSum = SVDMaxSumAlgorithm(rawCluster.getClsSamples(false));
82
83 std::vector<float> selectedSamples = maxSum.getSelectedSamples();
84 firstFrame = maxSum.getFirstFrame();
85
86
87 auto begin = selectedSamples.begin();
88 const auto end = selectedSamples.end();
89
90 auto retval = 0., norm = 0.;
91 for (auto step = 0.; begin != end; ++begin, step += m_apvClockPeriod) {
92 norm += static_cast<double>(*begin);
93 retval += static_cast<double>(*begin) * step;
94 }
95 float rawtime = retval / norm;
96
97 if (std::isnan(float(m_triggerBin)))
98 B2FATAL("OOPS, we can't continue, you have to set the trigger bin!");
99
100 if (m_returnRawClusterTime)
101 time = rawtime;
102 else
103 //cellID = 10 not used for calibration
104 time = m_CoG3TimeCal.getCorrectedTime(rawCluster.getSensorID(), rawCluster.isUSide(), 10, rawtime, m_triggerBin);
105
106
107
108 // now compute the CoG3 time error
109 // assumptions:
110 // 1. calibration function parameters error not taken into account
111 // 2. 100% correlation among different strip noises
112 // 3. error on the sample amplitude = strip noise for all samples
113
114 //compute the noise of the clustered sample
115 //it is the same for all samples
116 //computed assuming 2. (-> linear sum, not quadratic)
117 std::vector<Belle2::SVD::StripInRawCluster> strips = rawCluster.getStripsInRawCluster();
118 float noise = std::accumulate(strips.begin(), strips.end(), 0., [](float sum, const Belle2::SVD::StripInRawCluster & strip) { return sum + strip.noise; });
119
120 //compute the noise of the raw time
121 //assuming only the clustered sample amplitude carries an uncertainty
122 double rawtimeError = 0;
123 begin = selectedSamples.begin();
124 for (float i = 0.; begin != end; ++begin, i += 1)
125 rawtimeError += TMath::Power((m_apvClockPeriod * i - rawtime) / norm, 2);
126 rawtimeError = sqrt(rawtimeError) * noise;
127
128 //compute the error on the calibrated time
129 timeError = m_CoG3TimeCal.getCorrectedTimeError(rawCluster.getSensorID(), rawCluster.isUSide(), 10, rawtime, rawtimeError,
130 m_triggerBin);
131 }
const std::vector< StripInRawCluster > getStripsInRawCluster() const
Definition RawCluster.h:110
Belle2::SVDShaperDigit::APVFloatSamples getClsSamples(bool inElectrons) const
VxdID getSensorID() const
Definition RawCluster.h:80
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28

◆ applyCoG6Time()

void applyCoG6Time ( const Belle2::SVD::RawCluster & rawCluster,
double & time,
double & timeError,
int & firstFrame )

CoG6 Time Algorithm.

Definition at line 23 of file SVDClusterTime.cc.

24 {
25
26 // ISSUES:
27 // 1. time error not computed
28
29 //the first frame is 0 by definition
30 firstFrame = 0;
31
32 //take the strips in the rawCluster
33 std::vector<Belle2::SVD::StripInRawCluster> strips = rawCluster.getStripsInRawCluster();
34
35 //initialize time, stripTime and sumAmplitudes
36 time = 0;
37 timeError = 0;
38 float sumAmplitudes = 0;
39
40 for (int i = 0; i < (int)strips.size(); i++) {
41
42 Belle2::SVD::StripInRawCluster strip = strips.at(i);
43
44 double stripTime = 0;
45 float stripSumAmplitudes = 0;
46
47 for (int k = 0; k < 6; k ++) {
48 stripTime += k * strip.samples[k];
49 stripSumAmplitudes += strip.samples[k];
50 }
51 if (stripSumAmplitudes != 0) {
52 stripTime /= (stripSumAmplitudes);
53 stripTime *= m_apvClockPeriod;
54 } else {
55 stripTime = -1;
56 B2WARNING("Trying to divide by 0 (ZERO)! Sum of amplitudes is nullptr! Skipping this SVDShaperDigit!");
57 }
58
59 // correct strip by the CalPeak
60 stripTime -= m_PulseShapeCal.getPeakTime(rawCluster.getSensorID(), rawCluster.isUSide(), strip.cellID);
61
62 if (std::isnan(float(m_triggerBin)))
63 B2FATAL("OOPS, we can't continue, you have to set the trigger bin!");
64
65 if (! m_returnRawClusterTime)
66 // calibrate strip time (cellID not used)
67 stripTime = m_CoG6TimeCal.getCorrectedTime(rawCluster.getSensorID(), rawCluster.isUSide(), strip.cellID, stripTime, m_triggerBin);
68
69 //update cluster time
70 time += stripTime * strip.maxSample;
71 sumAmplitudes += strip.maxSample;
72 }
73
74 //finally compute cluster time
75 time = time / sumAmplitudes;
76 }
Belle2::SVDShaperDigit::APVFloatSamples samples
ADC of the acquired samples.
Definition RawCluster.h:25
int maxSample
ADC max of the acquired samples.
Definition RawCluster.h:23

◆ applyELS3Time()

void applyELS3Time ( const Belle2::SVD::RawCluster & rawCluster,
double & time,
double & timeError,
int & firstFrame )

ELS3 Time Algorithm.

Definition at line 134 of file SVDClusterTime.cc.

135 {
136
137 // ISSUES:
138 // 1. ELS3 tau hardcoded
139 // 2. time error not computer
140
141 timeError = 0;
142 float m_ELS3tau = 55;
143
144 //take the MaxSum 3 samples
145 SVDMaxSumAlgorithm maxSum = SVDMaxSumAlgorithm(rawCluster.getClsSamples(false));
146
147 std::vector<float> selectedSamples = maxSum.getSelectedSamples();
148 firstFrame = maxSum.getFirstFrame();
149
150 auto begin = selectedSamples.begin();
151 const double E = std::exp(- m_apvClockPeriod / m_ELS3tau);
152 const double E2 = E * E;
153 const double E4 = E2 * E2;
154 double a0 = (*begin);
155 double a1 = (*(begin + 1));
156 double a2 = (*(begin + 2));
157
158 //compute raw time
159 const double w = (a0 - E2 * a2) / (2 * a0 + E * a1);
160 auto rawtime_num = 2 * E4 + w * E2;
161 auto rawtime_den = 1 - E4 - w * (2 + E2);
162 double rawtime = - m_apvClockPeriod * rawtime_num / rawtime_den;
163
164 if (std::isnan(float(m_triggerBin)))
165 B2FATAL("OOPS, we can't continue, you have to set the trigger bin!");
166
167 if (m_returnRawClusterTime)
168 time = rawtime;
169 else
170 time = m_ELS3TimeCal.getCorrectedTime(rawCluster.getSensorID(), rawCluster.isUSide(), 10, rawtime, m_triggerBin);
171
172 }
R E
internal precision of FFTW codelets

◆ computeClusterTime()

virtual void computeClusterTime ( Belle2::SVD::RawCluster & rawCluster,
double & time,
double & timeError,
int & firstFrame )
pure virtual

computes the cluster time, timeError and FirstFrame

Implemented in SVDCoG3Time, SVDCoG6Time, and SVDELS3Time.

◆ setReturnRawClusterTime()

void setReturnRawClusterTime ( )
inline

set to return the raw cluster time instead of the calibrated one

Definition at line 40 of file SVDClusterTime.h.

41 {m_returnRawClusterTime = true;};

◆ setTriggerBin()

void setTriggerBin ( const int triggerBin)
inline

set the trigger bin

Definition at line 46 of file SVDClusterTime.h.

47 { m_triggerBin = triggerBin; };

Member Data Documentation

◆ m_apvClockPeriod

double m_apvClockPeriod = 1. / m_hwClock->getClockFrequency(Const::EDetector::SVD, "sampling")
protected

APV clock period.

Definition at line 84 of file SVDClusterTime.h.

◆ m_CoG3TimeCal

SVD3SampleCoGTimeCalibrations m_CoG3TimeCal
protected

CoG3 time calibration wrapper.

Definition at line 76 of file SVDClusterTime.h.

◆ m_CoG6TimeCal

SVDCoGTimeCalibrations m_CoG6TimeCal
protected

CoG6 time calibration wrapper.

Definition at line 74 of file SVDClusterTime.h.

◆ m_ELS3TimeCal

SVD3SampleELSTimeCalibrations m_ELS3TimeCal
protected

ELS3 time calibration wrapper.

Definition at line 78 of file SVDClusterTime.h.

◆ m_hwClock

DBObjPtr<HardwareClockSettings> m_hwClock
protected

Hardware Clocks.

Definition at line 81 of file SVDClusterTime.h.

◆ m_PulseShapeCal

SVDPulseShapeCalibrations m_PulseShapeCal
protected

SVDPulseShaper calibration wrapper.

Definition at line 71 of file SVDClusterTime.h.

◆ m_returnRawClusterTime

bool m_returnRawClusterTime = false
protected

to be used for time calibration

Definition at line 90 of file SVDClusterTime.h.

◆ m_triggerBin

int m_triggerBin = std::numeric_limits<int>::quiet_NaN()
protected

trigger bin

Definition at line 87 of file SVDClusterTime.h.


The documentation for this class was generated from the following files: