14 #include "art/Framework/Core/EDAnalyzer.h"
15 #include "art/Framework/Core/ModuleMacros.h"
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Principal/Handle.h"
18 #include "canvas/Utilities/InputTag.h"
19 #include "fhiclcpp/types/Atom.h"
20 #include "fhiclcpp/types/OptionalAtom.h"
21 #include "cetlib_except/exception.h"
68 Comment(
"label of the data product to be checked")
73 Comment(
"number of expected entries in the data product")
78 Comment(
"label of a data product with the same size as the input")
87 : art::EDAnalyzer(config)
95 virtual void analyze(art::Event
const& event)
override;
129 auto collectionHandle =
event.getValidHandle<std::vector<Data_t>>(
inputLabel);
133 throw cet::exception(
"CheckDataProductSize")
134 <<
"Data product '" <<
inputLabel.encode() <<
"' has "
135 << collectionHandle->size() <<
" elements, " <<
expectedSize
136 <<
" were expected!\n";
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";
art::EDAnalyzer::Table< Config > Parameters
art::InputTag sameSizeAs
label of the data product with same size
art::InputTag inputLabel
label of the input data product
virtual void analyze(art::Event const &event) override
fhicl::OptionalAtom< size_t > expectedSize
bool doCheckSameSize
check that size is the same as another product
CheckDataProductSize(Parameters const &config)
Constructor; see the class documentation for the configuration.
BEGIN_PROLOG vertical distance to the surface Name
Checks the size of the specified collection.
bool doCheckExpectedSize
check that the size is the specified one
fhicl::Atom< art::InputTag > inputLabel
fhicl::OptionalAtom< art::InputTag > sameSizeAs
size_t expectedSize
expected size of the data product collection