5 const float targetTimePrecision)
6 : startTime_(startTime), stopTime_(stopTime), targetTimePrecision_(targetTimePrecision) {}
9 const std::vector<double>& amplitudes,
14 float& errOnTime)
const {
20 std::vector<float> pedSubSamples(nsample);
21 for (
unsigned int iSample = 0; iSample < nsample; iSample++) {
28 double gainratio = 1.;
30 if (gainId == 0 || gainId == 3) {
31 pedestal = aped->mean_x1;
33 }
else if (gainId == 1) {
34 pedestal = aped->mean_x12;
36 }
else if (gainId == 2) {
37 pedestal = aped->mean_x6;
41 amplitude = (
static_cast<float>(sample.
adc()) - pedestal) * gainratio;
45 amplitude = (4095. -
pedestal) * gainratio;
48 pedSubSamples[iSample] = amplitude;
50 if (amplitude > maxamplitude) {
51 maxamplitude = amplitude;
53 pulsenorm += fullpulse(iSample);
57 for (
auto const& amplit : amplitudes) {
59 int bxp3 = ipulse - 2;
60 int firstsamplet =
std::max(0, bxp3);
63 for (
unsigned int isample = firstsamplet; isample < nsample; ++isample) {
64 auto const pulse = fullpulse(isample + offset);
65 pedSubSamples[isample] =
std::max(0., pedSubSamples[isample] - amplit *
pulse / pulsenorm);
72 float tM = (tStart + tStop) / 2;
74 float distStart, distStop;
79 distStart =
computeCC(pedSubSamples, fullpulse, tStart);
80 distStop =
computeCC(pedSubSamples, fullpulse, tStop);
82 if (distStart > distStop) {
87 tM = (tStart + tStop) / 2;
104 const float time)
const {
114 auto facM1orP2 = 0.25 * tt * (tt - 1);
115 auto fac = (0.25 * (tt - 2) - 0.5 * (tt + 1)) * (tt - 1);
116 auto facP1 = (0.25 * (tt + 1) - 0.5 * (tt - 2)) * tt;
117 for (
unsigned int i = 1;
i < numberOfSamples - 2; ++
i) {
119 facM1orP2 * fullpulse[
i - 1] + fac * fullpulse[
i] + facP1 * fullpulse[
i + 1] + facM1orP2 * fullpulse[
i + 2];
125 interpPulse[0] = facM1orP2 * fullpulse[0] + facP1 * fullpulse[1] + facM1orP2 * fullpulse[2];
126 interpPulse[numberOfSamples - 2] = facM1orP2 * fullpulse[numberOfSamples - 3] + fac * fullpulse[numberOfSamples - 2] +
127 facP1 * fullpulse[numberOfSamples - 1];
128 interpPulse[numberOfSamples - 1] = 2 * facM1orP2 * fullpulse[numberOfSamples - 2] -
129 4 * facM1orP2 * fullpulse[numberOfSamples - 1] +
130 facP1 * fullpulse[numberOfSamples - 1];
133 for (
int i = 0;
i < interpPulseShifted.size(); ++
i) {
134 if (
i + shift >= 0 &&
i + shift < interpPulse.size())
135 interpPulseShifted[
i] = interpPulse[
i + shift];
137 interpPulseShifted[
i] = 0;
139 return interpPulseShifted;
144 const float time)
const {
145 constexpr
int exclude = 1;
146 float powerSamples = 0.;
147 float powerTemplate = 0.;
150 for (
int i = exclude;
i < int(samples.size() - exclude); ++
i) {
152 powerTemplate +=
std::pow(interpolated[i], 2);
153 cc += interpolated[
i] * samples[
i];
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
EcalMGPASample sample(int i) const
const float targetTimePrecision_
FullSampleVector interpolatePulse(const FullSampleVector &fullpulse, const float t=0) const
int gainId() const
get the gainId (2 bits)
static constexpr int TIME_WHEN_NOT_CONVERGING
static constexpr int MAX_NUM_OF_ITERATIONS
static constexpr double Samp_Period
float computeCC(const std::vector< float > &samples, const FullSampleVector &sigmalTemplate, const float t) const
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
static constexpr float GLOBAL_TIME_SHIFT
double pulse(double x, double y, double z, double t)
double computeTimeCC(const EcalDataFrame &dataFrame, const std::vector< double > &litudes, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const FullSampleVector &fullpulse, EcalUncalibratedRecHit &uncalibRecHit, float &errOnTime) const
float gain12Over6() const
static std::atomic< unsigned int > counter
static unsigned int const shift
static constexpr int MAXSAMPLES
Power< A, B >::type pow(const A &a, const B &b)
EcalUncalibRecHitTimingCCAlgo(const float startTime, const float stopTime, const float targetTimePrecision)
int adc() const
get the ADC sample (12 bits)