21 : sampicConversions_(iConfig.getParameter<
std::
string>(
"calibrationFile")),
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")) {}
32 for (
const auto &vec : input) {
35 float x_pos = 0.0f, y_pos = 0.0f, z_pos = 0.0f, x_width = 0.0f, y_width = 0.0f,
45 x_width = 2.0 * det->
params()[0],
46 y_width = 2.0 * det->
params()[1],
47 z_width = 2.0 * det->
params()[2];
50 <<
"Failed to retrieve a sensor for " << detid;
54 for (
const auto &digi : vec) {
55 const float triggerCellTimeInstant(
60 auto max_it = std::max_element(
data.begin(),
data.end());
66 std::vector<float> dataCorrected(
data.size());
67 for (
unsigned int i = 0;
i <
data.size(); ++
i)
68 dataCorrected[
i] =
data[
i] -
69 (baselineRegression.q + baselineRegression.m *
time[
i]);
70 auto max_corrected_it =
71 std::max_element(dataCorrected.begin(), dataCorrected.end());
80 x_pos, x_width, y_pos, y_width, z_pos, z_width,
81 t, triggerCellTimeInstant, .0, *max_corrected_it,
82 baselineRegression.rms,
mode_));
89 const std::vector<float> &
time,
const std::vector<float> &
data,
90 const unsigned int start_at,
const unsigned int points)
const {
92 if (time.size() != data.size()) {
95 if (start_at > time.size()) {
98 unsigned int stop_at =
std::min((
unsigned int)time.size(), start_at +
points);
99 unsigned int realPoints = stop_at - start_at;
100 auto t_begin =
std::next(time.begin(), start_at);
101 auto t_end =
std::next(time.begin(), stop_at);
102 auto d_begin =
std::next(data.begin(), start_at);
103 auto d_end =
std::next(data.begin(), stop_at);
106 std::for_each(t_begin, t_end, [&](
float value) { sx +=
value; });
108 std::for_each(t_begin, t_end, [&](
float value) { sxx += value *
value; });
111 std::for_each(d_begin, d_end, [&](
float value) { sy +=
value; });
113 std::for_each(d_begin, d_end, [&](
float value) { syy += value *
value; });
116 for (
unsigned int i = 0;
i < realPoints; ++
i)
117 sxy += (time[
i]) * (data[
i]);
120 results.
m = (sxy * realPoints - sx *
sy) / (sxx * realPoints - sx * sx);
121 results.
q = sy / realPoints - results.
m * sx / realPoints;
123 float correctedSyy = .0f;
124 for (
unsigned int i = 0; i < realPoints; ++
i)
125 correctedSyy +=
pow(data[i] - (results.
m * time[i] + results.
q), 2);
126 results.
rms =
sqrt(correctedSyy / realPoints);
132 const std::vector<float> &
data,
const float &
threshold)
const {
133 int threholdCrossingIndex = -1;
135 bool lockForHysteresis =
false;
137 for (
unsigned int i = 0;
i < data.size(); ++
i) {
139 if (!above && !lockForHysteresis && data[
i] > threshold) {
140 threholdCrossingIndex =
i;
142 lockForHysteresis =
true;
144 if (above && lockForHysteresis)
148 if (lockForHysteresis && data[
i] > threshold +
hysteresis_) {
149 lockForHysteresis =
false;
152 if (lockForHysteresis && data[
i] < threshold) {
154 lockForHysteresis =
false;
155 threholdCrossingIndex = -1;
160 return threholdCrossingIndex;
164 const std::vector<float> &
time,
const std::vector<float> &
data) {
165 std::vector<float> dataProcessed(data);
168 for (
int i = 0;
i < (
int)data.size(); ++
i) {
171 if ((
i + j) >= 0 && (
i + j) < (
int)data.size() && j != 0) {
178 auto max_it = std::max_element(dataProcessed.begin(), dataProcessed.end());
186 indexOfThresholdCrossing < (
int)time.size()) {
187 t = (time[indexOfThresholdCrossing - 1] -
188 time[indexOfThresholdCrossing]) /
189 (dataProcessed[indexOfThresholdCrossing - 1] -
190 dataProcessed[indexOfThresholdCrossing]) *
191 (threshold - dataProcessed[indexOfThresholdCrossing]) +
192 time[indexOfThresholdCrossing];
Translation translation() const
TotemTimingConversions sampicConversions_
void push_back(const T &t)
std::vector< float > getTimeSamples(const TotemTimingDigi &digi) const
const DetGeomDesc * getSensorNoThrow(unsigned int id) const
std::vector< float > getVoltSamples(const TotemTimingDigi &digi) const
Sin< T >::type sin(const T &t)
static const float SINC_COEFFICIENT
const float getTriggerTime(const TotemTimingDigi &digi) const
static std::string const input
reference find_or_insert(det_id_type id)
float constantFractionDiscriminator(const std::vector< float > &time, const std::vector< float > &data)
Geometrical description of a sensor.
TotemTimingRecHitProducerAlgorithm(const edm::ParameterSet &conf)
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
char data[epos_bytes_allocation]
std::vector< double > params() const
TotemTimingRecHit::TimingAlgorithm mode_
void build(const CTPPSGeometry *, const edm::DetSetVector< TotemTimingDigi > &, edm::DetSetVector< TotemTimingRecHit > &)
int fastDiscriminator(const std::vector< float > &data, const float &threshold) const
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 ...