Public Member Functions | Private Member Functions | Private Attributes | List of all members
trkf::SpacePointFinder Class Reference
Inheritance diagram for trkf::SpacePointFinder:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 SpacePointFinder (fhicl::ParameterSet const &pset)
 
- 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

void produce (art::Event &evt) override
 
void endJob () override
 

Private Attributes

SpacePointAlg fSptalg
 
std::string fClusterModuleLabel
 
unsigned int fMinHits
 
bool fClusterAssns
 
int fNumEvent
 
int fNumSpt2
 
int fNumSpt3
 

Additional Inherited Members

- 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 >
 
- 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

Definition at line 36 of file SpacePointFinder_module.cc.

Constructor & Destructor Documentation

trkf::SpacePointFinder::SpacePointFinder ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 61 of file SpacePointFinder_module.cc.

67  : EDProducer{pset}
68  , fSptalg(pset.get<fhicl::ParameterSet>("SpacePointAlg"))
69  , fMinHits(0)
70  , fClusterAssns(false)
71  , fNumEvent(0)
72  , fNumSpt2(0)
73  , fNumSpt3(0)
74  {
75  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
76  fMinHits = pset.get<unsigned int>("MinHits");
77  fClusterAssns = pset.get<bool>("ClusterAssns");
78 
79  produces<std::vector<art::PtrVector<recob::SpacePoint>>>();
80  produces<std::vector<recob::SpacePoint>>();
81  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
82  if (fClusterAssns) produces<art::Assns<recob::SpacePoint, recob::Cluster>>();
83 
84  // Report.
85 
86  mf::LogInfo("SpacePointFinder")
87  << "SpacePointFinder configured with the following parameters:\n"
88  << " ClusterModuleLabel = " << fClusterModuleLabel << "\n"
89  << " Minimum Hits per Cluster = " << fMinHits << "\n"
90  << " Cluster associations = " << fClusterAssns;
91  }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20

Member Function Documentation

void trkf::SpacePointFinder::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 320 of file SpacePointFinder_module.cc.

