AdcNoiseSignalFinder.h
Go to the documentation of this file.
1 // AdcNoiseSignalFinder.h
2 
3 // David Adams
4 // July 2019
5 //
6 // Tool to find and flag signal regions in ADC data using a threshold
7 // based on the noise level.
8 //
9 // For each tick with sample above threshold and/or below -threshold, the region
10 // [bin-BinsBefore, bin+binsAfter] is flagged as signal.
11 // An ROI is created for each range of contiguous signal samples.
12 //
13 // For
14 // sigfrac = fraction of samples flagged as signal
15 // noise = sample RMS for non-signal samples
16 // tr = threshold/noise
17 // trmin = ThresholdRatio - ThresholdRatioTol and
18 // trmax = ThresholdRatio + ThresholdRatioTol:
19 // If sigfrac > SigFracMax or tr < trmin, the threshold is increased
20 // Else if tr > trmax and threshold > thresholdMin, the threshold is decreased
21 //
22 // The signal finding is repeated until there is no change in threshold or
23 // the loop count reaches MaxLoop.
24 //
25 // Configuration:
26 // LogLevel - 0=silent, 1=init, 3=each event, >4=more
27 // 1 shows warnings for good channels, 2 for all
28 // SigFracMax - maximum allowed value for sigfrac
29 // ThresholdMin - minimum and starting threshold
30 // ThresholdRatio - Target threshold/noise
31 // ThresholdRatioTol - Tolerance for threshold/noise
32 // MaxLoop - Maximum # threshold iterations
33 // BinsBefore - lower limit for signal range
34 // BinsAfter - upper limit for signal range
35 // FlagPositive - Flag signals above Threshold
36 // FlagNegative - Flag signals below Threshold
37 //
38 // The following are returnd and added to the ADC channel metadata:
39 // float nsfSigFrac - fraction of samples above threshold
40 // float nsfNoise - sample RMS outside of signal range
41 // float nsfThreshold - final threshold
42 // int nsfLoopCount - # threshold iterations
43 // int nsfRoiCount - # ROIs
44 
45 #ifndef AdcNoiseSignalFinder_H
46 #define AdcNoiseSignalFinder_H
47 
49 #include "fhiclcpp/ParameterSet.h"
51 #include <string>
52 #include <vector>
53 
55 : public TpcDataTool {
56 
57 public:
58 
60 
61  DataMap view(const AdcChannelData& acd) const override;
62 
63  DataMap update(AdcChannelData& acd) const override;
64 
65 private:
66 
67  using Name = std::string;
68 
69  // Configuration data.
71  float m_SigFracMax;
75  unsigned int m_MaxLoop;
76  unsigned int m_BinsBefore;
77  unsigned int m_BinsAfter;
80 
81 };
82 
83 
84 #endif
std::string string
Definition: nybbler.cc:12
AdcNoiseSignalFinder(fhicl::ParameterSet const &ps)
DataMap view(const AdcChannelData &acd) const override
static constexpr double ps
Definition: Units.h:99
DataMap update(AdcChannelData &acd) const override