LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
hit::RFFHitFitter Class Reference

#include "RFFHitFitter.h"

Public Member Functions

 RFFHitFitter (float, unsigned int, float, float step=0.1, float max=5.0)
 
 RFFHitFitter (float step=0.1, float max=5.0)
 
void SetFitterParams (float, unsigned int, float)
 
void RunFitter (const std::vector< float > &signal)
 
const std::vector< float > & MeanVector ()
 
const std::vector< float > & SigmaVector ()
 
const std::vector< float > & MeanErrorVector ()
 
const std::vector< float > & SigmaErrorVector ()
 
const std::vector< float > & AmplitudeVector ()
 
const std::vector< float > & AmplitudeErrorVector ()
 
unsigned int NHits ()
 
void ClearResults ()
 
void PrintResults ()
 

Private Types

typedef std::pair< float, float > MeanSigmaPair
 

Private Member Functions

void CalculateAllMeansAndSigmas (const std::vector< float > &signal)
 
void CalculateMergedMeansAndSigmas (std::size_t signal_size)
 
void CalculateAmplitudes (const std::vector< float > &signal)
 
void CreateMergeVector ()
 
bool HitsBelowThreshold ()
 

Private Attributes

float fMeanMatchThreshold
 
unsigned int fMinMergeMultiplicity
 
float fFinalAmpThreshold
 
util::GaussianEliminationAlg fGEAlg
 
std::vector< float > fMeanVector
 
std::vector< float > fSigmaVector
 
std::vector< float > fMeanErrorVector
 
std::vector< float > fSigmaErrorVector
 
std::vector< float > fAmpVector
 
std::vector< float > fAmpErrorVector
 
std::multiset< MeanSigmaPair, SignalSetCompfSignalSet
 
std::vector< std::vector< std::multiset< MeanSigmaPair >::iterator > > fMergeVector
 

Detailed Description

Definition at line 31 of file RFFHitFitter.h.

Member Typedef Documentation

typedef std::pair<float,float> hit::RFFHitFitter::MeanSigmaPair
private

Definition at line 33 of file RFFHitFitter.h.

Constructor & Destructor Documentation

hit::RFFHitFitter::RFFHitFitter ( float  max_mean,
unsigned int  min_multi,
float  threshold,
float  step = 0.1,
float  max = 5.0 
)

Definition at line 25 of file RFFHitFitter.cxx.

References SetFitterParams().

29  :
30  fGEAlg(step,max)
31 {
32  SetFitterParams(max_mean,min_multi,threshold);
33 }
void SetFitterParams(float, unsigned int, float)
Int_t max
Definition: plot.C:27
util::GaussianEliminationAlg fGEAlg
Definition: RFFHitFitter.h:63
hit::RFFHitFitter::RFFHitFitter ( float  step = 0.1,
float  max = 5.0 
)

Title: RFFHitFitter Class Author: Wes Ketchum (wketc.nosp@m.hum@.nosp@m.lanl..nosp@m.gov)

Description: Class that does the base RFF algorithm. RFF works by simplifiying a Gaussian fit by dividing a pulse by its derivative. for a Gaussian, the result is a line, with the slope and intercept related to the sigma and mean of the Gaussian.

Input: Signal (vector of floats) Output: Guassian means and sigmas

Definition at line 21 of file RFFHitFitter.cxx.

21  :
22  fGEAlg(step,max)
23 {}
Int_t max
Definition: plot.C:27
util::GaussianEliminationAlg fGEAlg
Definition: RFFHitFitter.h:63

Member Function Documentation

const std::vector<float>& hit::RFFHitFitter::AmplitudeErrorVector ( )
inline

Definition at line 48 of file RFFHitFitter.h.

Referenced by hit::RFFHitFinderAlg::EmplaceHit().

48 { return fAmpErrorVector; }
std::vector< float > fAmpErrorVector
Definition: RFFHitFitter.h:70
const std::vector<float>& hit::RFFHitFitter::AmplitudeVector ( )
inline

Definition at line 47 of file RFFHitFitter.h.

Referenced by hit::RFFHitFinderAlg::EmplaceHit().

