LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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...
 

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 = HitAndAssociationsWriterBase::HitPtr_t
 

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...
 
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

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 481 of file HitCreator.h.

Member Typedef Documentation

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

References recob::HitAndAssociationsWriterBase::hits.

280  : HitAndAssociationsWriterBase(event, instance_name, doWireAssns, doRawDigitAssns)
281  {
282  hits.reset(new std::vector<recob::Hit>);
283  } // 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:235
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:444
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 506 of file HitCreator.h.

507  : HitCollectionCreator(event, "", doWireAssns, doRawDigitAssns)
508  {}
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:275

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

References CreatePtrToLastHit(), art::Ptr< T >::isNonnull(), recob::HitAndAssociationsWriterBase::RawDigitAssns, and recob::HitAndAssociationsWriterBase::WireAssns.

Referenced by emplace_back().

323  {
324  // if no association is required, we are done
325  if (!WireAssns && !RawDigitAssns) return;
326 
327  // art pointer to the hit we just created
328  HitPtr_t hit_ptr(CreatePtrToLastHit());
329 
330  // association with wires
331  if (WireAssns && wire.isNonnull())
332  WireAssns->addSingle(wire, hit_ptr); // if it fails, it throws
333 
334  // association with wires
335  if (RawDigitAssns && digits.isNonnull())
336  RawDigitAssns->addSingle(digits, hit_ptr); // if it fails, it throws
337 
338  } // HitCollectionCreator::CreateAssociationsToLastHit()
HitPtr_t CreatePtrToLastHit() const
Creates an art pointer to the hit with the last index.
Definition: HitCreator.h:632
HitAndAssociationsWriterBase::HitPtr_t HitPtr_t
Definition: HitCreator.h:629
std::unique_ptr< art::Assns< recob::Wire, recob::Hit > > WireAssns
Associations with wires.
Definition: HitCreator.h:446
bool isNonnull() const noexcept
Definition: Ptr.h:204
std::unique_ptr< art::Assns< raw::RawDigit, recob::Hit > > RawDigitAssns
Associations with raw digits.
Definition: HitCreator.h:448
HitPtr_t recob::HitAndAssociationsWriterBase::CreatePtr ( size_t  index) const
inlineprotectedinherited

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

Definition at line 470 of file HitCreator.h.

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

470 { return hitPtrMaker(index); }
art::PtrMaker< recob::Hit > hitPtrMaker
Tool to create hit pointers,.
Definition: HitCreator.h:452
HitPtr_t recob::HitCollectionCreator::CreatePtrToLastHit ( ) const
inlineprotected

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

Definition at line 632 of file HitCreator.h.

References hits().

Referenced by CreateAssociationsToLastHit().

633  {
634  return hits->empty() ? HitPtr_t() : CreatePtr(hits->size() - 1);
635  }
HitAndAssociationsWriterBase::HitPtr_t HitPtr_t
Definition: HitCreator.h:629
HitPtr_t CreatePtr(size_t index) const
Creates an art pointer to the hit with the specified index.
Definition: HitCreator.h:470
size_t size() const
Returns the number of hits currently in the collection.
Definition: HitCreator.h:597
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:444
void recob::HitAndAssociationsWriterBase::declare_products ( art::ProducesCollector collector,
std::string  instance_name = "",
bool  doWireAssns = true,
bool  doRawDigitAssns = true 
)
staticinherited

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 248 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().

253  {
254  collector.produces<std::vector<recob::Hit>>(instance_name);
255 
256  // declare the other products we are creating (if any)
257  if (doWireAssns) { collector.produces<art::Assns<recob::Wire, recob::Hit>>(instance_name); }
258  if (doRawDigitAssns) {
259  collector.produces<art::Assns<raw::RawDigit, recob::Hit>>(instance_name);
260  }
261  } // HitAndAssociationsWriterBase::declare_products()
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
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 286 of file HitCreator.cxx.

References CreateAssociationsToLastHit(), and recob::HitAndAssociationsWriterBase::hits.

Referenced by CRHitRemoval::copyAllHits(), CRHitRemoval::copyInTimeHits(), hit::DisambigCheater::MakeDisambigHit(), hit::TTHitFinder::produce(), hit::RawHitFinder::produce(), apa::APAHitFinder::produce(), hit::FFTHitFinder::produce(), hit::HitCheater::produce(), hit::GausHitFinder::produce(), and hit::DPRawHitFinder::produce().

289  {
290 
291  // add the hit to the collection
292  hits->emplace_back(std::move(hit));
293 
294  CreateAssociationsToLastHit(wire, digits);
295  } // 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:321
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:444
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 298 of file HitCreator.cxx.

References CreateAssociationsToLastHit(), and recob::HitAndAssociationsWriterBase::hits.

301  {
302 
303  // add the hit to the collection
304  hits->push_back(hit);
305 
306  CreateAssociationsToLastHit(wire, digits);
307  } // 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:321
Detector simulation of raw signals on wires.
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:444
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 550 of file HitCreator.h.

553  {
554  emplace_back(hit.move(), wire, digits);
555  }
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:286
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 565 of file HitCreator.h.

566  {
567  emplace_back(std::move(hit), art::Ptr<recob::Wire>(), digits);
568  }
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:286
Definition: fwd.h:26
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 578 of file HitCreator.h.

579  {
580  emplace_back(std::move(hit), art::Ptr<recob::Wire>(), digits);
581  }
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:286
Detector simulation of raw signals on wires.
Definition: fwd.h:26
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 590 of file HitCreator.h.

References recob::HitCreator::copy().

591  {
592  emplace_back(std::move(hit.copy()), art::Ptr<recob::Wire>(), digits);
593  }
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:286
Detector simulation of raw signals on wires.
Definition: fwd.h:26
std::vector<recob::Hit> const& recob::HitCollectionCreator::peek ( ) const
inline

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

Definition at line 626 of file HitCreator.h.

References hits().

626 { return *hits; }
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:444
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 614 of file HitCreator.h.

References put_into().

Referenced by hit::DisambigCheater::produce(), hit::TTHitFinder::produce(), hit::RawHitFinder::produce(), apa::APAHitFinder::produce(), hit::FFTHitFinder::produce(), hit::HitCheater::produce(), hit::GausHitFinder::produce(), hit::DPRawHitFinder::produce(), and put_into().

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

References recob::HitAndAssociationsWriterBase::hits, art::errors::LogicError, and recob::HitAndAssociationsWriterBase::put_into().

311  {
312  if (!hits) {
314  << "HitCollectionCreator is trying to put into the event"
315  " a hit collection that was never created!\n";
316  }
318  } // 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:264
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Definition: HitCreator.h:444
void recob::HitCollectionCreator::reserve ( size_t  new_size)
inline

Prepares the collection to host at least new_size hits.

Definition at line 600 of file HitCreator.h.

References hits().

Referenced by hit::RawHitFinder::produce().

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

Returns the number of hits currently in the collection.

Definition at line 597 of file HitCreator.h.

References hits().

Referenced by hit::TTHitFinder::produce(), and hit::HitCheater::produce().

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

Member Data Documentation

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

Pointer to the event we are using.

Definition at line 450 of file HitCreator.h.

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

Tool to create hit pointers,.

Definition at line 452 of file HitCreator.h.

std::string recob::HitAndAssociationsWriterBase::prod_instance
protectedinherited

Tame of the instance for data products.

Definition at line 441 of file HitCreator.h.

Referenced by recob::HitAndAssociationsWriterBase::put_into().


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