Public Member Functions | Private Attributes | List of all members
nnet::WaveformRoiFinder Class Reference
Inheritance diagram for nnet::WaveformRoiFinder:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 WaveformRoiFinder (fhicl::ParameterSet const &p)
 
 WaveformRoiFinder (WaveformRoiFinder const &)=delete
 
 WaveformRoiFinder (WaveformRoiFinder &&)=delete
 
WaveformRoiFinderoperator= (WaveformRoiFinder const &)=delete
 
WaveformRoiFinderoperator= (WaveformRoiFinder &&)=delete
 
void produce (art::Event &e) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

art::InputTag fRawProducerLabel
 
art::InputTag fWireProducerLabel
 
std::vector< std::unique_ptr< wavrec_tool::IWaveformRecog > > fWaveformRecogToolVec
 
int fNPlanes
 
unsigned int fWaveformSize
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 39 of file WaveformRoiFinder_module.cc.

Constructor & Destructor Documentation

nnet::WaveformRoiFinder::WaveformRoiFinder ( fhicl::ParameterSet const &  p)
explicit

Definition at line 64 of file WaveformRoiFinder_module.cc.

65  : EDProducer{p}
66  , fRawProducerLabel(p.get<art::InputTag>("RawProducerLabel", ""))
67  , fWireProducerLabel(p.get<art::InputTag>("WireProducerLabel", ""))
68 {
69  // use either raw waveform or recob waveform
71  throw cet::exception("WaveformRoiFinder")
72  << "Both RawProducerLabel and WireProducerLabel are empty";
73  }
74 
76  throw cet::exception("WaveformRoiFinder")
77  << "Only one of RawProducerLabel and WireProducerLabel should be set";
78  }
79 
80  auto const* geo = lar::providerFrom<geo::Geometry>();
81  fNPlanes = geo->Nplanes();
82 
83  // Signal/Noise waveform recognition tool
84  fWaveformRecogToolVec.reserve(fNPlanes);
85  auto const tool_psets = p.get<std::vector<fhicl::ParameterSet>>("WaveformRecogs");
86  fWaveformSize = tool_psets[0].get<unsigned int>("WaveformSize");
87  for (auto const& pset : tool_psets) {
88  fWaveformRecogToolVec.push_back(art::make_tool<wavrec_tool::IWaveformRecog>(pset));
89  }
90 
91  produces<std::vector<recob::Wire>>();
92 }
std::vector< std::unique_ptr< wavrec_tool::IWaveformRecog > > fWaveformRecogToolVec
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
bool empty() const noexcept
Definition: InputTag.cc:73
p
Definition: test.py:223
LArSoft geometry interface.
Definition: ChannelGeo.h:16
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
nnet::WaveformRoiFinder::WaveformRoiFinder ( WaveformRoiFinder const &  )
delete
nnet::WaveformRoiFinder::WaveformRoiFinder ( WaveformRoiFinder &&  )
delete

Member Function Documentation

WaveformRoiFinder& nnet::WaveformRoiFinder::operator= ( WaveformRoiFinder const &  )
delete
WaveformRoiFinder& nnet::WaveformRoiFinder::operator= ( WaveformRoiFinder &&  )
delete
void nnet::WaveformRoiFinder::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 95 of file WaveformRoiFinder_module.cc.

