Belle II Software  release-08-01-10
ExtraInfoPrinterModule.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include <analysis/modules/ExtraInfoPrinter/ExtraInfoPrinterModule.h>
10 
11 using namespace Belle2;
12 
13 REG_MODULE(ExtraInfoPrinter);
14 
16 {
17  setDescription("Prints the names of all ExtraInfo set for each particle in"
18  " the event. Useful for debugging and development.");
19 
20  addParam("particleList", m_listName, "Name of the particle list (an empty "
21  "string prints the EventExtraInfo)");
22  addParam("printOnce", m_printOnce, "Print for the first event, or for all "
23  "events (default true)", true);
24 }
25 
27 {
28  if (m_listName == "") {
29  m_eee.isRequired();
30  } else {
31  m_list.isRequired(m_listName);
32  m_peem.isRequired();
33  }
34 }
35 
37 {
39  return;
40 
41  // print the EventExtraInfo names
42  if (m_listName == "") {
43  if (m_eee.isValid()) {
44  std::ostringstream stream;
45  stream << "EventExtraInfo for this event: ";
46  for (auto const& name : m_eee->getNames()) stream << name << " ";
47  B2INFO(stream.str());
48  m_hasPrinted = true;
49  }
50  return;
51  }
52 
53  // print the ParticleExtraInfo names for the input ParticleList
54  unsigned int n = m_list->getListSize();
55  if (n < 1)
56  B2WARNING("The list: " << m_listName << " doesn't contain any particles");
57 
58  for (unsigned i = 0; i < n; i++) {
59  const Particle* p = m_list->getParticle(i);
60  std::ostringstream stream;
61  stream << "ExtraInfo for this particle: ";
62  for (auto const& name : p->getExtraInfoNames()) stream << name << " ";
63  B2INFO(stream.str());
64  m_hasPrinted = true;
65  }
66  return;
67 }
virtual void initialize() override
Initialises module.
virtual void event() override
Called for each event.
StoreObjPtr< EventExtraInfo > m_eee
the EventExtraInfo
StoreObjPtr< ParticleList > m_list
the ParticleList itself
bool m_hasPrinted
internal check if I've already printed
std::string m_listName
name of the ParticleList
bool m_printOnce
print for he first event or for all events?
StoreObjPtr< ParticleExtraInfoMap > m_peem
the map of particles to extra info
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Class to store reconstructed particles.
Definition: Particle.h:75
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
Abstract base class for different kinds of events.