Tpc2dDeconvolute.h
Go to the documentation of this file.
1 // Tpc2dDeconvolute.h
2 //
3 // David Adams
4 // August 2021
5 //
6 // Tool to perform 2D (time and channel) deconvolution of the 2D ROIs in TpcData.
7 //
8 // The observed charge qd is assumed to be related to the true charge by
9 // qd(m,i) = SUM(n,j) r(m,n;i,j) q0(n,j)
10 // where the indices repectively denote channel and time bin (tick) and r
11 // is the unbinned response matrix.
12 //
13 // Discrete Fourier transforms (DFTs) are used to express this in channel (kn, km)
14 // and time (ki, kj) wave numbers:
15 //
16 // Qd(km,ki) = R(km-kn,ki-kj) Q0(kn,kj)
17 //
18 // with charge and response assumed periodic in channel and time.
19 // This expression is then easily inverted to obtain and estimate Qe of Q0:
20 //
21 // Qe(kn,kj) = Fc(kn) Ft(kj) Qd(km,ki) /R(km-kn,ki-kj)
22 //
23 // HF filter functions Fc and Ft are introduced to suppress large values that can
24 // arise where R approaches zero and noise in the measurement of Qd keeps
25 // that value finite.
26 // The filter functions are Gaussian derived from user-supplied Gaussian sigmas in
27 // sample (tick) and channel.
28 //
29 // Low-frequency filtering is provided in sample only by the function
30 // 1/[ 1 + 1/(W N k)^P ]
31 // N is the number of samples and and k is the wave number.
32 // The width W and power P are configuration parameters.
33 // W < 0 disables the filter
34 // W = 0 filters out k = 0 only
35 // W > 0 removes k = 0 and applies the above for other values
36 //
37 // Other options may later be added for the response or filter.
38 //
39 // The response matrix is derived from an input reponse matrix ri(m,i) read from a
40 // channel-indexed vector of tick-indexed reponse vectors. This input reponse is
41 // the signal induced in the mth neighbor channel by a charge deposited at tick0.
42 // The tick-indexed reponse vectors can have varying lenght.
43 //
44 // The channel-tick dimensions of the response matrix r used in the deconvolution are
45 // those of the input data which must be rectangular in that space.
46 // The reponse matrix is derived from the input reponse assuming reflection symmetry
47 // in channel. Missing entries are filled with zeroes and those byond the data
48 // dimensions are ignored.
49 //
50 // Configuration:
51 // LogLevel: 0=silent, 1=init, 2=each event, >2=more
52 // ResponseVectors: Vector of discrete sequences giving the 2D response (ri above).
53 // ReponseCenter: Center tick for the response function (tick0 above).
54 // FftSize: Maximum FFT size, roughly ncha*nsam.
55 // InPath: Path to the input 2D ROIs.
56 // OutPath: Path to the output 2D ROIs. If "" or ".", the input ROIs are updated.
57 // SampleSigma: Tick sigma used to construct the sample filter. Zero means no filter.
58 // ChannelSigma: Channel sigma used to construct the sample filter. Zero means no filter.
59 // LowFilterWidth: - Width [tick] for the low-frequency sample filter. Zero means only k=0.
60 // LowFilterPower: - Power for the LF sample filter. Value <=0 disables the filter.
61 //
62 
63 #ifndef Tpc2dDeconvolute_H
64 #define Tpc2dDeconvolute_H
65 
67 #include "fhiclcpp/ParameterSet.h"
71 
73 
74 public:
75 
76  using Index = unsigned int;
77 
79 
80  ~Tpc2dDeconvolute() override =default;
81 
82  // Deconvolute.
83  DataMap updateTpcData(TpcData&) const override;
84 
85  // Viewing fails (for now).
86  DataMap viewTpcData(const TpcData&) const override;
87 
88  // Return the FFT transform (eventually for this thread).
89  Fw2dFFT& fft() const;
90 
91 private:
92 
93  using Name = std::string;
94  using IndexVector = std::vector<Index>;
95  using ResponseVector = AdcSignalVector; // Same type as AdcChannel data
96  using ResponseVectorVector = std::vector<ResponseVector>;
97 
98  // Configuration data.
109 
110  // Transform.
111  std::unique_ptr<Fw2dFFT> m_pfft;
112 
113 };
114 
116 
117 #endif
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
unsigned int Index
std::string string
Definition: nybbler.cc:12
std::vector< Index > IndexVector
~Tpc2dDeconvolute() override=default
std::vector< ResponseVector > ResponseVectorVector
Fw2dFFT & fft() const
DataMap viewTpcData(const TpcData &) const override
ResponseVectorVector m_ResponseVectors
static constexpr double ps
Definition: Units.h:99
Tpc2dDeconvolute(fhicl::ParameterSet const &ps)
AdcSignalVector ResponseVector
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
std::unique_ptr< Fw2dFFT > m_pfft
DataMap updateTpcData(TpcData &) const override