96 {
98  std::vector<art::Ptr<raw::RawDigit>> rawlist;
99  if (e.getByLabel(fRawProducerLabel, rawListHandle)) art::fill_ptr_vector(rawlist, rawListHandle);
100 
101  art::Handle<std::vector<recob::Wire>> wireListHandle;
102  std::vector<art::Ptr<recob::Wire>> wirelist;
103  if (e.getByLabel(fWireProducerLabel, wireListHandle))
104  art::fill_ptr_vector(wirelist, wireListHandle);
105 
106  std::unique_ptr<std::vector<recob::Wire>> outwires(new std::vector<recob::Wire>);
107 
108  auto const* geo = lar::providerFrom<geo::Geometry>();
109 
110  //##############################
111  //### Looping over the wires ###
112  //##############################
113  for (unsigned int ich = 0; ich < (rawlist.empty() ? wirelist.size() : rawlist.size()); ++ich) {
114 
115  std::vector<float> inputsignal(fWaveformSize);
116 
117  int view = -1;
118 
119  if (!wirelist.empty()) {
120  const auto& wire = wirelist[ich];
121  const auto& signal = wire->Signal();
122 
123  view = wire->View();
124 
125  for (size_t itck = 0; itck < inputsignal.size(); ++itck) {
126  inputsignal[itck] = signal[itck];
127  }
128  }
129  else if (!rawlist.empty()) {
130  const auto& digitVec = rawlist[ich];
131 
132  view = geo->View(rawlist[ich]->Channel());
133 
134  std::vector<short> rawadc(fWaveformSize);
135  raw::Uncompress(digitVec->ADCs(), rawadc, digitVec->GetPedestal(), digitVec->Compression());
136  for (size_t itck = 0; itck < rawadc.size(); ++itck) {
137  inputsignal[itck] = rawadc[itck] - digitVec->GetPedestal();
138  }
139  }
140 
141  // ... use waveform recognition CNN to perform inference on each window
142  std::vector<bool> inroi(fWaveformSize, false);
143  inroi = fWaveformRecogToolVec[view]->findROI(inputsignal);
144 
145  std::vector<float> sigs;
146  int lastsignaltick = -1;
147  int roistart = -1;
148 
150 
151  for (size_t i = 0; i < fWaveformSize; ++i) {
152  if (inroi[i]) {
153  if (sigs.empty()) {
154  sigs.push_back(inputsignal[i]);
155  lastsignaltick = i;
156  roistart = i;
157  }
158  else {
159  if (int(i) != lastsignaltick + 1) {
160  rois.add_range(roistart, std::move(sigs));
161  sigs.clear();
162  sigs.push_back(inputsignal[i]);
163  lastsignaltick = i;
164  roistart = i;
165  }
166  else {
167  sigs.push_back(inputsignal[i]);
168  lastsignaltick = i;
169  }
170  }
171  }
172  }
173  if (!sigs.empty()) { rois.add_range(roistart, std::move(sigs)); }
174  if (!wirelist.empty()) {
175  outwires->emplace_back(recob::Wire(rois, wirelist[ich]->Channel(), wirelist[ich]->View()));
176  }
177  else if (!rawlist.empty()) {
178  outwires->emplace_back(
179  recob::Wire(rois, rawlist[ich]->Channel(), geo->View(rawlist[ich]->Channel())));
180  }
181  }
182 
183  e.put(std::move(outwires));
184 }
std::vector< std::unique_ptr< wavrec_tool::IWaveformRecog > > fWaveformRecogToolVec
AdcChannelData::View View
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
LArSoft geometry interface.
Definition: ChannelGeo.h:16

Member Data Documentation

int nnet::WaveformRoiFinder::fNPlanes
private

Definition at line 60 of file WaveformRoiFinder_module.cc.

art::InputTag nnet::WaveformRoiFinder::fRawProducerLabel
private

Definition at line 55 of file WaveformRoiFinder_module.cc.

std::vector<std::unique_ptr<wavrec_tool::IWaveformRecog> > nnet::WaveformRoiFinder::fWaveformRecogToolVec
private

Definition at line 58 of file WaveformRoiFinder_module.cc.

unsigned int nnet::WaveformRoiFinder::fWaveformSize
private

Definition at line 61 of file WaveformRoiFinder_module.cc.

art::InputTag nnet::WaveformRoiFinder::fWireProducerLabel
private

Definition at line 56 of file WaveformRoiFinder_module.cc.


The documentation for this class was generated from the following file: