12 #include "art/Framework/Core/ModuleMacros.h"
13 #include "art/Framework/Core/EDAnalyzer.h"
14 #include "art/Framework/Principal/Event.h"
16 #include "fhiclcpp/types/Atom.h"
17 #include "fhiclcpp/types/Sequence.h"
18 #include "fhiclcpp/types/Table.h"
19 #include "fhiclcpp/types/OptionalAtom.h"
20 #include "fhiclcpp/types/Name.h"
21 #include "fhiclcpp/types/Comment.h"
65 fhicl::Atom<art::InputTag>
name {
67 Comment(
"Input tag of the data product to be checked")
72 Comment(
"whether the data product must exist or must not exist"),
79 (
"Number of expected entries (not checked if not specified).")
84 fhicl::Sequence<fhicl::Table<TargetInfo>>
hits {
86 Comment(
"list of hit collections and number of expected entries")
96 virtual void analyze(
const art::Event& event)
override;
142 template <
typename DATA>
144 art::Event
const& event,
TargetInfo_t const& targetInfo,
165 decltype(
auto) hits = config().hits();
166 fHitTargets.reserve(hits.size());
167 std::copy(hits.begin(), hits.end(), std::back_inserter(fHitTargets));
175 checkDataProducts<std::vector<recob::Hit>>(event, targetInfo,
"hits");
181 template <
typename DATA>
183 (art::Event
const& event,
TargetInfo_t const& targetInfo, std::string desc)
185 using Product_t = DATA;
187 art::InputTag tag = targetInfo.
name;
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)";
197 if (!found && targetInfo.
bExists) {
198 throw art::Exception(art::errors::ProductNotFound)
199 <<
"Data product '" << tag <<
"' (" << desc
200 <<
") was expected, but there is none.";
205 throw art::Exception(art::errors::ProductNotFound)
206 <<
"Data product '" << tag <<
"' (" << desc
208 <<
" entires, but it has " << data->size() <<
"!";
bool bExists
Whether data product must exist or must not exist.
fhicl::Atom< art::InputTag > name
unsigned int expectedEntries
Number of expected entries.
bool bCheckEntries
Whether to check the number of entries.
Declaration of signal hit object.
void checkDataProducts(art::Event const &event, TargetInfo_t const &targetInfo, std::string desc)
Checks the specified data product.
bool exists(std::string path)
art::EDAnalyzer::Table< Config > Parameters
fhicl::Atom< bool > exists
virtual void analyze(const art::Event &event) override
BEGIN_PROLOG vertical distance to the surface Name
fhicl::OptionalAtom< unsigned int > expected
art::InputTag name
Data product name.
TargetInfo_t(Config::TargetInfo const &config)
fhicl::Sequence< fhicl::Table< TargetInfo > > hits
std::vector< TargetInfo_t > fHitTargets
Configuration of all checks on hit collections.
Module verifying the presence of data products.
Configuration for a single data product check.
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test
HitDataProductChecker(Parameters const &config)