All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
15 #include "art/Framework/Core/EDFilter.h"
16 #include "art/Framework/Core/ModuleMacros.h"
17 #include "art/Framework/Principal/Event.h"
18 #include "art/Framework/Principal/View.h"
19 #include "art/Framework/Services/Registry/ServiceHandle.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 
39  std::string fDigitModuleLabel;
40  double fMinADC;
41  }; // class ADCFilter
42 
43  //-------------------------------------------------
44  ADCFilter::ADCFilter(fhicl::ParameterSet const & pset)
45  : EDFilter{pset}
46  {
47  fDigitModuleLabel = pset.get< std::string > ("DigitModuleLabel");
48  fMinADC = pset.get< double > ("MinADC");
49  }
50 
51  //-------------------------------------------------
52  bool ADCFilter::filter(art::Event &evt)
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
61  = art::ServiceHandle<lariov::ChannelStatusService const>()->GetProvider();
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 
79  DEFINE_ART_MODULE(ADCFilter)
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
Definition of basic raw digits.
Collect all the RawData header files together.
virtual bool IsGood(raw::ChannelID_t channel) const
Returns whether the specified channel is physical and good.
Class providing information about the quality of channels.
physics filters filter
ADCFilter(fhicl::ParameterSet const &)
Interface for experiment-specific channel quality info provider.
TCEvent evt
Definition: DataStructs.cxx:8
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