55 double runningAmpMean = 0.0;
56 double runningAmpRMS = 0.0;
58 int firstLowRMSBin = -1;
59 int lastLowRMSBin = -1;
60 bool lowRMSFlag =
false;
61 double RMSfirst = 0.0;
62 double RMSsecond = 0.0;
63 double RMSthird = 0.0;
64 int numNormalNeighbors = 0;
66 const int numBins = sig.size();
68 for (
int ibin = 0; ibin < numBins; ibin++) {
70 double ADCval = sig[ibin];
72 runningAmpMean += ADCval;
73 runningAmpRMS += ADCval*ADCval;
80 runningAmpRMS = std::sqrt(runningAmpRMS - runningAmpMean*runningAmpMean);
84 RMSthird = runningAmpRMS;
95 if(lowRMSFlag ==
false) {
99 lastLowRMSBin = ibin - windowSize + 1;
105 lastLowRMSBin = ibin - 2*windowSize + 1;
116 runningAmpMean = 0.0;
121 double chirpFrac = ((double) numLowRMS)/(((double) numBins)/((double)
windowSize));
122 double normalNeighborFrac = ((double) numNormalNeighbors)/((double) numLowRMS);
123 if ( (numLowRMS > 4) &&
126 && (lastLowRMSBin-firstLowRMSBin == numLowRMS*
windowSize)))
129 firstLowRMSBin =
std::max(1, firstLowRMSBin - windowSize);
130 lastLowRMSBin =
std::min(numBins, lastLowRMSBin + 2*windowSize);
132 if((numBins-lastLowRMSBin) < windowSize) {
133 lastLowRMSBin = numBins;
136 if(chirpFrac > 0.99) {
138 lastLowRMSBin = numBins;
141 beg = firstLowRMSBin - 1;
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
const double maxNormalNeighborFrac