84 produces< std::vector<cvn::GCNGraph> >();
111 std::unique_ptr<std::vector<cvn::GCNGraph>> graphs(
new std::vector<cvn::GCNGraph>);
115 std::vector<art::Ptr<recob::SpacePoint>> allSpacePoints;
117 if (spacePointHandle){
122 std::map<unsigned int,std::map<unsigned int,art::Ptr<recob::SpacePoint>>> allGraphSpacePoints;
131 std::map<unsigned int,std::vector<std::map<int,unsigned int>>> neighbourMap;
140 std::cerr <<
"Requested beam slice only yet one didn't exist, returning no graphs" <<
std::endl;
147 for(
const std::pair<
unsigned int,std::vector<const recob::PFParticle*>>
m : particleSliceMap){
148 unsigned int sliceID =
m.first;
149 std::map<unsigned int,art::Ptr<recob::SpacePoint>> sliceSpacePoints;
158 sliceSpacePoints.insert(std::make_pair(
s->ID(),allSpacePoints.at(
s->ID())));
161 allGraphSpacePoints[sliceID] = sliceSpacePoints;
166 std::vector<art::Ptr<recob::SpacePoint>> eventSpacePoints;
168 if (spacePointHandle){
172 std::map<unsigned int,art::Ptr<recob::SpacePoint>> mapVec;
174 mapVec.insert(std::make_pair(
p->ID(),
p));
177 allGraphSpacePoints.insert(std::make_pair(0,mapVec));
181 std::cout <<
"Found all neighbours for " << neighbourMap.size() <<
" slices, building graphs..." <<
std::endl;
200 std::cout <<
"Constructing graph for slice " << sps.first <<
" with " << sps.second.size() <<
" nodes." <<
std::endl;
206 const double *
pos = sp.second->XYZ();
207 for(
unsigned int p = 0;
p < 3; ++
p) position.push_back(pos[
p]);
214 features.push_back(neighbourMap.at(sps.first)[
m].at(sp.second->ID()));
218 features.push_back(chargeMap.at(sp.second->ID()));
225 float dotProduct = -999.;
226 int n1ID = twoNearest[sp.second->ID()].first;
227 int n2ID = twoNearest[sp.second->ID()].second;
231 features.push_back(dotProduct);
232 features.push_back(angle);
235 std::vector<float> truePDG;
236 truePDG.push_back(static_cast<float>(trueIDMap.at(sp.second->ID())));
237 newGraph.
AddNode(position,features,truePDG);
241 std::cout <<
"GCNGraphMakerProtoDUNE: produced GCNGraph object with " << newGraph.
GetNumberOfNodes() <<
" nodes" <<
std::endl;
244 graphs->push_back(newGraph);
Handle< PROD > getHandle(SelectorBase const &) const
EDProducer(fhicl::ParameterSet const &pset)
GCNGraph, basic input for the GCN.
void produce(art::Event &evt)
std::map< unsigned int, float > GetSpacePointChargeMap(std::vector< art::Ptr< recob::SpacePoint >> const &spacePoints, std::vector< std::vector< art::Ptr< recob::Hit >>> const &sp2Hit) const
Use the association between space points and hits to return a charge.
void AddNode(std::vector< float > position, std::vector< float > features)
Add a new node.
Utility class for truth labels.
std::map< int, std::pair< int, int > > GetTwoNearestNeighbours(art::Event const &evt, const std::string &spLabel) const
Get the two nearest neighbours to use for calcuation of angles between them and the node in question...
const std::map< unsigned int, std::vector< const recob::PFParticle * > > GetAllPFParticleSliceMap(art::Event const &evt, const std::string particleLabel) const
Get a map of slice index to all of the PFParticles within it.
bool fUseBeamSliceOnly
Use only the beam slice as determined by Pandora.
unsigned short fMinClusterHits
Minimum number of space points to produce a graph.
#define DEFINE_ART_MODULE(klass)
std::map< unsigned int, int > GetTruePDG(detinfo::DetectorClocksData const &clockData, art::Event const &evt, const std::string &spLabel, bool useAbsoluteTrackID, bool useHits) const
Get the true pdg code for each spacepoint.
const std::vector< const recob::SpacePoint * > GetPFParticleSpacePoints(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the SpacePoints associated to the PFParticle.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
void GetAngleAndDotProduct(const recob::SpacePoint &baseNode, const recob::SpacePoint &n1, const recob::SpacePoint &n2, float &dotProduct, float &angle) const
Get the angle and the dot product between the vector from the base node to its neighbours.
GCNGraphMakerProtoDUNE(fhicl::ParameterSet const &pset)
bool fUseHitsForTruthMatching
Hierarchical representation of particle flow.
std::string fParticleLabel
PFParticle module (typically Pandora)
unsigned short GetBeamSlice(art::Event const &evt, const std::string particleLabel) const
Try to get the slice tagged as beam. Returns 9999 if no beam slice was found.
std::string fSliceLabel
Slicing module (typically Pandora)
std::vector< std::map< int, unsigned int > > GetNeighboursForRadii(art::Event const &evt, const std::vector< float > &rangeCuts, const std::string &spLabel) const
Gets the number of nearest neigbours for each space point for a vector of cut values. Much more efficient that using the above functions multiple times.
Utilities for calculating feature values for the GCN.
const unsigned int GetNumberOfNodes() const
Get the number of nodes.
~GCNGraphMakerProtoDUNE()
std::string fSpacePointLabel
Module label for input space points.
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::map< unsigned int, float > GetSpacePointMeanHitRMSMap(art::Event const &evt, const std::string &spLabel) const
std::vector< float > fNeighbourRadii
Radii for calculating number of neighbours for any number of cut values.
QTextStream & endl(QTextStream &s)
Class containing some utility functions for all things CVN.