47 { return fAmpVector; }
std::vector< float > fAmpVector
Definition: RFFHitFitter.h:69
void hit::RFFHitFitter::CalculateAllMeansAndSigmas ( const std::vector< float > &  signal)
private

Definition at line 58 of file RFFHitFitter.cxx.

References fSignalSet, and pmtana::mean().

Referenced by RunFitter().

59 {
60  if(signal.size()<=2) return;
61 
62  float prev_dev=0,this_dev=0;;
63  float slope=0; float sigma=0;
64  float intercept=0; float mean=0;
65 
66  for(size_t i_tick=1; i_tick < signal.size()-1; i_tick++)
67  {
68  this_dev = 0.5*(signal[i_tick+1]-signal[i_tick-1])/signal[i_tick];
69  slope = this_dev - prev_dev;
70 
71  prev_dev = this_dev;
72 
73  if(slope>=0) continue;
74 
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;
78 
79  fSignalSet.insert(std::make_pair(mean,sigma));
80  }
81 }
std::multiset< MeanSigmaPair, SignalSetComp > fSignalSet
Definition: RFFHitFitter.h:72
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:15
void hit::RFFHitFitter::CalculateAmplitudes ( const std::vector< float > &  signal)
private

Definition at line 146 of file RFFHitFitter.cxx.

References bin, fAmpErrorVector, fAmpVector, fFinalAmpThreshold, fGEAlg, fMeanErrorVector, fMeanVector, fSigmaErrorVector, fSigmaVector, HitsBelowThreshold(), and util::GaussianEliminationAlg::SolveEquations().

Referenced by RunFitter().

147 {
148  std::vector<float> heightVector(fMeanVector.size());
149  size_t bin=0;
150 
151  for(size_t i=0; i<fMeanVector.size(); i++)
152  {
153  if (fMeanVector[i]<0) bin=0;
154  else if(fMeanVector[i]+1 > signal.size()) bin=signal.size()-2;
155  else bin = std::floor(fMeanVector[i]);
156 
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";
161 
162  heightVector[i] = signal[bin] - (fMeanVector[i]-(float)bin)*(signal[bin]-signal[bin+1]);
163  }
164 
166 
167  while(HitsBelowThreshold())
168  {
169  for(size_t i=0; i<fAmpVector.size(); i++)
170  {
172  {
173  fMeanVector.erase(fMeanVector.begin()+i);
174  fMeanErrorVector.erase(fMeanErrorVector.begin()+i);
175  fSigmaVector.erase(fSigmaVector.begin()+i);
176  fSigmaErrorVector.erase(fSigmaErrorVector.begin()+i);
177  fAmpVector.erase(fAmpVector.begin()+i);
178  heightVector.erase(heightVector.begin()+i);
179  }
180  }
182  }
183 
184  fAmpErrorVector.resize(fAmpVector.size(),0.0);
185 }
std::vector< float > fAmpErrorVector
Definition: RFFHitFitter.h:70
std::vector< float > fSigmaVector
Definition: RFFHitFitter.h:66
util::GaussianEliminationAlg fGEAlg
Definition: RFFHitFitter.h:63
float fFinalAmpThreshold
Definition: RFFHitFitter.h:58
const std::vector< float > & SolveEquations(const std::vector< float > &meanVector, const std::vector< float > &sigmaVector, const std::vector< float > &heightVector)
float bin[41]
Definition: plottest35.C:14
std::vector< float > fAmpVector
Definition: RFFHitFitter.h:69
std::vector< float > fSigmaErrorVector
Definition: RFFHitFitter.h:68
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< float > fMeanVector
Definition: RFFHitFitter.h:65
std::vector< float > fMeanErrorVector
Definition: RFFHitFitter.h:67
void hit::RFFHitFitter::CalculateMergedMeansAndSigmas ( std::size_t  signal_size)
private

Definition at line 98 of file RFFHitFitter.cxx.

References fMeanErrorVector, fMeanVector, fMergeVector, fMinMergeMultiplicity, fSigmaErrorVector, and fSigmaVector.

Referenced by RunFitter().

