62 ,
fPfpLabel(p.get<std::string>(
"PfpLabel",
"pandora"))
63 ,
fSliceLabel(p.get<std::string>(
"SliceLabel",
"pandora"))
64 ,
fHitLabel(p.get<std::string>(
"HitLabel",
"gaushit"))
69 produces<std::vector<recob::Hit>>();
79 auto outputHits = std::make_unique<std::vector<recob::Hit>>();
80 auto outputHitPartAssns = std::make_unique<HitParticleAssociations>();
85 auto assocPfpSlice = std::unique_ptr<art::FindManyP<recob::Slice>>(
89 e.getValidHandle<std::vector<recob::Slice>>(
fSliceLabel);
90 auto assocSliceHit = std::unique_ptr<art::FindManyP<recob::Hit>>(
95 std::unique_ptr<art::FindManyP<simb::MCParticle, anab::BackTrackerHitMatchingData>> hittruth;
97 hittruth = std::make_unique<art::FindManyP<simb::MCParticle, anab::BackTrackerHitMatchingData>>(
101 for (
size_t ipfp = 0; ipfp < inputPfp->size(); ipfp++) {
105 auto PDG = fabs(pfp->
PdgCode());
106 if (PDG != 12 && PDG != 14)
continue;
108 auto assocSlice = assocPfpSlice->at(pfp.
key());
109 auto sliceHits = assocSliceHit->at(assocSlice[0].key());
111 for (
size_t ihit = 0; ihit < sliceHits.size(); ++ihit) {
112 auto hit = sliceHits.at(ihit);
113 outputHits->emplace_back(*
hit);
115 if (!hittruth)
continue;
116 std::vector<art::Ptr<simb::MCParticle>> particle_vec = hittruth->at(
hit.key());
117 std::vector<anab::BackTrackerHitMatchingData const*> match_vec = hittruth->data(
hit.key());
119 for (
size_t i_p = 0; i_p < particle_vec.size(); ++i_p) {
120 outputHitPartAssns->addSingle(particle_vec[i_p], ahp, *match_vec[i_p]);
125 e.put(std::move(outputHits));
126 if (!
fHitTruthLabel.empty()) e.put(std::move(outputHitPartAssns));
NuSliceHitsProducer & operator=(NuSliceHitsProducer const &)=delete
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
int PdgCode() const
Return the type of particle as a PDG ID.
NuSliceHitsProducer(fhicl::ParameterSet const &p)
#define DEFINE_ART_MODULE(klass)
key_type key() const noexcept
bool IsPrimary() const
Returns whether the particle is the root of the flow.
std::string fHitTruthLabel
Detector simulation of raw signals on wires.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
void produce(art::Event &e) override