Public Member Functions | Protected Types | Protected Member Functions | List of all members
recob::HitCollectionCreator Class Reference

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

#include <HitCreator.h>

Inheritance diagram for recob::HitCollectionCreator:
recob::HitAndAssociationsWriterBase

Public Member Functions

size_t size () const
 Returns the number of hits currently in the collection. More...
 
void reserve (size_t new_size)
 Prepares the collection to host at least new_size hits. More...
 
void put_into (art::Event &)
 Moves the data into an 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...
 
Constructors
 HitCollectionCreator (art::Event &event, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
 Constructor: sets instance name and whether to build associations. More...
 
 HitCollectionCreator (art::Event &event, bool doWireAssns, bool doRawDigitAssns)
 Constructor: no product instance name. More...
 
Addition of hits
void emplace_back (recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
 Adds the specified hit to the data collection. More...
 
void emplace_back (recob::Hit const &hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
 Adds the specified hit to the data collection. More...
 
void emplace_back (HitCreator &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
 Adds the specified hit to the data collection. More...
 
void emplace_back (recob::Hit &&hit, art::Ptr< raw::RawDigit > const &digits)
 Adds the specified hit to the data collection. More...
 
void emplace_back (HitCreator &&hit, art::Ptr< raw::RawDigit > const &digits)
 Adds the specified hit to the data collection. More...
 
void emplace_back (HitCreator const &hit, art::Ptr< raw::RawDigit > const &digits)
 Adds the specified hit to the data collection. More...
 
- Public Member Functions inherited from recob::HitAndAssociationsWriterBase
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...
 

Protected Types

using HitPtr_t = HitAndAssociationsWriterBase::HitPtr_t
 
- Protected Types inherited from recob::HitAndAssociationsWriterBase
using HitPtr_t = art::Ptr< recob::Hit >
 Type of art pointer to Hit. More...
 

Protected Member Functions

HitPtr_t CreatePtrToLastHit () const
 Creates an art pointer to the hit with the last index. More...
 
void CreateAssociationsToLastHit (art::Ptr< recob::Wire > const &wire, art::Ptr< raw::RawDigit > const &digits)
 Creates associations between the last hit and the specified pointers. More...
 
- Protected Member Functions inherited from recob::HitAndAssociationsWriterBase
 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...
 

Additional Inherited Members

- Static Public Member Functions inherited from recob::HitAndAssociationsWriterBase
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 Attributes inherited from recob::HitAndAssociationsWriterBase
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

A 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 push hits into this object, and then move it into the event.

Definition at line 508 of file HitCreator.h.

Member Typedef Documentation

Definition at line 669 of file HitCreator.h.

Constructor & Destructor Documentation

recob::HitCollectionCreator::HitCollectionCreator ( art::Event event,
std::string  instance_name = "",
bool  doWireAssns = true,
bool  doRawDigitAssns = true 
)

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 278 of file HitCreator.cxx.

284  (event, instance_name, doWireAssns, doRawDigitAssns)
285  {
286  hits.reset(new std::vector<recob::Hit>);
287  } // HitCollectionCreator::HitCollectionCreator()
HitAndAssociationsWriterBase(art::Event &event, std::string instance_name, bool doWireAssns, bool doRawDigitAssns)
Constructor: sets instance name and whether to build associations.
Definition: HitCreator.cxx:233
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:465
recob::HitCollectionCreator::HitCollectionCreator ( art::Event event,
bool  doWireAssns,
bool  doRawDigitAssns 
)
inline

Constructor: no product instance name.

Parameters
eventthe event the products are going to be put into
doWireAssnswhether to enable associations to wires
doRawDigitAssnswhether to enable associations to raw digits

Definition at line 536 of file HitCreator.h.

539  :
540  HitCollectionCreator(event, "", doWireAssns, doRawDigitAssns)
541  {}
HitCollectionCreator(art::Event &event, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Constructor: sets instance name and whether to build associations.
Definition: HitCreator.cxx:278

Member Function Documentation

void recob::HitCollectionCreator::CreateAssociationsToLastHit ( art::Ptr< recob::Wire > const &  wire,
art::Ptr< raw::RawDigit > const &  digits 
)
protected

Creates associations between the last hit and the specified pointers.

Definition at line 327 of file HitCreator.cxx.

329  {
330  // if no association is required, we are done
331  if (!WireAssns && !RawDigitAssns) return;
332 
333  // art pointer to the hit we just created
334  HitPtr_t hit_ptr(CreatePtrToLastHit());
335 
336  // association with wires
337  if (WireAssns && wire.isNonnull())
338  WireAssns->addSingle(wire, hit_ptr); // if it fails, it throws
339 
340  // association with wires
341  if (RawDigitAssns && digits.isNonnull())
342  RawDigitAssns->addSingle(digits, hit_ptr); // if it fails, it throws
343 
344  } // HitCollectionCreator::CreateAssociationsToLastHit()
HitPtr_t CreatePtrToLastHit() const
Creates an art pointer to the hit with the last index.
Definition: HitCreator.h:672
HitAndAssociationsWriterBase::HitPtr_t HitPtr_t
Definition: HitCreator.h:669
std::unique_ptr< art::Assns< recob::Wire, recob::Hit > > WireAssns
Associations with wires.
Definition: HitCreator.h:467
bool isNonnull() const noexcept
Definition: Ptr.h:166
std::unique_ptr< art::Assns< raw::RawDigit, recob::Hit > > RawDigitAssns
Associations with raw digits.
Definition: HitCreator.h:469
HitPtr_t recob::HitCollectionCreator::CreatePtrToLastHit ( ) const
inlineprotected

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

Definition at line 672 of file HitCreator.h.

673  { return hits->empty()? HitPtr_t(): CreatePtr(hits->size() - 1); }
HitAndAssociationsWriterBase::HitPtr_t HitPtr_t
Definition: HitCreator.h:669
HitPtr_t CreatePtr(size_t index) const
Creates an art pointer to the hit with the specified index.
Definition: HitCreator.h:494
size_t size() const
Returns the number of hits currently in the collection.
Definition: HitCreator.h:636
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:465
void recob::HitCollectionCreator::emplace_back ( recob::Hit &&  hit,
art::Ptr< recob::Wire > const &  wire = art::Ptr<recob::Wire>(),
art::Ptr< raw::RawDigit > const &  digits = art::Ptr<raw::RawDigit>() 
)

Adds the specified hit to the data collection.

Parameters
hitthe hit that will be moved into the collection
wireart pointer to the wire to be associated to this hit
digitsart pointer to the raw digits to be associated to this hit

After this call, hit will be invalid. If a art pointer is not valid, that association will not be stored.

Definition at line 290 of file HitCreator.cxx.

293  {
294 
295  // add the hit to the collection
296  hits->emplace_back(std::move(hit));
297 
298  CreateAssociationsToLastHit(wire, digits);
299  } // HitCollectionCreator::emplace_back(Hit&&)
def move(depos, offset)
Definition: depos.py:107
void CreateAssociationsToLastHit(art::Ptr< recob::Wire > const &wire, art::Ptr< raw::RawDigit > const &digits)
Creates associations between the last hit and the specified pointers.
Definition: HitCreator.cxx:327
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:465
void recob::HitCollectionCreator::emplace_back ( recob::Hit const &  hit,
art::Ptr< recob::Wire > const &  wire = art::Ptr<recob::Wire>(),
art::Ptr< raw::RawDigit > const &  digits = art::Ptr<raw::RawDigit>() 
)

Adds the specified hit to the data collection.

Parameters
hitthe hit that will be copied into the collection
wireart pointer to the wire to be associated to this hit
digitsart pointer to the raw digits to be associated to this hit

If a art pointer is not valid, that association will not be stored.

Definition at line 303 of file HitCreator.cxx.

306  {
307 
308  // add the hit to the collection
309  hits->push_back(hit);
310 
311  CreateAssociationsToLastHit(wire, digits);
312  } // HitCollectionCreator::emplace_back(Hit)
void CreateAssociationsToLastHit(art::Ptr< recob::Wire > const &wire, art::Ptr< raw::RawDigit > const &digits)
Creates associations between the last hit and the specified pointers.
Definition: HitCreator.cxx:327
Detector simulation of raw signals on wires.
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:465
void recob::HitCollectionCreator::emplace_back ( HitCreator &&  hit,
art::Ptr< recob::Wire > const &  wire = art::Ptr<recob::Wire>(),
art::Ptr< raw::RawDigit > const &  digits = art::Ptr<raw::RawDigit>() 
)
inline

Adds the specified hit to the data collection.

Parameters
hitthe HitCreator object containing the hit
wireart pointer to the wire to be associated to this hit
digitsart pointer to the raw digits to be associated to this hit

After this call, the hit creator will be empty. If a art pointer is not valid, that association will not be stored.

Definition at line 590 of file HitCreator.h.

595  { emplace_back(hit.move(), wire, digits); }
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Definition: HitCreator.cxx:290
Detector simulation of raw signals on wires.
void recob::HitCollectionCreator::emplace_back ( recob::Hit &&  hit,
art::Ptr< raw::RawDigit > const &  digits 
)
inline

Adds the specified hit to the data collection.

Parameters
hitthe hit that will be moved into the collection
digitsart pointer to the raw digits to be associated to this hit

After this call, hit will be invalid. If the digit pointer is not valid, its association will not be stored.

Definition at line 606 of file HitCreator.h.

607  { emplace_back(std::move(hit), art::Ptr<recob::Wire>(), digits); }
def move(depos, offset)
Definition: depos.py:107
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Definition: HitCreator.cxx:290
void recob::HitCollectionCreator::emplace_back ( HitCreator &&  hit,
art::Ptr< raw::RawDigit > const &  digits 
)
inline

Adds the specified hit to the data collection.

Parameters
hitthe HitCreator object containing the hit
digitsart pointer to the raw digits to be associated to this hit

After this call, the hit creator will be empty. If the digit pointer is not valid, its association will not be stored.

Definition at line 618 of file HitCreator.h.

def move(depos, offset)
Definition: depos.py:107
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Definition: HitCreator.cxx:290
Detector simulation of raw signals on wires.
void recob::HitCollectionCreator::emplace_back ( HitCreator const &  hit,
art::Ptr< raw::RawDigit > const &  digits 
)
inline

Adds the specified hit to the data collection.

Parameters
hitthe HitCreator object containing the hit
digitsart pointer to the raw digits to be associated to this hit

If the digit pointer is not valid, its association will not be stored.

Definition at line 630 of file HitCreator.h.

631  { emplace_back(std::move(hit.copy()), art::Ptr<recob::Wire>(), digits); }
def move(depos, offset)
Definition: depos.py:107
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Definition: HitCreator.cxx:290
Detector simulation of raw signals on wires.
std::vector<recob::Hit> const& recob::HitCollectionCreator::peek ( ) const
inline

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

Definition at line 665 of file HitCreator.h.

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

Moves the data into an 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 652 of file HitCreator.h.

652 { put_into(); }
void put_into()
Moves the data into the event.
Definition: HitCreator.cxx:316
void recob::HitCollectionCreator::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 316 of file HitCreator.cxx.

316  {
317  if (!hits) {
319  << "HitCollectionCreator is trying to put into the event"
320  " a hit collection that was never created!\n";
321  }
323  } // HitCollectionCreator::put_into()
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void put_into()
Moves the data into the event.
Definition: HitCreator.cxx:267
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:465
void recob::HitCollectionCreator::reserve ( size_t  new_size)
inline

Prepares the collection to host at least new_size hits.

Definition at line 640 of file HitCreator.h.

640 { if (hits) hits->reserve(new_size); }
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:465
size_t recob::HitCollectionCreator::size ( void  ) const
inline

Returns the number of hits currently in the collection.

Definition at line 636 of file HitCreator.h.

636 { return hits->size(); }
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:465

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