105 auto const& geom = *lar::providerFrom<geo::Geometry>();
112 std::unique_ptr<std::vector<recob::Shower>> out_shower_v(
new std::vector<recob::Shower>);
113 std::unique_ptr<art::Assns<recob::Shower, recob::Cluster>> sc_assn(
115 std::unique_ptr<art::Assns<recob::Shower, recob::Hit>> sh_assn(
117 std::unique_ptr<art::Assns<recob::PFParticle, recob::Shower>> sp_assn(
133 std::vector<std::vector<::util::PxHit>> local_clusters;
136 for (
size_t i = 0; i < cHandle->size(); ++i) {
137 local_clusters.push_back(std::vector<::util::PxHit>());
139 const std::vector<art::Ptr<recob::Hit>>& hits = hit_m.at(i);
141 conv.GeneratePxHit(hits, local_clusters.back());
148 std::vector<size_t> shower_pfpart_index;
150 std::vector<std::vector<unsigned int>> matched_pairs;
152 std::vector<recob::Shower> shower_v;
166 std::map<art::Ptr<recob::Cluster>,
size_t>
cmap;
167 for (
size_t i = 0; i < cHandle->size(); ++i) {
174 art::FindManyP<recob::Cluster> cluster_m(pfHandle, e,
fInputProducer);
176 for (
size_t i = 0; i < pfHandle->size(); ++i) {
180 if (pf->PdgCode() != 11)
continue;
182 const std::vector<art::Ptr<recob::Cluster>>& clusters = cluster_m.at(i);
184 std::vector<unsigned int> one_pair;
185 one_pair.reserve(clusters.size());
187 for (
auto const& cptr : clusters) {
189 auto iter = cmap.find(cptr);
190 if (iter == cmap.end())
192 <<
"PFParticle=>Cluster association not valid!" <<
std::endl;
194 one_pair.push_back((*iter).second);
196 matched_pairs.push_back(one_pair);
197 shower_pfpart_index.push_back(i);
204 if (shower_v.size() != matched_pairs.size())
206 <<
"Logic error: # of matched pairs != # of reco-ed showers!" <<
std::endl;
209 out_shower_v->reserve(shower_v.size());
211 for (
size_t i = 0; i < shower_v.size(); ++i) {
214 shower_v[i].set_id(i);
216 out_shower_v->push_back(shower_v[i]);
219 std::vector<art::Ptr<recob::Cluster>> ass_clusters;
221 std::vector<art::Ptr<recob::Hit>> ass_hits;
222 for (
auto const& cindex : matched_pairs[i]) {
226 const std::vector<art::Ptr<recob::Hit>>& hits = hit_m.at(cindex);
228 for (
auto const& ptr : hits)
229 ass_hits.push_back(ptr);
232 util::CreateAssn(*
this, e, *(out_shower_v.get()), ass_clusters, *(sc_assn.get()));
234 util::CreateAssn(*
this, e, *(out_shower_v.get()), ass_hits, *(sh_assn.get()));
243 util::CreateAssn(*
this, e, *(out_shower_v.get()), pf_ptr, *(sp_assn.get()));
::showerreco::ShowerRecoManager fManager
bool isValid() const noexcept
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::string fInputProducer
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
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.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
ClusterAss_t Reconstruct(geo::GeometryCore const &geom, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< std::vector< util::PxHit >> &clusters, std::vector<::recob::Shower > &showers)