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.;
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) {
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;
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];
133 for (
int i = 0;
i < interpPulseShifted.size(); ++
i) {
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);
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
const float targetTimePrecision_
static constexpr int TIME_WHEN_NOT_CONVERGING
static constexpr int MAX_NUM_OF_ITERATIONS
EcalMGPASample sample(int i) const
static constexpr double Samp_Period
float computeCC(const std::vector< float > &samples, const FullSampleVector &sigmalTemplate, const float t) const
float gain12Over6() 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)
static std::atomic< unsigned int > counter
static unsigned int const shift
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
static constexpr int MAXSAMPLES
FullSampleVector interpolatePulse(const FullSampleVector &fullpulse, const float t=0) const
Power< A, B >::type pow(const A &a, const B &b)
EcalUncalibRecHitTimingCCAlgo(const float startTime, const float stopTime, const float targetTimePrecision)