324  {
325  mf::LogInfo("SpacePointFinder")
326  << "SpacePointFinder statistics:\n"
327  << " Number of events = " << fNumEvent << "\n"
328  << " Number of 2-view space points created = " << fNumSpt2 << "\n"
329  << " Number of 3-view space points created = " << fNumSpt3;
330  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void trkf::SpacePointFinder::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 95 of file SpacePointFinder_module.cc.

101  {
102  ++fNumEvent;
103 
104  // Get Services.
105 
107 
108  // Get clusters.
109 
111  evt.getByLabel(fClusterModuleLabel, clusterh);
112 
113  // Make a double or triple loop over clusters in distinct views
114  // (depending on minimum number of views configured in SpacePointAlg).
115 
116  if (clusterh.isValid()) {
117 
118  // Make a collection of space points that will be inserted into the event.
119 
120  std::unique_ptr<std::vector<art::PtrVector<recob::SpacePoint>>> sptvecs(
122  std::unique_ptr<std::vector<recob::SpacePoint>> spts(new std::vector<recob::SpacePoint>);
123  std::unique_ptr<art::Assns<recob::SpacePoint, recob::Hit>> sphitassn(
125  std::unique_ptr<art::Assns<recob::SpacePoint, recob::Cluster>> spclassn(
127 
128  // Make a hit vector which will be used to store hits to be passed
129  // to SpacePointAlg.
130 
132  art::FindManyP<recob::Hit> fm(clusterh, evt, fClusterModuleLabel);
133 
134  auto const clockData =
136  auto const detProp =
138 
139  // Loop over first cluster.
140 
141  int nclus = clusterh->size();
142  for (int iclus = 0; iclus < nclus; ++iclus) {
143  art::Ptr<recob::Cluster> piclus(clusterh, iclus);
144  geo::View_t iview = piclus->View();
145 
146  std::vector<art::Ptr<recob::Hit>> ihits = fm.at(iclus);
147 
148  // Test first view.
149 
150  if (ihits.size() >= fMinHits &&
151  ((iview == geo::kU && fSptalg.enableU()) || (iview == geo::kV && fSptalg.enableV()) ||
152  (iview == geo::kZ && fSptalg.enableW()))) {
153 
154  // Store hits from first view into hit vector.
155 
156  unsigned int nihits = ihits.size();
157  hits.clear();
158  hits.reserve(nihits);
159  for (std::vector<art::Ptr<recob::Hit>>::const_iterator i = ihits.begin();
160  i != ihits.end();
161  ++i)
162  hits.push_back(*i);
163 
164  // Loop over second cluster.
165 
166  for (int jclus = 0; jclus < iclus; ++jclus) {
167  art::Ptr<recob::Cluster> pjclus(clusterh, jclus);
168  geo::View_t jview = pjclus->View();
169 
170  std::vector<art::Ptr<recob::Hit>> jhits = fm.at(jclus);
171 
172  // Test second view.
173 
174  if (jhits.size() >= fMinHits &&
175  ((jview == geo::kU && fSptalg.enableU()) ||
176  (jview == geo::kV && fSptalg.enableV()) ||
177  (jview == geo::kZ && fSptalg.enableW())) &&
178  jview != iview) {
179 
180  // Store hits from second view into hit vector.
181 
182  unsigned int njhits = jhits.size();
183  assert(hits.size() >= nihits);
184  //hits.resize(nihits);
185  while (hits.size() > nihits)
186  hits.pop_back();
187  assert(hits.size() == nihits);
188  hits.reserve(nihits + njhits);
189  for (std::vector<art::Ptr<recob::Hit>>::const_iterator j = jhits.begin();
190  j != jhits.end();
191  ++j)
192  hits.push_back(*j);
193 
194  // If two-view space points are allowed, make them here.
195 
196  if (fSptalg.minViews() <= 2) {
197  std::vector<recob::SpacePoint> new_spts;
198  fSptalg.makeSpacePoints(clockData, detProp, hits, new_spts);
199 
200  // If we found some space points, insert them into the event.
201 
202  if (new_spts.size() > 0) {
203  fNumSpt2 += new_spts.size();
205  clusters.reserve(2);
206  clusters.push_back(piclus);
207  clusters.push_back(pjclus);
208 
209  // Insert newly found space points into event collection.
210 
211  int nspt = spts->size();
212  spts->insert(spts->end(), new_spts.begin(), new_spts.end());
213 
214  // Associate space points with hits and clusters.
215 
217  for (unsigned int ispt = nspt; ispt < spts->size(); ++ispt) {
218  const recob::SpacePoint& spt = (*spts)[ispt];
220  util::CreateAssn(evt, *spts, hits, *sphitassn, ispt);
221  if (fClusterAssns) util::CreateAssn(evt, *spts, clusters, *spclassn, ispt);
222 
223  // make the PtrVector for this collection of space points
224  // Do not reproduce the following lines
225  // Contact brebel@fnal.gov if you think you need to reproduce these lines.
226  art::ProductID spid = evt.getProductID<std::vector<recob::SpacePoint>>();
227  art::Ptr<recob::SpacePoint> spptr(spid, ispt, evt.productGetter(spid));
228  sptvec.push_back(spptr);
229  }
230  sptvecs->push_back(sptvec);
231  }
232  }
233 
234  // Loop over third cluster.
235 
236  for (int kclus = 0; kclus < jclus; ++kclus) {
237  art::Ptr<recob::Cluster> pkclus(clusterh, kclus);
238  geo::View_t kview = pkclus->View();
239 
240  std::vector<art::Ptr<recob::Hit>> khits = fm.at(kclus);
241 
242  // Test third view.
243 
244  if (khits.size() >= fMinHits &&
245  ((kview == geo::kU && fSptalg.enableU()) ||
246  (kview == geo::kV && fSptalg.enableV()) ||
247  (kview == geo::kZ && fSptalg.enableW())) &&
248  kview != iview && kview != jview) {
249 
250  // Store hits from third view into hit vector.
251 
252  unsigned int nkhits = khits.size();
253  assert(hits.size() >= nihits + njhits);
254  //hits.resize(nihits + njhits);
255  while (hits.size() > nihits + njhits)
256  hits.pop_back();
257  assert(hits.size() == nihits + njhits);
258  hits.reserve(nihits + njhits + nkhits);
259  for (std::vector<art::Ptr<recob::Hit>>::const_iterator k = khits.begin();
260  k != khits.end();
261  ++k)
262  hits.push_back(*k);
263 
264  // Make three-view space points.
265 
266  std::vector<recob::SpacePoint> new_spts;
267  fSptalg.makeSpacePoints(clockData, detProp, hits, new_spts);
268 
269  // If we found some space points, insert them into the event.
270 
271  if (new_spts.size() > 0) {
272  fNumSpt3 += new_spts.size();
274  clusters.reserve(3);
275  clusters.push_back(piclus);
276  clusters.push_back(pjclus);
277  clusters.push_back(pkclus);
278 
279  // Insert newly found space points into event collection.
280 
281  int nspt = spts->size();
282  spts->insert(spts->end(), new_spts.begin(), new_spts.end());
283 
284  // Associate space points with hits and clusters.
285 
287  for (unsigned int ispt = nspt; ispt < spts->size(); ++ispt) {
288  const recob::SpacePoint& spt = (*spts)[ispt];
290  util::CreateAssn(evt, *spts, hits, *sphitassn, ispt);
291  if (fClusterAssns) util::CreateAssn(evt, *spts, clusters, *spclassn, ispt);
292 
293  // make the PtrVector for this collection of space points
294  // Do not reproduce the following lines
295  // Contact brebel@fnal.gov if you think you need to reproduce these lines.
296  art::ProductID spid = evt.getProductID<std::vector<recob::SpacePoint>>();
297  art::Ptr<recob::SpacePoint> spptr(spid, ispt, evt.productGetter(spid));
298  sptvec.push_back(spptr);
299  }
300  sptvecs->push_back(sptvec);
301  }
302  }
303  }
304  }
305  }
306  }
307  }
308 
309  // Add space points and associations to event.
310 
311  evt.put(std::move(spts));
312  evt.put(std::move(sptvecs));
313  evt.put(std::move(sphitassn));
314  if (fClusterAssns) evt.put(std::move(spclassn));
315  }
316  }
void reserve(size_type n)
Definition: PtrVector.h:337
bool enableW() const noexcept
bool enableV() const noexcept
ProductID getProductID(std::string const &instance_name="") const
Definition: DataViewImpl.h:338
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure V.
Definition: geo_types.h:130
struct vector vector
Planes which measure Z direction.
Definition: geo_types.h:132
int minViews() const noexcept
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
bool isValid() const noexcept
Definition: Handle.h:191
Planes which measure U.
Definition: geo_types.h:129
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
def move(depos, offset)
Definition: depos.py:107
EDProductGetter const * productGetter(ProductID const pid) const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
size_type size() const
Definition: PtrVector.h:302
bool enableU() const noexcept
void pop_back()
Definition: PtrVector.h:457
static constexpr double fm
Definition: Units.h:75
void clear()
Definition: PtrVector.h:533

Member Data Documentation

bool trkf::SpacePointFinder::fClusterAssns
private

Definition at line 49 of file SpacePointFinder_module.cc.

std::string trkf::SpacePointFinder::fClusterModuleLabel
private

Definition at line 47 of file SpacePointFinder_module.cc.

unsigned int trkf::SpacePointFinder::fMinHits
private

Definition at line 48 of file SpacePointFinder_module.cc.

int trkf::SpacePointFinder::fNumEvent
private

Definition at line 53 of file SpacePointFinder_module.cc.

int trkf::SpacePointFinder::fNumSpt2
private

Definition at line 54 of file SpacePointFinder_module.cc.

int trkf::SpacePointFinder::fNumSpt3
private

Definition at line 55 of file SpacePointFinder_module.cc.

SpacePointAlg trkf::SpacePointFinder::fSptalg
private

Definition at line 46 of file SpacePointFinder_module.cc.


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