Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 7, 2024
1 parent 5e33144 commit 4d5690c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/TRestRawSignal.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -977,29 +977,29 @@ vector<pair<UShort_t, double>> TRestRawSignal::GetPeaks(double threshold, UShort
}

// If it's a peak and it´s above the threshold and further than distance to the previous peak, add
// to peaks the biggest amplitude bin within the next "distance" bins and as amplitude the TripleMaxAverage.
// This is because for flat regions the detected peak is more to the left than the actual one.
// to peaks the biggest amplitude bin within the next "distance" bins and as amplitude the
// TripleMaxAverage. This is because for flat regions the detected peak is more to the left than
// the actual one.
if (isPeak && smoothedValue > threshold) {
if (peaks.empty() || i - peaks.back().first >= distance) {

// Initialize variables to find the max amplitude within the next "distance" bins
int maxBin = i;
double maxAmplitude = smoothedValues[i];

// Look ahead within the specified distance to find the bin with the maximum amplitude
for (int j = i + 1; j <= i + distance && j < smoothedValues.size(); ++j) {
if (smoothedValues[j] > maxAmplitude) {
maxAmplitude = smoothedValues[j];
maxBin = j;
}
}

// Calculate the peak amplitude as the average of maxBin and its two neighbors
double amplitude1 = GetRawData(maxBin - 1);
double amplitude2 = GetRawData(maxBin);
double amplitude3 = GetRawData(maxBin + 1);
double peakAmplitude = (amplitude1 + amplitude2 + amplitude3) / 3.0;

// Store the peak position and amplitude
peaks.push_back(std::make_pair(maxBin, peakAmplitude));
}
Expand Down

0 comments on commit 4d5690c

Please sign in to comment.