46 produces<art::Assns<recob::Track, recob::PFParticle>>();
52 std::unique_ptr<art::Assns<recob::Track, recob::PFParticle>> trackPFParticleAssns(
65 evt.
put(std::move(trackPFParticleAssns));
74 evt.
put(std::move(trackPFParticleAssns));
80 std::map<int, std::vector<art::Ptr<recob::Track>>>;
87 HitToTrackMap hitToTrackMap;
90 for (
size_t idx = 0; idx < trackHandle->size(); idx++) {
93 std::vector<art::Ptr<recob::Hit>> trackHitVec = trackHitAssns.at(track.
key());
95 for (
const auto& hitPtr : trackHitVec) {
96 hitToTrackMap[hitPtr.key()].push_back(track);
109 using TrackToPFParticleHitMap =
110 std::map<art::Ptr<recob::Track>,
111 std::map<art::Ptr<recob::PFParticle>, std::vector<art::Ptr<recob::Hit>>>>;
113 TrackToPFParticleHitMap trackToPFParticleHitMap;
116 for (
size_t idx = 0; idx < pfParticleHandle->size(); idx++) {
120 std::vector<art::Ptr<recob::Cluster>> clusterVec = clusterAssns.at(pfParticle.
key());
123 for (
const auto&
cluster : clusterVec) {
125 std::vector<art::Ptr<recob::Hit>> hitVec = clusterHitAssns.at(
cluster.key());
128 for (
const auto&
hit : hitVec) {
131 if (hitToTrackItr != hitToTrackMap.end()) {
132 for (
auto&
track : hitToTrackItr->second)
133 trackToPFParticleHitMap[
track][pfParticle].push_back(
hit);
140 for (
auto& trackMapItr : trackToPFParticleHitMap) {
141 std::vector<art::Ptr<recob::PFParticle>> pfParticleVec;
143 for (
auto& pfParticleMapItr : trackMapItr.second) {
148 int nHitsPerView[] = {0, 0, 0};
150 for (
const auto&
hit : pfParticleMapItr.second) {
151 nHitsPerView[
hit->View()]++;
154 int nViewsWithHits(0);
156 for (
auto& nHits : nHitsPerView)
157 if (nHits > 0) nViewsWithHits++;
159 if (nViewsWithHits < 2)
continue;
162 std::vector<art::Ptr<recob::Hit>> trackHitVec = trackHitAssns.at(trackMapItr.first.key());
165 float sharedHitFrac = float(pfParticleMapItr.second.size()) /
float(trackHitVec.size());
167 if (sharedHitFrac < 0.3)
continue;
170 pfParticleVec.push_back(pfParticleMapItr.first);
173 util::CreateAssn(evt, trackMapItr.first, pfParticleVec, *trackPFParticleAssns);
176 evt.
put(std::move(trackPFParticleAssns));
TrackPFParticleMatch(fhicl::ParameterSet const &p)
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
Cluster finding and building.
bool isValid() const noexcept
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::string fTrackModuleLabel
std::string fPFParticleModuleLabel
#define DEFINE_ART_MODULE(klass)
key_type key() const noexcept
Provides recob::Track data product.
Declaration of cluster object.
Detector simulation of raw signals on wires.
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
void produce(art::Event &e) override