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

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

Inheritance diagram for lar::test::AssnsChainClusterMaker:
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

 AssnsChainClusterMaker (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::Hit > > collectHits (art::Event const &event) const
 Returns a list of hits to be clustered. More...
 

Private Attributes

std::vector< art::InputTaghitTags
 List of hit tags for clustering. More...
 
unsigned int nHitsPerCluster
 Maximum number of hits per cluster. 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 clusters and associations to hits.

Configuration parameters

Definition at line 49 of file AssnsChainClusterMaker_module.cc.

Member Typedef Documentation

Definition at line 69 of file AssnsChainClusterMaker_module.cc.

Constructor & Destructor Documentation

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

Definition at line 71 of file AssnsChainClusterMaker_module.cc.

72  : EDProducer{config}, hitTags(config().hits())
73  , nHitsPerCluster(config().hitsPerCluster())
74  {
75  produces<std::vector<recob::Cluster>>();
76  produces<art::Assns<recob::Hit, recob::Cluster>>();
77  }
std::vector< art::InputTag > hitTags
List of hit tags for clustering.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
static Config * config
Definition: config.cpp:1054
unsigned int nHitsPerCluster
Maximum number of hits per cluster.

Member Function Documentation

std::vector< art::Ptr< recob::Hit > > lar::test::AssnsChainClusterMaker::collectHits ( art::Event const &  event) const
private

Returns a list of hits to be clustered.

Definition at line 207 of file AssnsChainClusterMaker_module.cc.

208 {
209 
210  std::vector<art::Ptr<recob::Hit>> allHits;
211 
212  for (auto const& tag: hitTags) {
213  auto hits = event.getValidHandle<std::vector<recob::Hit>>(tag);
214 
215  std::size_t const nHits = hits->size();
216  for (std::size_t i = 0; i < nHits; ++i)
217  allHits.emplace_back(hits, i);
218 
219  } // for
220 
221  return allHits;
222 } // lar::test::AssnsChainClusterMaker::collectHits()
std::vector< art::InputTag > hitTags
List of hit tags for clustering.
void lar::test::AssnsChainClusterMaker::produce ( art::Event event)
overridevirtual

Implements art::EDProducer.

Definition at line 107 of file AssnsChainClusterMaker_module.cc.

107  {
108 
109  //
110  // prepare input: merge all hits in a single collection
111  //
112  std::vector<art::Ptr<recob::Hit>> hits = collectHits(event);
113 
114  //
115  // prepare output
116  //
117  auto clusters = std::make_unique<std::vector<recob::Cluster>>();
118  auto hitClusterAssns
119  = std::make_unique<art::Assns<recob::Hit, recob::Cluster>>();
120 
121  //
122  // create the clusters
123  //
124  unsigned int nClusters = hits.size() / nHitsPerCluster;
125  if (nClusters * nHitsPerCluster < hits.size()) ++nClusters;
126 
127  art::PtrMaker<recob::Cluster> ptrMaker(event);
128 
129  for (unsigned int i = 0; i < nClusters; ++i) {
130 
131  //
132  // assign hits to cluster
133  //
134  std::vector<art::Ptr<recob::Hit>> clusterHits;
135  std::size_t iHit = i;
136  while (iHit < hits.size()) {
137  clusterHits.push_back(hits[iHit]);
138  iHit += nClusters;
139  } // while
140 
141  //
142  // generate the cluster
143  //
144  clusters->emplace_back(
145  float(clusterHits.front()->WireID().Wire), // start_wire
146  1.0, // sigma_start_wire
147  clusterHits.front()->PeakTime(), // start_tick
148  clusterHits.front()->SigmaPeakTime(), // sigma_start_tick
149  clusterHits.front()->Integral(), // start_charge
150  0.0, // start_angle
151  0.0, // start_opening
152  float(clusterHits.back()->WireID().Wire), // end_wire
153  1.0, // sigma_end_wire
154  clusterHits.back()->PeakTime(), // end_tick
155  clusterHits.back()->SigmaPeakTime(), // sigma_end_tick
156  clusterHits.back()->Integral(), // end_charge
157  0.0, // end_angle
158  0.0, // end_opening
159  std::accumulate(clusterHits.cbegin(), clusterHits.cend(), 0.0,
160  [](float sum, art::Ptr<recob::Hit> const& hit)
161  { return sum + hit->Integral(); }
162  ), // integral
163  std::sqrt(std::accumulate(clusterHits.cbegin(), clusterHits.cend(), 0.0,
164  [](float sum, art::Ptr<recob::Hit> const& hit)
165  { return sum + sqr(hit->SigmaIntegral()); }
166  )), // integral_stddev
167  std::accumulate(clusterHits.cbegin(), clusterHits.cend(), 0.0,
168  [](float sum, art::Ptr<recob::Hit> const& hit)
169  { return sum + hit->SummedADC(); }
170  ), // summedADC
171  std::sqrt(std::accumulate(clusterHits.cbegin(), clusterHits.cend(), 0.0,
172  [](float sum, art::Ptr<recob::Hit> const& hit)
173  { return sum + hit->SummedADC(); }
174  )), // summedADC_stddev
175  clusterHits.size(), // n_hits
176  0.0, // multiple_hit_density
177  2.0, // width
178  recob::Cluster::ID_t(i + 1), // ID
179  clusterHits.front()->View(), // view
180  clusterHits.front()->WireID().asPlaneID(), // plane
182  );
183 
184  //
185  // generate associations
186  //
187  auto const clusterPtr = ptrMaker(i); // art pointer to the new cluster
188  for (art::Ptr<recob::Hit> const& hit: clusterHits)
189  hitClusterAssns->addSingle(hit, clusterPtr);
190 
191  } // for
192 
193  mf::LogInfo("AssnsChainClusterMaker")
194  << "Created " << clusters->size() << " clusters with about "
195  << nHitsPerCluster << " hits each from " << hits.size() << " hits and "
196  << hitClusterAssns->size() << " associations from "
197  << hitTags.size() << " collections";
198 
199  event.put(std::move(clusters));
200  event.put(std::move(hitClusterAssns));
201 
202 } // lar::test::AssnsChainClusterMaker::produce()
std::vector< art::InputTag > hitTags
List of hit tags for clustering.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< art::Ptr< recob::Hit > > collectHits(art::Event const &event) const
Returns a list of hits to be clustered.
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
T sqr(T v)
def move(depos, offset)
Definition: depos.py:107
Detector simulation of raw signals on wires.
unsigned int nHitsPerCluster
Maximum number of hits per cluster.
int ID_t
Type of cluster ID.
Definition: Cluster.h:74

Member Data Documentation

std::vector<art::InputTag> lar::test::AssnsChainClusterMaker::hitTags
private

List of hit tags for clustering.

Definition at line 82 of file AssnsChainClusterMaker_module.cc.

unsigned int lar::test::AssnsChainClusterMaker::nHitsPerCluster
private

Maximum number of hits per cluster.

Definition at line 83 of file AssnsChainClusterMaker_module.cc.


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