84 using HitToTrackMap = std::map<int, std::vector<art::Ptr<recob::Track>>>;
91 HitToTrackMap hitToTrackMap;
94 for(
size_t idx = 0; idx < trackHandle->size(); idx++)
98 std::vector<art::Ptr<recob::Hit>> trackHitVec = trackHitAssns.at(track.key());
100 for (
const auto& hitPtr : trackHitVec)
102 hitToTrackMap[hitPtr.key()].push_back(track);
115 using TrackToPFParticleHitMap = std::map<art::Ptr<recob::Track>, std::map<art::Ptr<recob::PFParticle>,std::vector<art::Ptr<recob::Hit>>>>;
117 TrackToPFParticleHitMap trackToPFParticleHitMap;
120 for(
size_t idx = 0; idx < pfParticleHandle->size(); idx++)
125 std::vector<art::Ptr<recob::Cluster>> clusterVec = clusterAssns.at(pfParticle.key());
128 for(
const auto&
cluster : clusterVec)
131 std::vector<art::Ptr<recob::Hit>> hitVec = clusterHitAssns.at(
cluster.key());
134 for(
const auto&
hit : hitVec)
138 if (hitToTrackItr != hitToTrackMap.end())
140 for(
auto& track : hitToTrackItr->second)
141 trackToPFParticleHitMap[track][pfParticle].push_back(
hit);
148 for (
auto& trackMapItr : trackToPFParticleHitMap)
150 std::vector<art::Ptr<recob::PFParticle>> pfParticleVec;
152 for(
auto& pfParticleMapItr : trackMapItr.second)
158 int nHitsPerView[] = {0,0,0};
160 for(
const auto&
hit : pfParticleMapItr.second)
162 nHitsPerView[
hit->View()]++;
165 int nViewsWithHits(0);
167 for(
auto& nHits : nHitsPerView)
if (nHits > 0) nViewsWithHits++;
169 if (nViewsWithHits < 2)
continue;
172 std::vector<art::Ptr<recob::Hit>> trackHitVec = trackHitAssns.at(trackMapItr.first.key());
175 float sharedHitFrac =
float(pfParticleMapItr.second.size()) /
float(trackHitVec.size());
177 if (sharedHitFrac < 0.3)
continue;
180 pfParticleVec.push_back(pfParticleMapItr.first);
Cluster finding and building.
bool isValid() const noexcept
std::string fTrackModuleLabel
std::string fPFParticleModuleLabel
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
Detector simulation of raw signals on wires.