21 : mergeTimePeaks_(iConfig.getParameter<
bool>(
"mergeTimePeaks")),
22 baselinePoints_(iConfig.getParameter<
int>(
"baselinePoints")),
23 saturationLimit_(iConfig.getParameter<double>(
"saturationLimit")),
24 cfdFraction_(iConfig.getParameter<double>(
"cfdFraction")),
25 smoothingPoints_(iConfig.getParameter<
int>(
"smoothingPoints")),
26 lowPassFrequency_(iConfig.getParameter<double>(
"lowPassFrequency")),
27 hysteresis_(iConfig.getParameter<double>(
"hysteresis")) {}
40 for (
const auto& vec :
input) {
43 float x_pos = 0.f, y_pos = 0.f, z_pos = 0.f;
44 float x_width = 0.f, y_width = 0.f, z_width = 0.f;
56 y_width = 2.0 * diamondDimensions.yHalfWidth;
57 z_width = 2.0 * diamondDimensions.zHalfWidth;
59 throw cms::Exception(
"TotemTimingRecHitProducerAlgorithm") <<
"Failed to retrieve a sensor for " << detid;
62 throw cms::Exception(
"TotemTimingRecHitProducerAlgorithm") <<
"No timing conversion retrieved.";
66 for (
const auto& digi : vec) {
72 auto max_it = std::max_element(
data.begin(),
data.end());
77 std::vector<float> dataCorrected(
data.size());
78 for (
unsigned int i = 0;
i <
data.size(); ++
i)
79 dataCorrected[
i] =
data[
i] - (baselineRegression.q + baselineRegression.m *
time[
i]);
80 auto max_corrected_it = std::max_element(dataCorrected.begin(), dataCorrected.end());
95 triggerCellTimeInstant,
98 baselineRegression.rms,
107 const std::vector<float>&
time,
108 const std::vector<float>&
data,
109 const unsigned int start_at,
110 const unsigned int points)
const {
114 if (start_at >
time.size())
117 unsigned int realPoints = stop_at - start_at;
123 const float sx = std::accumulate(t_begin, t_end, 0.);
124 const float sxx = std::inner_product(t_begin, t_end, t_begin, 0.);
125 const float sy = std::accumulate(d_begin, d_end, 0.);
128 for (
unsigned int i = 0;
i < realPoints; ++
i)
132 results.m = (sxy * realPoints -
sx *
sy) / (sxx * realPoints -
sx *
sx);
135 float correctedSyy = 0.;
136 for (
unsigned int i = 0;
i < realPoints; ++
i)
146 int threholdCrossingIndex = -1;
148 bool lockForHysteresis =
false;
150 for (
unsigned int i = 0;
i <
data.size(); ++
i) {
153 threholdCrossingIndex =
i;
155 lockForHysteresis =
true;
157 if (above && lockForHysteresis)
162 lockForHysteresis =
false;
166 lockForHysteresis =
false;
167 threholdCrossingIndex = -1;
172 return threholdCrossingIndex;
176 const std::vector<float>&
data) {
177 std::vector<float> dataProcessed(
data);
179 for (
unsigned short i = 0;
i <
data.size(); ++
i)
181 if ((
i +
j) >= 0 && (
i +
j) <
data.size() &&
j != 0) {
185 auto max_it = std::max_element(dataProcessed.begin(), dataProcessed.end());
192 return (indexOfThresholdCrossing >= 1 && indexOfThresholdCrossing >=
baselinePoints_ &&
193 indexOfThresholdCrossing < (
int)
time.size())
194 ? (
time[indexOfThresholdCrossing - 1] -
time[indexOfThresholdCrossing]) /
195 (dataProcessed[indexOfThresholdCrossing - 1] - dataProcessed[indexOfThresholdCrossing]) *
196 (
threshold - dataProcessed[indexOfThresholdCrossing]) +
197 time[indexOfThresholdCrossing]