19 : mergeTimePeaks_(iConfig.getParameter<
bool>(
"mergeTimePeaks")),
20 baselinePoints_(iConfig.getParameter<
int>(
"baselinePoints")),
21 saturationLimit_(iConfig.getParameter<double>(
"saturationLimit")),
22 cfdFraction_(iConfig.getParameter<double>(
"cfdFraction")),
23 smoothingPoints_(iConfig.getParameter<
int>(
"smoothingPoints")),
24 lowPassFrequency_(iConfig.getParameter<double>(
"lowPassFrequency")),
25 hysteresis_(iConfig.getParameter<double>(
"hysteresis")) {}
38 for (
const auto& vec :
input) {
41 float x_pos = 0.f, y_pos = 0.f, z_pos = 0.f;
42 float x_width = 0.f, y_width = 0.f, z_width = 0.f;
52 x_width = 2.0 * det->
params()[0],
53 y_width = 2.0 * det->
params()[1], z_width = 2.0 * det->
params()[2];
55 throw cms::Exception(
"TotemTimingRecHitProducerAlgorithm") <<
"Failed to retrieve a sensor for " << detid;
58 throw cms::Exception(
"TotemTimingRecHitProducerAlgorithm") <<
"No timing conversion retrieved.";
62 for (
const auto& digi : vec) {
68 auto max_it = std::max_element(
data.begin(),
data.end());
73 std::vector<float> dataCorrected(
data.size());
74 for (
unsigned int i = 0;
i <
data.size(); ++
i)
75 dataCorrected[
i] =
data[
i] - (baselineRegression.q + baselineRegression.m *
time[
i]);
76 auto max_corrected_it = std::max_element(dataCorrected.begin(), dataCorrected.end());
91 triggerCellTimeInstant,
94 baselineRegression.rms,
103 const std::vector<float>&
time,
104 const std::vector<float>&
data,
105 const unsigned int start_at,
106 const unsigned int points)
const {
110 if (start_at >
time.size())
113 unsigned int realPoints = stop_at - start_at;
119 const float sx = std::accumulate(t_begin, t_end, 0.);
120 const float sxx = std::inner_product(t_begin, t_end, t_begin, 0.);
121 const float sy = std::accumulate(d_begin, d_end, 0.);
124 for (
unsigned int i = 0;
i < realPoints; ++
i)
128 results.m = (sxy * realPoints -
sx *
sy) / (sxx * realPoints -
sx *
sx);
131 float correctedSyy = 0.;
132 for (
unsigned int i = 0;
i < realPoints; ++
i)
142 int threholdCrossingIndex = -1;
144 bool lockForHysteresis =
false;
146 for (
unsigned int i = 0;
i <
data.size(); ++
i) {
149 threholdCrossingIndex =
i;
151 lockForHysteresis =
true;
153 if (above && lockForHysteresis)
158 lockForHysteresis =
false;
162 lockForHysteresis =
false;
163 threholdCrossingIndex = -1;
168 return threholdCrossingIndex;
172 const std::vector<float>&
data) {
173 std::vector<float> dataProcessed(
data);
175 for (
unsigned short i = 0;
i <
data.size(); ++
i)
177 if ((
i +
j) >= 0 && (
i +
j) <
data.size() &&
j != 0) {
181 auto max_it = std::max_element(dataProcessed.begin(), dataProcessed.end());
188 return (indexOfThresholdCrossing >= 1 && indexOfThresholdCrossing >=
baselinePoints_ &&
189 indexOfThresholdCrossing < (
int)
time.size())
190 ? (
time[indexOfThresholdCrossing - 1] -
time[indexOfThresholdCrossing]) /
191 (dataProcessed[indexOfThresholdCrossing - 1] - dataProcessed[indexOfThresholdCrossing]) *
192 (
threshold - dataProcessed[indexOfThresholdCrossing]) +
193 time[indexOfThresholdCrossing]