40 class MCParticleTrackMatching;
72 produces<art::Assns<recob::Track, simb::MCParticle, anab::BackTrackerMatchingData>>();
80 std::unique_ptr<art::Assns<recob::Track, simb::MCParticle, anab::BackTrackerMatchingData>>
92 std::unordered_map<int, double> trkide;
100 if (!trackListHandle.
isValid()) {
101 std::cerr <<
"Track handle is not valid!" << std::endl;
105 if (!hitListHandle.
isValid()) {
106 std::cerr <<
"Hit handle is not valid!" << std::endl;
110 auto const& trackList(*trackListHandle);
114 for (
size_t i_t = 0; i_t < trackList.size(); ++i_t) {
121 std::vector<art::Ptr<recob::Hit>> allHits = fmtht.at(i_t);
123 std::vector<anab::BackTrackerHitMatchingData const*> bthmd_vec;
124 std::vector<art::Ptr<simb::MCParticle>> matchedParticlePtrs;
129 for (
size_t i_h = 0; i_h < allHits.size(); ++i_h) {
131 matchedParticlePtrs.clear();
132 particles_per_hit.
get(allHits[i_h].key(), matchedParticlePtrs, bthmd_vec);
134 for (
size_t i_p = 0; i_p < matchedParticlePtrs.size(); ++i_p) {
135 trkide[matchedParticlePtrs[i_p]->TrackId()] += bthmd_vec[i_p]->energy;
136 tote += bthmd_vec[i_p]->energy;
137 if (trkide[matchedParticlePtrs[i_p]->TrackId()] > maxe) {
138 maxe = trkide[matchedParticlePtrs[i_p]->TrackId()];
139 maxp = matchedParticlePtrs[i_p];
146 if (maxe > 0) MCPartTrackassn->addSingle(trkPtr, maxp, btdata);
150 evt.
put(std::move(MCPartTrackassn));
code to link reconstructed objects back to the MC truth information
art::InputTag fTrackHitAssnLabel
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
MCParticleTrackMatching & operator=(MCParticleTrackMatching const &)=delete
bool isValid() const noexcept
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
MCParticleTrackMatching(fhicl::ParameterSet const &p)
#define DEFINE_ART_MODULE(klass)
Provides recob::Track data product.
art::InputTag fHitModuleLabel
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
size_type get(size_type i, reference item, data_reference data) const
void produce(art::Event &e) override
art::InputTag fTrackModuleLabel
art::InputTag fHitParticleAssnLabel