LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
VertexDecoder Class Reference
Inheritance diagram for VertexDecoder:
DecoderToolBase

Public Member Functions

 VertexDecoder (const fhicl::ParameterSet &pset)
 Constructor. More...
 
virtual ~VertexDecoder () noexcept=default
 Virtual Destructor. More...
 
void declareProducts (art::ProducesCollector &collector) override
 declareProducts function More...
 
void writeEmptyToEvent (art::Event &e, const vector< vector< size_t >> &idsmap) override
 writeEmptyToEvent function More...
 
void writeToEvent (art::Event &e, const vector< vector< size_t >> &idsmap, const vector< NuGraphOutput > &infer_output) override
 Decoder function. More...
 
void printVector (const std::vector< float > &vec)
 
template<typename T , size_t N>
void softmax (std::array< T, N > &arr)
 
void setDebugAndPlanes (bool d, vector< std::string > &p)
 

Protected Attributes

bool debug
 
vector< std::string > planes
 
std::string instancename
 
std::string outputname
 

Private Attributes

string outputDictElem
 

Detailed Description

Definition at line 6 of file VertexDecoder_tool.cc.

Constructor & Destructor Documentation

VertexDecoder::VertexDecoder ( const fhicl::ParameterSet pset)

Constructor.

Parameters
pset

Definition at line 51 of file VertexDecoder_tool.cc.

References fhicl::ParameterSet::get().

52  : DecoderToolBase(p), outputDictElem{p.get<string>("outputDictElem")}
53 {}
DecoderToolBase(fhicl::ParameterSet const &p)
Construcutor.
virtual VertexDecoder::~VertexDecoder ( )
virtualdefaultnoexcept

Virtual Destructor.

Member Function Documentation

void VertexDecoder::declareProducts ( art::ProducesCollector collector)
inlineoverridevirtual

declareProducts function

Parameters
art::ProducesCollector

Implements DecoderToolBase.

Definition at line 26 of file VertexDecoder_tool.cc.

References e, DecoderToolBase::instancename, art::ProducesCollector::produces(), lar::dump::vector(), writeEmptyToEvent(), and writeToEvent().

27  {
28  collector.produces<vector<recob::Vertex>>(instancename);
29  }
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
std::string instancename
void DecoderToolBase::printVector ( const std::vector< float > &  vec)
inlineinherited

Definition at line 69 of file DecoderToolBase.h.

Referenced by FilterDecoder::writeToEvent(), and SemanticDecoder::writeToEvent().

70  {
71  for (size_t i = 0; i < vec.size(); ++i) {
72  std::cout << vec[i];
73  // Print space unless it's the last element
74  if (i != vec.size() - 1) { std::cout << " "; }
75  }
76  std::cout << std::endl;
77  std::cout << std::endl;
78  }
void DecoderToolBase::setDebugAndPlanes ( bool  d,
vector< std::string > &  p 
)
inlineinherited

Definition at line 98 of file DecoderToolBase.h.

References d, and tca::debug.

99  {
100  debug = d;
101  planes = p;
102  }
vector< std::string > planes
Float_t d
Definition: plot.C:235
template<typename T , size_t N>
void DecoderToolBase::softmax ( std::array< T, N > &  arr)
inlineinherited

Definition at line 81 of file DecoderToolBase.h.

References sum.

Referenced by SemanticDecoder::writeToEvent().

82  {
83  T m = -std::numeric_limits<T>::max();
84  for (size_t i = 0; i < arr.size(); i++) {
85  if (arr[i] > m) { m = arr[i]; }
86  }
87  T sum = 0.0;
88  for (size_t i = 0; i < arr.size(); i++) {
89  sum += expf(arr[i] - m);
90  }
91  T offset = m + logf(sum);
92  for (size_t i = 0; i < arr.size(); i++) {
93  arr[i] = expf(arr[i] - offset);
94  }
95  return;
96  }
Double_t sum
Definition: plot.C:31
void VertexDecoder::writeEmptyToEvent ( art::Event e,
const vector< vector< size_t >> &  idsmap 
)
overridevirtual

writeEmptyToEvent function

Parameters
art::Eventevent record

Implements DecoderToolBase.

Definition at line 55 of file VertexDecoder_tool.cc.

References DecoderToolBase::instancename, and art::Event::put().

Referenced by declareProducts().

56 {
57  //
58  auto vertcol = std::make_unique<vector<recob::Vertex>>();
59  e.put(std::move(vertcol), instancename);
60  //
61 }
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
std::string instancename
void VertexDecoder::writeToEvent ( art::Event e,
const vector< vector< size_t >> &  idsmap,
const vector< NuGraphOutput > &  infer_output 
)
overridevirtual

Decoder function.

Parameters
art::Eventevent record for decoder

Implements DecoderToolBase.

Definition at line 63 of file VertexDecoder_tool.cc.

References DecoderToolBase::debug, DEFINE_ART_CLASS_TOOL, DecoderToolBase::instancename, outputDictElem, and art::Event::put().

Referenced by declareProducts().

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 }
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
std::string instancename

Member Data Documentation

bool DecoderToolBase::debug
protectedinherited
string VertexDecoder::outputDictElem
private

Definition at line 48 of file VertexDecoder_tool.cc.

Referenced by writeToEvent().

std::string DecoderToolBase::outputname
protectedinherited
vector<std::string> DecoderToolBase::planes
protectedinherited

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