9#include <framework/logging/Logger.h>
10#include <svd/reconstruction/SVDClusterTime.h>
11#include <svd/reconstruction/SVDMaxSumAlgorithm.h>
38 float sumAmplitudes = 0;
40 for (
int i = 0; i < (int)strips.size(); i++) {
45 float stripSumAmplitudes = 0;
47 for (
int k = 0; k < 6; k ++) {
48 stripTime += k * strip.
samples[k];
49 stripSumAmplitudes += strip.
samples[k];
51 if (stripSumAmplitudes != 0) {
52 stripTime /= (stripSumAmplitudes);
56 B2WARNING(
"Trying to divide by 0 (ZERO)! Sum of amplitudes is nullptr! Skipping this SVDShaperDigit!");
63 B2FATAL(
"OOPS, we can't continue, you have to set the trigger bin!");
75 time = time / sumAmplitudes;
87 auto begin = selectedSamples.begin();
88 const auto end = selectedSamples.end();
90 auto retval = 0., norm = 0.;
92 norm +=
static_cast<double>(*begin);
93 retval +=
static_cast<double>(*begin) * step;
95 float rawtime = retval / norm;
98 B2FATAL(
"OOPS, we can't continue, you have to set the trigger bin!");
118 float noise = std::accumulate(strips.begin(), strips.end(), 0., [](
float sum,
const Belle2::SVD::StripInRawCluster & strip) { return sum + strip.noise; });
122 double rawtimeError = 0;
123 begin = selectedSamples.begin();
124 for (
float i = 0.; begin != end; ++begin, i += 1)
126 rawtimeError =
sqrt(rawtimeError) * noise;
142 float m_ELS3tau = 55;
150 auto begin = selectedSamples.begin();
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));
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);
165 B2FATAL(
"OOPS, we can't continue, you have to set the trigger bin!");
double getCorrectedTimeError(const Belle2::VxdID &sensorID, const bool &isU, const unsigned short &strip, const double &raw_time, const double &raw_timeError, const int &bin) const
Return the error of the CoG cluster time.
double getCorrectedTime(const Belle2::VxdID &sensorID, const bool &isU, const unsigned short &strip, const double &raw_time, const int &bin) const
Return the charge (number of electrons/holes) collected on a specific strip, given the number of ADC ...
double getCorrectedTime(const Belle2::VxdID &sensorID, const bool &isU, const unsigned short &strip, const double &raw_time, const int &bin) const
Return the charge (number of electrons/holes) collected on a specific strip, given the number of ADC ...
double getCorrectedTime(const Belle2::VxdID &sensorID, const bool &isU, const unsigned short &strip, const double &raw_time, const int &bin) const
Return the strip time, given the raw strip time.
float getPeakTime(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
Return the peaking time of the strip.
Class representing a raw cluster candidate during clustering of the SVD.
const std::vector< StripInRawCluster > getStripsInRawCluster() const
Belle2::SVDShaperDigit::APVFloatSamples getClsSamples(bool inElectrons) const
VxdID getSensorID() const
void applyELS3Time(const Belle2::SVD::RawCluster &rawCluster, double &time, double &timeError, int &firstFrame)
ELS3 Time Algorithm.
void applyCoG6Time(const Belle2::SVD::RawCluster &rawCluster, double &time, double &timeError, int &firstFrame)
CoG6 Time Algorithm.
SVD3SampleCoGTimeCalibrations m_CoG3TimeCal
CoG3 time calibration wrapper.
SVDCoGTimeCalibrations m_CoG6TimeCal
CoG6 time calibration wrapper.
SVDPulseShapeCalibrations m_PulseShapeCal
SVDPulseShaper calibration wrapper.
void applyCoG3Time(const Belle2::SVD::RawCluster &rawCluster, double &time, double &timeError, int &firstFrame)
CoG3 Time Algorithm.
SVD3SampleELSTimeCalibrations m_ELS3TimeCal
ELS3 time calibration wrapper.
int m_triggerBin
trigger bin
double m_apvClockPeriod
APV clock period.
bool m_returnRawClusterTime
to be used for time calibration
Class implementing the MaxSum algorithm.
std::vector< float > getSelectedSamples()
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.
structure containing the relevant informations of each strip of the raw cluster
Belle2::SVDShaperDigit::APVFloatSamples samples
ADC of the acquired samples.
int maxSample
ADC max of the acquired samples.