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"
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 {
53  reconfigure(p);
54 }
55 
57  fChannels = pset.get<std::vector<unsigned int>>("Channels");
58  fRawDataLabel = pset.get<art::InputTag>("RawDataLabel");
59  fThresholdADC = pset.get<double>("ThresholdADC", 10);
60  fPulseIsNegative = pset.get<bool>("PulseIsNegative", true);
61 }
62 
64 {
65  // Get raw digits
67  std::vector<art::Ptr<rawdata::RawBeamlineDigit>> digits;
68  if (e.getByLabel(fRawDataLabel, digitHandle)) art::fill_ptr_vector(digits, digitHandle);
69 
70  for (auto d : digits) {
71  // Skip if not in fChannels
72  if (std::find_if(fChannels.begin(), fChannels.end(), [d](unsigned int ch){ return d->ChannelID().Channel == ch; } ) == fChannels.end()) {
73  continue;
74  }
75 
76  std::vector<uint16_t> adcs = d->ADCs();
77 
78  for (size_t i=0; i<adcs.size(); i++) {
79  if (fPulseIsNegative) {
80  if (adcs[i] < fThresholdADC) {
81  //std::cout << e.run() << " " << e.subRun() << " " << e.event() << " ch" << d->Channel() << " below threshold" << std::endl;
82  return false;
83  }
84  } else {
85  if (adcs[i] > fThresholdADC) {
86  return false;
87  }
88  }
89  }
90  }
91 
92  return true;
93 }
94 
95 
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
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
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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:464
Float_t e
Definition: plot.C:35