DuneDPhase3x1x1NoiseRemovalService.h
Go to the documentation of this file.
1 // DuneDPhase3x1x1NoiseRemovalService.h
2 //
3 // Robert Sulej, Aug 2017
4 // Christoph Alt, Nov 2017 (update)
5 //
6 // Remove coherent noise from 3x1x1 data.
7 //
8 
9 #ifndef DuneDPhase3x1x1NoiseRemovalService_H
10 #define DuneDPhase3x1x1NoiseRemovalService_H
11 
12 #include "TFFTRealComplex.h"
13 #include "TFFTComplexReal.h"
14 
17 
18 class AdcChannelTool;
19 
20 namespace geo { class Geometry; }
21 namespace util { class LArFFT; }
22 
23 using GroupChannelMap = std::unordered_map<unsigned int, std::vector<unsigned int> >;
24 
26 
27 public:
28 
30 
31  int update(AdcChannelDataMap& datamap) const;
32 
33  std::ostream& print(std::ostream& out = std::cout, std::string prefix = "") const;
34 
35 private:
36 
37  std::vector<float> getMeanCorrection(
38  const std::vector<unsigned int> & channels,
39  const AdcChannelDataMap & datamap) const;
40 
41  std::vector<float> getMedianCorrection(
42  const std::vector<unsigned int> & channels,
43  const AdcChannelDataMap & datamap) const;
44 
45  void fftFltInPlace(std::vector< float > & adc, const std::vector< float > & coeffs) const;
46  std::vector< float > fftFlt(const std::vector< float > & adc, const std::vector< float > & coeffs) const;
47 
48  void removeCoherent(const GroupChannelMap & ch_groups, AdcChannelDataMap& datamap) const;
49  void removeHighFreq(AdcChannelDataMap& datamap) const;
50  void removeSlope(AdcChannelDataMap& datamap) const;
51  void removeSlopePolynomial(AdcChannelDataMap& datamap) const;
52 
53  std::vector<bool> roiMask(const AdcChannelData & adc) const;
54 
55  /// Make groups of channels using 3x1x1 DAQ numbering. Channels tagged as noisy are excluded at this stage.
56  GroupChannelMap makeDaqGroups(size_t gsize, const std::vector< size_t > & gidx) const;
57  /// Make groups of channels using LArSoft numbering. Channels tagged as noisy are excluded at this stage.
58  GroupChannelMap makeGroups(size_t gsize, const std::vector< size_t > & gidx) const;
59 
60  bool has(const std::vector<size_t> & v, size_t idx) const
61  {
62  for (auto c : v) if (c == idx) return true;
63  return false;
64  }
65 
66  /// Get 3x1x1 DAQ channel number from the LArSoft's channel index.
67  static size_t get311Chan(size_t LAr_chan);
68 
69  std::vector<double> GaussJordanSolv(std::vector< std::vector<long double> > matrix) const;
70 
71  // Configuration parameters.
72  bool fDoTwoPassFilter, fCoherent32, fCoherent16, fLowPassFlt, fLowPassFltSecondPass, fFlatten, fFlattenExtrapolate;
73  float fLowPassFltFCut, fLowPassFltExpo;
74  std::vector< size_t > fCoherent32Groups;
75  std::vector< size_t > fCoherent16Groups;
76  std::vector< float > fLowPassCoeffs;
82  int fMode;
84 
85  //Tools
86  using AdcChannelToolPtr = std::unique_ptr<const AdcChannelTool>;
87 
90 
93 
96 
97  // Services.
99  mutable util::LArFFT* fFFT;
100 };
101 
103 
104 #endif
Namespace for general, non-LArSoft-specific utilities.
std::string string
Definition: nybbler.cc:12
DECLARE_ART_SERVICE_INTERFACE_IMPL(MySharedService, art::test::MyServiceInterface, SHARED) DEFINE_ART_SERVICE_INTERFACE_IMPL(MySharedService
struct vector vector
int16_t adc
Definition: CRTFragment.hh:202
std::unique_ptr< const AdcChannelTool > AdcChannelToolPtr
The geometry of one entire detector, as served by art.
Definition: Geometry.h:196
unsigned int AdcIndex
Definition: AdcTypes.h:15
std::unordered_map< unsigned int, std::vector< unsigned int > > GroupChannelMap
static TemplateFilterFactory::AutoRegister< FilterFlatten > fFlatten("flatten")
bool has(const std::vector< size_t > &v, size_t idx) const
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
LArSoft geometry interface.
Definition: ChannelGeo.h:16