LArSoft
v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
|
Creates a collection of space points with associated charge. More...
#include "ChargedSpacePointCreator.h"
Public Member Functions | |
void | put () |
Puts all data products into the event, leaving the creator empty() . More... | |
Constructors | |
ChargedSpacePointCollectionCreator (art::Event &event, std::string const &instanceName={}) | |
Constructor binding this object to a specific art event. More... | |
template<typename Producer > | |
ChargedSpacePointCollectionCreator (art::Event &event, Producer const &producer, std::string const &instanceName={}, std::enable_if_t< details::is_art_module_v< Producer >> *=nullptr) | |
Constructor binding this object to a specific art event. More... | |
Insertion and finish operations | |
void | add (recob::SpacePoint const &spacePoint, recob::PointCharge const &charge) |
Inserts the specified space point and associated data into the collection. More... | |
void | add (recob::SpacePoint &&spacePoint, recob::PointCharge &&charge) |
Inserts the specified space point and associated data into the collection. More... | |
void | addAll (std::vector< recob::SpacePoint > &&spacePoints, std::vector< recob::PointCharge > &&charges) |
Inserts all the space points and associated data from the vectors into the collection. More... | |
void | addAll (std::vector< recob::SpacePoint > const &spacePoints, std::vector< recob::PointCharge > const &charges) |
Inserts all the space points and associated data from the vectors into the collection. More... | |
Queries and operations | |
bool | empty () const |
Returns whether there are currently no space points in the collection. More... | |
std::size_t | size () const |
Returns the number of space points currently in the collection. More... | |
void | clear () |
Removes all data from the collection, making it empty() . More... | |
bool | spent () const |
Returns whether put() has already been called. More... | |
bool | canMakePointers () const |
Returns whether art pointer making is enabled. More... | |
Complimentary unchecked element access | |
recob::SpacePoint const & | spacePoint (std::size_t i) const |
Returns the specified space point; undefined behaviour if not there. More... | |
recob::SpacePoint const & | lastSpacePoint () const |
Returns the last inserted space point; undefined behaviour if empty() . More... | |
art::Ptr< recob::SpacePoint > | spacePointPtr (std::size_t i) const |
Returns an art pointer to the specified space point (no check done!). More... | |
art::Ptr< recob::SpacePoint > | lastSpacePointPtr () const |
Returns an art pointer to the last inserted space point (no check!). More... | |
recob::PointCharge const & | charge (std::size_t i) const |
Returns the last inserted charge; undefined behaviour if empty() . More... | |
recob::PointCharge const & | lastCharge () const |
Returns the last inserted charge; undefined behaviour if empty() . More... | |
art::Ptr< recob::PointCharge > | chargePtr (std::size_t i) const |
Returns an art pointer to the specified charge (no check done!). More... | |
art::Ptr< recob::PointCharge > | lastChargePtr () const |
Returns an art pointer to the inserted charge (no check!). More... | |
Static Public Member Functions | |
Static constructor interface | |
These methods take care of initialization that needs to take place on construction of the module. | |
static void | produces (art::ProducerBase &producer, std::string const &instanceName={}) |
Declares the data products being produced. More... | |
Private Member Functions | |
std::size_t | lastIndex () const |
Returns the index of the last element (undefined if empty). More... | |
Private Attributes | |
art::Event & | fEvent |
The event this object is bound to. More... | |
std::string | fInstanceName |
Instance name of all the data products. More... | |
std::unique_ptr< std::vector< recob::SpacePoint > > | fSpacePoints |
Space point data. More... | |
std::unique_ptr< art::PtrMaker< recob::SpacePoint > > | fSpacePointPtrMaker |
Space point pointer maker. More... | |
std::unique_ptr< std::vector< recob::PointCharge > > | fCharges |
Charge data. More... | |
std::unique_ptr< art::PtrMaker< recob::PointCharge > > | fChargePtrMaker |
Charge pointer maker. More... | |
Creates a collection of space points with associated charge.
This class facilitates the creation of data products satisfying the requirements the proxy::ChargedSpacePoints
proxy relies on. It will keep track of space points and reconstructed charge, and will put them into the event at the end.
The requirements guaranteed by the output of this collection creator satisfy the proxy::ChargedSpacePoints
proxy requirements. They are:
i
is associated to space point at the same position i
art::Assns
data product is producedThe usage pattern is made of two main parts:
The second part happens within the context of the producer's produce()
(or filter()
, or equivalent) method, and it can be split into three stages:
In the same fashion as data products must be declared to art with a produces()
call, the collection creator will have to perform an equivalent step. This is achieved by calling the static
produces()` method (see its documentation for an example).
Collection creator objects are bound to a specific event and therefore can't be data members of the producer class. In the produces()
method, we'll have:
If art pointers to the data products are needed (e.g. to create associations), then the producer must be specified in the constructor:
In both cases, an instance name can be specified which will be used for all the managed data products (space points and reconstructed charge).
The core of the usage of this object is feeding the objects to the data product collections. This is done using the add()
member function. If the data objects already exist, they can be moved in instead of being copied. For example:
If your algorithm is creating a subcollection of space points and charges which are in the same order, a shortcut to a loop of add()
is addAll()
:
While the collection creator object is designed to be just a single-use, single-pattern helper, there are a few operations that it allows:
size()
), whether there are any (empty()
), and whether put()
has been already called (spent()
; see below)lastSpacePointPtr()
, lastChargePtr()
, spacePointPtr()
and chargePtr()
to the elements of the future data productsAgain as in the standard producer pattern, where Event::put()
needs to be called to finally move the data into art, the collection creator will need to be told to do the same:
The instance name used in put()
had been set at construction time.
After put()
is called, the object has served its purpose and can't be used any further. In this state, spent()
method will return true
.
Definition at line 239 of file ChargedSpacePointCreator.h.
recob::ChargedSpacePointCollectionCreator::ChargedSpacePointCollectionCreator | ( | art::Event & | event, |
std::string const & | instanceName = {} |
||
) |
Constructor binding this object to a specific art event.
event | the art event to bind to |
instanceName | _(default: empty)_ instance name for all data products |
When the object is constructed with this constructor, the creation of art pointers will not be enabled (canMakePointers()
will return false
).
Definition at line 24 of file ChargedSpacePointCreator.cpp.
References add().
recob::ChargedSpacePointCollectionCreator::ChargedSpacePointCollectionCreator | ( | art::Event & | event, |
Producer const & | producer, | ||
std::string const & | instanceName = {} , |
||
std::enable_if_t< details::is_art_module_v< Producer >> * | = nullptr |
||
) |
Constructor binding this object to a specific art event.
Producer | the type of producer required |
event | the art event to bind to |
producer | pointer to the producer |
instanceName | _(default: empty)_ instance name for all data products |
This constructor enables the creation of art pointers.
Definition at line 489 of file ChargedSpacePointCreator.h.
References fChargePtrMaker, fEvent, fInstanceName, and fSpacePointPtrMaker.
void recob::ChargedSpacePointCollectionCreator::add | ( | recob::SpacePoint const & | spacePoint, |
recob::PointCharge const & | charge | ||
) |
Inserts the specified space point and associated data into the collection.
spacePoint | the space point to be copied into the collection |
charge | the charge to be copied into the collection |
The data is pushed as the new last element of the collection.
Data is copied or moved depending on which variant of this method is used.
Definition at line 34 of file ChargedSpacePointCreator.cpp.
Referenced by reco3d::SpacePointSolver::AddSpacePoint(), and ChargedSpacePointCollectionCreator().
void recob::ChargedSpacePointCollectionCreator::add | ( | recob::SpacePoint && | spacePoint, |
recob::PointCharge && | charge | ||
) |
Inserts the specified space point and associated data into the collection.
spacePoint | the space point to be copied into the collection |
charge | the charge to be copied into the collection |
The data is pushed as the new last element of the collection.
Data is copied or moved depending on which variant of this method is used.
Definition at line 50 of file ChargedSpacePointCreator.cpp.
void recob::ChargedSpacePointCollectionCreator::addAll | ( | std::vector< recob::SpacePoint > && | spacePoints, |
std::vector< recob::PointCharge > && | charges | ||
) |
Inserts all the space points and associated data from the vectors into the collection.
spacePoints | the space point to be copied into the collection |
charges | the charges to be copied into the collection |
cet::exception | (category ChargedSpacePointCollectionCreator ) if the input collections are inconsistent |
The data is pushed as the new last element of the collection.
Data is copied or moved depending on which variant of this method is used.
No exception safety is offered here.
Definition at line 65 of file ChargedSpacePointCreator.cpp.
References empty(), fCharges, and fSpacePoints.
void recob::ChargedSpacePointCollectionCreator::addAll | ( | std::vector< recob::SpacePoint > const & | spacePoints, |
std::vector< recob::PointCharge > const & | charges | ||
) |
Inserts all the space points and associated data from the vectors into the collection.
spacePoints | the space point to be copied into the collection |
charges | the charges to be copied into the collection |
cet::exception | (category ChargedSpacePointCollectionCreator ) if the input collections are inconsistent |
The data is pushed as the new last element of the collection.
Data is copied or moved depending on which variant of this method is used.
No exception safety is offered here.
Definition at line 101 of file ChargedSpacePointCreator.cpp.
References fCharges, and fSpacePoints.
|
inline |
Returns whether art pointer making is enabled.
Definition at line 362 of file ChargedSpacePointCreator.h.
|
inline |
Returns the last inserted charge; undefined behaviour if empty()
.
Definition at line 389 of file ChargedSpacePointCreator.h.
art::Ptr< recob::PointCharge > recob::ChargedSpacePointCollectionCreator::chargePtr | ( | std::size_t | i | ) | const |
Returns an art pointer to the specified charge (no check done!).
Definition at line 166 of file ChargedSpacePointCreator.cpp.
References fChargePtrMaker, and produces().
Referenced by spacePointPtr().
void recob::ChargedSpacePointCollectionCreator::clear | ( | ) |
Removes all data from the collection, making it empty()
.
Definition at line 143 of file ChargedSpacePointCreator.cpp.
References empty(), fCharges, fSpacePoints, and spacePointPtr().
|
inline |
Returns whether there are currently no space points in the collection.
Definition at line 350 of file ChargedSpacePointCreator.h.
Referenced by addAll(), clear(), and put().
|
inline |
Returns the last inserted charge; undefined behaviour if empty()
.
Definition at line 393 of file ChargedSpacePointCreator.h.
|
inline |
Returns an art pointer to the inserted charge (no check!).
Definition at line 400 of file ChargedSpacePointCreator.h.
|
inlineprivate |
Returns the index of the last element (undefined if empty).
Definition at line 453 of file ChargedSpacePointCreator.h.
|
inline |
Returns the last inserted space point; undefined behaviour if empty()
.
Definition at line 377 of file ChargedSpacePointCreator.h.
|
inline |
Returns an art pointer to the last inserted space point (no check!).
Definition at line 384 of file ChargedSpacePointCreator.h.
Referenced by reco3d::SpacePointSolver::FillSystemToSpacePointsAndAssns().
|
static |
Declares the data products being produced.
producer | the module producing the data products |
instanceName | _(default: empty)_ name of instance of all data products |
Call this method in the constructor of producer
, e.g.:
Definition at line 174 of file ChargedSpacePointCreator.cpp.
References art::ProductRegistryHelper::produces().
Referenced by chargePtr(), and reco3d::SpacePointSolver::SpacePointSolver().
void recob::ChargedSpacePointCollectionCreator::put | ( | ) |
Puts all data products into the event, leaving the creator empty()
.
The accumulated data is moved into the event.
This is the last valid action of the object. After this, only empty()
, spent()
and the art pointer makers (if enabled) are guaranteed to work.
Definition at line 132 of file ChargedSpacePointCreator.cpp.
References empty(), fCharges, fEvent, fInstanceName, fSpacePoints, art::Event::put(), and spent().
Referenced by reco3d::SpacePointSolver::produce().
|
inline |
Returns the number of space points currently in the collection.
Definition at line 353 of file ChargedSpacePointCreator.h.
References clear().
|
inline |
Returns the specified space point; undefined behaviour if not there.
Definition at line 373 of file ChargedSpacePointCreator.h.
art::Ptr< recob::SpacePoint > recob::ChargedSpacePointCollectionCreator::spacePointPtr | ( | std::size_t | i | ) | const |
Returns an art pointer to the specified space point (no check done!).
Definition at line 156 of file ChargedSpacePointCreator.cpp.
References chargePtr(), and fSpacePointPtrMaker.
Referenced by clear().
|
inline |
Returns whether put()
has already been called.
Definition at line 359 of file ChargedSpacePointCreator.h.
Referenced by put().
|
private |
Charge pointer maker.
Definition at line 450 of file ChargedSpacePointCreator.h.
Referenced by ChargedSpacePointCollectionCreator(), and chargePtr().
|
private |
Charge data.
Definition at line 448 of file ChargedSpacePointCreator.h.
|
private |
The event this object is bound to.
Definition at line 439 of file ChargedSpacePointCreator.h.
Referenced by ChargedSpacePointCollectionCreator(), and put().
|
private |
Instance name of all the data products.
Definition at line 441 of file ChargedSpacePointCreator.h.
Referenced by ChargedSpacePointCollectionCreator(), and put().
|
private |
Space point pointer maker.
Definition at line 446 of file ChargedSpacePointCreator.h.
Referenced by ChargedSpacePointCollectionCreator(), and spacePointPtr().
|
private |
Space point data.
Definition at line 444 of file ChargedSpacePointCreator.h.