LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
recob::HitAndAssociationsWriterBase Class Reference

Base class handling a collection of hits and its associations. More...

#include "HitCreator.h"

Inheritance diagram for recob::HitAndAssociationsWriterBase:
recob::HitCollectionAssociator recob::HitCollectionCreator recob::HitRefinerAssociator

Public Member Functions

size_t size () const
 Returns the number of hits currently in the collection. More...
 
void put_into (art::Event &)
 Moves the data into the event. More...
 
void put_into ()
 Moves the data into the event. More...
 
std::vector< recob::Hit > const & peek () const
 Returns a read-only reference to the current list of hits. More...
 

Static Public Member Functions

static void declare_products (art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
 Declares the hit products we are going to fill. More...
 

Protected Types

using HitPtr_t = art::Ptr< recob::Hit >
 Type of art pointer to Hit. More...
 

Protected Member Functions

 HitAndAssociationsWriterBase (art::Event &event, std::string instance_name, bool doWireAssns, bool doRawDigitAssns)
 Constructor: sets instance name and whether to build associations. More...
 
HitPtr_t CreatePtr (size_t index) const
 Creates an art pointer to the hit with the specified index. More...
 

Protected Attributes

std::string prod_instance
 Tame of the instance for data products. More...
 
std::unique_ptr< std::vector< recob::Hit > > hits
 Collection of hits. More...
 
std::unique_ptr< art::Assns< recob::Wire, recob::Hit > > WireAssns
 Associations with wires. More...
 
std::unique_ptr< art::Assns< raw::RawDigit, recob::Hit > > RawDigitAssns
 Associations with raw digits. More...
 
art::Eventevent = nullptr
 Pointer to the event we are using. More...
 
art::PtrMaker< recob::HithitPtrMaker
 Tool to create hit pointers,. More...
 

Detailed Description

Base class handling a collection of hits and its associations.


Instead of creating a collection of hits, one for its association with wires and one for its association with raw digits, one can use a class derived from this one:

The typical usage is to have the constructor of the module call the static function

(this example declares a collection with empty instance name and that we want associations to both wires and raw digits), and then in produce():

HitAndAssociationsWriterDerived hcol(*this, event);
// ... fill hcol in the proper way ...
hcol.put_into(); // calls art::Event::put()

Definition at line 391 of file HitCreator.h.

Member Typedef Documentation

Type of art pointer to Hit.

Definition at line 447 of file HitCreator.h.

Constructor & Destructor Documentation

recob::HitAndAssociationsWriterBase::HitAndAssociationsWriterBase ( art::Event event,
std::string  instance_name,
bool  doWireAssns,
bool  doRawDigitAssns 
)
protected

Constructor: sets instance name and whether to build associations.

Parameters
eventthe event the products are going to be put into
instance_namename of the instance for all data products
doWireAssnswhether to enable associations to wires
doRawDigitAssnswhether to enable associations to raw digits

All the data products (hit collection and associations) will have the specified product instance name.

Definition at line 248 of file HitCreator.cxx.

252  : prod_instance(instance_name)
253  , hits()
254  , WireAssns(doWireAssns ? new art::Assns<recob::Wire, recob::Hit> : nullptr)
255  , RawDigitAssns(doRawDigitAssns ? new art::Assns<raw::RawDigit, recob::Hit> : nullptr)
256  , event(&event)
257  , hitPtrMaker(*(this->event), prod_instance)
258  {} // HitAndAssociationsWriterBase::HitAndAssociationsWriterBase()
std::string prod_instance
Tame of the instance for data products.
Definition: HitCreator.h:449
art::PtrMaker< recob::Hit > hitPtrMaker
Tool to create hit pointers,.
Definition: HitCreator.h:460
std::unique_ptr< art::Assns< recob::Wire, recob::Hit > > WireAssns
Associations with wires.
Definition: HitCreator.h:454
art::Event * event
Pointer to the event we are using.
Definition: HitCreator.h:458
std::unique_ptr< art::Assns< raw::RawDigit, recob::Hit > > RawDigitAssns
Associations with raw digits.
Definition: HitCreator.h:456
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:452

Member Function Documentation

HitPtr_t recob::HitAndAssociationsWriterBase::CreatePtr ( size_t  index) const
inlineprotected

Creates an art pointer to the hit with the specified index.

Definition at line 478 of file HitCreator.h.

Referenced by recob::HitCollectionAssociator::prepare_associations(), and recob::HitRefinerAssociator::prepare_associations().

478 { return hitPtrMaker(index); }
art::PtrMaker< recob::Hit > hitPtrMaker
Tool to create hit pointers,.
Definition: HitCreator.h:460
void recob::HitAndAssociationsWriterBase::declare_products ( art::ProducesCollector collector,
std::string  instance_name = "",
bool  doWireAssns = true,
bool  doRawDigitAssns = true 
)
static

Declares the hit products we are going to fill.

Template Parameters
ModuleTypetype of producing module (EDProducer or EDFilter)
Parameters
producerthe module producing the data products
instance_namename of the instance for all data products
doWireAssnswhether to enable associations to wires
doRawDigitAssnswhether to enable associations to raw digits

This declaration must be given in the constructor of producer. It is equivalent to manually declare the relevant among these products:

produces<std::vector<recob::Hit>>(prod_instance);
produces<art::Assns<recob::Wire, recob::Hit>>(prod_instance);
produces<art::Assns<raw::RawDigit, recob::Hit>>(prod_instance);

in the producer constructor. All the data products (hit collection and associations) will have the specified product instance name.

Definition at line 261 of file HitCreator.cxx.

References art::ProducesCollector::produces().

Referenced by apa::APAHitFinder::APAHitFinder(), cluster::ClusterCrawler::ClusterCrawler(), CRHitRemoval::CRHitRemoval(), hit::DisambigCheater::DisambigCheater(), hit::DPRawHitFinder::DPRawHitFinder(), hit::FFTHitFinder::FFTHitFinder(), hit::GausHitFinder::GausHitFinder(), hit::HitCheater::HitCheater(), hit::HitFinder::HitFinder(), cluster::LineCluster::LineCluster(), hit::RawHitFinder::RawHitFinder(), hit::RFFHitFinder::RFFHitFinder(), cluster::TrajCluster::TrajCluster(), and hit::TTHitFinder::TTHitFinder().

266  {
267  collector.produces<std::vector<recob::Hit>>(instance_name);
268 
269  // declare the other products we are creating (if any)
270  if (doWireAssns) { collector.produces<art::Assns<recob::Wire, recob::Hit>>(instance_name); }
271  if (doRawDigitAssns) {
272  collector.produces<art::Assns<raw::RawDigit, recob::Hit>>(instance_name);
273  }
274  } // HitAndAssociationsWriterBase::declare_products()
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
std::vector<recob::Hit> const& recob::HitAndAssociationsWriterBase::peek ( ) const
inline

Returns a read-only reference to the current list of hits.

Definition at line 420 of file HitCreator.h.

References hits().

420 { return *hits; }
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:452
void recob::HitAndAssociationsWriterBase::put_into ( art::Event )
inline

Moves the data into the event.

The calling module must have already declared the production of these products with the proper instance name. After the move, the collections in this object are empty.

Deprecated:
Use the version with no arguments instead.

Definition at line 408 of file HitCreator.h.

References put_into().

Referenced by put_into().

408 { put_into(); }
void put_into()
Moves the data into the event.
Definition: HitCreator.cxx:277
void recob::HitAndAssociationsWriterBase::put_into ( )

Moves the data into the event.

The calling module must have already declared the production of these products with the proper instance name. After the move, the collections in this object are empty.

Definition at line 277 of file HitCreator.cxx.

References hits, prod_instance, RawDigitAssns, and WireAssns.

Referenced by recob::HitCollectionCreator::put_into(), recob::HitCollectionAssociator::put_into(), and recob::HitRefinerAssociator::put_into().

278  {
279  assert(event);
280  if (hits) event->put(std::move(hits), prod_instance);
281  if (WireAssns) event->put(std::move(WireAssns), prod_instance);
282  if (RawDigitAssns) event->put(std::move(RawDigitAssns), prod_instance);
283  } // HitAndAssociationsWriterBase::put_into()
std::string prod_instance
Tame of the instance for data products.
Definition: HitCreator.h:449
std::unique_ptr< art::Assns< recob::Wire, recob::Hit > > WireAssns
Associations with wires.
Definition: HitCreator.h:454
std::unique_ptr< art::Assns< raw::RawDigit, recob::Hit > > RawDigitAssns
Associations with raw digits.
Definition: HitCreator.h:456
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:452
Event finding and building.
size_t recob::HitAndAssociationsWriterBase::size ( ) const
inline

Returns the number of hits currently in the collection.

Definition at line 397 of file HitCreator.h.

References hits().

397 { return hits ? hits->size() : 0; }
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:452

Member Data Documentation

art::Event* recob::HitAndAssociationsWriterBase::event = nullptr
protected

Pointer to the event we are using.

Definition at line 458 of file HitCreator.h.

art::PtrMaker<recob::Hit> recob::HitAndAssociationsWriterBase::hitPtrMaker
protected

Tool to create hit pointers,.

Definition at line 460 of file HitCreator.h.

std::string recob::HitAndAssociationsWriterBase::prod_instance
protected

Tame of the instance for data products.

Definition at line 449 of file HitCreator.h.

Referenced by put_into().


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