10 #include "art/Persistency/Common/PtrMaker.h"
15 #include "art/Framework/Core/EDProducer.h"
16 #include "art/Framework/Core/ModuleMacros.h"
17 #include "art/Framework/Principal/Event.h"
19 #include "canvas/Persistency/Common/Ptr.h"
20 #include "canvas/Persistency/Common/Assns.h"
21 #include "canvas/Utilities/InputTag.h"
23 #include "fhiclcpp/types/Atom.h"
24 #include "fhiclcpp/types/Sequence.h"
25 #include "fhiclcpp/types/Name.h"
26 #include "fhiclcpp/types/Comment.h"
27 #include "messagefacility/MessageLogger/MessageLogger.h"
59 Comment(
"collections of clusters to be combined")
63 Name(
"clustersPerPFO"),
64 Comment(
"number of clusters combined into each PFParticle"),
77 produces<std::vector<recob::PFParticle>>();
78 produces<art::Assns<recob::Cluster, recob::PFParticle>>();
81 virtual void produce(art::Event& event)
override;
89 (art::Event
const& event)
const;
106 std::vector<art::Ptr<recob::Cluster>> clusters =
collectClusters(event);
111 auto PFOs = std::make_unique<std::vector<recob::PFParticle>>();
113 = std::make_unique<art::Assns<recob::Cluster, recob::PFParticle>>();
121 art::PtrMaker<recob::PFParticle> ptrMaker(event);
123 unsigned int nDaughtersPerParticle = 2;
124 unsigned int nParticlesInTier = 1;
125 std::size_t firstPFOinThisTier = 0;
126 std::size_t firstPFOinNextTier = firstPFOinThisTier + nParticlesInTier;
127 std::size_t nextDaughter = firstPFOinNextTier;
128 std::vector<std::size_t> parents
130 for (
unsigned int i = 0; i < nPFOs; ++i) {
133 if (i >= firstPFOinNextTier) {
134 firstPFOinThisTier = firstPFOinNextTier;
136 nParticlesInTier *= nDaughtersPerParticle;
137 nDaughtersPerParticle += 1;
138 firstPFOinNextTier += nParticlesInTier;
144 std::vector<art::Ptr<recob::Cluster>> PFOclusters;
145 std::size_t iCluster = i;
146 while (iCluster < clusters.size()) {
147 PFOclusters.push_back(clusters[iCluster]);
154 std::size_t
const endDaughter
155 = std::min(nextDaughter + nDaughtersPerParticle, (std::size_t) nPFOs);
156 std::vector<std::size_t> daughters;
157 daughters.reserve(endDaughter - nextDaughter);
158 while (nextDaughter < endDaughter) {
159 parents[nextDaughter] = i;
160 daughters.push_back(nextDaughter);
174 auto const PFOptr = ptrMaker(i);
175 for (art::Ptr<recob::Cluster>
const&
cluster: PFOclusters) {
176 mf::LogVerbatim(
"AssnsChainPFParticleMaker")
177 <<
"Associating cluster " <<
cluster <<
" with PFO " << PFOptr;
178 clusterPFOassns->addSingle(
cluster, PFOptr);
183 mf::LogInfo(
"AssnsChainPFParticleMaker")
184 <<
"Created " << PFOs->size() <<
" particle flow objects with about "
186 <<
" clusters and " << clusterPFOassns->size() <<
" associations from "
189 event.put(std::move(PFOs));
190 event.put(std::move(clusterPFOassns));
196 std::vector<art::Ptr<recob::Cluster>>
198 (art::Event
const& event)
const
201 std::vector<art::Ptr<recob::Cluster>> allClusters;
203 for (
auto const& tag: clusterTags) {
204 auto clusters =
event.getValidHandle<std::vector<recob::Cluster>>(tag);
206 std::size_t
const nClusters = clusters->size();
207 for (std::size_t i = 0; i < nClusters; ++i)
208 allClusters.emplace_back(clusters, i);
std::vector< art::InputTag > clusterTags
List of cluster tags.
AssnsChainPFParticleMaker(Parameters const &config)
static constexpr size_t kPFParticlePrimary
Define index to signify primary particle.
unsigned int nClustersPerPFO
Maximum number of clusters per PFO.
std::vector< art::Ptr< recob::Cluster > > collectClusters(art::Event const &event) const
Returns a list of clusters to be combined.
BEGIN_PROLOG vertical distance to the surface Name
art::EDProducer::Table< Config > Parameters
Declaration of cluster object.
fhicl::Sequence< art::InputTag > clusters
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour clustersPerPFO
fhicl::Atom< unsigned int > clustersPerPFO
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test
Creates some dummy PFParticles and associations to clusters.
virtual void produce(art::Event &event) override