16 #include "cetlib_except/exception.h" 23 unsigned int min_multi,
55 if (signal.size() <= 2)
return;
57 float prev_dev = 0, this_dev = 0;
64 for (
size_t i_tick = 1; i_tick < signal.size() - 1; i_tick++) {
65 this_dev = 0.5 * (signal[i_tick + 1] - signal[i_tick - 1]) / signal[i_tick];
66 slope = this_dev - prev_dev;
70 if (slope >= 0)
continue;
72 sigma = std::sqrt(-1 / slope);
73 intercept = 0.5 * (signal[i_tick + 1] - signal[i_tick - 1]) / signal[i_tick] - slope * i_tick;
74 mean = -1 * intercept / slope;
76 fSignalSet.insert(std::make_pair(mean, sigma));
85 float prev_mean = -9e6;
92 prev_mean = it->first;
103 for (
size_t i_col = 0; i_col <
fMergeVector.size(); i_col++) {
140 std::vector<float> heightVector(
fMeanVector.size());
147 bin = signal.size() - 2;
151 if (bin >= signal.size() - 1)
153 <<
"Error in CalculatAmplitudes! bin is out of range!\n" 154 <<
"\tFor element " << i <<
" bin is " << bin <<
"(" <<
fMeanVector[i] <<
")" 155 <<
" but size is " << signal.size() <<
".\n";
157 heightVector[i] = signal[
bin] - (
fMeanVector[i] - (float)bin) * (signal[
bin] - signal[bin + 1]);
163 for (
size_t i = 0; i <
fAmpVector.size(); i++) {
170 heightVector.erase(heightVector.begin() + i);
200 std::cout <<
"InitialSignalSet" << std::endl;
203 std::cout <<
"\t" << sigpair.first <<
" / " << sigpair.second << std::endl;
205 std::cout <<
"\nNHits = " <<
NHits() << std::endl;
206 std::cout <<
"\tMean / Sigma / Amp" << std::endl;
207 for (
size_t i = 0; i <
NHits(); i++)
std::vector< float > fAmpErrorVector
unsigned int fMinMergeMultiplicity
void RunFitter(const std::vector< float > &signal)
void SetFitterParams(float, unsigned int, float)
std::vector< std::vector< std::multiset< MeanSigmaPair >::iterator > > fMergeVector
constexpr auto abs(T v)
Returns the absolute value of the argument.
void CalculateMergedMeansAndSigmas(std::size_t signal_size)
std::vector< float > fSigmaVector
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
void CalculateAllMeansAndSigmas(const std::vector< float > &signal)
bool HitsBelowThreshold()
util::GaussianEliminationAlg fGEAlg
const std::vector< float > & SolveEquations(const std::vector< float > &meanVector, const std::vector< float > &sigmaVector, const std::vector< float > &heightVector)
std::multiset< MeanSigmaPair, SignalSetComp > fSignalSet
std::vector< float > fAmpVector
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
RFFHitFitter(float, unsigned int, float, float step=0.1, float max=5.0)
void CalculateAmplitudes(const std::vector< float > &signal)
std::vector< float > fSigmaErrorVector
float fMeanMatchThreshold
cet::coded_exception< error, detail::translate > exception
std::vector< float > fMeanVector
std::vector< float > fMeanErrorVector