Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar::test::AssnsChainPFParticleMaker Class Reference

Creates some dummy PFParticles and associations to clusters. More...

Inheritance diagram for lar::test::AssnsChainPFParticleMaker:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  Config
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 
- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 

Public Member Functions

 AssnsChainPFParticleMaker (Parameters const &config)
 
virtual void produce (art::Event &event) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

std::vector< art::Ptr< recob::Cluster > > collectClusters (art::Event const &event) const
 Returns a list of clusters to be combined. More...
 

Private Attributes

std::vector< art::InputTagclusterTags
 List of cluster tags. More...
 
unsigned int nClustersPerPFO
 Maximum number of clusters per PFO. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Creates some dummy PFParticles and associations to clusters.

Configuration parameters

Definition at line 50 of file AssnsChainPFParticleMaker_module.cc.

Member Typedef Documentation

Definition at line 70 of file AssnsChainPFParticleMaker_module.cc.

Constructor & Destructor Documentation

lar::test::AssnsChainPFParticleMaker::AssnsChainPFParticleMaker ( Parameters const &  config)
inlineexplicit

Definition at line 72 of file AssnsChainPFParticleMaker_module.cc.

74  , clusterTags(config().clusters())
75  , nClustersPerPFO(config().clustersPerPFO())
76  {
77  produces<std::vector<recob::PFParticle>>();
78  produces<art::Assns<recob::Cluster, recob::PFParticle>>();
79  }
std::vector< art::InputTag > clusterTags
List of cluster tags.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
unsigned int nClustersPerPFO
Maximum number of clusters per PFO.
static Config * config
Definition: config.cpp:1054

Member Function Documentation

std::vector< art::Ptr< recob::Cluster > > lar::test::AssnsChainPFParticleMaker::collectClusters ( art::Event const &  event) const
private

Returns a list of clusters to be combined.

Definition at line 198 of file AssnsChainPFParticleMaker_module.cc.

199 {
200 
201  std::vector<art::Ptr<recob::Cluster>> allClusters;
202 
203  for (auto const& tag: clusterTags) {
204  auto clusters = event.getValidHandle<std::vector<recob::Cluster>>(tag);
205 
206  std::size_t const nClusters = clusters->size();
207  for (std::size_t i = 0; i < nClusters; ++i)
208  allClusters.emplace_back(clusters, i);
209 
210  } // for
211 
212  return allClusters;
213 } // lar::test::AssnsChainPFParticleMaker::collectClusters()
std::vector< art::InputTag > clusterTags
List of cluster tags.
void lar::test::AssnsChainPFParticleMaker::produce ( art::Event event)
overridevirtual

Implements art::EDProducer.

Definition at line 101 of file AssnsChainPFParticleMaker_module.cc.

101  {
102 
103  //
104  // prepare input: merge all hits in a single collection
105  //
106  std::vector<art::Ptr<recob::Cluster>> clusters = collectClusters(event);
107 
108  //
109  // prepare output
110  //
111  auto PFOs = std::make_unique<std::vector<recob::PFParticle>>();
112  auto clusterPFOassns
113  = std::make_unique<art::Assns<recob::Cluster, recob::PFParticle>>();
114 
115  //
116  // create the PFParticles
117  //
118  unsigned int nPFOs = clusters.size() / nClustersPerPFO;
119  if (nPFOs * nClustersPerPFO < clusters.size()) ++nPFOs;
120 
121  art::PtrMaker<recob::PFParticle> ptrMaker(event);
122 
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
129  (nPFOs, std::size_t(recob::PFParticle::kPFParticlePrimary));
130  for (unsigned int i = 0; i < nPFOs; ++i) {
131 
132  // prepare for the next tier, if needed
133  if (i >= firstPFOinNextTier) {
134  firstPFOinThisTier = firstPFOinNextTier;
135 
136  nParticlesInTier *= nDaughtersPerParticle;
137  nDaughtersPerParticle += 1;
138  firstPFOinNextTier += nParticlesInTier;
139  } // if
140 
141  //
142  // assign clusters to PFO
143  //
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]);
148  iCluster += nPFOs;
149  } // while
150 
151  //
152  // generate the PFParticle
153  //
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);
161  ++nextDaughter;
162  } // while
163 
164  PFOs->emplace_back(
165  11, // pdgCode (11 = shower-like)
166  i, // self
167  parents[i], // parent
168  std::move(daughters)
169  );
170 
171  //
172  // generate associations
173  //
174  auto const PFOptr = ptrMaker(i); // art pointer to the new PFParticle
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);
179  }
180 
181  } // for
182 
183  mf::LogInfo("AssnsChainPFParticleMaker")
184  << "Created " << PFOs->size() << " particle flow objects with about "
185  << nClustersPerPFO << " clusters each from " << clusters.size()
186  << " clusters and " << clusterPFOassns->size() << " associations from "
187  << clusterTags.size() << " collections";
188 
189  event.put(std::move(PFOs));
190  event.put(std::move(clusterPFOassns));
191 
192 } // lar::test::AssnsChainClusterMaker::produce()
std::vector< art::InputTag > clusterTags
List of cluster tags.
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
static constexpr size_t kPFParticlePrimary
Define index to signify primary particle.
Definition: PFParticle.h:61
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Cluster finding and building.
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.
def move(depos, offset)
Definition: depos.py:107
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55

Member Data Documentation

std::vector<art::InputTag> lar::test::AssnsChainPFParticleMaker::clusterTags
private

List of cluster tags.

Definition at line 84 of file AssnsChainPFParticleMaker_module.cc.

unsigned int lar::test::AssnsChainPFParticleMaker::nClustersPerPFO
private

Maximum number of clusters per PFO.

Definition at line 85 of file AssnsChainPFParticleMaker_module.cc.


The documentation for this class was generated from the following file: