LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
VertexDecoder_tool.cc
Go to the documentation of this file.
1 #include "DecoderToolBase.h"
2 
4 #include <torch/torch.h>
5 
6 class VertexDecoder : public DecoderToolBase {
7 
8 public:
15 
19  virtual ~VertexDecoder() noexcept = default;
20 
26  void declareProducts(art::ProducesCollector& collector) override
27  {
28  collector.produces<vector<recob::Vertex>>(instancename);
29  }
30 
36  void writeEmptyToEvent(art::Event& e, const vector<vector<size_t>>& idsmap) override;
37 
43  void writeToEvent(art::Event& e,
44  const vector<vector<size_t>>& idsmap,
45  const vector<NuGraphOutput>& infer_output) override;
46 
47 private:
49 };
50 
52  : DecoderToolBase(p), outputDictElem{p.get<string>("outputDictElem")}
53 {}
54 
55 void VertexDecoder::writeEmptyToEvent(art::Event& e, const vector<vector<size_t>>& idsmap)
56 {
57  //
58  auto vertcol = std::make_unique<vector<recob::Vertex>>();
59  e.put(std::move(vertcol), instancename);
60  //
61 }
62 
64  const vector<vector<size_t>>& idsmap,
65  const vector<NuGraphOutput>& infer_output)
66 {
67  //
68  auto vertcol = std::make_unique<vector<recob::Vertex>>();
69 
70  const std::vector<float>* x_vertex_data = nullptr;
71  for (auto& io : infer_output) {
72  if (io.output_name == outputDictElem) x_vertex_data = &io.output_vec;
73  }
74  if (x_vertex_data->size() == 3) {
75  double vpos[3] = {(*x_vertex_data)[0], (*x_vertex_data)[1], (*x_vertex_data)[2]};
76  vertcol->push_back(recob::Vertex(vpos));
77  if (debug)
78  std::cout << "NuGraph vertex pos=" << vpos[0] << ", " << vpos[1] << ", " << vpos[2]
79  << std::endl;
80  }
81  else {
82  std::cout << "ERROR -- Wrong size returned by NuGraph vertex decoder" << std::endl;
83  }
84  e.put(std::move(vertcol), instancename);
85  //
86 }
87 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
void declareProducts(art::ProducesCollector &collector) override
declareProducts function
VertexDecoder(const fhicl::ParameterSet &pset)
Constructor.
void writeToEvent(art::Event &e, const vector< vector< size_t >> &idsmap, const vector< NuGraphOutput > &infer_output) override
Decoder function.
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
T get(std::string const &key) const
Definition: ParameterSet.h:314
void writeEmptyToEvent(art::Event &e, const vector< vector< size_t >> &idsmap) override
writeEmptyToEvent function
std::string instancename
Float_t e
Definition: plot.C:35
virtual ~VertexDecoder() noexcept=default
Virtual Destructor.