ADCFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // ADCFilter class:
4 // Algorithm to ignore events with no ADC values
5 // above user-defined threshold.
6 //
7 // msoderbe@syr.edu
8 //
9 ////////////////////////////////////////////////////////////////////////
10 
11 #include <algorithm>
12 
13 //Framework Includes
14 #include "fhiclcpp/ParameterSet.h"
20 
21 //Larsoft Includes
22 #include "lardataobj/RawData/raw.h"
26 
27 
28 namespace filter {
29 
30  class ADCFilter : public art::EDFilter {
31 
32  public:
33 
34  explicit ADCFilter(fhicl::ParameterSet const& );
35 
36  private:
37  bool filter(art::Event& evt);
38 
40  double fMinADC;
41  }; // class ADCFilter
42 
43  //-------------------------------------------------
45  : EDFilter{pset}
46  {
47  fDigitModuleLabel = pset.get< std::string > ("DigitModuleLabel");
48  fMinADC = pset.get< double > ("MinADC");
49  }
50 
51  //-------------------------------------------------
53  {
54  //Read in raw data
55  art::View<raw::RawDigit> rawdigitView;
56  evt.getView(fDigitModuleLabel, rawdigitView);
57 
58  if(!rawdigitView.size()) return false;
59 
60  lariov::ChannelStatusProvider const& channelFilter
62 
63  // look through the good channels
64 // for(const raw::RawDigit* digit: filter::SelectGoodChannels(rawdigitView))
65  for(const raw::RawDigit* digit: rawdigitView)
66  {
67  if (!channelFilter.IsGood(digit->Channel())) continue;
68  //get ADC values after decompressing
69  std::vector<short> rawadc(digit->Samples());
70  raw::Uncompress(digit->ADCs(),rawadc,digit->Compression());
71  short max = *std::max_element(rawadc.begin(),rawadc.end()) - digit->GetPedestal();
72  if(max>=fMinADC) return true;//found one ADC value above threshold, pass filter
73  }
74 
75  return false;//didn't find ADC above threshold
76 
77  }
78 
80 
81 } //namespace filter
std::string fDigitModuleLabel
bool filter(art::Event &evt)
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::string string
Definition: nybbler.cc:12
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
virtual bool IsGood(raw::ChannelID_t channel) const
Returns whether the specified channel is physical and good.
Definition: fwd.h:46
Class providing information about the quality of channels.
static int max(int a, int b)
ADCFilter(fhicl::ParameterSet const &)
auto size() const noexcept
Definition: View.h:119
Interface for experiment-specific channel quality info provider.
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:21
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:500
TCEvent evt
Definition: DataStructs.cxx:7
Interface for experiment-specific service for channel quality info.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776