DigitizerSaturationFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DigitizerSaturationFilter
3 // Plugin Type: filter (art v2_12_01)
4 // File: DigitizerSaturationFilter_module.cc
5 //
6 // Aidan Medcalf (University of Dallas) <amedcalf@fnal.gov>
7 //
8 // Discard events which saturate (clip) the digitizer
9 ////////////////////////////////////////////////////////////////////////
10 
18 #include "fhiclcpp/ParameterSet.h"
23 #include "art_root_io/TFileService.h"
24 #include "art_root_io/TFileDirectory.h"
26 
28 #include "BeamlineRecoBase/ToF.h"
29 #include "RawData/RawBeamline.h"
30 #include "Utilities/AssociationUtil.h"
31 
32 #include <iostream>
33 #include <map>
34 
35 namespace beamlinereco {
37  public:
39 
40  bool filter(art::Event &e);
41  void reconfigure(const fhicl::ParameterSet &p);
42 
43  private:
44  std::vector<unsigned int> fChannels;
46  double fThresholdADC;
48  };
49 }
50 
52 : EDFilter(p)
53 {
54  reconfigure(p);
55 }
56 
58  fChannels = pset.get<std::vector<unsigned int>>("Channels");
59  fRawDataLabel = pset.get<art::InputTag>("RawDataLabel");
60  fThresholdADC = pset.get<double>("ThresholdADC", 10);
61  fPulseIsNegative = pset.get<bool>("PulseIsNegative", true);
62 }
63 
65 {
66  // Get raw digits
68  std::vector<art::Ptr<rawdata::RawBeamlineDigit>> digits;
69  if (e.getByLabel(fRawDataLabel, digitHandle)) art::fill_ptr_vector(digits, digitHandle);
70 
71  for (auto d : digits) {
72  // Skip if not in fChannels
73  if (std::find_if(fChannels.begin(), fChannels.end(), [d](unsigned int ch){ return d->ChannelID().Channel == ch; } ) == fChannels.end()) {
74  continue;
75  }
76 
77  std::vector<uint16_t> adcs = d->ADCs();
78 
79  for (size_t i=0; i<adcs.size(); i++) {
80  if (fPulseIsNegative) {
81  if (adcs[i] < fThresholdADC) {
82  //std::cout << e.run() << " " << e.subRun() << " " << e.event() << " ch" << d->Channel() << " below threshold" << std::endl;
83  return false;
84  }
85  } else {
86  if (adcs[i] > fThresholdADC) {
87  return false;
88  }
89  }
90  }
91  }
92 
93  return true;
94 }
95 
96 
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
Encapsulation of reconstructed digitizer &#39;hits&#39;. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
T get(std::string const &key) const
Definition: ParameterSet.h:231
Encapsulation of reconstructed Time-of-Flight (ToF) information. Part of beamline reconstruction for ...
Float_t d
Definition: plot.C:236
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:22
Raw data definitions for beamline data used in NOvA test beam experiment.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:291
Float_t e
Definition: plot.C:35