ExpTailRemover.h
Go to the documentation of this file.
1 // ExpTailRemover.h
2 //
3 // David Adams
4 // May 2019
5 //
6 // Tool to remove an exponential tail from AC-coupled front-end electronics.
7 //
8 // The measured charge vector is assumed to be a sum of signal and tail:
9 //
10 // Qdat = Qsig + Qtai + Qnoise
11 //
12 // where <Qnoise> = 0.
13 //
14 // This tool replaces the sample vector (assumed to be Qdat) in
15 // AdcChannelData with signal (pus noise), i.e. it removes the tail.
16 //
17 // Any signal contribution is assumed to be accompanied by an exponential tail
18 // whose integral cancels that of the signal. The decay time of the exponential
19 // is a parameter of this tool.
20 //
21 // The data is fit with this model and two varied parameters: the (residual)
22 // pedestal ped and the initial charge of the tail csi.
23 //
24 // The fit is iterative using samples not flagged as signal to evaluate these
25 // parameters. Each iteration, the samples are updated and those values are used
26 // to evaluate the signal for the next iteration. Iterations stop when the signal
27 // evalaution does not change or the maximum # iterations is reached.
28 //
29 // The fit is done in time-domain, i.e there is no deconvolution following the
30 // the model in tool UndershootCorr and DUNE-doc-11662.
31 // Details of the fit procedure are in DUNE-doc-14203.
32 //
33 // Configuration:
34 // LogLevel - 0=silent, 1=init, 2=each event, >2=more
35 // DecayTime: Exponential decay time in ticks.
36 // SignalFlag: Specifies how signal regions are identified in the samples.
37 // 0 - Use all samples.
38 // 1 - Use the input acd.signal. If not enough values, pad with
39 // false and log warning.
40 // 2 - Apply the signal finder on updated samples each iteration.
41 // 3 - Same as 2 plus the signal finder is applied on the final
42 // samples.
43 // SignalIterationLimit - Maximum nimber of fit iterations.
44 // SignalTool - Name of the tool used identify signals. The method called is
45 // AdcChannelTool::update, i.e. single-channel signal finding.
46 // IncludeChannelRanges - List of channel ranges to correct. If empty, all channels
47 // Use empty or "all" for all channels or "none" for no channels.
48 // Tool channelRanges is used to map these names to channels.
49 // ExcludeChannelRanges - List of channel ranges whose channels are excluded from
50 // the list to process derived from IncludeChannelRanges.
51 // If "all", no channels are processed.
52 //
53 // The following metadata is added to each channel (i.e. to AdcChannelData):
54 // uscPedestal - fitted pedestal (w.r.t. input samples)
55 // uscTail - Fitted tail for the first bin (tau[0])
56 // uscNoise - Noise = RMS of (sample - pedestal) in the no-signal region
57 //
58 // The following are returned in the call toi view:
59 // uscPedestal - As above
60 // uscTail - As above.
61 // uscNsamFit - # non-signal samples
62 // uscNiteration - # fit iterations
63 
64 #ifndef ExpTailRemover_H
65 #define ExpTailRemover_H
66 
68 #include "fhiclcpp/ParameterSet.h"
70 #include <vector>
71 
73 
74 public:
75 
76  using Index = unsigned int;
77  using Vector = std::vector<double>;
78  using Name = std::string;
79  using NameVector = std::vector<Name>;
80 
82 
83  ~ExpTailRemover() override =default;
84 
85  DataMap update(AdcChannelData& acd) const override;
86 
87 private:
88 
89  // Configuration data.
94  double m_DecayTime;
97 
98  // Derived from configuration.
99  bool m_useChannelRanges; // If true, only channels in checkChannels are processed.
100  std::vector<bool> m_checkChannels;
102 
103  // private methods
104 
105  // Remove the pedestal and tail from a data vactor.
106  void getSignal(const Vector& qdats, double ped, double csi, Vector& qsigs) const;
107 
108  // Use the samples qdats to estimate the pedestal ped and initial tail charge csi.
109  // nsamFit is the # samples used in the fit, i.e. those not considered signal
110  void estimatepars(const Vector& qdats, double& ped, double& csi, Index& nsamFit) const;
111 
112  // Fit to line.
113  void wlinfit(const Vector& x, const Vector& y, const Vector& e,
114  double& slope, double& intercept) const;
115 
116 };
117 
118 
119 #endif
Index m_SignalIterationLimit
unsigned int Index
std::string string
Definition: nybbler.cc:12
DataMap update(AdcChannelData &acd) const override
void getSignal(const Vector &qdats, double ped, double csi, Vector &qsigs) const
ExpTailRemover(fhicl::ParameterSet const &ps)
AdcChannelTool * m_pSignalTool
NameVector m_IncludeChannelRanges
~ExpTailRemover() override=default
std::vector< bool > m_checkChannels
const double e
std::string Name
std::vector< Name > NameVector
void estimatepars(const Vector &qdats, double &ped, double &csi, Index &nsamFit) const
NameVector m_ExcludeChannelRanges
static constexpr double ps
Definition: Units.h:99
list x
Definition: train.py:276
std::vector< double > Vector
void wlinfit(const Vector &x, const Vector &y, const Vector &e, double &slope, double &intercept) const