Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar::test::AssnsChainTest Class Reference

Prints all the hits associated to the specified shower. More...

Inheritance diagram for lar::test::AssnsChainTest:
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

 AssnsChainTest (Parameters const &config)
 
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 Member Functions

template<typename ShowerHandle >
void printAssociatedPFOs (art::Event const &event, ShowerHandle const &showers) const
 
template<typename ShowerHandle >
void printAssociatedClusters (art::Event const &event, ShowerHandle const &showers) const
 
template<typename ShowerHandle >
void printAssociatedHits (art::Event const &event, ShowerHandle const &showers) const
 

Private Attributes

art::InputTag showerTag
 Label of the input collection of showers. More...
 
unsigned int nObjectsPerLine
 Number of objects to print on one line. More...
 
unsigned int nShowers
 Total number of expected showers. More...
 
unsigned int nPFOs
 Total number of expected particles. More...
 
unsigned int nClusters
 Total number of expected clusters. More...
 
unsigned int nHits
 Total number of expected hits. 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

Prints all the hits associated to the specified shower.

The hits are searched transversing associations from showers to particle flow objects to clusters to hits.

Configuration parameters

Definition at line 65 of file AssnsChainTest_module.cc.

Member Typedef Documentation

Definition at line 105 of file AssnsChainTest_module.cc.

Constructor & Destructor Documentation

lar::test::AssnsChainTest::AssnsChainTest ( Parameters const &  config)
explicit

Definition at line 141 of file AssnsChainTest_module.cc.

143  , showerTag(config().showers())
144  , nObjectsPerLine(config().hitsPerLine())
145  , nShowers(config().nShowers())
146  , nPFOs(config().nParticles())
147  , nClusters(config().nClusters())
148  , nHits(config().nHits())
149  {}
unsigned int nShowers
Total number of expected showers.
unsigned int nPFOs
Total number of expected particles.
static Config * config
Definition: config.cpp:1054
unsigned int nHits
Total number of expected hits.
unsigned int nClusters
Total number of expected clusters.
art::InputTag showerTag
Label of the input collection of showers.
unsigned int nObjectsPerLine
Number of objects to print on one line.

Member Function Documentation

void lar::test::AssnsChainTest::analyze ( art::Event const &  event)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 153 of file AssnsChainTest_module.cc.

153  {
154 
155  //
156  // read the input collection
157  //
158  auto showers = event.getValidHandle<std::vector<recob::Shower>>(showerTag);
159  mf::LogVerbatim("AssnsChainTest") << event.id() << " contains "
160  << showers->size() << " showers from '" << showerTag.encode() << "'";
161 
162  if (showers->size() != nShowers) {
163  throw cet::exception("AssnsChainTest")
164  << "Data product '" << showerTag.encode() << "' contains "
165  << showers->size() << " showers, " << nShowers << " were expected.\n";
166  }
167 
168  mf::LogVerbatim("AssnsChainTest") << "\nPrinting: shower particle";
170 
171  mf::LogVerbatim("AssnsChainTest") << "\nPrinting: shower clusters";
173 
174  mf::LogVerbatim("AssnsChainTest") << "\nPrinting: shower hits";
176 
177 } // lar::test::AssnsChainTest::analyze()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void printAssociatedHits(art::Event const &event, ShowerHandle const &showers) const
unsigned int nShowers
Total number of expected showers.
std::string encode() const
Definition: InputTag.cc:97
art::InputTag showerTag
Label of the input collection of showers.
void printAssociatedPFOs(art::Event const &event, ShowerHandle const &showers) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Event finding and building.
void printAssociatedClusters(art::Event const &event, ShowerHandle const &showers) const
template<typename ShowerHandle >
void lar::test::AssnsChainTest::printAssociatedClusters ( art::Event const &  event,
ShowerHandle const &  showers 
) const
private

Definition at line 261 of file AssnsChainTest_module.cc.

