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
SrsensorModule.cc
1
/**************************************************************************
2
* BASF2 (Belle Analysis Framework 2) *
3
* Copyright(C) 2010-2011 Belle II Collaboration *
4
* *
5
* Author: The Belle II Collaboration *
6
* Contributors: Susanne Koblitz *
7
* *
8
**************************************************************************/
9
10
#include <beast/srsensor/modules/SrsensorModule.h>
11
#include <beast/srsensor/dataobjects/SrsensorSimHit.h>
12
#include <mdst/dataobjects/MCParticle.h>
13
#include <framework/datastore/StoreArray.h>
14
#include <framework/datastore/RelationArray.h>
15
#include <framework/datastore/RelationIndex.h>
16
#include <framework/logging/Logger.h>
17
#include <boost/foreach.hpp>
18
19
using namespace
std;
20
21
namespace
Belle2
{
27
namespace
srsensor {
28
29
//We have to register the module to the Framework. The "Module" part of the
30
//class name will be appended automatically so every module hast to be named
31
//XxxModule
32
REG_MODULE
(Srsensor)
33
34
35
SrsensorModule
::
SrsensorModule
() :
Module
(), m_intParameter(0), m_doubleParameter(0), m_stringParameter("")
36
{
37
setDescription(
"Creates Synchroton Radiation senor - sub-detector of BEASTII"
);
38
39
//We can define parameters which can be set from the steering file. The arguments are:
40
// name, reference to the veriable where the value will be stored, description, default value
41
//If the default value is ommited the user has to specify this parameter, otherwise an error is produced
42
addParam(
"intParameter"
, m_intParameter,
43
"Useless parameter of type integer"
, 0);
44
addParam(
"doubleParameter"
, m_doubleParameter,
45
"Useless parameter of type double"
, 0.0);
46
addParam(
"stringParameter"
, m_stringParameter,
47
"Useless parameter of type string"
,
string
(
""
));
48
addParam(
"doubleListParameter"
, m_doubleListParameter,
49
"Useless parameter of type vector<double>"
, vector<double>(3, 0));
50
51
//Valid parameter types are int, double, string, bool and vectors of any of those
52
}
53
54
void
SrsensorModule::initialize()
55
{
56
B2INFO(
"Srsensor: Initialize"
);
57
//Here you can do some stuff before processing starts. If you want to
58
//write to some collections of the DataStore you have to register these
59
//here by using StoreArray<T>::registerPersistent() for collections which
60
//should be written to the output file by default or
61
//StoreArray<T>::registerTransient() for collections which will not be
62
//saved by default. If one just wants to access collections one should
63
//check if they were registered by using the isRequired member
64
65
StoreArray<MCParticle>
mcParticles;
66
StoreArray<SrsensorSimHit>
simHits;
67
RelationArray
relMCSimHit(mcParticles, simHits);
68
if
(!(mcParticles.isRequired() && simHits.isRequired() && relMCSimHit.
isRequired
())) {
69
//Fatal is not neccessary here as the storeArrays should just look
70
//empty if not registered but let's make sure everything is present
71
B2FATAL(
"Not all collections found, exiting processing"
);
72
}
73
}
74
75
void
SrsensorModule::beginRun()
76
{
77
B2INFO(
"Srsensor: Begin of new run"
);
78
//Here comes the initialisation specific to each run
79
}
80
81
void
SrsensorModule::event()
82
{
83
B2INFO(
"Srsensor: Event is being processed"
);
84
//Here comes the actual event processing
85
86
StoreArray<MCParticle>
mcParticles;
87
StoreArray<SrsensorSimHit>
simHits;
88
89
//RelationIndex is a readonly, bidirectional index for a Relation so that one
90
//can easily use the RelationArray without looping over it manually.
91
RelationIndex<MCParticle, SrsensorSimHit>
relMCSimHit(mcParticles, simHits);
92
93
//Lets loop over all created SrsensorSimHits:
94
//int nSimHits = simHits.getEntries();
95
//for (int i = 0; i < nSimHits; ++i) {
96
//SrsensorSimHit& hit = *simHits[i];
97
//Find all MCParticles which point to that SimHit and the corresponding weight
98
//RelationIndex<MCParticle, SrsensorSimHit>::range_to range = relMCSimHit.getElementsTo(hit);
99
//for (; range.first != range.second; ++range.first) {
100
//And Print something about the relation
101
//const RelationIndex<MCParticle, SrsensorSimHit>::Element& relation = *range.to;
102
//B2INFO("SrsensorSimHit #" << i << " has an energy deposition of " << hit.getEnergyDep()
103
// << " and is related to MCParticle #" << relation.indexFrom
104
// << " which has an PDG code of " << relation.from->getPDG());
105
//}
106
//}
107
108
//Now let's do it the other way round:
109
int
nMCParticles = mcParticles.
getEntries
();
110
for
(
int
i = 0; i < nMCParticles; ++i) {
111
MCParticle
& mcp = *mcParticles[i];
112
//Find all SrsensorSimHits which point from that MCParticle using a typedef and BOOST_FOREACH
113
//The typedef is needed as BOOST_FOREACH is a macro and cannot handle anything including a comma
114
typedef
RelationIndex<MCParticle, SrsensorSimHit>::Element
relMCSimHit_Element;
115
BOOST_FOREACH(
const
relMCSimHit_Element & relation, relMCSimHit.
getElementsFrom
(mcp)) {
116
B2INFO(
"MCParticle #"
<< i <<
" created the AwesomSimHit #"
<< relation.indexTo
117
<<
" which has an energy deposition of "
<< relation.to->getEnergyDep());
118
}
119
}
120
}
121
122
void
SrsensorModule::endRun()
123
{
124
B2INFO(
"Srsensor: End of run"
);
125
//Here cleanup after each run
126
}
127
128
129
void
SrsensorModule::terminate()
130
{
131
B2INFO(
"Srsensor: Terminate"
);
132
//Here final cleanup
133
}
134
135
}
//srsensor namespace
137
}
//Belle2 namespace
Belle2::RelationArray
Low-level class to create/modify relations between StoreArrays.
Definition:
RelationArray.h:72
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition:
Module.h:652
Belle2::RelationIndex
Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation.
Definition:
RelationIndex.h:84
Belle2::Module
Base class for Modules.
Definition:
Module.h:74
Belle2::RelationIndexContainer::Element
Element type for the index.
Definition:
RelationIndexContainer.h:62
Belle2::StoreAccessorBase::isRequired
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Definition:
StoreAccessorBase.h:80
Belle2::RelationIndex::getElementsFrom
range_from getElementsFrom(const FROM *from) const
Return a range of all elements pointing from the given object.
Definition:
RelationIndex.h:157
Belle2
Abstract base class for different kinds of events.
Definition:
MillepedeAlgorithm.h:19
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition:
MCParticle.h:43
Belle2::StoreArray< MCParticle >
Belle2::srsensor::SrsensorModule
The Srsensor module.
Definition:
SrsensorModule.h:38
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition:
StoreArray.h:226
beast
srsensor
modules
src
SrsensorModule.cc
Generated on Tue Jan 4 2022 02:52:32 for Belle II Software by
1.8.17