30 #include "CLHEP/Units/SystemOfUnits.h" 38 class KNNClusterFinderAlg;
79 fGeo = gar::providerFrom<geo::GeometryGAr>();
80 fDetProp = gar::providerFrom<detinfo::DetectorPropertiesService>();
84 fClusterAlgo = std::make_unique<rec::alg::KNNClusterAlg>(fClusterAlgoPars);
87 consumes<std::vector<gar::rec::CaloHit>>(tag);
89 produces< art::Assns<gar::rec::Cluster, gar::rec::CaloHit> >(
fInstanceName);
96 std::unordered_map< const gar::rec::CaloHit*, art::Ptr<gar::rec::CaloHit> > hitMaptoArtPtr;
97 std::unordered_map< const gar::rec::Track*, art::Ptr<gar::rec::Track> > trkMaptoArtPtr;
101 std::vector< art::Ptr<gar::rec::Track> > artTrk;
106 std::vector< art::Ptr<gar::rec::CaloHit> > artHits;
111 fClusterAlgo->PrepareAlgo(artTrk, artHits, trkMaptoArtPtr, hitMaptoArtPtr);
118 std::unique_ptr< std::vector<gar::rec::Cluster> > ClusterCol(
new std::vector<gar::rec::Cluster>);
125 <<
"Found " << ClusterVec.size() <<
" Clusters";
128 for(
auto const &it : ClusterVec)
131 <<
"Cluster has " << it->CalorimeterHits().size() <<
" calo hits";
133 ClusterCol->emplace_back(*it);
138 const std::vector< gar::rec::CaloHit* > hitVec = it->CalorimeterHits();
139 for (
size_t i=0; i<hitVec.size(); ++i)
143 if(hitMaptoArtPtr.find(pCaloHit) != hitMaptoArtPtr.end())
147 ClusterHitAssns->addSingle(clusterPtr, hitpointer);
153 const std::vector< gar::rec::Track* > trkVec = it->Tracks();
157 if(trkMaptoArtPtr.find(pTrack) != trkMaptoArtPtr.end())
161 ClusterTrackAssns->addSingle(clusterPtr, trkpointer);
178 auto theHits = evt.
getHandle< std::vector<gar::rec::CaloHit> >(itag);
179 if (!theHits)
return;
181 for (
unsigned int i = 0; i < theHits->size(); ++i)
184 hitVector.push_back(hit);
190 auto theTracks = evt.
getHandle< std::vector<gar::rec::Track> >(
label);
191 if (!theTracks)
return;
193 for (
unsigned int i = 0; i < theTracks->size(); ++i)
196 trkVector.push_back(track);
std::string fTrackLabel
label to find the reco tracks
void CollectTracks(const art::Event &evt, const std::string &label, std::vector< art::Ptr< gar::rec::Track > > &trkVector)
Handle< PROD > getHandle(SelectorBase const &) const
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
const std::string instance
Description of geometry of one entire detector.
#define DEFINE_ART_MODULE(klass)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::string fCaloHitLabel
label to find the right reco calo hits
General GArSoft Utilities.
CaloClustering(fhicl::ParameterSet const &p)
std::string fInstanceName
product instance name
void CollectHits(const art::Event &evt, const std::string &label, const std::string &instance, std::vector< art::Ptr< gar::rec::CaloHit > > &hitVector)
const geo::GeometryCore * fGeo
pointer to the geometry
std::vector< gar::rec::Cluster * > ClusterVec
art framework interface to geometry description
const detinfo::DetectorProperties * fDetProp
detector properties
std::unique_ptr< rec::alg::KNNClusterAlg > fClusterAlgo
void produce(art::Event &e) override