All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
recob::test::HitDataProductChecker Class Reference

Module verifying the presence of data products. More...

Inheritance diagram for recob::test::HitDataProductChecker:

Classes

struct  Config
 
struct  TargetInfo_t
 Configuration for a single data product check. More...
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 HitDataProductChecker (Parameters const &config)
 
virtual void analyze (const art::Event &event) override
 

Private Member Functions

template<typename DATA >
void checkDataProducts (art::Event const &event, TargetInfo_t const &targetInfo, std::string desc)
 Checks the specified data product. More...
 

Private Attributes

std::vector< TargetInfo_tfHitTargets
 Configuration of all checks on hit collections. More...
 

Detailed Description

Module verifying the presence of data products.

Throws an exception on failure.

Service requirements

This module requires no service.

Configuration parameters

Definition at line 54 of file HitDataProductChecker_module.cc.

Member Typedef Documentation

using recob::test::HitDataProductChecker::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 91 of file HitDataProductChecker_module.cc.

Constructor & Destructor Documentation

recob::test::HitDataProductChecker::HitDataProductChecker ( Parameters const &  config)
explicit

Definition at line 162 of file HitDataProductChecker_module.cc.

163  : EDAnalyzer(config)
164 {
165  decltype(auto) hits = config().hits();
166  fHitTargets.reserve(hits.size());
167  std::copy(hits.begin(), hits.end(), std::back_inserter(fHitTargets));
168 } // HitDataProductChecker::HitDataProductChecker()
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
std::vector< TargetInfo_t > fHitTargets
Configuration of all checks on hit collections.
T copy(T const &v)

Member Function Documentation

void recob::test::HitDataProductChecker::analyze ( const art::Event &  event)
overridevirtual

Definition at line 172 of file HitDataProductChecker_module.cc.

172  {
173 
174  for (auto const& targetInfo: fHitTargets)
175  checkDataProducts<std::vector<recob::Hit>>(event, targetInfo, "hits");
176 
177 } // HitCollectionCreatorTest::analyze()
std::vector< TargetInfo_t > fHitTargets
Configuration of all checks on hit collections.
template<typename DATA >
void recob::test::HitDataProductChecker::checkDataProducts ( art::Event const &  event,
TargetInfo_t const &  targetInfo,
std::string  desc 
)
private

Checks the specified data product.

Template Parameters
DATAtype of data product to be checked
Parameters
eventthe event to read the data product from
targetInfodetails of the data product expected information
descdescription of the content of the data product
Exceptions
art::Exception(art::errors::ProductNotFound) when unexpected

The checks include:

  • existence of the data product
  • size of the data product collection (optional)

Definition at line 183 of file HitDataProductChecker_module.cc.

184 {
185  using Product_t = DATA;
186 
187  art::InputTag tag = targetInfo.name;
188 
189  art::Handle<Product_t> data;
190  bool found = event.getByLabel<Product_t>(tag, data);
191  if (found && !targetInfo.bExists) {
192  throw art::Exception(art::errors::ProductNotFound)
193  << "Data product '" << tag << "' (" << desc
194  << ") was expected not to exist, and there it is instead! (with "
195  << data->size() << " elements)";
196  }
197  if (!found && targetInfo.bExists) {
198  throw art::Exception(art::errors::ProductNotFound)
199  << "Data product '" << tag << "' (" << desc
200  << ") was expected, but there is none.";
201  }
202 
203  if (targetInfo.bCheckEntries && (data->size() != targetInfo.expectedEntries))
204  {
205  throw art::Exception(art::errors::ProductNotFound)
206  << "Data product '" << tag << "' (" << desc
207  << ") was expected to have " << targetInfo.expectedEntries
208  << " entires, but it has " << data->size() << "!";
209  }
210 
211 } // recob::test::HitDataProductChecker::HitCollectionCreator_test()

Member Data Documentation

std::vector<TargetInfo_t> recob::test::HitDataProductChecker::fHitTargets
private

Configuration of all checks on hit collections.

Definition at line 126 of file HitDataProductChecker_module.cc.


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