10#ifndef _SVD_SIMULATION_SIMULATIONTOOLS_H
11#define _SVD_SIMULATION_SIMULATIONTOOLS_H
18#include <framework/gearbox/Unit.h>
39 typedef std::array<apvSampleBaseType, nAPVSamples>
apvSamples;
63 if (t < 0.0)
return 0.0;
64 else return t * exp(1.0 - t);
75 if (t < 0.0 || t > 1.0)
78 return 6.75 * t * (1.0 - t) * (1.0 - t);
91 return 149.012 * pow(t, 2) * pow(1.0 + t, -10);
117 return (p[0] + p[1] * t) * exp(-p[2] * t) + (p[3] + p[4] * t + p[5] * pow(t, 2) + p[6] * pow(t, 3)) * exp(-p[7] * t);
143 return (p[0] + p[1] * t) * exp(-p[2] * t) + (p[3] + p[4] * t + p[5] * pow(t, 2) + p[6] * pow(t, 3)) * exp(-p[7] * t);
166 [
this, t0, tau](
double t)->double { return m_waveform((t - t0) / tau); }
184 std::replace_if(a.begin(), a.end(), std::bind(std::less<double>(), std::placeholders::_1, thr), 0.0);
195 return (search_n(a.begin(), a.end(), 3, thr, std::greater<double>()) != a.end());
205 inline double tau_raw2real(
double raw_tau) {
return 7.32313 * raw_tau; }
221 double min_tau,
double max_tau):
237 void setBounds(
double min_amplitude,
double max_amplitude,
238 double min_tau,
double max_tau)
263 void print(std::ostringstream& os)
const
265 os <<
"TauEncoder object, "
268 <<
" ATRatio: " <<
m_ATRatio << std::endl;
Encoder/decoder for neural network tau values.
TauEncoder()
Default constructor Parameterless constructor to default-construct the class.
double m_minAmplitude
lower bound of amplitude range
double m_maxTau
upper bound of tau range
double m_ATRatio
ratio of amplitude to tau ranges
double m_minTau
lower bound of tau range
double m_maxAmplitude
upper bound of amplitdue range
void print(std::ostringstream &os) const
print tool
double decodeTau(double scaledTau) const
Scale back a previously scaled tau value.
TauEncoder(double min_amplitude, double max_amplitude, double min_tau, double max_tau)
Constructor takes amplitude and tau ranges, typically from a network xml file.
void setBounds(double min_amplitude, double max_amplitude, double min_tau, double max_tau)
Set encoder baounds (e.g.
double encodeTau(double tau) const
Return encoded value for a waveform width tau value.
Waveform generator This is a functor to calculate APV samples from waveform.
WaveformShape m_waveform
the wave function
apvSamples m_samples
for storage of computed data
void setWaveform(WaveformShape waveform)
Set waveform.
const apvSamples & operator()(double t0, double tau)
Operator () returns 6 APV samples.
WaveGenerator(WaveformShape waveform=w_betaprime)
Constructor takes waveform function.
static const double ns
Standard of [time].
std::array< apvSampleBaseType, nAPVSamples > apvSamples
vector od apvSample BaseType objects
double w_poly3(double t)
Polynomial waveform shape, x.
double tau_raw2real(double raw_tau)
Convert Hao's raw tau (integral, in latency units) to correct betaprime scale.
double w_adjacentU(double t)
Adjacent-channel waveform U-side.
const std::size_t nAPVSamples
Number of APV samples.
double w_betaprime(double t)
Beta-prime waveform shape, x^alpha/(1+x)^beta.
std::function< double(double)> WaveformShape
WaveformShape type.
double w_adjacentV(double t)
Adjacent-channel waveform V-side.
const apvSamples apvTimeBase
APV time base - times for the 6 signals.
double w_expo(double t)
Gamma waveform shape, x.exp(-x) This is only historically useful.
void zeroSuppress(T &a, double thr)
pass zero suppression
double apvSampleBaseType
Vector of input samples in float form.
const double dt_APV
APV sampling time.
bool pass3Samples(const T &a, double thr)
pass 3-samples
Abstract base class for different kinds of events.