112 std::vector<art::Ptr<recob::SpacePoint>> spacePoints;
114 auto spacePointHandle = evt.
getHandle<std::vector<recob::SpacePoint>>(itag1);
115 if (!spacePointHandle) {
118 <<
"Could not find spacepoints with module label " 124 std::vector<std::vector<art::Ptr<recob::Hit>>> sp2Hit(spacePoints.size());
125 for (
size_t spIdx = 0; spIdx < sp2Hit.size(); ++spIdx) {
126 sp2Hit[spIdx] = fmp.at(spIdx);
130 std::unique_ptr<std::vector<cvn::GCNGraph>> graphs(
new std::vector<cvn::GCNGraph>);
131 std::unique_ptr<std::vector<cvn::GCNParticleFlow>> gpf(
nullptr);
133 gpf = std::make_unique<std::vector<cvn::GCNParticleFlow> >();
150 std::unique_ptr<std::map<unsigned int, int>
const> trueIDMap{
nullptr};
152 trueIDMap = std::make_unique<std::map<unsigned int, int>>(graphUtil.
GetTrueG4ID(clockData, spacePoints, sp2Hit));
156 std::map<unsigned int, std::vector<float>> hitMap;
164 <<
"You must enable deghosting ground truth if using direction ground truth!";
166 std::vector<float> nodeDeghostingGroundTruth;
167 std::vector<std::vector<float>>* nodeDirectionGroundTruth =
nullptr;
174 std::set<unsigned int> trueParticles;
175 for (
size_t spIdx = 0; spIdx < spacePoints.size(); ++spIdx) {
181 bool collectionHit =
false;
183 if (
hit->View() == 2) {
184 collectionHit =
true;
189 if (!collectionHit)
continue;
195 const double *
pos = sp->
XYZ();
196 for (
size_t p = 0;
p < 3; ++
p) position.push_back(pos[
p]);
203 features.push_back(chargeMap.at(sp->
ID()));
206 features.insert(features.end(), hitMap.at(sp->
ID()).
begin(), hitMap.at(sp->
ID()).
end());
211 truth.push_back(trueIDMap->at(sp->
ID()));
212 trueParticles.insert(
abs(trueIDMap->at(sp->
ID())));
217 truth.push_back(nodeDeghostingGroundTruth[spIdx]);
220 truth.insert(truth.end(), nodeDirectionGroundTruth->at(spIdx).begin(),
221 nodeDirectionGroundTruth->at(spIdx).end());
226 newGraph.
AddNode(position, features, truth);
233 mf::LogInfo(
"GCNGraphMaker") <<
"Produced GCNGraph object with " 234 << newGraph.
GetNumberOfNodes() <<
" nodes from " << spacePoints.size() <<
" spacepoints.";
237 graphs->push_back(newGraph);
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Handle< PROD > getHandle(SelectorBase const &) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
GCNGraph, basic input for the GCN.
std::map< unsigned int, std::vector< float > > Get2DFeatures(std::vector< art::Ptr< recob::SpacePoint >> const &spacePoints, std::vector< std::vector< art::Ptr< recob::Hit >>> const &sp2Hit) const
Get 2D hit features for a given spacepoint.
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.
std::string fSpacePointModuleLabel
Module label for input space points.
std::vector< float > GetNodeGroundTruth(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::SpacePoint >> const &spacePoints, std::vector< std::vector< art::Ptr< recob::Hit >>> const &spToHit, float distCut, std::vector< std::vector< float >> *dirTruth=nullptr) const
Get ground truth for spacepoint deghosting graph network.
std::string fSpacePointInstanceLabel
std::map< unsigned int, unsigned int > GetParticleFlowMap(const std::set< unsigned int > &particles) const
Get hierarchy map from set of particles.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
unsigned short fMinClusterHits
Minimum number of space points to produce a graph.
Detector simulation of raw signals on wires.
bool fUseNodeDeghostingGroundTruth
Include ground truth for node - and if so, define proximity.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
bool fInclude2DFeatures
2D node features
const Double32_t * XYZ() const
bool fCollectionPlaneOnly
Do we want collection plane hits only?
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
const unsigned int GetNumberOfNodes() const
Get the number of nodes.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
bool fSaveTrueParticle
Include true GEANT ID of primary associated particle as graph feature.
bool fSaveParticleFlow
Whether to save particle hierarchy for particle flow ground truth.
bool fUseNodeDirectionGroundTruth
std::map< unsigned int, int > GetTrueG4ID(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::SpacePoint >> const &spacePoints, std::vector< std::vector< art::Ptr< recob::Hit >>> const &sp2Hit) const
Get the true G4 ID for each spacepoint using energy matching.
Class containing some utility functions for all things CVN.