99 {
100  fMeanVector.reserve(fMergeVector.size());
101  fSigmaVector.reserve(fMergeVector.size());
102  fMeanErrorVector.reserve(fMergeVector.size());
103  fSigmaErrorVector.reserve(fMergeVector.size());
104 
105  for(size_t i_col=0; i_col<fMergeVector.size(); i_col++)
106  {
107  if(fMergeVector[i_col].size()<fMinMergeMultiplicity) continue;
108 
109  fMeanVector.push_back(0.0);
110  fSigmaVector.push_back(0.0);
111 
112  for(auto const& sigpair : fMergeVector[i_col])
113  {
114  fMeanVector.back() += sigpair->first;
115  fSigmaVector.back() += sigpair->second;
116  }
117 
118  fMeanVector.back() /= fMergeVector[i_col].size();
119  fSigmaVector.back() /= fMergeVector[i_col].size();
120 
121  if(fMeanVector.back() < 0 || fMeanVector.back()>signal_size-1)
122  {
123  fMeanVector.pop_back();
124  fSigmaVector.pop_back();
125  continue;
126  }
127 
128  fMeanErrorVector.push_back(0.0);
129  fSigmaErrorVector.push_back(0.0);
130 
131  for(auto const& sigpair : fMergeVector[i_col])
132  {
133  fMeanErrorVector.back() +=
134  (sigpair->first-fMeanVector.back())*(sigpair->first-fMeanVector.back());
135  fSigmaErrorVector.back() +=
136  (sigpair->second-fSigmaVector.back())*(sigpair->second-fSigmaVector.back());
137  }
138 
139  fMeanErrorVector.back() = std::sqrt(fMeanErrorVector.back()) / fMergeVector[i_col].size();
140  fSigmaErrorVector.back() = std::sqrt(fSigmaErrorVector.back()) / fMergeVector[i_col].size();
141 
142  }
143 
144 }
unsigned int fMinMergeMultiplicity
Definition: RFFHitFitter.h:57
std::vector< float > fSigmaVector
Definition: RFFHitFitter.h:66
std::vector< std::vector< std::multiset< MeanSigmaPair >::iterator > > fMergeVector
Definition: RFFHitFitter.h:74
std::vector< float > fSigmaErrorVector
Definition: RFFHitFitter.h:68
std::vector< float > fMeanVector
Definition: RFFHitFitter.h:65
std::vector< float > fMeanErrorVector
Definition: RFFHitFitter.h:67
void hit::RFFHitFitter::ClearResults ( )

Definition at line 194 of file RFFHitFitter.cxx.

References fAmpErrorVector, fAmpVector, fMeanErrorVector, fMeanVector, fMergeVector, fSigmaErrorVector, fSigmaVector, and fSignalSet.

Referenced by RunFitter(), and SetFitterParams().

195 {
196  fMeanVector.clear();
197  fSigmaVector.clear();
198  fMeanErrorVector.clear();
199  fSigmaErrorVector.clear();
200  fAmpVector.clear();
201  fAmpErrorVector.clear();
202  fSignalSet.clear();
203  fMergeVector.clear();
204 }
std::vector< float > fAmpErrorVector
Definition: RFFHitFitter.h:70
std::vector< float > fSigmaVector
Definition: RFFHitFitter.h:66
std::vector< std::vector< std::multiset< MeanSigmaPair >::iterator > > fMergeVector
Definition: RFFHitFitter.h:74
std::multiset< MeanSigmaPair, SignalSetComp > fSignalSet
Definition: RFFHitFitter.h:72
std::vector< float > fAmpVector
Definition: RFFHitFitter.h:69
std::vector< float > fSigmaErrorVector
Definition: RFFHitFitter.h:68
std::vector< float > fMeanVector
Definition: RFFHitFitter.h:65
std::vector< float > fMeanErrorVector
Definition: RFFHitFitter.h:67
void hit::RFFHitFitter::CreateMergeVector ( )
private

Definition at line 83 of file RFFHitFitter.cxx.

References fMeanMatchThreshold, fMergeVector, fSignalSet, and lar::dump::vector().

Referenced by RunFitter().

