74 Comment(
"label of the shower collection to be explored")
79 Comment(
"how many associated hits to print per line"),
85 Comment(
"total number of expected hits"),
90 Comment(
"total number of expected clusters"),
95 Comment(
"total number of expected particle flow objects"),
100 Comment(
"total number of expected showers"),
119 template <
typename ShowerHandle>
123 template <
typename ShowerHandle>
127 template <
typename ShowerHandle>
181 template <
typename ShowerHandle>
191 assert(showerHits.
size() == showers->size());
196 unsigned int nDuplicates = 0;
197 std::set<art::Ptr<recob::Hit>> foundHits;
198 std::set<art::ProductID> foundHitProducts;
202 for (std::size_t iShower = 0; iShower < showers->size(); ++iShower) {
203 auto const& hits = showerHits.
at(iShower);
204 log <<
"\n #" << iShower <<
": " << hits.size() <<
" hits";
205 if (hits.empty())
continue;
207 unsigned int hitsLeft = pageSize;
209 if (foundHits.count(
hit) == 0) {
210 foundHits.insert(
hit);
211 foundHitProducts.insert(
hit.id());
215 <<
"ERROR: Hit " <<
hit <<
" appears in more than one shower!";
218 if (hitsLeft-- == 0) {
228 << foundHits.size() <<
" hits collected for " 229 << showers->size() <<
" showers ('" 230 << showers.provenance()->inputTag().encode() <<
"') from " 231 << foundHitProducts.size() <<
" data products:";
234 if (event.
get(PID, hits)) {
236 << hits.
provenance()->inputTag().encode() <<
"' (contains " 237 << hits->size() <<
" hits)";
240 mf::LogVerbatim(
"AssnsChainTest") <<
" - <" << PID <<
"> (not found!)";
244 if (nDuplicates > 0) {
246 <<
"Test failed: " << nDuplicates
247 <<
" hits appear in more than one shower.\n";
249 if (foundHits.size() !=
nHits) {
251 <<
"Test failed: counted " << foundHits.size()
252 <<
" hits, expected " <<
nHits <<
".\n";
259 template <
typename ShowerHandle>
270 assert(showerObjects.
size() == showers->size());
272 using ObjectPtr_t = decltype(showerObjects)::TargetPtr_t;
277 unsigned int nDuplicates = 0;
278 std::set<art::Ptr<recob::Cluster>> foundObjects;
279 std::set<art::ProductID> foundObjectProducts;
283 for (std::size_t iShower = 0; iShower < showers->size(); ++iShower) {
284 auto const& objects = showerObjects.
at(iShower);
285 log <<
"\n #" << iShower <<
": " << objects.size() <<
" " << objectsDesc;
286 if (objects.empty())
continue;
288 unsigned int objectsLeft = pageSize;
289 for (ObjectPtr_t
const&
object: objects) {
290 if (foundObjects.count(
object) == 0) {
291 foundObjects.insert(
object);
292 foundObjectProducts.insert(
object.
id());
296 <<
"ERROR: Cluster " <<
object <<
" appears in more than one shower!";
299 if (objectsLeft-- == 0) {
300 objectsLeft = pageSize;
303 log <<
" " << object;
309 << foundObjects.size() <<
" " << objectsDesc <<
" collected for " 310 << showers->size() <<
" showers ('" 311 << showers.provenance()->inputTag().encode() <<
"') from " 312 << foundObjectProducts.size() <<
" data products:";
315 if (event.
get(PID, objects)) {
317 << objects.
provenance()->inputTag().encode() <<
"' (contains " 318 << objects->size() <<
" " << objectsDesc <<
")";
321 mf::LogVerbatim(
"AssnsChainTest") <<
" - <" << PID <<
"> (not found!)";
325 if (nDuplicates > 0) {
327 <<
"Test failed: " << nDuplicates
328 <<
" clusters appear in more than one shower.\n";
332 <<
"Test failed: counted " << foundObjects.size()
333 <<
" clusters, expected " <<
nClusters <<
".\n";
340 template <
typename ShowerHandle>
344 std::string const objectsDesc =
"particle flow objects";
351 assert(showerObjects.
size() == showers->size());
353 using ObjectPtr_t = decltype(showerObjects)::TargetPtr_t;
358 unsigned int nDuplicates = 0;
359 std::set<art::Ptr<recob::PFParticle>> foundObjects;
360 std::set<art::ProductID> foundObjectProducts;
364 for (std::size_t iShower = 0; iShower < showers->size(); ++iShower) {
365 auto const& objects = showerObjects.
at(iShower);
366 log <<
"\n #" << iShower <<
": " << objects.size() <<
" " << objectsDesc;
368 unsigned int objectsLeft = pageSize;
369 for (ObjectPtr_t
const&
object: objects) {
370 if (foundObjects.count(
object) == 0) {
371 foundObjects.insert(
object);
372 foundObjectProducts.insert(
object.
id());
376 <<
"ERROR: Particle " <<
object 377 <<
" appears in more than one shower!";
380 if (objectsLeft-- == 0) {
381 objectsLeft = pageSize;
384 log <<
" " << object;
387 if (objects.size() != 1) {
389 <<
"all showers are expected to have one PFParticle associated, while #" 390 << iShower <<
" has " << objects.size() <<
"\n";
396 << foundObjects.size() <<
" " << objectsDesc <<
" collected for " 397 << showers->size() <<
" showers ('" 398 << showers.provenance()->inputTag().encode() <<
"') from " 399 << foundObjectProducts.size() <<
" data products:";
402 if (event.
get(PID, objects)) {
404 << objects.
provenance()->inputTag().encode() <<
"' (contains " 405 << objects->size() <<
" " << objectsDesc <<
")";
408 mf::LogVerbatim(
"AssnsChainTest") <<
" - <" << PID <<
"> (not found!)";
412 if (nDuplicates > 0) {
414 <<
"Test failed: " << nDuplicates
415 <<
" particle flow objects appear in more than one shower.\n";
417 if (foundObjects.size() !=
nPFOs) {
419 <<
"Test failed: counted " << foundObjects.size()
420 <<
" particle flow objects, expected " <<
nPFOs <<
".\n";
Utility to navigate chains of associations.
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void printAssociatedHits(art::Event const &event, ShowerHandle const &showers) const
unsigned int nShowers
Total number of expected showers.
ChannelGroupService::Name Name
TargetPtrCollection_t const & at(std::size_t i) const
Returns all the Target objects associated to specified object.
fhicl::Atom< art::InputTag > showers
bool get(SelectorBase const &, Handle< PROD > &result) const
fhicl::Atom< unsigned int > nShowers
Prints all the hits associated to the specified shower.
EDAnalyzer(fhicl::ParameterSet const &pset)
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
unsigned int nPFOs
Total number of expected particles.
#define DEFINE_ART_MODULE(klass)
fhicl::Atom< unsigned int > nParticles
Provenance const * provenance() const
std::size_t size() const noexcept
Returns the number of Source objects we have information about.
Query object collecting a list of associated objects.
unsigned int nHits
Total number of expected hits.
Detector simulation of raw signals on wires.
fhicl::Atom< unsigned int > nClusters
Declaration of signal hit object.
unsigned int nClusters
Total number of expected clusters.
LArSoft-specific namespace.
fhicl::Atom< unsigned int > nHits
art::InputTag showerTag
Label of the input collection of showers.
virtual void analyze(art::Event const &event) override
AssnsChainTest(Parameters const &config)
unsigned int nObjectsPerLine
Number of objects to print on one line.
void printAssociatedPFOs(art::Event const &event, ShowerHandle const &showers) const
cet::coded_exception< error, detail::translate > exception
Event finding and building.
void printAssociatedClusters(art::Event const &event, ShowerHandle const &showers) const
fhicl::Atom< unsigned int > hitsPerLine