LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ADCFilter_module.cc
Go to the documentation of this file.
1 //
3 // ADCFilter class:
4 // Algorithm to ignore events with no ADC values
5 // above user-defined threshold.
6 //
7 // msoderbe@syr.edu
8 //
10 
11 #include <algorithm>
12 
13 //Framework Includes
19 #include "fhiclcpp/ParameterSet.h"
20 
21 //Larsoft Includes
23 #include "lardataobj/RawData/raw.h"
24 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h"
25 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h"
26 
27 namespace filter {
28 
29  class ADCFilter : public art::EDFilter {
30 
31  public:
32  explicit ADCFilter(fhicl::ParameterSet const&);
33 
34  private:
35  bool filter(art::Event& evt);
36 
37  std::string fDigitModuleLabel;
38  double fMinADC;
39  }; // class ADCFilter
40 
41  //-------------------------------------------------
43  {
44  fDigitModuleLabel = pset.get<std::string>("DigitModuleLabel");
45  fMinADC = pset.get<double>("MinADC");
46  }
47 
48  //-------------------------------------------------
50  {
51  //Read in raw data
52  art::View<raw::RawDigit> rawdigitView;
53  evt.getView(fDigitModuleLabel, rawdigitView);
54 
55  if (!rawdigitView.size()) return false;
56 
57  lariov::ChannelStatusProvider const& channelFilter =
59 
60  // look through the good channels
61  // for(const raw::RawDigit* digit: filter::SelectGoodChannels(rawdigitView))
62  for (const raw::RawDigit* digit : rawdigitView) {
63  if (!channelFilter.IsGood(digit->Channel())) continue;
64  //get ADC values after decompressing
65  std::vector<short> rawadc(digit->Samples());
66  raw::Uncompress(digit->ADCs(), rawadc, digit->Compression());
67  short max = *std::max_element(rawadc.begin(), rawadc.end()) - digit->GetPedestal();
68  if (max >= fMinADC) return true; //found one ADC value above threshold, pass filter
69  }
70 
71  return false; //didn't find ADC above threshold
72  }
73 
75 
76 } //namespace filter
std::string fDigitModuleLabel
bool filter(art::Event &evt)
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:68
Definition of basic raw digits.
Framework includes.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
Collect all the RawData header files together.
Definition: fwd.h:46
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
ADCFilter(fhicl::ParameterSet const &)
auto size() const noexcept
Definition: View.h:119
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.cc:6
TCEvent evt
Definition: DataStructs.cxx:8
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:744