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,
49 <<
"The geometry element for " << detid
50 <<
" has no parents. Check the geometry hierarchy!";
56 x_width = 2.0 * det->
params().at(0),
57 y_width = 2.0 * det->
params().at(1),
58 z_width = 2.0 * det->
params().at(2);
61 <<
"Failed to retrieve a sensor for " << detid;
65 for (
const auto &digi : vec) {
66 const float triggerCellTimeInstant(
71 auto max_it = std::max_element(
data.begin(),
data.end());
77 std::vector<float> dataCorrected(
data.size());
78 for (
unsigned int i = 0;
i <
data.size(); ++
i)
79 dataCorrected.at(
i) =
data.at(
i) -
80 (baselineRegression.q + baselineRegression.m *
time.at(
i));
81 auto max_corrected_it =
82 std::max_element(dataCorrected.begin(), dataCorrected.end());
91 x_pos, x_width, y_pos, y_width, z_pos, z_width,
92 t, triggerCellTimeInstant, .0, *max_corrected_it,
93 baselineRegression.rms,
mode_));
100 const std::vector<float> &
time,
const std::vector<float> &
data,
101 const unsigned int start_at,
const unsigned int points)
const {
103 if (time.size() != data.size()) {
106 if (start_at > time.size()) {
109 unsigned int stop_at =
std::min((
unsigned int)time.size(), start_at +
points);
110 unsigned int realPoints = stop_at - start_at;
111 auto t_begin =
std::next(time.begin(), start_at);
112 auto t_end =
std::next(time.begin(), stop_at);
113 auto d_begin =
std::next(data.begin(), start_at);
114 auto d_end =
std::next(data.begin(), stop_at);
117 std::for_each(t_begin, t_end, [&](
float value) { sx +=
value; });
119 std::for_each(t_begin, t_end, [&](
float value) { sxx += value *
value; });
122 std::for_each(d_begin, d_end, [&](
float value) { sy +=
value; });
124 std::for_each(d_begin, d_end, [&](
float value) { syy += value *
value; });
127 for (
unsigned int i = 0;
i < realPoints; ++
i)
128 sxy += (time.at(
i)) * (data.at(
i));
131 results.
m = (sxy * realPoints - sx *
sy) / (sxx * realPoints - sx * sx);
132 results.
q = sy / realPoints - results.
m * sx / realPoints;
134 float correctedSyy = .0;
135 for (
unsigned int i = 0;
i < realPoints; ++
i)
136 correctedSyy +=
pow(data.at(
i) - (results.
m * time.at(
i) + results.
q), 2);
137 results.
rms =
sqrt(correctedSyy / realPoints);
143 const std::vector<float> &
data,
const float &
threshold)
const {
144 int threholdCrossingIndex = -1;
146 bool lockForHysteresis =
false;
148 for (
unsigned int i = 0;
i < data.size(); ++
i) {
150 if (!above && !lockForHysteresis && data.at(
i) >
threshold) {
151 threholdCrossingIndex =
i;
153 lockForHysteresis =
true;
155 if (above && lockForHysteresis)
159 if (lockForHysteresis && data.at(
i) > threshold +
hysteresis_) {
160 lockForHysteresis =
false;
163 if (lockForHysteresis && data.at(
i) <
threshold) {
165 lockForHysteresis =
false;
166 threholdCrossingIndex = -1;
171 return threholdCrossingIndex;
175 const std::vector<float> &
time,
const std::vector<float> &
data) {
176 std::vector<float> dataProcessed(data);
179 for (
int i = 0;
i < (
int)data.size(); ++
i) {
182 if ((
i + j) >= 0 && (
i + j) < (
int)data.size() && j != 0) {
184 dataProcessed.at(
i) += data.at(
i + j) *
std::sin(x) /
x;
189 auto max_it = std::max_element(dataProcessed.begin(), dataProcessed.end());
197 indexOfThresholdCrossing < (
int)time.size()) {
198 t = (time.at(indexOfThresholdCrossing - 1) -
199 time.at(indexOfThresholdCrossing)) /
200 (dataProcessed.at(indexOfThresholdCrossing - 1) -
201 dataProcessed.at(indexOfThresholdCrossing)) *
202 (threshold - dataProcessed.at(indexOfThresholdCrossing)) +
203 time.at(indexOfThresholdCrossing);
TotemTimingConversions sampicConversions_
void push_back(const T &t)
std::vector< float > getTimeSamples(const TotemTimingDigi &digi) 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)
const DetGeomDesc * getSensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
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 ...