LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
recob::HitAndAssociationsWriterManager< Writer, ModuleType > Class Template Reference

A helper to centralise creation of a hit collection data product. More...

#include "HitCreator.h"

Public Types

using Writer_t = Writer
 Type of managed hit collection writer. More...
 
using Module_t = ModuleType
 Type of producing module. More...
 

Public Member Functions

 HitAndAssociationsWriterManager ()=default
 Constructor: does not declare anything. More...
 
 HitAndAssociationsWriterManager (Module_t &callingProducer, std::string instanceName="", bool doWireAssns=true, bool doRawDigitAssns=true)
 Declares the hit products we are going to fill. More...
 
void declareProducts (Module_t &callingProducer, std::string instanceName="", bool doWireAssns=true, bool doRawDigitAssns=true)
 Declares the hit products we are going to fill. More...
 
Writer_t collectionWriter (art::Event &event) const
 Returns a new writer already configured. More...
 
std::string instanceName () const
 Returns the configured product instance name. More...
 
bool ready () const
 Returns whether the class is fully configured. More...
 

Protected Attributes

Module_tproducer = nullptr
 Producer this manager is bound to. More...
 
std::string prodInstance
 Tame of the instance for data products. More...
 
bool hasRawDigitAssns = true
 Whether we produce hit-digit associations. More...
 
bool hasWireAssns = true
 Whether we produce hit-wire associations. More...
 

Detailed Description

template<typename Writer, typename ModuleType = art::EDProducer>
class recob::HitAndAssociationsWriterManager< Writer, ModuleType >

A helper to centralise creation of a hit collection data product.

Template Parameters
Writerwriter class to manage
ModuleTypeowning module: art::EDProducer or art::EDFilter

This class adds an indirection layer to the model relying on HitAndAssociationsWriter. In that one, two different steps are required, one in the constructor of the module, where data products are declared, and one in the place where hits are actually assembled. These two steps need consistent setup, but they are separate and formally independent. The "manager" approach consists of an object performing the first step directly, and delivering an already configured object for the second step.

An example of usage in a module:

class MyHitProducer: public art::EDProducer {
hitCollCreator;
public:
MyHitProducer(fhicl::ParameterSet const& pset)
: hitCollCreator(*this, pset.get<std::string>("instanceName", ""))
{}
void produce(art::Event& event)
{
auto hitCollWriter = hitCollCreator.collectionWriter(event);
for (recob::Wire const& wire: Wires) {
// create hits...
hitCollWriter.emplace_back(hit, wire, digit);
}
hitCollWriter.put_into();
}
}; // class MyHitProducer

Definition at line 1007 of file HitCreator.h.

Member Typedef Documentation

template<typename Writer, typename ModuleType = art::EDProducer>
using recob::HitAndAssociationsWriterManager< Writer, ModuleType >::Module_t = ModuleType

Type of producing module.

Definition at line 1011 of file HitCreator.h.

template<typename Writer, typename ModuleType = art::EDProducer>
using recob::HitAndAssociationsWriterManager< Writer, ModuleType >::Writer_t = Writer

Type of managed hit collection writer.

Definition at line 1010 of file HitCreator.h.

Constructor & Destructor Documentation

template<typename Writer, typename ModuleType = art::EDProducer>
recob::HitAndAssociationsWriterManager< Writer, ModuleType >::HitAndAssociationsWriterManager ( )
default

Constructor: does not declare anything.

This constructor does not declare products. Calling declare_products() explicitly is then required in the module constructor.

Referenced by recob::HitCollectionAssociator::HitCollectionAssociator().

template<typename Writer , typename ModuleType >
recob::HitAndAssociationsWriterManager< Writer, ModuleType >::HitAndAssociationsWriterManager ( Module_t callingProducer,
std::string  instanceName = "",
bool  doWireAssns = true,
bool  doRawDigitAssns = true 
)

Declares the hit products we are going to fill.

Parameters
callingProducerthe module this manager is bound to
instanceNamename of the instance for all data products
doWireAssnswhether to enable associations to wires
doRawDigitAssnswhether to enable associations to raw digits

This constructor calls declareProducts().

Definition at line 1222 of file HitCreator.h.

References recob::HitAndAssociationsWriterManager< Writer, ModuleType >::declareProducts().

