LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
nnet::EmTrackClusterId2out Class Reference
Inheritance diagram for nnet::EmTrackClusterId2out:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  Config
 

Public Types

typedef std::unordered_map< unsigned int, std::vector< size_t > > view_keymap
 
typedef std::unordered_map< unsigned int, view_keymaptpc_view_keymap
 
typedef std::unordered_map< unsigned int, tpc_view_keymapcryo_tpc_view_keymap
 
using Parameters = art::EDProducer::Table< Config >
 
using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 EmTrackClusterId2out (Parameters const &p)
 
 EmTrackClusterId2out (EmTrackClusterId2out const &)=delete
 
 EmTrackClusterId2out (EmTrackClusterId2out &&)=delete
 
EmTrackClusterId2outoperator= (EmTrackClusterId2out const &)=delete
 
EmTrackClusterId2outoperator= (EmTrackClusterId2out &&)=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)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
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)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
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 ()
 

Private Member Functions

void produce (art::Event &e) override
 
bool isViewSelected (int view) const
 

Private Attributes

size_t fBatchSize
 
PointIdAlg fPointIdAlg
 
anab::MVAWriter< 2 > fMVAWriter
 
art::InputTag fWireProducerLabel
 
art::InputTag fHitModuleLabel
 
art::InputTag fClusterModuleLabel
 
art::InputTag fTrackModuleLabel
 
bool fDoClusters
 
bool fDoTracks
 
std::vector< int > fViews
 
art::InputTag fNewClustersTag
 

Detailed Description

Definition at line 56 of file EmTrackClusterId2out_module.cc.

Member Typedef Documentation

typedef std::unordered_map<unsigned int, tpc_view_keymap> nnet::EmTrackClusterId2out::cryo_tpc_view_keymap

Definition at line 61 of file EmTrackClusterId2out_module.cc.

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

typedef std::unordered_map<unsigned int, view_keymap> nnet::EmTrackClusterId2out::tpc_view_keymap

Definition at line 60 of file EmTrackClusterId2out_module.cc.

typedef std::unordered_map<unsigned int, std::vector<size_t> > nnet::EmTrackClusterId2out::view_keymap

Definition at line 59 of file EmTrackClusterId2out_module.cc.

Constructor & Destructor Documentation

nnet::EmTrackClusterId2out::EmTrackClusterId2out ( EmTrackClusterId2out::Parameters const &  config)
explicit

Definition at line 121 of file EmTrackClusterId2out_module.cc.

References fBatchSize, fClusterModuleLabel, fDoClusters, fDoTracks, fHitModuleLabel, fMVAWriter, fNewClustersTag, fPointIdAlg, fTrackModuleLabel, fViews, fWireProducerLabel, art::InputTag::label(), anab::FVectorWriter< N >::produces_using(), and art::ProductRegistryHelper::producesCollector().