84 {
85  fMergeVector.clear(); fMergeVector.reserve( fSignalSet.size() );
86 
87  float prev_mean=-9e6;
88  for(std::multiset<MeanSigmaPair>::iterator it=fSignalSet.begin(); it!=fSignalSet.end(); it++)
89  {
90  if( std::abs(it->first - prev_mean) > fMeanMatchThreshold || fMergeVector.size()==0 )
92  else
93  fMergeVector.back().push_back(it);
94  prev_mean = it->first;
95  }
96 }
intermediate_table::iterator iterator
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::vector< std::vector< std::multiset< MeanSigmaPair >::iterator > > fMergeVector
Definition: RFFHitFitter.h:74
std::multiset< MeanSigmaPair, SignalSetComp > fSignalSet
Definition: RFFHitFitter.h:72
float fMeanMatchThreshold
Definition: RFFHitFitter.h:56
bool hit::RFFHitFitter::HitsBelowThreshold ( )
private

Definition at line 187 of file RFFHitFitter.cxx.

References fAmpVector, and fFinalAmpThreshold.

Referenced by CalculateAmplitudes().

188 {
189  for(auto const& amp : fAmpVector)
190  if(amp < fFinalAmpThreshold) return true;
191  return false;
192 }
float fFinalAmpThreshold
Definition: RFFHitFitter.h:58
std::vector< float > fAmpVector
Definition: RFFHitFitter.h:69
const std::vector<float>& hit::RFFHitFitter::MeanErrorVector ( )
inline

Definition at line 45 of file RFFHitFitter.h.

Referenced by hit::RFFHitFinderAlg::EmplaceHit().

45 { return fMeanErrorVector; }
std::vector< float > fMeanErrorVector
Definition: RFFHitFitter.h:67
const std::vector<float>& hit::RFFHitFitter::MeanVector ( )
inline

Definition at line 43 of file RFFHitFitter.h.

Referenced by hit::RFFHitFinderAlg::EmplaceHit().

43 { return fMeanVector; }
std::vector< float > fMeanVector
Definition: RFFHitFitter.h:65
unsigned int hit::RFFHitFitter::NHits ( )
inline

Definition at line 49 of file RFFHitFitter.h.

Referenced by hit::RFFHitFinderAlg::EmplaceHit(), and PrintResults().

49 { return fMeanVector.size(); }
std::vector< float > fMeanVector
Definition: RFFHitFitter.h:65
void hit::RFFHitFitter::PrintResults ( )

Definition at line 206 of file RFFHitFitter.cxx.

References fAmpErrorVector, fAmpVector, fMeanErrorVector, fMeanVector, fSigmaErrorVector, fSigmaVector, fSignalSet, and NHits().

207 {
208  std::cout << "InitialSignalSet" << std::endl;
209 
210  for(auto const& sigpair : fSignalSet)
211  std::cout << "\t" << sigpair.first << " / " << sigpair.second << std::endl;
212 
213  std::cout << "\nNHits = " << NHits() << std::endl;
214  std::cout << "\tMean / Sigma / Amp" << std::endl;
215  for(size_t i=0; i<NHits(); i++)
216  std::cout << "\t"
217  << fMeanVector[i] << " +- " << fMeanErrorVector[i] << " / "
218  << fSigmaVector[i] << " +- " << fSigmaErrorVector[i] << " / "
219  << fAmpVector[i] << " +- " << fAmpErrorVector[i]
220  << std::endl;
221 }
std::vector< float > fAmpErrorVector
Definition: RFFHitFitter.h:70
std::vector< float > fSigmaVector
Definition: RFFHitFitter.h:66
std::multiset< MeanSigmaPair, SignalSetComp > fSignalSet
Definition: RFFHitFitter.h:72
std::vector< float > fAmpVector
Definition: RFFHitFitter.h:69
std::vector< float > fSigmaErrorVector
Definition: RFFHitFitter.h:68
unsigned int NHits()
Definition: RFFHitFitter.h:49
std::vector< float > fMeanVector
Definition: RFFHitFitter.h:65
std::vector< float > fMeanErrorVector
Definition: RFFHitFitter.h:67
void hit::RFFHitFitter::RunFitter ( const std::vector< float > &  signal)

Definition at line 49 of file RFFHitFitter.cxx.