1226 {
1228  (callingProducer, instanceName, doWireAssns, doRawDigitAssns);
1229 } // recob::HitAndAssociationsWriterManager::HitAndAssociationsWriterManager()
void declareProducts(Module_t &callingProducer, std::string instanceName="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.h:1235
std::string instanceName() const
Returns the configured product instance name.
Definition: HitCreator.h:1064

Member Function Documentation

template<typename Writer , typename ModuleType >
recob::HitAndAssociationsWriterManager< Writer, ModuleType >::Writer_t recob::HitAndAssociationsWriterManager< Writer, ModuleType >::collectionWriter ( art::Event event) const

Returns a new writer already configured.

Definition at line 1259 of file HitCreator.h.

References recob::HitAndAssociationsWriterBase::event, and art::errors::LogicError.

Referenced by recob::HitAndAssociationsWriterManager< Writer, ModuleType >::declareProducts().

1260 {
1261  if (!producer) {
1262  // this means you forgot to code a call to declaredProducts()
1263  // or used the wrong constructor:
1265  << "HitAndAssociationsWriter<>::collectionWriter() called"
1266  " before products are declared.";
1267  }
1268  return
1270 } // recob::HitAndAssociationsWriterManager::collectionWriter()
Module_t * producer
Producer this manager is bound to.
Definition: HitCreator.h:1070
bool hasRawDigitAssns
Whether we produce hit-digit associations.
Definition: HitCreator.h:1075
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
bool hasWireAssns
Whether we produce hit-wire associations.
Definition: HitCreator.h:1078
std::string prodInstance
Tame of the instance for data products.
Definition: HitCreator.h:1072
template<typename Writer , typename ModuleType >
void recob::HitAndAssociationsWriterManager< Writer, ModuleType >::declareProducts ( Module_t callingProducer,
std::string  instanceName = "",
bool  doWireAssns = true,
bool  doRawDigitAssns = true 
)

Declares the hit products we are going to fill.

Parameters
callingProducerthe module this manager is bound to
instanceNamename of the instance for all data products
doWireAssnswhether to enable associations to wires
doRawDigitAssnswhether to enable associations to raw digits

This declaration must be made 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 1235 of file HitCreator.h.

References recob::HitAndAssociationsWriterManager< Writer, ModuleType >::collectionWriter(), recob::HitAndAssociationsWriterBase::declare_products(), and art::errors::LogicError.

Referenced by recob::HitAndAssociationsWriterManager< Writer, ModuleType >::HitAndAssociationsWriterManager().

1239 {
1240  if (producer) {
1241  // this means you already called to declaredProducts()
1242  // or used the wrong constructor (which did that for you):
1244  << "HitAndAssociationsWriter<> has already declared its products.";
1245  }
1246  producer = &callingProducer;
1248  hasWireAssns = doWireAssns;
1249  hasRawDigitAssns = doRawDigitAssns;
1251  (callingProducer, prodInstance, hasWireAssns, hasRawDigitAssns);
1252 } // recob::HitAndAssociationsWriterManager::declareProducts()
static void declare_products(ModuleType &producer, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.h:1117
Module_t * producer
Producer this manager is bound to.
Definition: HitCreator.h:1070
bool hasRawDigitAssns
Whether we produce hit-digit associations.
Definition: HitCreator.h:1075
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string instanceName() const
Returns the configured product instance name.
Definition: HitCreator.h:1064
bool hasWireAssns
Whether we produce hit-wire associations.
Definition: HitCreator.h:1078
std::string prodInstance
Tame of the instance for data products.
Definition: HitCreator.h:1072
template<typename Writer, typename ModuleType = art::EDProducer>
std::string recob::HitAndAssociationsWriterManager< Writer, ModuleType >::instanceName ( ) const
inline

Returns the configured product instance name.

Definition at line 1064 of file HitCreator.h.

1064 { return prodInstance; }
std::string prodInstance
Tame of the instance for data products.
Definition: HitCreator.h:1072
template<typename Writer, typename ModuleType = art::EDProducer>
bool recob::HitAndAssociationsWriterManager< Writer, ModuleType >::ready ( ) const
inline

Returns whether the class is fully configured.

Definition at line 1067 of file HitCreator.h.

1067 { return producer; }
Module_t * producer
Producer this manager is bound to.
Definition: HitCreator.h:1070

Member Data Documentation

template<typename Writer, typename ModuleType = art::EDProducer>
bool recob::HitAndAssociationsWriterManager< Writer, ModuleType >::hasRawDigitAssns = true
protected

Whether we produce hit-digit associations.

Definition at line 1075 of file HitCreator.h.

template<typename Writer, typename ModuleType = art::EDProducer>
bool recob::HitAndAssociationsWriterManager< Writer, ModuleType >::hasWireAssns = true
protected

Whether we produce hit-wire associations.

Definition at line 1078 of file HitCreator.h.

template<typename Writer, typename ModuleType = art::EDProducer>
std::string recob::HitAndAssociationsWriterManager< Writer, ModuleType >::prodInstance
protected

Tame of the instance for data products.

Definition at line 1072 of file HitCreator.h.

template<typename Writer, typename ModuleType = art::EDProducer>
Module_t* recob::HitAndAssociationsWriterManager< Writer, ModuleType >::producer = nullptr
protected

Producer this manager is bound to.

Definition at line 1070 of file HitCreator.h.


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