122  : EDProducer{config}
123  , fBatchSize(config().BatchSize())
124  , fPointIdAlg(config().PointIdAlg())
125  , fMVAWriter(producesCollector(), "emtrack")
126  , fWireProducerLabel(config().WireLabel())
127  , fHitModuleLabel(config().HitModuleLabel())
128  , fClusterModuleLabel(config().ClusterModuleLabel())
129  , fTrackModuleLabel(config().TrackModuleLabel())
130  , fViews(config().Views())
131  ,
132 
133  fNewClustersTag(config.get_PSet().get<std::string>("module_label"),
134  "",
136  {
138 
139  if (!fClusterModuleLabel.label().empty()) {
140  produces<std::vector<recob::Cluster>>();
141  produces<art::Assns<recob::Cluster, recob::Hit>>();
142 
144  fDoClusters = true;
145  }
146  else {
147  fDoClusters = false;
148  }
149 
150  if (!fTrackModuleLabel.label().empty()) {
152  fDoTracks = true;
153  }
154  else {
155  fDoTracks = false;
156  }
157  }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
Set of hits with a 2D structure.
Definition: Cluster.h:69
std::string const & label() const noexcept
Definition: InputTag.cc:79
ProducesCollector & producesCollector() noexcept
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
nnet::EmTrackClusterId2out::EmTrackClusterId2out ( EmTrackClusterId2out const &  )
delete
nnet::EmTrackClusterId2out::EmTrackClusterId2out ( EmTrackClusterId2out &&  )
delete

Member Function Documentation

template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::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 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
bool nnet::EmTrackClusterId2out::isViewSelected ( int  view) const
private

Definition at line 420 of file EmTrackClusterId2out_module.cc.

References DEFINE_ART_MODULE, and fViews.

Referenced by produce().

421  {
422  if (fViews.empty())
423  return true;
424  else {
425  for (auto k : fViews)
426  if (k == view) { return true; }
427  return false;
428  }
429  }
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
EmTrackClusterId2out& nnet::EmTrackClusterId2out::operator= ( EmTrackClusterId2out const &  )
delete
EmTrackClusterId2out& nnet::EmTrackClusterId2out::operator= ( EmTrackClusterId2out &&  )
delete
void nnet::EmTrackClusterId2out::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 160 of file EmTrackClusterId2out_module.cc.

References anab::MVAWriter< N >::addOutput(), util::CreateAssn(), art::EventID::event(), fBatchSize, fClusterModuleLabel, fDoClusters, fDoTracks, fHitModuleLabel, art::fill_ptr_vector(), fMVAWriter, fNewClustersTag, fPointIdAlg, fTrackModuleLabel, fWireProducerLabel, anab::MVAWriter< N >::getOutput(), art::ProductRetriever::getValidHandle(), art::Event::id(), anab::FVectorWriter< N >::initOutputs(), nnet::PointIdAlg::isInsideFiducialRegion(), isViewSelected(), nnet::PointIdAlg::outputLabels(), recob::Hit::PeakTime(), geo::WireID::planeID(), nnet::PointIdAlg::predictIdVectors(), art::PtrVector< T >::push_back(), art::Event::put(), art::Event::run(), anab::FVectorWriter< N >::saveOutputs(), anab::MVAWriter< N >::setOutput(), img::DataProviderAlg::setWireDriftData(), geo::WireID::Wire, and recob::Hit::WireID().

161  {
162  mf::LogVerbatim("EmTrackClusterId2out")
163  << "next event: " << evt.run() << " / " << evt.id().event();
164 
165  auto wireHandle = evt.getValidHandle<std::vector<recob::Wire>>(fWireProducerLabel);
166 
167  unsigned int cryo, tpc, view;
168 
169  // ******************* get and sort hits ********************
170  auto hitListHandle = evt.getValidHandle<std::vector<recob::Hit>>(fHitModuleLabel);
171  std::vector<art::Ptr<recob::Hit>> hitPtrList;
172  art::fill_ptr_vector(hitPtrList, hitListHandle);
173 
175  for (auto const& h : hitPtrList) {
176  view = h->WireID().Plane;
177  if (!isViewSelected(view)) continue;
178 
179  cryo = h->WireID().Cryostat;
180  tpc = h->WireID().TPC;
181 
182  hitMap[cryo][tpc][view].push_back(h.key());
183  }
184 
185  // ********************* classify hits **********************
186  auto hitID = fMVAWriter.initOutputs<recob::Hit>(
187  fHitModuleLabel, hitPtrList.size(), fPointIdAlg.outputLabels());
188 
189  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
190  auto const detProp =
192 
193  std::vector<char> hitInFA(
194  hitPtrList.size(),
195  0); // tag hits in fid. area as 1, use 0 for hits close to the projectrion edges
196  for (auto const& pcryo : hitMap) {
197  cryo = pcryo.first;
198  for (auto const& ptpc : pcryo.second) {
199  tpc = ptpc.first;
200  for (auto const& pview : ptpc.second) {
201  view = pview.first;
202  if (!isViewSelected(view)) continue; // should not happen, hits were selected
203 
204  fPointIdAlg.setWireDriftData(clockData, detProp, *wireHandle, view, tpc, cryo);
205 
206  // (1) do all hits in this plane ------------------------------------------------
207  for (size_t idx = 0; idx < pview.second.size(); idx += fBatchSize) {
208  std::vector<std::pair<unsigned int, float>> points;
209  std::vector<size_t> keys;
210  for (size_t k = 0; k < fBatchSize; ++k) {
211  if (idx + k >= pview.second.size()) { break; } // careful about the tail
212 
213  size_t h = pview.second[idx + k]; // h is the Ptr< recob::Hit >::key()
214  const recob::Hit& hit = *(hitPtrList[h]);
215  points.emplace_back(hit.WireID().Wire, hit.PeakTime());
216  keys.push_back(h);
217  }
218 
219  auto batch_out = fPointIdAlg.predictIdVectors(points);
220  if (points.size() != batch_out.size()) {
221  throw cet::exception("EmTrackClusterId") << "hits processing failed" << std::endl;
222  }
223 
224  for (size_t k = 0; k < points.size(); ++k) {
225  size_t h = keys[k];
226  fMVAWriter.setOutput(hitID, h, batch_out[k]);
227  if (fPointIdAlg.isInsideFiducialRegion(points[k].first, points[k].second)) {
228  hitInFA[h] = 1;
229  }
230  }
231  } // hits done ------------------------------------------------------------------
232  }
233  }
234  }
235 
236  // (2) do clusters when hits are ready in all planes ----------------------------------------
237  if (fDoClusters) {
238  // **************** prepare for new clusters ****************
239  auto clusters = std::make_unique<std::vector<recob::Cluster>>();
240  auto clu2hit = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
241 
242  // ************** get and sort input clusters ***************
243  auto cluListHandle = evt.getValidHandle<std::vector<recob::Cluster>>(fClusterModuleLabel);
244  std::vector<art::Ptr<recob::Cluster>> cluPtrList;
245  art::fill_ptr_vector(cluPtrList, cluListHandle);
246 
248  for (auto const& c : cluPtrList) {
249  view = c->Plane().Plane;
250  if (!isViewSelected(view)) continue;
251 
252  cryo = c->Plane().Cryostat;
253  tpc = c->Plane().TPC;
254 
255  cluMap[cryo][tpc][view].push_back(c.key());
256  }
257 
258  auto cluID =
260 
261  unsigned int cidx = 0; // new clusters index
262  art::FindManyP<recob::Hit> hitsFromClusters(cluListHandle, evt, fClusterModuleLabel);
263  std::vector<bool> hitUsed(hitPtrList.size(), false); // tag hits used in clusters
264  for (auto const& pcryo : cluMap) {
265  cryo = pcryo.first;
266  for (auto const& ptpc : pcryo.second) {
267  tpc = ptpc.first;
268  for (auto const& pview : ptpc.second) {
269  view = pview.first;
270  if (!isViewSelected(view)) continue; // should not happen, clusters were pre-selected
271 
272  for (size_t c : pview.second) // c is the Ptr< recob::Cluster >::key()
273  {
274  auto v = hitsFromClusters.at(c);
275  if (v.empty()) continue;
276 
277  for (auto const& hit : v) {
278  if (hitUsed[hit.key()]) {
279  mf::LogWarning("EmTrackClusterId2out") << "hit already used in another cluster";
280  }
281  hitUsed[hit.key()] = true;
282  }
283 
284  auto vout = fMVAWriter.getOutput<recob::Hit>(
285  v, [&](art::Ptr<recob::Hit> const& ptr) { return (float)hitInFA[ptr.key()]; });
286 
287  mf::LogVerbatim("EmTrackClusterId2out")
288  << "cluster in tpc:" << tpc << " view:" << view << " size:" << v.size()
289  << " p:" << vout[0];
290 
291  clusters->emplace_back(recob::Cluster(0.0F,
292  0.0F,
293  0.0F,
294  0.0F,
295  0.0F,
296  0.0F,
297  0.0F,
298  0.0F,
299  0.0F,
300  0.0F,
301  0.0F,
302  0.0F,
303  0.0F,
304  0.0F,
305  0.0F,
306  0.0F,
307  0.0F,
308  0.0F,
309  v.size(),
310  0.0F,
311  0.0F,
312  cidx,
313  (geo::View_t)view,
314  v.front()->WireID().planeID()));
315  util::CreateAssn(evt, *clusters, v, *clu2hit);
316  cidx++;
317 
318  fMVAWriter.addOutput(cluID, vout); // add copy of the input cluster
319  }
320 
321  // (2b) make single-hit clusters --------------------------------------------
322  for (size_t h : hitMap[cryo][tpc][view]) // h is the Ptr< recob::Hit >::key()
323  {
324  if (hitUsed[h]) continue;
325 
326  auto vout = fMVAWriter.getOutput<recob::Hit>(h);
327 
328  mf::LogVerbatim("EmTrackClusterId2out")
329  << "single hit in tpc:" << tpc << " view:" << view
330  << " wire:" << hitPtrList[h]->WireID().Wire
331  << " drift:" << hitPtrList[h]->PeakTime() << " p:" << vout[0];
332 
333  art::PtrVector<recob::Hit> cluster_hits;
334  cluster_hits.push_back(hitPtrList[h]);
335  clusters->emplace_back(recob::Cluster(0.0F,
336  0.0F,
337  0.0F,
338  0.0F,
339  0.0F,
340  0.0F,
341  0.0F,
342  0.0F,
343  0.0F,
344  0.0F,
345  0.0F,
346  0.0F,
347  0.0F,
348  0.0F,
349  0.0F,
350  0.0F,
351  0.0F,
352  0.0F,
353  1,
354  0.0F,
355  0.0F,
356  cidx,
357  (geo::View_t)view,
358  hitPtrList[h]->WireID().planeID()));
359  util::CreateAssn(evt, *clusters, cluster_hits, *clu2hit);
360  cidx++;
361 
362  fMVAWriter.addOutput(cluID, vout); // add single-hit cluster tagging unclutered hit
363  }
364  mf::LogVerbatim("EmTrackClusterId2out")
365  << "...produced " << cidx - pview.second.size() << " single-hit clusters.";
366  }
367  }
368  }
369 
370  evt.put(std::move(clusters));
371  evt.put(std::move(clu2hit));
372  } // all clusters done ----------------------------------------------------------------------
373 
374  // (3) do tracks when all hits in all cryo/tpc/plane are done -------------------------------
375  if (fDoTracks) {
376  auto trkListHandle = evt.getValidHandle<std::vector<recob::Track>>(fTrackModuleLabel);
377  art::FindManyP<recob::Hit> hitsFromTracks(trkListHandle, evt, fTrackModuleLabel);
378  std::vector<std::vector<art::Ptr<recob::Hit>>> trkHitPtrList(trkListHandle->size());
379  for (size_t t = 0; t < trkListHandle->size(); ++t) {
380  auto v = hitsFromTracks.at(t);
381  size_t nh[3] = {0, 0, 0};
382  for (auto const& hptr : v) {
383  ++nh[hptr->View()];
384  }
385  size_t best_view = 2; // collection
386  if ((nh[0] >= nh[1]) && (nh[0] > 2 * nh[2])) best_view = 0; // ind1
387  if ((nh[1] >= nh[0]) && (nh[1] > 2 * nh[2])) best_view = 1; // ind2
388 
389  size_t k = 0;
390  while (!isViewSelected(best_view)) {
391  best_view = (best_view + 1) % 3;
392  if (++k > 3) {
393  throw cet::exception("EmTrackClusterId2out")
394  << "No views selected at all?" << std::endl;
395  }
396  }
397 
398  for (auto const& hptr : v) {
399  if (hptr->View() == best_view) trkHitPtrList[t].emplace_back(hptr);
400  }
401  }
402 
403  auto trkID = fMVAWriter.initOutputs<recob::Track>(
404  fTrackModuleLabel, trkHitPtrList.size(), fPointIdAlg.outputLabels());
405  for (size_t t = 0; t < trkHitPtrList.size(); ++t) // t is the Ptr< recob::Track >::key()
406  {
407  auto vout =
408  fMVAWriter.getOutput<recob::Hit>(trkHitPtrList[t], [&](art::Ptr<recob::Hit> const& ptr) {
409  return (float)hitInFA[ptr.key()];
410  });
411  fMVAWriter.setOutput(trkID, t, vout);
412  }
413  }
414  // tracks done ------------------------------------------------------------------------------
415 
417  }
bool isInsideFiducialRegion(unsigned int wire, float drift) const
Definition: PointIdAlg.cxx:330
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
unsigned int event
Definition: DataStructs.h:627
std::vector< std::string > const & outputLabels() const
network output labels
Definition: PointIdAlg.h:121
unsigned int run
Definition: DataStructs.h:628
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void setOutput(FVector_ID id, size_t key, std::array< float, N > const &values)
Definition: MVAWriter.h:214
Set of hits with a 2D structure.
Definition: Cluster.h:69
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:280
FVector_ID initOutputs(std::string const &dataTag, size_t dataSize, std::vector< std::string > const &names=std::vector< std::string >(N,""))
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
std::array< float, N > getOutput(std::vector< art::Ptr< T >> const &items) const
Definition: MVAWriter.h:251
void saveOutputs(art::Event &evt)
Check consistency and save all the results in the event.
Definition: MVAWriter.h:404
Detector simulation of raw signals on wires.
void addOutput(FVector_ID id, std::array< float, N > const &values)
Definition: MVAWriter.h:231
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
std::unordered_map< unsigned int, tpc_view_keymap > cryo_tpc_view_keymap
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:220
bool setWireDriftData(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const std::vector< recob::Wire > &wires, unsigned int plane, unsigned int tpc, unsigned int cryo)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
constexpr PlaneID const & planeID() const
Definition: geo_types.h:620
TCEvent evt
Definition: DataStructs.cxx:8
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
std::vector< std::vector< float > > predictIdVectors(std::vector< std::pair< unsigned int, float >> points) const
Definition: PointIdAlg.cxx:257
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

size_t nnet::EmTrackClusterId2out::fBatchSize
private

Definition at line 105 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

art::InputTag nnet::EmTrackClusterId2out::fClusterModuleLabel
private

Definition at line 111 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

bool nnet::EmTrackClusterId2out::fDoClusters
private

Definition at line 113 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

bool nnet::EmTrackClusterId2out::fDoTracks
private

Definition at line 113 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

art::InputTag nnet::EmTrackClusterId2out::fHitModuleLabel
private

Definition at line 110 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

anab::MVAWriter<2> nnet::EmTrackClusterId2out::fMVAWriter
private

Definition at line 107 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

art::InputTag nnet::EmTrackClusterId2out::fNewClustersTag
private

Definition at line 117 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

PointIdAlg nnet::EmTrackClusterId2out::fPointIdAlg
private

Definition at line 106 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

art::InputTag nnet::EmTrackClusterId2out::fTrackModuleLabel
private

Definition at line 112 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().

std::vector<int> nnet::EmTrackClusterId2out::fViews
private

Definition at line 115 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and isViewSelected().

art::InputTag nnet::EmTrackClusterId2out::fWireProducerLabel
private

Definition at line 109 of file EmTrackClusterId2out_module.cc.

Referenced by EmTrackClusterId2out(), and produce().


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