19 #include "cetlib_except/exception.h" 26 unsigned int min_multi,
36 unsigned int min_multi,
60 if(signal.size()<=2)
return;
62 float prev_dev=0,this_dev=0;;
63 float slope=0;
float sigma=0;
64 float intercept=0;
float mean=0;
66 for(
size_t i_tick=1; i_tick < signal.size()-1; i_tick++)
68 this_dev = 0.5*(signal[i_tick+1]-signal[i_tick-1])/signal[i_tick];
69 slope = this_dev - prev_dev;
73 if(slope>=0)
continue;
75 sigma = std::sqrt(-1/slope);
76 intercept = 0.5*(signal[i_tick+1]-signal[i_tick-1])/signal[i_tick] - slope*i_tick;
77 mean = -1*intercept/slope;
94 prev_mean = it->first;
148 std::vector<float> heightVector(
fMeanVector.size());
154 else if(
fMeanVector[i]+1 > signal.size()) bin=signal.size()-2;
157 if(bin >= signal.size()-1)
158 throw cet::exception(
"RFFHitFitter") <<
"Error in CalculatAmplitudes! bin is out of range!\n" 159 <<
"\tFor element " << i <<
" bin is " << bin <<
"(" <<
fMeanVector[i] <<
")" 160 <<
" but size is " << signal.size() <<
".\n";
162 heightVector[i] = signal[
bin] - (
fMeanVector[i]-(float)bin)*(signal[
bin]-signal[bin+1]);
178 heightVector.erase(heightVector.begin()+i);
208 std::cout <<
"InitialSignalSet" << std::endl;
211 std::cout <<
"\t" << sigpair.first <<
" / " << sigpair.second << std::endl;
213 std::cout <<
"\nNHits = " <<
NHits() << std::endl;
214 std::cout <<
"\tMean / Sigma / Amp" << std::endl;
215 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
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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)
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