Belle II Software
development
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
15
ExtraInfoPrinterModule::ExtraInfoPrinterModule
() :
Module
()
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
26
void
ExtraInfoPrinterModule::initialize
()
27
{
28
if
(
m_listName
==
""
) {
29
m_eee
.isRequired();
30
}
else
{
31
m_list
.isRequired(
m_listName
);
32
m_peem
.isRequired();
33
}
34
}
35
36
void
ExtraInfoPrinterModule::event
()
37
{
38
if
(
m_printOnce
&&
m_hasPrinted
)
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
}
Belle2::ExtraInfoPrinterModule::initialize
virtual void initialize() override
Initialises module.
Definition:
ExtraInfoPrinterModule.cc:26
Belle2::ExtraInfoPrinterModule::event
virtual void event() override
Called for each event.
Definition:
ExtraInfoPrinterModule.cc:36
Belle2::ExtraInfoPrinterModule::m_eee
StoreObjPtr< EventExtraInfo > m_eee
the EventExtraInfo
Definition:
ExtraInfoPrinterModule.h:32
Belle2::ExtraInfoPrinterModule::m_list
StoreObjPtr< ParticleList > m_list
the ParticleList itself
Definition:
ExtraInfoPrinterModule.h:30
Belle2::ExtraInfoPrinterModule::m_hasPrinted
bool m_hasPrinted
internal check if I've already printed
Definition:
ExtraInfoPrinterModule.h:28
Belle2::ExtraInfoPrinterModule::m_listName
std::string m_listName
name of the ParticleList
Definition:
ExtraInfoPrinterModule.h:29
Belle2::ExtraInfoPrinterModule::ExtraInfoPrinterModule
ExtraInfoPrinterModule()
Constructor.
Definition:
ExtraInfoPrinterModule.cc:15
Belle2::ExtraInfoPrinterModule::m_printOnce
bool m_printOnce
print for he first event or for all events?
Definition:
ExtraInfoPrinterModule.h:27
Belle2::ExtraInfoPrinterModule::m_peem
StoreObjPtr< ParticleExtraInfoMap > m_peem
the map of particles to extra info
Definition:
ExtraInfoPrinterModule.h:31
Belle2::Module
Base class for Modules.
Definition:
Module.h:72
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition:
Module.cc:214
Belle2::Particle
Class to store reconstructed particles.
Definition:
Particle.h:75
Belle2::Module::addParam
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition:
Module.h:560
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition:
Module.h:650
Belle2
Abstract base class for different kinds of events.
Definition:
MillepedeAlgorithm.h:17
analysis
modules
ExtraInfoPrinter
src
ExtraInfoPrinterModule.cc
Generated on Fri Nov 8 2024 02:32:23 for Belle II Software by
1.9.6