22 : mergeTimePeaks_(iConfig.getParameter<
bool>(
"mergeTimePeaks")),
23 baselinePoints_(iConfig.getParameter<
int>(
"baselinePoints")),
24 saturationLimit_(iConfig.getParameter<double>(
"saturationLimit")),
25 cfdFraction_(iConfig.getParameter<double>(
"cfdFraction")),
26 smoothingPoints_(iConfig.getParameter<
int>(
"smoothingPoints")),
27 lowPassFrequency_(iConfig.getParameter<double>(
"lowPassFrequency")),
28 hysteresis_(iConfig.getParameter<double>(
"hysteresis")),
29 sampicOffset_(iConfig.getParameter<double>(
"sampicOffset")),
30 sampicSamplingPeriodNs_(iConfig.getParameter<double>(
"sampicSamplingPeriodNs")) {}
43 for (
const auto& vec :
input) {
46 float x_pos = 0.f, y_pos = 0.f, z_pos = 0.f;
47 float x_width = 0.f, y_width = 0.f, z_width = 0.f;
59 y_width = 2.0 * diamondDimensions.yHalfWidth;
60 z_width = 2.0 * diamondDimensions.zHalfWidth;
62 throw cms::Exception(
"TotemTimingRecHitProducerAlgorithm") <<
"Failed to retrieve a sensor for " << detid;
65 throw cms::Exception(
"TotemTimingRecHitProducerAlgorithm") <<
"No timing conversion retrieved.";
69 for (
const auto& digi : vec) {
75 auto [min_it, max_it] = std::minmax_element(
data.begin(),
data.end());
77 if (det->
name() ==
"CTPPS_Diamond_Segment") {
79 for (
unsigned int i = 0;
i <
data.size(); ++
i)
85 std::vector<float> dataCorrected(
data.size());
86 for (
unsigned int i = 0;
i <
data.size(); ++
i)
87 dataCorrected[
i] =
data[
i] - (baselineRegression.
q + baselineRegression.
m *
time[
i]);
89 auto max_corrected_it = std::max_element(dataCorrected.begin(), dataCorrected.end());
107 triggerCellTimeInstant,
110 baselineRegression.
rms,
119 const std::vector<float>&
time,
120 const std::vector<float>&
data,
121 const unsigned int start_at,
122 const unsigned int points)
const {
126 if (start_at >
time.size())
129 unsigned int realPoints = stop_at - start_at;
135 const float sx = std::accumulate(t_begin, t_end, 0.);
136 const float sxx = std::inner_product(t_begin, t_end, t_begin, 0.);
137 const float sy = std::accumulate(d_begin, d_end, 0.);
140 for (
unsigned int i = 0;
i < realPoints; ++
i)
144 results.m = (sxy * realPoints -
sx *
sy) / (sxx * realPoints -
sx *
sx);
147 float correctedSyy = 0.;
148 for (
unsigned int i = 0;
i < realPoints; ++
i)
158 int threholdCrossingIndex = -1;
160 bool lockForHysteresis =
false;
162 for (
unsigned int i = 0;
i <
data.size(); ++
i) {
165 threholdCrossingIndex =
i;
167 lockForHysteresis =
true;
169 if (above && lockForHysteresis)
174 lockForHysteresis =
false;
178 lockForHysteresis =
false;
179 threholdCrossingIndex = -1;
184 return threholdCrossingIndex;
188 const std::vector<float>&
data) {
189 std::vector<float> dataProcessed(
data);
191 for (
unsigned short i = 0;
i <
data.size(); ++
i)
193 if ((
i +
j) >= 0 && (
i +
j) <
data.size() &&
j != 0) {
197 auto max_it = std::max_element(dataProcessed.begin(), dataProcessed.end());
204 return (indexOfThresholdCrossing >= 1 && indexOfThresholdCrossing >=
baselinePoints_ &&
205 indexOfThresholdCrossing < (
int)
time.size())
206 ? (
time[indexOfThresholdCrossing - 1] -
time[indexOfThresholdCrossing]) /
207 (dataProcessed[indexOfThresholdCrossing - 1] - dataProcessed[indexOfThresholdCrossing]) *
208 (
threshold - dataProcessed[indexOfThresholdCrossing]) +
209 time[indexOfThresholdCrossing]
const Translation & translation() const
Sin< T >::type sin(const T &t)
static std::string const input
static constexpr float SINC_COEFFICIENT
RegressionResults simplifiedLinearRegression(const std::vector< float > &time, const std::vector< float > &data, const unsigned int start_at, const unsigned int points) const
float parentZPosition() const
decltype(auto) emplace_back(Args &&... args)
float constantFractionDiscriminator(const std::vector< float > &time, const std::vector< float > &data)
double sampicSamplingPeriodNs_
TotemTimingRecHitProducerAlgorithm(const edm::ParameterSet &conf)
const DiamondDimensions & getDiamondDimensions() const
void build(const CTPPSGeometry &, const edm::DetSetVector< TotemTimingDigi > &, edm::DetSetVector< TotemTimingRecHit > &)
The manager class for TOTEM RP geometry.
const std::string & name() const
Base class for CTPPS detector IDs.
std::unique_ptr< TotemTimingConversions > sampicConversions_
void setCalibration(const PPSTimingCalibration &)
char data[epos_bytes_allocation]
TotemTimingRecHit::TimingAlgorithm mode_
Power< A, B >::type pow(const A &a, const B &b)
int fastDiscriminator(const std::vector< float > &data, float threshold) const