All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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:

Classes

struct  Config
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 

Public Member Functions

 AssnsChainClusterMaker (Parameters const &config)
 
virtual void produce (art::Event &event) override
 

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::InputTag > hitTags
 List of hit tags for clustering. More...
 
unsigned int nHitsPerCluster
 Maximum number of hits per cluster. More...
 

Detailed Description

Creates some dummy clusters and associations to hits.

Configuration parameters

Definition at line 49 of file AssnsChainClusterMaker_module.cc.

Member Typedef Documentation

using lar::test::AssnsChainClusterMaker::Parameters = art::EDProducer::Table<Config>

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.
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive hitsPerCluster
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

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.
process_name hit
Definition: cheaterreco.fcl:51
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
constexpr T sqr(T v)
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: