LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
VertexDecoder_tool.cc
Go to the documentation of this file.
1 #include "DecoderToolBase.h"
2 
4 
6 #include <torch/torch.h>
7 
8 class VertexDecoder : public DecoderToolBase {
9 
10 public:
17 
21  virtual ~VertexDecoder() noexcept = default;
22 
28  void declareProducts(art::ProducesCollector& collector) override
29  {
30  collector.produces<vector<recob::Vertex>>(instancename);
31  }
32 
38  void writeEmptyToEvent(art::Event& e, const vector<vector<size_t>>& idsmap) override;
39 
45  void writeToEvent(art::Event& e,
46  const vector<vector<size_t>>& idsmap,
47  const vector<NuGraphOutput>& infer_output) override;
48 
49 private:
51 };
52 
54  : DecoderToolBase(p), outputDictElem{p.get<string>("outputDictElem")}
55 {}
56 
57 void VertexDecoder::writeEmptyToEvent(art::Event& e, const vector<vector<size_t>>& idsmap)
58 {
59  //
60  auto vertcol = std::make_unique<vector<recob::Vertex>>();
61  e.put(std::move(vertcol), instancename);
62  //
63 }
64 
66  const vector<vector<size_t>>& idsmap,
67  const vector<NuGraphOutput>& infer_output)
68 {
69  //
70  auto vertcol = std::make_unique<vector<recob::Vertex>>();
71 
72  const std::vector<float>* x_vertex_data = nullptr;
73  for (auto& io : infer_output) {
74  if (io.output_name == outputDictElem) x_vertex_data = &io.output_vec;
75  }
76  if (x_vertex_data->size() == 3) {
77  double vpos[3] = {(*x_vertex_data)[0], (*x_vertex_data)[1], (*x_vertex_data)[2]};
78  vertcol->push_back(recob::Vertex(vpos));
79  if (debug)
80  std::cout << "NuGraph vertex pos=" << vpos[0] << ", " << vpos[1] << ", " << vpos[2]
81  << std::endl;
82  }
83  else {
84  std::cout << "ERROR -- Wrong size returned by NuGraph vertex decoder" << std::endl;
85  }
86  e.put(std::move(vertcol), instancename);
87  //
88 }
89 
#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.