262 {
263  std::string const objectsDesc = "clusters";
264 
265  //
266  // get the associated objects
267  //
269  (showers, event, showerTag);
270  assert(showerObjects.size() == showers->size());
271 
272  using ObjectPtr_t = decltype(showerObjects)::TargetPtr_t;
273 
274  //
275  // print the associated objects (just the art pointer so far)
276  //
277  unsigned int nDuplicates = 0;
278  std::set<art::Ptr<recob::Cluster>> foundObjects; // all objects found
279  std::set<art::ProductID> foundObjectProducts;
280 
281  unsigned int const pageSize = nObjectsPerLine; // objects per line
282  mf::LogVerbatim log("AssnsChainTest");
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;
287 
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());
293  }
294  else {
295  mf::LogProblem("AssnsChainTest")
296  << "ERROR: Cluster " << object << " appears in more than one shower!";
297  ++nDuplicates;
298  }
299  if (objectsLeft-- == 0) {
300  objectsLeft = pageSize;
301  log << "\n ";
302  }
303  log << " " << object; // just print the art pointer
304  } // for objects
305 
306  } // for iShower
307 
308  mf::LogVerbatim("AssnsChainTest")
309  << foundObjects.size() << " " << objectsDesc << " collected for "
310  << showers->size() << " showers ('"
311  << showers.provenance()->inputTag().encode() << "') from "
312  << foundObjectProducts.size() << " data products:";
313  for (art::ProductID const& PID: foundObjectProducts) {
315  if (event.get(PID, objects)) {
316  mf::LogVerbatim("AssnsChainTest") << " - '"
317  << objects.provenance()->inputTag().encode() << "' (contains "
318  << objects->size() << " " << objectsDesc << ")";
319  }
320  else {
321  mf::LogVerbatim("AssnsChainTest") << " - <" << PID << "> (not found!)";
322  }
323  } // for PIDs
324 
325  if (nDuplicates > 0) {
326  throw cet::exception("AssnsChainTest")
327  << "Test failed: " << nDuplicates
328  << " clusters appear in more than one shower.\n";
329  }
330  if (foundObjects.size() != nClusters) {
331  throw cet::exception("AssnsChainTest")
332  << "Test failed: counted " << foundObjects.size()
333  << " clusters, expected " << nClusters << ".\n";
334  }
335 
336 } // lar::test::AssnsChainTest::printAssociatedClusters()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
Provenance const * provenance() const
Definition: Handle.h:205
Query object collecting a list of associated objects.
unsigned int nClusters
Total number of expected clusters.
art::InputTag showerTag
Label of the input collection of showers.
unsigned int nObjectsPerLine
Number of objects to print on one line.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Event finding and building.
template<typename ShowerHandle >
void lar::test::AssnsChainTest::printAssociatedHits ( art::Event const &  event,
ShowerHandle const &  showers 
) const
private

Definition at line 183 of file AssnsChainTest_module.cc.

184 {
185 
186  //
187  // get the associated hits
188  //
190  showerHits(showers, event, showerTag);
191  assert(showerHits.size() == showers->size());
192 
193  //
194  // print the associated hits (just the art pointer so far)
195  //
196  unsigned int nDuplicates = 0;
197  std::set<art::Ptr<recob::Hit>> foundHits; // all hits found
198  std::set<art::ProductID> foundHitProducts;
199 
200  unsigned int const pageSize = nObjectsPerLine; // hits per line
201  mf::LogVerbatim log("AssnsChainTest");
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;
206 
207  unsigned int hitsLeft = pageSize;
208  for (art::Ptr<recob::Hit> const& hit: hits) {
209  if (foundHits.count(hit) == 0) {
210  foundHits.insert(hit);
211  foundHitProducts.insert(hit.id());
212  }
213  else {
214  mf::LogProblem("AssnsChainTest")
215  << "ERROR: Hit " << hit << " appears in more than one shower!";
216  ++nDuplicates;
217  }
218  if (hitsLeft-- == 0) {
219  hitsLeft = pageSize;
220  log << "\n ";
221  }
222  log << " " << hit; // just print the art pointer
223  } // for hits
224 
225  } // for iShower
226 
227  mf::LogVerbatim("AssnsChainTest")
228  << foundHits.size() << " hits collected for "
229  << showers->size() << " showers ('"
230  << showers.provenance()->inputTag().encode() << "') from "
231  << foundHitProducts.size() << " data products:";
232  for (art::ProductID const& PID: foundHitProducts) {
234  if (event.get(PID, hits)) {
235  mf::LogVerbatim("AssnsChainTest") << " - '"
236  << hits.provenance()->inputTag().encode() << "' (contains "
237  << hits->size() << " hits)";
238  }
239  else {
240  mf::LogVerbatim("AssnsChainTest") << " - <" << PID << "> (not found!)";
241  }
242  } // for PIDs
243 
244  if (nDuplicates > 0) {
245  throw cet::exception("AssnsChainTest")
246  << "Test failed: " << nDuplicates
247  << " hits appear in more than one shower.\n";
248  }
249  if (foundHits.size() != nHits) {
250  throw cet::exception("AssnsChainTest")
251  << "Test failed: counted " << foundHits.size()
252  << " hits, expected " << nHits << ".\n";
253  }
254 
255 } // lar::test::AssnsChainTest::printAssociatedHits()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
Provenance const * provenance() const
Definition: Handle.h:205
Query object collecting a list of associated objects.
unsigned int nHits
Total number of expected hits.
Detector simulation of raw signals on wires.
art::InputTag showerTag
Label of the input collection of showers.
unsigned int nObjectsPerLine
Number of objects to print on one line.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Event finding and building.
template<typename ShowerHandle >
void lar::test::AssnsChainTest::printAssociatedPFOs ( art::Event const &  event,
ShowerHandle const &  showers 
) const
private

