40 class MCParticleShowerMatching;
72 produces<art::Assns<recob::Shower, simb::MCParticle, anab::BackTrackerMatchingData>>();
80 std::unique_ptr<art::Assns<recob::Shower, simb::MCParticle, anab::BackTrackerMatchingData>>
93 std::unordered_map<int, double> trkide;
101 if (!showerListHandle.
isValid()) {
102 std::cerr <<
"Shower handle is not valid!" << std::endl;
106 if (!hitListHandle.
isValid()) {
107 std::cerr <<
"Hit handle is not valid!" << std::endl;
111 auto const& showerList(*showerListHandle);
115 for (
size_t i_t = 0; i_t < showerList.size(); ++i_t) {
122 std::vector<art::Ptr<recob::Hit>> allHits = fmtht.at(i_t);
124 std::vector<anab::BackTrackerHitMatchingData const*> bthmd_vec;
125 std::vector<art::Ptr<simb::MCParticle>> matchedParticlePtrs;
130 for (
size_t i_h = 0; i_h < allHits.size(); ++i_h) {
132 matchedParticlePtrs.clear();
133 particles_per_hit.
get(allHits[i_h].key(), matchedParticlePtrs, bthmd_vec);
135 for (
size_t i_p = 0; i_p < matchedParticlePtrs.size(); ++i_p) {
136 trkide[matchedParticlePtrs[i_p]->TrackId()] += bthmd_vec[i_p]->energy;
137 tote += bthmd_vec[i_p]->energy;
138 if (trkide[matchedParticlePtrs[i_p]->TrackId()] > maxe) {
139 maxe = trkide[matchedParticlePtrs[i_p]->TrackId()];
140 maxp = matchedParticlePtrs[i_p];
147 if (maxe > 0) MCPartShowerassn->addSingle(shwPtr, maxp, btdata);
151 evt.
put(std::move(MCPartShowerassn));
code to link reconstructed objects back to the MC truth information
art::InputTag fHitModuleLabel
Declaration of signal hit object.
MCParticleShowerMatching & operator=(MCParticleShowerMatching const &)=delete
EDProducer(fhicl::ParameterSet const &pset)
bool isValid() const noexcept
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
#define DEFINE_ART_MODULE(klass)
void produce(art::Event &e) override
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MCParticleShowerMatching(fhicl::ParameterSet const &p)
size_type get(size_type i, reference item, data_reference data) const
art::InputTag fShowerHitAssnLabel
art::InputTag fHitParticleAssnLabel
art::InputTag fShowerModuleLabel