Belle II Software  release-05-02-19
ExtraInfoPrinterModule.cc
1 /**************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3 * Copyright(C) 2018 - Belle II Collaboration *
4 * *
5 * Author: The Belle II Collaboration *
6 * Contributors: Sam Cunliffe *
7 * *
8 * This software is provided "as is" without any warranty. *
9 **************************************************************************/
10 
11 #include <analysis/modules/ExtraInfoPrinter/ExtraInfoPrinterModule.h>
12 
13 using namespace Belle2;
14 
15 REG_MODULE(ExtraInfoPrinter)
16 
18 {
19  setDescription("Prints the names of all ExtraInfo set for each particle in"
20  " the event. Usefull for debugging and development.");
21 
22  addParam("particleList", m_listName, "Name of the particle list (an empty "
23  "string prints the EventExtraInfo)");
24  addParam("printOnce", m_printOnce, "Print for the first event, or for all "
25  "events (default true)", true);
26 }
27 
29 {
30  if (m_listName == "") {
31  m_eee.isRequired();
32  } else {
33  m_list.isRequired(m_listName);
34  m_peem.isRequired();
35  }
36 }
37 
39 {
41  return;
42 
43  // print the EventExtraInfo names
44  if (m_listName == "") {
45  if (m_eee.isValid()) {
46  std::ostringstream stream;
47  stream << "EventExtraInfo for this event: ";
48  for (auto const& name : m_eee->getNames()) stream << name << " ";
49  B2INFO(stream.str());
50  m_hasPrinted = true;
51  }
52  return;
53  }
54 
55  // print the ParticleExtraInfo names for the input ParticleList
56  unsigned int n = m_list->getListSize();
57  if (n < 1)
58  B2WARNING("The list: " << m_listName << " doesn't contain any particles");
59 
60  for (unsigned i = 0; i < n; i++) {
61  const Particle* p = m_list->getParticle(i);
62  std::ostringstream stream;
63  stream << "ExtraInfo for this particle: ";
64  for (auto const& name : p->getExtraInfoNames()) stream << name << " ";
65  B2INFO(stream.str());
66  m_hasPrinted = true;
67  }
68  return;
69 }
Belle2::ExtraInfoPrinterModule::m_hasPrinted
bool m_hasPrinted
internal check if I've already printed
Definition: ExtraInfoPrinterModule.h:41
Belle2::ExtraInfoPrinterModule::m_list
StoreObjPtr< ParticleList > m_list
the ParticleList itself
Definition: ExtraInfoPrinterModule.h:43
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::ExtraInfoPrinterModule
Prints the names of the ExtraInfos for a ParticleList or for the Event.
Definition: ExtraInfoPrinterModule.h:38
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::ExtraInfoPrinterModule::initialize
virtual void initialize() override
Initialises module.
Definition: ExtraInfoPrinterModule.cc:28
Belle2::ExtraInfoPrinterModule::m_listName
std::string m_listName
name of the ParticleList
Definition: ExtraInfoPrinterModule.h:42
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ExtraInfoPrinterModule::m_peem
StoreObjPtr< ParticleExtraInfoMap > m_peem
the map of particles to extra info
Definition: ExtraInfoPrinterModule.h:44
Belle2::ExtraInfoPrinterModule::m_eee
StoreObjPtr< EventExtraInfo > m_eee
the EventExtraInfo
Definition: ExtraInfoPrinterModule.h:45
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::ExtraInfoPrinterModule::event
virtual void event() override
Called for each event.
Definition: ExtraInfoPrinterModule.cc:38
Belle2::ExtraInfoPrinterModule::m_printOnce
bool m_printOnce
print for he first event or for all events?
Definition: ExtraInfoPrinterModule.h:40