9#include <framework/logging/Logger.h>
10#include <framework/utilities/MathHelpers.h>
11#include <svd/reconstruction/SVDClusterTime.h>
12#include <svd/reconstruction/SVDMaxSumAlgorithm.h>
39 float sumAmplitudes = 0;
41 for (
int i = 0; i < (int)strips.size(); i++) {
46 float stripSumAmplitudes = 0;
48 for (
int k = 0; k < 6; k ++) {
49 stripTime += k * strip.
samples[k];
50 stripSumAmplitudes += strip.
samples[k];
52 if (stripSumAmplitudes != 0) {
53 stripTime /= (stripSumAmplitudes);
57 B2WARNING(
"Trying to divide by 0 (ZERO)! Sum of amplitudes is nullptr! Skipping this SVDShaperDigit!");
64 B2FATAL(
"OOPS, we can't continue, you have to set the trigger bin!");
76 time = time / sumAmplitudes;
88 auto begin = selectedSamples.begin();
89 const auto end = selectedSamples.end();
91 auto retval = 0., norm = 0.;
93 norm +=
static_cast<double>(*begin);
94 retval +=
static_cast<double>(*begin) * step;
96 float rawtime = retval / norm;
99 B2FATAL(
"OOPS, we can't continue, you have to set the trigger bin!");
119 float noise = std::accumulate(strips.begin(), strips.end(), 0., [](
float sum,
const Belle2::SVD::StripInRawCluster & strip) { return sum + strip.noise; });
123 double rawtimeError = 0;
124 begin = selectedSamples.begin();
125 for (
float i = 0.; begin != end; ++begin, i += 1)
127 rawtimeError =
sqrt(rawtimeError) * noise;
143 float m_ELS3tau = 55;
151 auto begin = selectedSamples.begin();
153 const double E2 =
E *
E;
154 const double E4 = E2 * E2;
155 double a0 = (*begin);
156 double a1 = (*(begin + 1));
157 double a2 = (*(begin + 2));
160 const double w = (a0 - E2 * a2) / (2 * a0 +
E * a1);
161 auto rawtime_num = 2 * E4 + w * E2;
162 auto rawtime_den = 1 - E4 - w * (2 + E2);
166 B2FATAL(
"OOPS, we can't continue, you have to set the trigger bin!");
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()
constexpr T square(const T &x)
Calculate the square of the input.
double sqrt(double a)
sqrt for double
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Abstract base class for different kinds of events.
structure containing the relevant information of each strip of the raw cluster
Belle2::SVDShaperDigit::APVFloatSamples samples
ADC of the acquired samples.
int maxSample
ADC max of the acquired samples.