References CalculateAllMeansAndSigmas(), CalculateAmplitudes(), CalculateMergedMeansAndSigmas(), ClearResults(), and CreateMergeVector().

Referenced by hit::RFFHitFinderAlg::Run().

50 {
51  ClearResults();
54  CalculateMergedMeansAndSigmas(signal.size());
55  CalculateAmplitudes(signal);
56 }
void CalculateMergedMeansAndSigmas(std::size_t signal_size)
void CalculateAllMeansAndSigmas(const std::vector< float > &signal)
void CalculateAmplitudes(const std::vector< float > &signal)
void hit::RFFHitFitter::SetFitterParams ( float  max_mean,
unsigned int  min_multi,
float  threshold 
)

Definition at line 35 of file RFFHitFitter.cxx.

References ClearResults(), fFinalAmpThreshold, fMeanMatchThreshold, and fMinMergeMultiplicity.

Referenced by RFFHitFitter(), and hit::RFFHitFinderAlg::SetFitterParams().

38 {
39  fMeanMatchThreshold = max_mean;
40  fMinMergeMultiplicity = min_multi;
41 
43 
44  fFinalAmpThreshold = threshold;
45 
46  ClearResults();
47 }
unsigned int fMinMergeMultiplicity
Definition: RFFHitFitter.h:57
float fFinalAmpThreshold
Definition: RFFHitFitter.h:58
float fMeanMatchThreshold
Definition: RFFHitFitter.h:56
const std::vector<float>& hit::RFFHitFitter::SigmaErrorVector ( )
inline

Definition at line 46 of file RFFHitFitter.h.

Referenced by hit::RFFHitFinderAlg::EmplaceHit().

46 { return fSigmaErrorVector; }
std::vector< float > fSigmaErrorVector
Definition: RFFHitFitter.h:68
const std::vector<float>& hit::RFFHitFitter::SigmaVector ( )
inline

Definition at line 44 of file RFFHitFitter.h.

Referenced by hit::RFFHitFinderAlg::EmplaceHit().

44 { return fSigmaVector; }
std::vector< float > fSigmaVector
Definition: RFFHitFitter.h:66

Member Data Documentation

std::vector<float> hit::RFFHitFitter::fAmpErrorVector
private

Definition at line 70 of file RFFHitFitter.h.

Referenced by CalculateAmplitudes(), ClearResults(), and PrintResults().

std::vector<float> hit::RFFHitFitter::fAmpVector
private

Definition at line 69 of file RFFHitFitter.h.

Referenced by CalculateAmplitudes(), ClearResults(), HitsBelowThreshold(), and PrintResults().

float hit::RFFHitFitter::fFinalAmpThreshold
private

Definition at line 58 of file RFFHitFitter.h.

Referenced by CalculateAmplitudes(), HitsBelowThreshold(), and SetFitterParams().

util::GaussianEliminationAlg hit::RFFHitFitter::fGEAlg
private

Definition at line 63 of file RFFHitFitter.h.

Referenced by CalculateAmplitudes().

std::vector<float> hit::RFFHitFitter::fMeanErrorVector
private
float hit::RFFHitFitter::fMeanMatchThreshold
private

Definition at line 56 of file RFFHitFitter.h.

Referenced by CreateMergeVector(), and SetFitterParams().

std::vector<float> hit::RFFHitFitter::fMeanVector
private
std::vector< std::vector< std::multiset<MeanSigmaPair>::iterator > > hit::RFFHitFitter::fMergeVector
private

Definition at line 74 of file RFFHitFitter.h.

Referenced by CalculateMergedMeansAndSigmas(), ClearResults(), and CreateMergeVector().

unsigned int hit::RFFHitFitter::fMinMergeMultiplicity
private

Definition at line 57 of file RFFHitFitter.h.

Referenced by CalculateMergedMeansAndSigmas(), and SetFitterParams().

std::vector<float> hit::RFFHitFitter::fSigmaErrorVector
private
std::vector<float> hit::RFFHitFitter::fSigmaVector
private
std::multiset< MeanSigmaPair, SignalSetComp > hit::RFFHitFitter::fSignalSet
private

The documentation for this class was generated from the following files: