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"))
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;
57 x_width = 2.0 * det->
params()[0],
58 y_width = 2.0 * det->
params()[1],
59 z_width = 2.0 * det->
params()[2];
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 max_it = std::max_element(
data.begin(),
data.end());
81 std::vector<float> dataCorrected(
data.size());
82 for (
unsigned int i = 0;
i <
data.size(); ++
i)
83 dataCorrected[
i] =
data[
i] - (baselineRegression.q + baselineRegression.m *
time[
i]);
84 auto max_corrected_it =
85 std::max_element(dataCorrected.begin(), dataCorrected.end());
94 x_pos, x_width, y_pos, y_width, z_pos, z_width,
95 t, triggerCellTimeInstant, timePrecision, *max_corrected_it,
96 baselineRegression.rms,
mode_));
105 const unsigned int start_at,
const unsigned int points)
const 108 if (time.size() != data.size())
110 if (start_at > time.size())
112 unsigned int stop_at =
std::min((
unsigned int)time.size(), start_at +
points);
113 unsigned int realPoints = stop_at - start_at;
114 auto t_begin =
std::next(time.begin(), start_at);
115 auto t_end =
std::next(time.begin(), stop_at);
116 auto d_begin =
std::next(data.begin(), start_at);
117 auto d_end =
std::next(data.begin(), stop_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)
125 sxy += time[
i]*data[
i];
128 results.
m = (sxy * realPoints - sx *
sy) / (sxx * realPoints - sx * sx);
129 results.
q = sy / realPoints - results.
m * sx / realPoints;
131 float correctedSyy = 0.;
132 for (
unsigned int i = 0;
i < realPoints; ++
i)
133 correctedSyy +=
pow(data[
i] - (results.
m * time[
i] + results.
q), 2);
134 results.
rms =
sqrt(correctedSyy / realPoints);
144 int threholdCrossingIndex = -1;
146 bool lockForHysteresis =
false;
148 for (
unsigned int i = 0;
i < data.size(); ++
i) {
150 if (!above && !lockForHysteresis && data[
i] > threshold) {
151 threholdCrossingIndex =
i;
153 lockForHysteresis =
true;
155 if (above && lockForHysteresis)
159 if (lockForHysteresis && data[
i] > threshold +
hysteresis_)
160 lockForHysteresis =
false;
162 if (lockForHysteresis && data[
i] < threshold) {
164 lockForHysteresis =
false;
165 threholdCrossingIndex = -1;
170 return threholdCrossingIndex;
176 std::vector<float> dataProcessed(data);
178 for (
unsigned short i = 0;
i < data.size(); ++
i)
180 if ((
i+j) >= 0 && (
i+j) < data.size() && j != 0) {
184 auto max_it = std::max_element(dataProcessed.begin(), dataProcessed.end());
191 return (indexOfThresholdCrossing >= 1
193 && indexOfThresholdCrossing < (
int)time.size())
194 ? (time[indexOfThresholdCrossing-1]-time[indexOfThresholdCrossing])
195 / (dataProcessed[indexOfThresholdCrossing-1] -dataProcessed[indexOfThresholdCrossing]) * (threshold-dataProcessed[indexOfThresholdCrossing])
196 + time[indexOfThresholdCrossing]
Translation translation() const
void push_back(const T &t)
const DetGeomDesc * getSensorNoThrow(unsigned int id) const
Sin< T >::type sin(const T &t)
static std::string const input
reference find_or_insert(det_id_type id)
static float SINC_COEFFICIENT
float constantFractionDiscriminator(const std::vector< float > &time, const std::vector< float > &data)
int fastDiscriminator(const std::vector< float > &data, float threshold) const
Geometrical description of a sensor.
TotemTimingRecHitProducerAlgorithm(const edm::ParameterSet &conf)
void build(const CTPPSGeometry &, const edm::DetSetVector< TotemTimingDigi > &, edm::DetSetVector< TotemTimingRecHit > &)
RegressionResults simplifiedLinearRegression(const std::vector< float > &time, const std::vector< float > &data, const unsigned int start_at, const unsigned int points) const
The manager class for TOTEM RP geometry.
float parentZPosition() const
std::unique_ptr< TotemTimingConversions > sampicConversions_
void setCalibration(const PPSTimingCalibration &)
char data[epos_bytes_allocation]
std::vector< double > params() const
TotemTimingRecHit::TimingAlgorithm mode_
Power< A, B >::type pow(const A &a, const B &b)
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...