18 #include "cetlib_except/exception.h" 25 unsigned int min_multi,
35 unsigned int min_multi,
59 if(signal.size()<=2)
return;
61 float prev_dev=0,this_dev=0;;
62 float slope=0;
float sigma=0;
63 float intercept=0;
float mean=0;
65 for(
size_t i_tick=1; i_tick < signal.size()-1; i_tick++)
67 this_dev = 0.5*(signal[i_tick+1]-signal[i_tick-1])/signal[i_tick];
68 slope = this_dev - prev_dev;
72 if(slope>=0)
continue;
74 sigma = std::sqrt(-1/slope);
75 intercept = 0.5*(signal[i_tick+1]-signal[i_tick-1])/signal[i_tick] - slope*i_tick;
76 mean = -1*intercept/slope;
93 prev_mean = it->first;
147 std::vector<float> heightVector(
fMeanVector.size());
153 else if(
fMeanVector[i]+1 > signal.size()) bin=signal.size()-2;
156 if(bin >= signal.size()-1)
157 throw cet::exception(
"RFFHitFitter") <<
"Error in CalculatAmplitudes! bin is out of range!\n" 158 <<
"\tFor element " << i <<
" bin is " << bin <<
"(" <<
fMeanVector[i] <<
")" 159 <<
" but size is " << signal.size() <<
".\n";
177 heightVector.erase(heightVector.begin()+i);
207 std::cout <<
"InitialSignalSet" <<
std::endl;
210 std::cout <<
"\t" << sigpair.first <<
" / " << sigpair.second <<
std::endl;
213 std::cout <<
"\tMean / Sigma / Amp" <<
std::endl;
214 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)
void CalculateMergedMeansAndSigmas(std::size_t signal_size)
std::vector< float > fSigmaVector
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
void CalculateAllMeansAndSigmas(const std::vector< float > &signal)
bool HitsBelowThreshold()
std::vector< std::vector< std::multiset< MeanSigmaPair >::iterator > > fMergeVector
util::GaussianEliminationAlg fGEAlg
const std::vector< float > & SolveEquations(const std::vector< float > &meanVector, const std::vector< float > &sigmaVector, const std::vector< float > &heightVector)
static int max(int a, int b)
std::multiset< MeanSigmaPair, SignalSetComp > fSignalSet
std::vector< float > fAmpVector
RFFHitFitter(float, unsigned int, float, float step=0.1, float max=5.0)
void CalculateAmplitudes(const std::vector< float > &signal)
std::vector< float > fSigmaErrorVector
QTextStream & bin(QTextStream &s)
float fMeanMatchThreshold
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
std::vector< float > fMeanVector
std::vector< float > fMeanErrorVector