Classes | Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
lar::example::tests::CheckDataProductSize Class Reference

Checks the size of the specified collection. More...

Inheritance diagram for lar::example::tests::CheckDataProductSize:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 CheckDataProductSize (Parameters const &config)
 Constructor; see the class documentation for the configuration. More...
 
virtual void analyze (art::Event const &event) override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Types

using Data_t = recob::SpacePoint
 
using OtherData_t = recob::SpacePoint
 

Private Attributes

art::InputTag inputLabel
 label of the input data product More...
 
bool doCheckExpectedSize
 check that the size is the specified one More...
 
bool doCheckSameSize
 check that size is the same as another product More...
 
size_t expectedSize
 expected size of the data product collection More...
 
art::InputTag sameSizeAs
 label of the data product with same size More...
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Checks the size of the specified collection.

Throws an exception if the size of the collection in the specified data product is not as expected. The expectation can be expressed directly as a number of elements in the collection, or indirectly as the requirement that the tested collection has the same size as another one (still of recob::SpacePoint).

Configuration parameters

Definition at line 54 of file CheckDataProductSize_module.cc.

Member Typedef Documentation

Definition at line 56 of file CheckDataProductSize_module.cc.

Definition at line 57 of file CheckDataProductSize_module.cc.

Definition at line 83 of file CheckDataProductSize_module.cc.

Constructor & Destructor Documentation

lar::example::tests::CheckDataProductSize::CheckDataProductSize ( Parameters const &  config)
inlineexplicit

Constructor; see the class documentation for the configuration.

Definition at line 86 of file CheckDataProductSize_module.cc.

89  {
92  consumes<std::vector<Data_t>>(inputLabel);
93  }
art::InputTag sameSizeAs
label of the data product with same size
art::InputTag inputLabel
label of the input data product
bool doCheckSameSize
check that size is the same as another product
static Config * config
Definition: config.cpp:1054
bool doCheckExpectedSize
check that the size is the specified one
size_t expectedSize
expected size of the data product collection

Member Function Documentation

void lar::example::tests::CheckDataProductSize::analyze ( art::Event const &  event)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 123 of file CheckDataProductSize_module.cc.

124 {
125 
126  //
127  // read the input
128  //
129  auto collectionHandle = event.getValidHandle<std::vector<Data_t>>(inputLabel);
130 
131  if (doCheckExpectedSize) {
132  if (collectionHandle->size() != expectedSize) {
133  throw cet::exception("CheckDataProductSize")
134  << "Data product '" << inputLabel.encode() << "' has "
135  << collectionHandle->size() << " elements, " << expectedSize
136  << " were expected!\n";
137  }
138  } // if doCheckExpectedSize
139 
140  if (doCheckSameSize) {
141  auto otherCollectionHandle
142  = event.getValidHandle<std::vector<OtherData_t>>(sameSizeAs);
143  if (collectionHandle->size() != otherCollectionHandle->size()) {
144  throw cet::exception("CheckDataProductSize")
145  << "Data product '" << inputLabel.encode() << "' has "
146  << collectionHandle->size() << " elements, " << expectedSize
147  << " were expected as in '" << sameSizeAs.encode() << "'!\n";
148  }
149  } // if doCheckSameSize
150 
151 } // lar::example::tests::CheckDataProductSize::analyze()
art::InputTag sameSizeAs
label of the data product with same size
art::InputTag inputLabel
label of the input data product
std::string encode() const
Definition: InputTag.cc:97
bool doCheckSameSize
check that size is the same as another product
bool doCheckExpectedSize
check that the size is the specified one
size_t expectedSize
expected size of the data product collection
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

bool lar::example::tests::CheckDataProductSize::doCheckExpectedSize
private

check that the size is the specified one

Definition at line 101 of file CheckDataProductSize_module.cc.

bool lar::example::tests::CheckDataProductSize::doCheckSameSize
private

check that size is the same as another product

Definition at line 102 of file CheckDataProductSize_module.cc.

size_t lar::example::tests::CheckDataProductSize::expectedSize
private

expected size of the data product collection

Definition at line 104 of file CheckDataProductSize_module.cc.

art::InputTag lar::example::tests::CheckDataProductSize::inputLabel
private

label of the input data product

Definition at line 99 of file CheckDataProductSize_module.cc.

art::InputTag lar::example::tests::CheckDataProductSize::sameSizeAs
private

label of the data product with same size

Definition at line 105 of file CheckDataProductSize_module.cc.


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