Definition at line 342 of file AssnsChainTest_module.cc.

343 {
344  std::string const objectsDesc = "particle flow objects";
345 
346  //
347  // get the associated objects
348  //
350  (showers, event, showerTag);
351  assert(showerObjects.size() == showers->size());
352 
353  using ObjectPtr_t = decltype(showerObjects)::TargetPtr_t;
354 
355  //
356  // print the associated objects (just the art pointer so far)
357  //
358  unsigned int nDuplicates = 0;
359  std::set<art::Ptr<recob::PFParticle>> foundObjects; // all objects found
360  std::set<art::ProductID> foundObjectProducts;
361 
362  unsigned int const pageSize = nObjectsPerLine; // objects per line
363  mf::LogVerbatim log("AssnsChainTest");
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;
367 
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());
373  }
374  else {
375  mf::LogProblem("AssnsChainTest")
376  << "ERROR: Particle " << object
377  << " appears in more than one shower!";
378  ++nDuplicates;
379  }
380  if (objectsLeft-- == 0) {
381  objectsLeft = pageSize;
382  log << "\n ";
383  }
384  log << " " << object; // just print the art pointer
385  } // for objects
386 
387  if (objects.size() != 1) {
388  throw cet::exception("AssnsChainTest")
389  << "all showers are expected to have one PFParticle associated, while #"
390  << iShower << " has " << objects.size() << "\n";
391  }
392 
393  } // for iShower
394 
395  mf::LogVerbatim("AssnsChainTest")
396  << foundObjects.size() << " " << objectsDesc << " collected for "
397  << showers->size() << " showers ('"
398  << showers.provenance()->inputTag().encode() << "') from "
399  << foundObjectProducts.size() << " data products:";
400  for (art::ProductID const& PID: foundObjectProducts) {
402  if (event.get(PID, objects)) {
403  mf::LogVerbatim("AssnsChainTest") << " - '"
404  << objects.provenance()->inputTag().encode() << "' (contains "
405  << objects->size() << " " << objectsDesc << ")";
406  }
407  else {
408  mf::LogVerbatim("AssnsChainTest") << " - <" << PID << "> (not found!)";
409  }
410  } // for PIDs
411 
412  if (nDuplicates > 0) {
413  throw cet::exception("AssnsChainTest")
414  << "Test failed: " << nDuplicates
415  << " particle flow objects appear in more than one shower.\n";
416  }
417  if (foundObjects.size() != nPFOs) {
418  throw cet::exception("AssnsChainTest")
419  << "Test failed: counted " << foundObjects.size()
420  << " particle flow objects, expected " << nPFOs << ".\n";
421  }
422 
423 } // lar::test::AssnsChainTest::printAssociatedPFOs()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
unsigned int nPFOs
Total number of expected particles.
Provenance const * provenance() const
Definition: Handle.h:205
Query object collecting a list of associated objects.
art::InputTag showerTag
Label of the input collection of showers.
unsigned int nObjectsPerLine
Number of objects to print on one line.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Event finding and building.

Member Data Documentation

unsigned int lar::test::AssnsChainTest::nClusters
private

Total number of expected clusters.

Definition at line 116 of file AssnsChainTest_module.cc.

unsigned int lar::test::AssnsChainTest::nHits
private

Total number of expected hits.

Definition at line 117 of file AssnsChainTest_module.cc.

unsigned int lar::test::AssnsChainTest::nObjectsPerLine
private

Number of objects to print on one line.

Definition at line 113 of file AssnsChainTest_module.cc.

unsigned int lar::test::AssnsChainTest::nPFOs
private

Total number of expected particles.

Definition at line 115 of file AssnsChainTest_module.cc.

unsigned int lar::test::AssnsChainTest::nShowers
private

Total number of expected showers.

Definition at line 114 of file AssnsChainTest_module.cc.

art::InputTag lar::test::AssnsChainTest::showerTag
private

Label of the input collection of showers.

Definition at line 112 of file AssnsChainTest_module.cc.


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