74 produces<std::vector<recob::Shower>>();
75 produces<art::Assns<recob::Shower, recob::Cluster>>();
76 produces<art::Assns<recob::Shower, recob::Hit>>();
77 if (fUsePFParticle) produces<art::Assns<recob::PFParticle, recob::Shower>>();
106 auto const& geom = *lar::providerFrom<geo::Geometry>();
113 std::unique_ptr<std::vector<recob::Shower>> out_shower_v(
new std::vector<recob::Shower>);
114 std::unique_ptr<art::Assns<recob::Shower, recob::Cluster>> sc_assn(
116 std::unique_ptr<art::Assns<recob::Shower, recob::Hit>> sh_assn(
118 std::unique_ptr<art::Assns<recob::PFParticle, recob::Shower>> sp_assn(
131 throw cet::exception(__FUNCTION__) <<
"Invalid input cluster label!" << std::endl;
134 std::vector<std::vector<::util::PxHit>> local_clusters;
137 for (
size_t i = 0; i < cHandle->size(); ++i) {
138 local_clusters.push_back(std::vector<::util::PxHit>());
140 const std::vector<art::Ptr<recob::Hit>>&
hits = hit_m.at(i);
142 conv.GeneratePxHit(hits, local_clusters.back());
149 std::vector<size_t> shower_pfpart_index;
151 std::vector<std::vector<unsigned int>> matched_pairs;
153 std::vector<recob::Shower> shower_v;
164 throw cet::exception(__FUNCTION__) <<
"Invalid input PFParticle label!" << std::endl;
167 std::map<art::Ptr<recob::Cluster>,
size_t> cmap;
168 for (
size_t i = 0; i < cHandle->size(); ++i) {
177 for (
size_t i = 0; i < pfHandle->size(); ++i) {
181 if (pf->
PdgCode() != 11)
continue;
183 const std::vector<art::Ptr<recob::Cluster>>& clusters = cluster_m.at(i);
185 std::vector<unsigned int> one_pair;
186 one_pair.reserve(clusters.size());
188 for (
auto const& cptr : clusters) {
190 auto iter = cmap.find(cptr);
191 if (iter == cmap.end())
193 <<
"PFParticle=>Cluster association not valid!" << std::endl;
195 one_pair.push_back((*iter).second);
197 matched_pairs.push_back(one_pair);
198 shower_pfpart_index.push_back(i);
205 if (shower_v.size() != matched_pairs.size())
207 <<
"Logic error: # of matched pairs != # of reco-ed showers!" << std::endl;
210 out_shower_v->reserve(shower_v.size());
212 for (
size_t i = 0; i < shower_v.size(); ++i) {
215 shower_v[i].set_id(i);
217 out_shower_v->push_back(shower_v[i]);
220 std::vector<art::Ptr<recob::Cluster>> ass_clusters;
222 std::vector<art::Ptr<recob::Hit>> ass_hits;
223 for (
auto const& cindex : matched_pairs[i]) {
227 const std::vector<art::Ptr<recob::Hit>>&
hits = hit_m.at(cindex);
229 for (
auto const& ptr : hits)
230 ass_hits.push_back(ptr);
249 e.
put(std::move(out_shower_v));
250 e.
put(std::move(sh_assn));
251 e.
put(std::move(sc_assn));
void Algo(ShowerRecoAlgBase *alg)
::calo::CalorimetryAlg * fCaloAlgo
Utilities related to art service access.
::cmtool::CPAlgoArray * fCPAlgoArray
Declaration of signal hit object.
::showerreco::ShowerRecoManager fManager
EDProducer(fhicl::ParameterSet const &pset)
int PdgCode() const
Return the type of particle as a PDG ID.
::cmtool::CFAlgoTimeOverlap * fCFAlgoTimeOverlap
void produce(art::Event &e) override
void CaloAlgo(calo::CalorimetryAlg *alg)
bool isValid() const noexcept
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::string fInputProducer
#define DEFINE_ART_MODULE(klass)
void setEcorrection(bool on)
Function to set whether to use E correction.
Class def header for a class CPAlgoArray.
Declaration of cluster object.
void SetUseArea(bool on)
Function to decide if to use Area or Pulse Amplitude for calculations.
Class def header for a class CPAlgoNHits.
::cmtool::CMatchManager & MatchManager()
void Verbose(bool verbose)
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.
ShowerReco3D(fhicl::ParameterSet const &p)
::cmtool::CPAlgoIgnoreTracks * fCPAlgoIgnoreTracks
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
::showerreco::ShowerRecoAlg * fShowerAlgo
Class def header for a class CMatchManager.
Class def header for a class CPAlgoIgnoreTracks.
ShowerReco3D & operator=(ShowerReco3D const &)=delete
Class def header for a class CFAlgoTimeOverlap.
::cmtool::CPAlgoNHits * fCPAlgoNHits
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
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)
Class def header for a class ShowerRecoManager.