27 TF1 fitFunction(
"fitFunction",
"gaus" );
28 fitFunction.SetLineColor( 2 );
29 fitFunction.SetLineWidth( 2 );
31 std::pair<int,double> largestAmplitude( 0, 0. );
32 double anAmplitude = 0.;
35 const int approxOffset =
static_cast<int>(
offset );
38 const unsigned int meanPosition = 256 + approxOffset;
41 const unsigned int halfWindowSize = 33;
47 for(
unsigned int strip = meanPosition - halfWindowSize;
strip < meanPosition + halfWindowSize; ++
strip ) {
50 histogram->SetBinContent( 1 +
strip, anAmplitude );
51 if( anAmplitude > largestAmplitude.second ) {
52 largestAmplitude.first =
strip; largestAmplitude.second = anAmplitude;
58 double sum1 = 0., sum2 = 0.;
61 if( strip < meanPosition - halfWindowSize || strip > meanPosition + halfWindowSize ) {
65 sum2 +=
pow( anAmplitude, 2 );
71 const double noise =
sqrt( 1. / ( nStrips - 1 ) * ( sum2 -
pow( sum1, 2 ) / nStrips ) );
74 if( fabs( sum0 ) < 1.
e-3 ) {
75 std::cerr <<
" [LASPeakFinder::FindPeakIn] ** WARNING: Empty profile (sum=" << sum0 <<
")." << std::endl;
81 std::cerr <<
" [LASPeakFinder::FindPeakIn] ** WARNING: No reasonably large peak." << std::endl;
86 fitFunction.SetParameter( 0, largestAmplitude.second );
87 fitFunction.SetParameter( 1, largestAmplitude.first );
88 fitFunction.SetParameter( 2, 3. );
91 fitFunction.SetParLimits( 0, largestAmplitude.second * 0.3, largestAmplitude.second * 1.8 );
92 fitFunction.SetParLimits( 1, largestAmplitude.first - 12, largestAmplitude.first + 12 );
93 fitFunction.SetParLimits( 2, 0.5, 8. );
97 histogram->Fit( &fitFunction,
"QWEB",
"", largestAmplitude.first - 12, largestAmplitude.first + 12 );
100 result.first = fitFunction.GetParameter( 1 );
101 result.second = fitFunction.GetParError( 1 );
double GetValue(unsigned int theStripNumber) const
bool FindPeakIn(const LASModuleProfile &, std::pair< double, double > &, TH1D *, const double)
double amplitudeThreshold
void SetAmplitudeThreshold(double)
unsigned int offset(bool)
Power< A, B >::type pow(const A &a, const B &b)