LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ChargedSpacePointCreator.h
Go to the documentation of this file.
1 
13 #ifndef LARDATA_ARTDATAHELPER_CHARGEDSPACEPOINTCREATOR_H
14 #define LARDATA_ARTDATAHELPER_CHARGEDSPACEPOINTCREATOR_H
15 
16 // LArSoft libraries
19 
20 // framework libraries
23 
24 // C/C++ standard libraries
25 #include <cstdlib> // std::size_t
26 #include <memory> // std::unique_ptr<>
27 #include <type_traits> // std::enable_if_t, ...
28 #include <vector>
29 
30 namespace art {
31  class Event;
32  class ProducesCollector;
33 }
34 
35 namespace recob {
36 
229 
230  public:
231  //--- BEGIN Constructors ---------------------------------------------------
234 
245  ChargedSpacePointCollectionCreator(art::Event& event, std::string const& instanceName = {});
246 
256  static ChargedSpacePointCollectionCreator forPtrs(art::Event& event,
257  std::string const& instanceName = {});
258 
260  //--- END Constructors ---------------------------------------------------
261 
262  //--- BEGIN Insertion and finish operations --------------------------------
265 
267 
278  void add(recob::SpacePoint const& spacePoint, recob::PointCharge const& charge);
279  void add(recob::SpacePoint&& spacePoint, recob::PointCharge&& charge);
281 
283 
298  void addAll(std::vector<recob::SpacePoint>&& spacePoints,
299  std::vector<recob::PointCharge>&& charges);
300  void addAll(std::vector<recob::SpacePoint> const& spacePoints,
301  std::vector<recob::PointCharge> const& charges);
303 
314  void put();
315 
317  //--- END Insertion and finish operations --------------------------------
318 
319  //--- BEGIN Queries and operations -----------------------------------------
322 
324  bool empty() const { return spent() || fSpacePoints->empty(); }
325 
327  std::size_t size() const { return spent() ? 0U : fSpacePoints->size(); }
328 
330  void clear();
331 
333  bool spent() const { return !fSpacePoints; }
334 
336  bool canMakePointers() const { return bool(fSpacePointPtrMaker); }
337 
339  //--- END Queries and operations -------------------------------------------
340 
341  //--- BEGIN Complimentary unchecked element access -------------------------
344 
346  recob::SpacePoint const& spacePoint(std::size_t i) const { return fSpacePoints->operator[](i); }
347 
349  recob::SpacePoint const& lastSpacePoint() const { return spacePoint(lastIndex()); }
350 
352  art::Ptr<recob::SpacePoint> spacePointPtr(std::size_t i) const;
353 
355  art::Ptr<recob::SpacePoint> lastSpacePointPtr() const { return spacePointPtr(lastIndex()); }
356 
358  recob::PointCharge const& charge(std::size_t i) const { return fCharges->operator[](i); }
359 
361  recob::PointCharge const& lastCharge() const { return charge(lastIndex()); }
362 
364  art::Ptr<recob::PointCharge> chargePtr(std::size_t i) const;
365 
367  art::Ptr<recob::PointCharge> lastChargePtr() const { return chargePtr(lastIndex()); }
368 
370  //--- END Complimentary unchecked element access ---------------------------
371 
372  //--- BEGIN Static constructor interface -----------------------------------
374 
396  static void produces(art::ProducesCollector& producesCollector,
397  std::string const& instanceName = {});
398 
400  //--- END Static constructor interface -------------------------------------
401 
402  private:
404 
405  std::string fInstanceName;
406 
408  std::unique_ptr<std::vector<recob::SpacePoint>> fSpacePoints;
410  std::unique_ptr<art::PtrMaker<recob::SpacePoint>> fSpacePointPtrMaker;
412  std::unique_ptr<std::vector<recob::PointCharge>> fCharges;
414  std::unique_ptr<art::PtrMaker<recob::PointCharge>> fChargePtrMaker;
415 
417  std::size_t lastIndex() const { return size() - 1U; }
418 
419  }; // class ChargedSpacePointCollectionCreator
420 
421 } // namespace recob
422 
423 //------------------------------------------------------------------------------
424 
425 #endif // LARDATA_ARTDATAHELPER_CHARGEDSPACEPOINTCREATOR_H
std::size_t size() const
Returns the number of space points currently in the collection.
Reconstruction base classes.
art::Event & fEvent
The event this object is bound to.
recob::PointCharge const & charge(std::size_t i) const
Returns the last inserted charge; undefined behaviour if empty().
std::size_t lastIndex() const
Returns the index of the last element (undefined if empty).
art::Ptr< recob::SpacePoint > lastSpacePointPtr() const
Returns an art pointer to the last inserted space point (no check!).
std::unique_ptr< std::vector< recob::SpacePoint > > fSpacePoints
Space point data.
std::string fInstanceName
Instance name of all the data products.
std::unique_ptr< art::PtrMaker< recob::SpacePoint > > fSpacePointPtrMaker
Space point pointer maker.
Information about charge reconstructed in the active volume.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
art::Ptr< recob::PointCharge > lastChargePtr() const
Returns an art pointer to the inserted charge (no check!).
bool spent() const
Returns whether put() has already been called.
recob::PointCharge const & lastCharge() const
Returns the last inserted charge; undefined behaviour if empty().
bool empty() const
Returns whether there are currently no space points in the collection.
recob::SpacePoint const & lastSpacePoint() const
Returns the last inserted space point; undefined behaviour if empty().
Creates a collection of space points with associated charge.
std::unique_ptr< std::vector< recob::PointCharge > > fCharges
Charge data.
bool canMakePointers() const
Returns whether art pointer making is enabled.
Definition: MVAAlg.h:12
recob::SpacePoint const & spacePoint(std::size_t i) const
Returns the specified space point; undefined behaviour if not there.
vec_iX clear()
Event finding and building.
std::unique_ptr< art::PtrMaker< recob::PointCharge > > fChargePtrMaker
Charge pointer maker.
Charge reconstructed in the active volume.
Definition: PointCharge.h:30