Belle II Software
release-05-02-19
Main Page
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Typedefs
a
b
c
d
e
h
i
l
m
n
p
r
s
t
v
w
Enumerations
Enumerator
c
d
f
p
t
u
v
w
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
Enumerator
a
b
c
d
e
f
g
h
k
l
m
n
o
p
r
s
t
u
v
w
z
Related Functions
b
c
d
g
i
o
r
s
t
Files
File List
File Members
All
Functions
SignalSideVariablesToDaughterExtraInfoModule.cc
1
/**************************************************************************
2
* BASF2 (Belle Analysis Framework 2) *
3
* Copyright(C) 2018 - Belle II Collaboration *
4
* *
5
* Author: The Belle II Collaboration *
6
* Contributors: Frank Meier *
7
* *
8
* This software is provided "as is" without any warranty. *
9
**************************************************************************/
10
11
#include <analysis/modules/SignalSideVariablesToDaughterExtraInfo/SignalSideVariablesToDaughterExtraInfoModule.h>
12
#include <framework/core/ModuleParam.templateDetails.h>
13
#include <framework/datastore/StoreArray.h>
14
15
#include <analysis/dataobjects/Particle.h>
16
#include <analysis/dataobjects/RestOfEvent.h>
17
18
using namespace
Belle2
;
19
20
//-----------------------------------------------------------------
21
// Register the Module
22
//-----------------------------------------------------------------
23
REG_MODULE
(SignalSideVariablesToDaughterExtraInfo)
24
25
//-----------------------------------------------------------------
26
// Implementation
27
//-----------------------------------------------------------------
28
29
SignalSideVariablesToDaughterExtraInfoModule
::
SignalSideVariablesToDaughterExtraInfoModule
() :
Module
()
30
{
31
// Set module properties
32
33
setDescription(
"The module writes properties (values of specified variables) of the particle related to the current ROE\n"
34
"as an ExtraInfo to the single particle in the input ParticleList.\n"
35
"This module is intended to be executed only in for_each ROE path."
);
36
37
// Parameter definitions
38
std::map<std::string, std::string> emptymap;
39
addParam(
"particleListName"
, m_particleListName,
"The input particleList name. This list should contain at most 1 particle"
,
40
std::string(
""
));
41
addParam(
"variablesToExtraInfo"
, m_variablesToExtraInfo,
42
"Dictionary of variables and extraInfo names to save in the extra-info field."
,
43
emptymap);
44
addParam(
"overwrite"
, m_overwrite,
45
"-1/0/1/2: Overwrite if lower / don't overwrite / overwrite if higher / always overwrite, in case if extra info with given name already exists"
,
46
0);
47
}
48
49
void
SignalSideVariablesToDaughterExtraInfoModule::initialize
()
50
{
51
StoreArray<Particle>
().isRequired();
52
m_inputList
.isRequired(
m_particleListName
);
53
54
for
(
const
auto
& pair :
m_variablesToExtraInfo
) {
55
const
Variable::Manager::Var
* var =
Variable::Manager::Instance
().
getVariable
(pair.first);
56
if
(!var) {
57
B2ERROR(
"Variable '"
<< pair.first <<
"' is not available in Variable::Manager!"
);
58
}
else
{
59
m_functions
.push_back(var->function);
60
m_extraInfoNames
.push_back(pair.second);
61
}
62
}
63
}
64
65
void
SignalSideVariablesToDaughterExtraInfoModule::event
()
66
{
67
StoreObjPtr<ParticleList>
plist(
m_particleListName
);
68
unsigned
int
n = plist->getListSize();
69
70
if
(n == 0)
71
return
;
72
73
if
(n > 1)
74
B2WARNING(
"Input ParticleList "
<<
m_particleListName
<<
" contains more than 1 particle. plist.size = "
<< n);
75
76
StoreObjPtr<RestOfEvent>
roe(
"RestOfEvent"
);
77
if
(roe.
isValid
()) {
78
auto
* signalSide = roe->getRelated<
Particle
>();
79
Particle
* daughter = plist->getParticle(0);
80
81
const
unsigned
int
nVars =
m_functions
.size();
82
for
(
unsigned
int
iVar = 0; iVar < nVars; iVar++) {
83
double
value =
m_functions
[iVar](signalSide);
84
if
(daughter->hasExtraInfo(
m_extraInfoNames
[iVar])) {
85
double
current = daughter->getExtraInfo(
m_extraInfoNames
[iVar]);
86
if
(
m_overwrite
== -1) {
87
if
(value < current)
88
daughter->setExtraInfo(
m_extraInfoNames
[iVar], value);
89
}
else
if
(
m_overwrite
== 1) {
90
if
(value > current)
91
daughter->setExtraInfo(
m_extraInfoNames
[iVar], value);
92
}
else
if
(
m_overwrite
== 0) {
93
B2WARNING(
"Extra info with given name "
<<
m_extraInfoNames
[iVar] <<
" already set, I won't set it again."
);
94
}
else
if
(
m_overwrite
== 2) {
95
daughter->setExtraInfo(
m_extraInfoNames
[iVar], value);
96
}
97
}
else
{
98
daughter->addExtraInfo(
m_extraInfoNames
[iVar], value);
99
}
100
}
101
}
102
}
Belle2::Variable::Manager::Var
A variable returning a floating-point value for a given Particle.
Definition:
Manager.h:137
Belle2::SignalSideVariablesToDaughterExtraInfoModule
The module writes properties (values of specified variables) of the particle related to the current R...
Definition:
SignalSideVariablesToDaughterExtraInfoModule.h:44
Belle2::Variable::Manager::getVariable
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
Definition:
Manager.cc:33
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition:
Module.h:652
Belle2::SignalSideVariablesToDaughterExtraInfoModule::initialize
virtual void initialize() override
Register input and output data.
Definition:
SignalSideVariablesToDaughterExtraInfoModule.cc:49
Belle2::SignalSideVariablesToDaughterExtraInfoModule::m_extraInfoNames
std::vector< std::string > m_extraInfoNames
Vector of extra info names.
Definition:
SignalSideVariablesToDaughterExtraInfoModule.h:75
Belle2::Module
Base class for Modules.
Definition:
Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition:
MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition:
ParticleList.h:33
Belle2::SignalSideVariablesToDaughterExtraInfoModule::m_inputList
StoreObjPtr< ParticleList > m_inputList
input particle list
Definition:
SignalSideVariablesToDaughterExtraInfoModule.h:63
Belle2::SignalSideVariablesToDaughterExtraInfoModule::event
virtual void event() override
Process events.
Definition:
SignalSideVariablesToDaughterExtraInfoModule.cc:65
Belle2::SignalSideVariablesToDaughterExtraInfoModule::m_variablesToExtraInfo
std::map< std::string, std::string > m_variablesToExtraInfo
Map of variable and extraInfo names to save in the extra-info field.
Definition:
SignalSideVariablesToDaughterExtraInfoModule.h:70
Belle2::SignalSideVariablesToDaughterExtraInfoModule::m_overwrite
int m_overwrite
-1/0/1/2: Overwrite if lower / don't overwrite / overwrite if higher / always overwrite,...
Definition:
SignalSideVariablesToDaughterExtraInfoModule.h:77
Belle2::Particle
Class to store reconstructed particles.
Definition:
Particle.h:77
Belle2::SignalSideVariablesToDaughterExtraInfoModule::m_particleListName
std::string m_particleListName
The input particleList name.
Definition:
SignalSideVariablesToDaughterExtraInfoModule.h:62
Belle2::SignalSideVariablesToDaughterExtraInfoModule::m_functions
std::vector< Variable::Manager::FunctionPtr > m_functions
Vector of function pointers corresponding to given variables.
Definition:
SignalSideVariablesToDaughterExtraInfoModule.h:73
Belle2::StoreArray< Particle >
Belle2::StoreObjPtr::isValid
bool isValid() const
Check whether the object was created.
Definition:
StoreObjPtr.h:120
Belle2::Variable::Manager::Instance
static Manager & Instance()
get singleton instance.
Definition:
Manager.cc:27
analysis
modules
SignalSideVariablesToDaughterExtraInfo
src
SignalSideVariablesToDaughterExtraInfoModule.cc
Generated on Tue Jan 4 2022 02:50:10 for Belle II Software by
1.8.17