10#ifndef _SVD_RECONSTRUCTION_NNwAVEFITTER_H
11#define _SVD_RECONSTRUCTION_NNWAVEFITTER_H
19#include <svd/reconstruction/NNWaveFitTool.h>
20#include <svd/simulation/SVDSimulationTools.h>
92 std::shared_ptr<nnFitterBinData>
getFit(
const apvSamples& samples,
double tau);
146 [](
double x) ->
double {
return std::max(
double(0.0), x); };
149 [](
double x) ->
double {
double e = std::exp(x);
return e / (1.0 + e); };
155 Eigen::VectorXd
softmax(
const Eigen::VectorXd& input)
157 auto output = input.array().unaryExpr(
158 [](
double x)->
double {
return ((x > 0.0) ? exp(x) : 0.0); }
160 double norm = output.sum();
161 return output / norm;
173 typedef std::map< size_t, std::pair< Eigen::MatrixXd, Eigen::VectorXd > >
The class uses a neural network to find a probability distribution of arrival times for a sextet of A...
nnBoundsType getTimeShiftBounds() const
Get time shift bounds.
std::size_t m_nLayers
number of NN layers, read from xml
std::vector< Eigen::VectorXd > layerStatesType
Storage for internal states.
void setNetwrok(const std::string &xmlData)
Set proper network definition file.
TauEncoder m_tauCoder
Tau encoder class instance to scale tau values.
layerStatesType m_layerStates
vectors of layer states
const NNWaveFitTool & getFitTool() const
Get a handle to a NNWaveFit object.
int readNetworkData(const std::string &xmlFileName)
The method that actually reads the xml file.
nnBoundsType m_waveWidthBounds
Waveform width range of the network.
activationType relu
Rectifier activation.
nnFitterBins m_bins
NN time bin boundaries.
std::pair< double, double > nnBoundsType
Bounds type used to hold network parameter bounds used in training the network.
bool isValid() const
Is this fitter working? Return false if the fitter was not initialized properly.
activationType m_activation
Network activation function.
std::function< double(double)> activationType
Activation functions type.
nnBoundsType getWaveWidthBounds() const
Get width bounds Width bounds are minimum and maximum width used in training the network.
std::vector< std::size_t > m_layerSizes
NN layer sizes.
activationType sigmoid
Sigmoid activation.
std::map< size_t, std::pair< Eigen::MatrixXd, Eigen::VectorXd > > networkWeightsType
We use map to store network layers since we don't know if we'll be reading them in correct order.
networkWeightsType m_networkCoefs
NN weights and intercepts.
bool checkCoefficients(const std::string &dumpname, double tol=1.0e-10)
Check NN data against a dump from Python.
const nnFitterBins & getBins() const
Get bins of netwrok output.
std::shared_ptr< NNWaveFitTool > m_fitTool
FitterTool object allowing calculations on network fits.
nnBoundsType m_amplitudeBounds
Amplitude range of the network.
const nnFitterBinData & getBinCenters() const
Get bin times of the network output.
nnFitterBinData m_binCenters
centers of NN time bins
bool m_isValid
true if fitter was properly initialized
Eigen::VectorXd softmax(const Eigen::VectorXd &input)
Softmax function, normalization for the network's output layer.
nnBoundsType getAmplitudeBounds() const
Get amplitude bounds.
WaveformShape m_wave
Wave function used in training the network.
nnBoundsType m_timeShiftBounds
Time shift range of the network.
std::shared_ptr< nnFitterBinData > getFit(const apvSamples &samples, double tau)
Fitting method Send data and get rseult structure.
Encoder/decoder for neural network tau values.
std::array< apvSampleBaseType, nAPVSamples > apvSamples
vector od apvSample BaseType objects
std::vector< double > nnFitterBins
Vector of bin edges, nnFitterBinData.size() + 1.
std::function< double(double)> WaveformShape
WaveformShape type.
std::vector< double > nnFitterBinData
Vector of values defined for bins, such as bin times or bin probabilities.
Abstract base class for different kinds of events.