All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawDigitCorrelatedCorrectionAlg.h
Go to the documentation of this file.
1 #ifndef RAWDIGITCORRELATEDCORRECTIONALG_H
2 #define RAWDIGITCORRELATEDCORRECTIONALG_H
3 ////////////////////////////////////////////////////////////////////////
4 //
5 // Class: RawDigitCorrelatedCorrectionAlg
6 // Module Type: algorithm
7 // File: RawDigitCorrelatedCorrectionAlg.cxx
8 //
9 // The intent of this algorithm is to perform "correlated noise"
10 // correction across the input waveforms
11 //
12 // Configuration parameters:
13 //
14 // TheChoseWire - Wire chosen for "example" hists
15 // MaxPedestalDiff - Baseline difference to pedestal to flag
16 // SmoothCorrelatedNoise - Turns on the correlated noise suppression
17 // NumWiresToGroup - When removing correlated noise, # wires to group
18 // FillHistograms - Turn on histogram filling for diagnostics
19 // RunFFTInputWires - FFT analyze the input RawDigits if true - diagnostics
20 // RunFFTCorrectedWires - FFT analyze the output RawDigits if true - diagnostics
21 // TruncateTicks: - Provide mechanism to truncate a readout window to a smaller size
22 // WindowSize: - The desired size of the output window
23 // NumTicksToDropFront: - The number ticks dropped off the front of the original window
24 //
25 //
26 // Created by Tracy Usher (usher@slac.stanford.edu) on January 6, 2016
27 // Based on work done by Brian Kirby, Mike Mooney and Jyoti Joshi
28 //
29 ////////////////////////////////////////////////////////////////////////
30 
32 #include "fhiclcpp/ParameterSet.h"
33 #include "art/Framework/Services/Registry/ServiceHandle.h"
34 #include "art_root_io/TFileService.h"
36 
37 #include "TH1.h"
38 #include "TH2.h"
39 #include "TProfile.h"
40 #include "TProfile2D.h"
41 
42 #include <set>
43 
44 namespace caldata
45 {
47 {
48 public:
49 
50  // Copnstructors, destructor.
51  RawDigitCorrelatedCorrectionAlg(fhicl::ParameterSet const & pset);
53 
54  // Provide for initialization
55  void reconfigure(fhicl::ParameterSet const & pset);
56  void initializeHists(art::ServiceHandle<art::TFileService>&);
57 
58  void removeCorrelatedNoise(RawDigitAdcIdxPair& digitIdxPair,
59  unsigned int viewIdx,
60  std::vector<float>& truncMeanWireVec,
61  std::vector<float>& truncRmsWireVec,
62  std::vector<short>& minMaxWireVec,
63  std::vector<short>& meanWireVec,
64  std::vector<float>& skewnessWireVec,
65  std::vector<float>& neighborRatioWireVec,
66  std::vector<float>& pedCorWireVec,
67  unsigned int& fftSize, unsigned int& halfFFTSize,
68  void* fplan, void* rplan) const;
69 
70 private:
71 
72  void smoothCorrectionVec(std::vector<float>&, unsigned int&) const;
73 
74  template<class T> T getMedian(std::vector<T>&, T) const;
75 
76  template <typename T> void findPeaks(typename std::vector<T>::iterator startItr,
77  typename std::vector<T>::iterator stopItr,
78  std::vector<std::tuple<size_t,size_t,size_t>>& peakTupleVec,
79  T threshold,
80  size_t firstTick) const;
81 
82  // Fcl parameters.
83  float fTruncMeanFraction; ///< Fraction for truncated mean
84 // bool fSmoothCorrelatedNoise; ///< Should we smooth the noise?
85  bool fApplyCorSmoothing; ///< Attempt to smooth the correlated noise correction?
86  bool fApplyFFTCorrection; ///< Use an FFT to get the correlated noise correction
87  bool fFillFFTHistograms; ///< Fill associated FFT histograms
88  std::vector<size_t> fFFTHistsWireGroup; ///< Wire Group to pick on
89  std::vector<size_t> fFFTNumHists; ///< Number of hists total per view
90  std::vector<double> fFFTHistsStartTick; ///< Starting tick for histograms
91  std::vector<double> fFFTMinPowerThreshold; ///< Threshold for trimming FFT power spectrum
92  std::vector<size_t> fNumWiresToGroup; ///< If smoothing, the number of wires to look at
93  bool fFillHistograms; ///< if true then will fill diagnostic hists
94  bool fRunFFTCorrected; ///< Should we run FFT's on corrected wires?
95  std::vector<float> fNumRmsToSmoothVec; ///< # "sigma" to smooth correlated correction vec
96 
97  std::vector<std::set<size_t>> fBadWiresbyViewAndWire;
98 
99  // Useful services, keep copies for now (we can update during begin run periods)
100  art::ServiceHandle<geo::Geometry> fGeometry; ///< pointer to Geometry service
101 };
102 
103 } // end caldata namespace
104 
105 #endif
bool fApplyFFTCorrection
Use an FFT to get the correlated noise correction.
std::vector< double > fFFTHistsStartTick
Starting tick for histograms.
bool fFillFFTHistograms
Fill associated FFT histograms.
std::pair< WireToRawDigitVecMap, WireToAdcIdxMap > RawDigitAdcIdxPair
bool fApplyCorSmoothing
Attempt to smooth the correlated noise correction?
std::vector< std::set< size_t > > fBadWiresbyViewAndWire
std::vector< size_t > fFFTHistsWireGroup
Wire Group to pick on.
RawDigitCorrelatedCorrectionAlg(fhicl::ParameterSet const &pset)
float fTruncMeanFraction
Fraction for truncated mean.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void removeCorrelatedNoise(RawDigitAdcIdxPair &digitIdxPair, unsigned int viewIdx, std::vector< float > &truncMeanWireVec, std::vector< float > &truncRmsWireVec, std::vector< short > &minMaxWireVec, std::vector< short > &meanWireVec, std::vector< float > &skewnessWireVec, std::vector< float > &neighborRatioWireVec, std::vector< float > &pedCorWireVec, unsigned int &fftSize, unsigned int &halfFFTSize, void *fplan, void *rplan) const
void findPeaks(typename std::vector< T >::iterator startItr, typename std::vector< T >::iterator stopItr, std::vector< std::tuple< size_t, size_t, size_t >> &peakTupleVec, T threshold, size_t firstTick) const
bool fFillHistograms
if true then will fill diagnostic hists
art::ServiceHandle< geo::Geometry > fGeometry
pointer to Geometry service
void smoothCorrectionVec(std::vector< float > &, unsigned int &) const
void initializeHists(art::ServiceHandle< art::TFileService > &)
Begin job method.
bool fRunFFTCorrected
Should we run FFT&#39;s on corrected wires?
std::vector< size_t > fFFTNumHists
Number of hists total per view.
std::vector< size_t > fNumWiresToGroup
If smoothing, the number of wires to look at.
std::vector< float > fNumRmsToSmoothVec
&quot;sigma&quot; to smooth correlated correction vec
std::vector< double > fFFTMinPowerThreshold
Threshold for trimming FFT power spectrum.
process_name can override from command line with o or output caldata
Definition: pid.fcl:40
void reconfigure(fhicl::ParameterSet const &pset)
art framework interface to geometry description