GCNParticleFlow.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file GCNParticleFlow.cxx
3 /// \brief MC truth particle flow for graph connection ground truth
4 /// \author Jeremy Hewes - jhewes15@fnal.gov
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include <sstream>
9 
10 namespace cvn
11 {
12  /// Constructor
13  GCNParticleFlow::GCNParticleFlow(std::map<unsigned int, unsigned int> truthMap)
14  : fTruthMap(truthMap)
15  {}
16 
17  /// Add true particle to map
18  void GCNParticleFlow::AddParticle(unsigned int particle,
19  unsigned int parent) {
20 
21  // Check this particle isn't already filled
22  if (fTruthMap.count(particle)) {
23  // If it is filled, just check the results are consistent
24  if (fTruthMap[particle] != parent) {
25  std::ostringstream err;
26  err << "Asked to add parent " << parent << " for particle "
27  << particle << ", but its parent was already assigned as "
28  << fTruthMap[particle] << "!";
29  throw std::runtime_error(err.str());
30  }
31  else return; // If the map is already filled, don't do anything
32  }
33 
34  // Add particle parent
35  fTruthMap[particle] = parent;
36  return;
37 
38  } // function GCNParticleFlow::AddParticle
39 
40  unsigned int GCNParticleFlow::GetParent(unsigned int particle) {
41 
42  // Check corresponding map entry is filled
43  if (!fTruthMap.count(particle)) {
44  std::ostringstream err;
45  err << "No parent defined for true particle " << particle << "!";
46  throw std::runtime_error(err.str());
47  }
48 
49  // Otherwise return
50  return fTruthMap[particle];
51 
52  } // function GCNParticleFlow::GetParent
53 
54 } // namespace cvn
Utility class for truth labels.
MC truth particle flow for graph connection ground truth.
std::map< unsigned int, unsigned int > fTruthMap
Map of true particle ID to parent particle ID.
GCNParticleFlow()
Default constructor.
void err(const char *fmt,...)
Definition: message.cpp:226
unsigned int GetParent(unsigned int particle)
void AddParticle(unsigned int particle, unsigned int parent)
Add a new true particle.
def parent(G, child, parent_type)
Definition: graph.py:67