20 : sampicConversions_(iConfig.getParameter<
std::
string>(
"calibrationFile")),
21 baselinePoints_(iConfig.getParameter<
int>(
"baselinePoints")),
22 saturationLimit_(iConfig.getParameter<double>(
"saturationLimit")),
23 cfdFraction_(iConfig.getParameter<double>(
"cfdFraction")),
24 smoothingPoints_(iConfig.getParameter<
int>(
"smoothingPoints")),
25 lowPassFrequency_(iConfig.getParameter<double>(
"lowPassFrequency")),
26 hysteresis_(iConfig.getParameter<double>(
"hysteresis")) {}
31 for (
const auto &vec : input) {
34 float x_pos = 0, y_pos = 0, z_pos = 0, x_width = 0, y_width = 0,
44 <<
"The geometry element for " << detid
45 <<
" has no parents. Check the geometry hierarchy!";
51 x_width = 2.0 * det->
params().at(0),
52 y_width = 2.0 * det->
params().at(1),
53 z_width = 2.0 * det->
params().at(2);
56 <<
"Failed to retrieve a sensor for " << detid;
60 for (
const auto &digi : vec) {
61 const float triggerCellTimeInstant(
66 auto max_it = std::max_element(
data.begin(),
data.end());
72 std::vector<float> dataCorrected(
data.size());
73 for (
unsigned int i = 0;
i <
data.size(); ++
i)
74 dataCorrected.at(
i) =
data.at(
i) -
75 (baselineRegression.q + baselineRegression.m *
time.at(
i));
76 auto max_corrected_it =
77 std::max_element(dataCorrected.begin(), dataCorrected.end());
86 x_pos, x_width, y_pos, y_width, z_pos, z_width,
87 t, triggerCellTimeInstant, .0, *max_corrected_it,
88 baselineRegression.rms,
mode_));
95 const std::vector<float> &
time,
const std::vector<float> &
data,
96 const unsigned int start_at,
const unsigned int points)
const {
98 if (time.size() != data.size()) {
101 if (start_at > time.size()) {
104 unsigned int stop_at =
std::min((
unsigned int)time.size(), start_at +
points);
105 unsigned int realPoints = stop_at - start_at;
106 auto t_begin =
std::next(time.begin(), start_at);
107 auto t_end =
std::next(time.begin(), stop_at);
108 auto d_begin =
std::next(data.begin(), start_at);
109 auto d_end =
std::next(data.begin(), stop_at);
112 std::for_each(t_begin, t_end, [&](
float value) { sx +=
value; });
114 std::for_each(t_begin, t_end, [&](
float value) { sxx += value *
value; });
117 std::for_each(d_begin, d_end, [&](
float value) { sy +=
value; });
119 std::for_each(d_begin, d_end, [&](
float value) { syy += value *
value; });
122 for (
unsigned int i = 0;
i < realPoints; ++
i)
123 sxy += (time.at(
i)) * (data.at(
i));
126 results.
m = (sxy * realPoints - sx *
sy) / (sxx * realPoints - sx * sx);
127 results.
q = sy / realPoints - results.
m * sx / realPoints;
129 float correctedSyy = .0;
130 for (
unsigned int i = 0;
i < realPoints; ++
i)
131 correctedSyy +=
pow(data.at(
i) - (results.
m * time.at(
i) + results.
q), 2);
132 results.
rms =
sqrt(correctedSyy / realPoints);
138 const std::vector<float> &
data,
const float &
threshold)
const {
139 int threholdCrossingIndex = -1;
141 bool lockForHysteresis =
false;
143 for (
unsigned int i = 0;
i < data.size(); ++
i) {
145 if (!above && !lockForHysteresis && data.at(
i) >
threshold) {
146 threholdCrossingIndex =
i;
148 lockForHysteresis =
true;
150 if (above && lockForHysteresis)
154 if (lockForHysteresis && data.at(
i) > threshold +
hysteresis_) {
155 lockForHysteresis =
false;
158 if (lockForHysteresis && data.at(
i) <
threshold) {
160 lockForHysteresis =
false;
161 threholdCrossingIndex = -1;
166 return threholdCrossingIndex;
170 const std::vector<float> &
time,
const std::vector<float> &
data) {
171 std::vector<float> dataProcessed(data);
174 for (
int i = 0;
i < (
int)data.size(); ++
i) {
177 if ((
i + j) >= 0 && (
i + j) < (
int)data.size() && j != 0) {
179 dataProcessed.at(
i) += data.at(
i + j) *
std::sin(x) /
x;
184 auto max_it = std::max_element(dataProcessed.begin(), dataProcessed.end());
192 indexOfThresholdCrossing < (
int)time.size()) {
193 t = (time.at(indexOfThresholdCrossing - 1) -
194 time.at(indexOfThresholdCrossing)) /
195 (dataProcessed.at(indexOfThresholdCrossing - 1) -
196 dataProcessed.at(indexOfThresholdCrossing)) *
197 (threshold - dataProcessed.at(indexOfThresholdCrossing)) +
198 time.at(indexOfThresholdCrossing);
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.
virtual std::vector< DDExpandedNode > parents() const
returns all the components below
DDTranslation translation() const
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.
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 ...