All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawDigitCharacterizationAlg.h
Go to the documentation of this file.
1 #ifndef RAWDIGITCHARACTERIZATIONALG_H
2 #define RAWDIGITCHARACTERIZATIONALG_H
3 ////////////////////////////////////////////////////////////////////////
4 //
5 // Class: RawDigitCharacterizationAlg
6 // Module Type: producer
7 // File: RawDigitCharacterizationAlg.h
8 //
9 // The intent of this module is to provide methods for
10 // characterizing an input RawDigit waveform
11 //
12 // Configuration parameters:
13 //
14 // TruncMeanFraction - the fraction of waveform bins to discard when
15 // computing the means and rms
16 // RMSRejectionCutHi - vector of maximum allowed rms values to keep channel
17 // RMSRejectionCutLow - vector of lowest allowed rms values to keep channel
18 // RMSSelectionCut - vector of rms values below which to not correct
19 // MaxPedestalDiff - Baseline difference to pedestal to flag
20 //
21 // Created by Tracy Usher (usher@slac.stanford.edu) on January 6, 2016
22 // Based on work done by Brian Kirby, Mike Mooney and Jyoti Joshi
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
27 #include "fhiclcpp/ParameterSet.h"
28 
29 #include "art/Framework/Services/Registry/ServiceHandle.h"
30 #include "art_root_io/TFileService.h"
35 
37 
38 #include "TH1.h"
39 #include "TH2.h"
40 #include "TProfile.h"
41 #include "TProfile2D.h"
42 
43 namespace caldata
44 {
46 {
47 public:
48 
49  // Copnstructors, destructor.
50  RawDigitCharacterizationAlg(fhicl::ParameterSet const & pset);
52 
53  // provide for initialization
54  void reconfigure(fhicl::ParameterSet const & pset);
55  void initializeHists(art::ServiceHandle<art::TFileService>&);
56 
57  // Basic waveform mean and rms
58  void getMeanAndRms(const RawDigitVector& rawWaveform,
59  float& aveVal,
60  float& rmsVal,
61  int& numBins) const;
62 
63  // Basic waveform mean and rms plus trunated rms
64  void getMeanAndTruncRms(const RawDigitVector& rawWaveform,
65  float& aveVal,
66  float& rmsVal,
67  float& rmsTrunc,
68  int& numBins) const;
69 
70  // Truncated rms calculation
71  void getTruncatedRMS(const RawDigitVector& rawWaveform,
72  float& pedestal,
73  float& truncRms) const;
74 
75  // Basic waveform mean, rms and pedestal offset
76  void getMeanRmsAndPedCor(const RawDigitVector& rawWaveform,
77  unsigned int channel,
78  unsigned int view,
79  unsigned int wire,
80  float& aveVal,
81  float& rmsVal,
82  float& pedCorVal) const;
83 
84  // Basic waveform mean, rms and pedestal offset
85  void getWaveformParams(const RawDigitVector& rawWaveform,
86  unsigned int channel,
87  unsigned int view,
88  unsigned int wire,
89  float& truncMean,
90  float& truncRms,
91  short& mean,
92  short& median,
93  short& mode,
94  float& skewness,
95  float& rms,
96  short& minMax,
97  float& neighborRatio,
98  float& pedCorVal) const;
99 
100  bool classifyRawDigitVec(RawDigitVector& rawWaveform,
101  unsigned int viewIdx,
102  unsigned int wire,
103  float truncRms,
104  short minMax,
105  short mean,
106  float skewness,
107  float neighborRatio,
108  GroupToDigitIdxPairMap& groupToDigitIdxPairMap) const;
109 
110  template<class T> T getMedian(std::vector<T>&, T) const;
111 
112 private:
113 
114  // Fcl parameters.
115  float fTruncMeanFraction; ///< Fraction for truncated mean
116  std::vector<float> fRmsRejectionCutHi; ///< Maximum rms for input channels, reject if larger
117  std::vector<float> fRmsRejectionCutLow; ///< Minimum rms to consider channel "alive"
118  std::vector<float> fRmsSelectionCut; ///< Don't use/apply correction to wires below this
119  std::vector<short> fMinMaxSelectionCut; ///< Plane by plane cuts for spread cut
120  unsigned int fTheChosenWire; ///< For example hist
121  double fMaxPedestalDiff; ///< Max pedestal diff to db to warn
122  std::vector<size_t> fHistsWireGroup; ///< Wire Group to pick on
123  std::vector<size_t> fNumWiresToGroup; ///< If smoothing, the number of wires to look at
124  bool fFillHistograms; ///< if true then will fill diagnostic hists
125 
126  // Make sure hists for this instance are initialized
128 
129  // Pointers to the histograms we'll create for monitoring what is happening
130  TH1D* fAdcCntHist[3];
131  TH1D* fAveValHist[3];
132  TH1D* fRmsTValHist[3];
133  TH1D* fRmsFValHist[3];
134  TH1D* fPedValHist[3];
135  TH1D* fAverageHist[3];
136  TProfile* fRmsValProf[3];
137  TProfile* fMinMaxValProf[3];
138  TProfile* fPedValProf[3];
139 
140  std::vector<TProfile*> fMinMaxProfiles;
141  std::vector<TProfile*> fSkewnessProfiles;
142  std::vector<TProfile*> fModeRatioProfiles;
143 
145 
146  // Useful services, keep copies for now (we can update during begin run periods)
147  art::ServiceHandle<geo::Geometry> fGeometry; ///< pointer to Geometry service
148  ///< Detector properties service
149  const lariov::DetPedestalProvider& fPedestalRetrievalAlg; ///< Keep track of an instance to the pedestal retrieval alg
150 };
151 
152 } // end of namespace caldata
153 
154 #endif
std::vector< float > fRmsSelectionCut
Don&#39;t use/apply correction to wires below this.
RawDigitCharacterizationAlg(fhicl::ParameterSet const &pset)
std::vector< short > fMinMaxSelectionCut
Plane by plane cuts for spread cut.
void getMeanRmsAndPedCor(const RawDigitVector &rawWaveform, unsigned int channel, unsigned int view, unsigned int wire, float &aveVal, float &rmsVal, float &pedCorVal) const
void getMeanAndRms(const RawDigitVector &rawWaveform, float &aveVal, float &rmsVal, int &numBins) const
double fMaxPedestalDiff
Max pedestal diff to db to warn.
bool classifyRawDigitVec(RawDigitVector &rawWaveform, unsigned int viewIdx, unsigned int wire, float truncRms, short minMax, short mean, float skewness, float neighborRatio, GroupToDigitIdxPairMap &groupToDigitIdxPairMap) const
bool fFillHistograms
if true then will fill diagnostic hists
raw::RawDigit::ADCvector_t RawDigitVector
void getMeanAndTruncRms(const RawDigitVector &rawWaveform, float &aveVal, float &rmsVal, float &rmsTrunc, int &numBins) const
art::ServiceHandle< geo::Geometry > fGeometry
Detector properties service.
unsigned int fTheChosenWire
For example hist.
std::map< size_t, RawDigitAdcIdxPair > GroupToDigitIdxPairMap
const char mode
Definition: noise_ana.cxx:20
std::vector< float > fRmsRejectionCutLow
Minimum rms to consider channel &quot;alive&quot;.
void reconfigure(fhicl::ParameterSet const &pset)
const lariov::DetPedestalProvider & fPedestalRetrievalAlg
Keep track of an instance to the pedestal retrieval alg.
void getTruncatedRMS(const RawDigitVector &rawWaveform, float &pedestal, float &truncRms) const
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
std::vector< size_t > fNumWiresToGroup
If smoothing, the number of wires to look at.
std::vector< float > fRmsRejectionCutHi
Maximum rms for input channels, reject if larger.
std::vector< size_t > fHistsWireGroup
Wire Group to pick on.
void initializeHists(art::ServiceHandle< art::TFileService > &)
Begin job method.
void getWaveformParams(const RawDigitVector &rawWaveform, unsigned int channel, unsigned int view, unsigned int wire, float &truncMean, float &truncRms, short &mean, short &median, short &mode, float &skewness, float &rms, short &minMax, float &neighborRatio, float &pedCorVal) const
process_name can override from command line with o or output caldata
Definition: pid.fcl:40
float fTruncMeanFraction
Fraction for truncated mean.
art framework interface to geometry description