AnalysisTree
Toggle main menu visibility
Loading...
Searching...
No Matches
core
Module.hpp
1
/* Copyright (C) 2019-2021 GSI, Universität Tübingen, MEPhI
2
SPDX-License-Identifier: GPL-3.0-only
3
Authors: Viktor Klochkov, Eugeny Kashirin, Ilya Selyuzhenkov */
4
#ifndef ANALYSISTREE_SRC_MODULE_H_
5
#define ANALYSISTREE_SRC_MODULE_H_
6
7
#include <stdexcept>
8
9
#include <TVector3.h>
10
11
#include "Container.hpp"
12
13
namespace
AnalysisTree
{
14
15
class
Module :
public
Container {
16
17
public
:
18
Module() =
default
;
19
explicit
Module(
const
Container& cont) : Container(cont) {}
20
Module(
const
Module& otherModule) =
default
;
21
Module(Module&& otherModule) =
default
;
22
Module& operator=(Module&&) =
default
;
23
Module& operator=(
const
Module& part) =
default
;
24
25
explicit
Module(
size_t
id
) : Container(
id
) {}
26
Module(
size_t
id
,
const
BranchConfig
& branch) noexcept : Container(
id
, branch) {}
27
28
ANALYSISTREE_ATTR_NODISCARD Floating_t GetSignal()
const
{
return
signal_; }
29
ANALYSISTREE_ATTR_NODISCARD ShortInt_t GetNumber()
const
{
return
number_; }
30
31
void
SetSignal(Floating_t signal) { signal_ = signal; }
32
void
SetNumber(ShortInt_t number) { number_ = number; }
33
34
friend
bool
operator==(
const
Module& that,
const
Module& other);
35
36
template
<
typename
T>
37
T GetField(Integer_t iField)
const
{
38
if
(iField >= 0)
39
return
Container::GetField<T>(iField);
40
else
{
41
switch
(iField) {
42
case
ModuleFields::kNumber:
return
GetNumber();
43
case
ModuleFields::kSignal:
return
GetSignal();
44
case
ModuleFields::kId:
return
GetId();
45
default
:
throw
std::out_of_range(
"Module::GetField - Index "
+ std::to_string(iField) +
" is not found"
);
46
}
47
}
48
}
49
50
template
<
typename
T>
51
void
SetField(T value, Int_t field_id) {
52
if
(field_id >= 0) {
53
Container::SetField(value, field_id);
54
}
else
{
55
switch
(field_id) {
56
case
ModuleFields::kSignal: signal_ = value;
break
;
57
case
ModuleFields::kNumber: number_ = value;
break
;
58
case
ModuleFields::kId:
break
;
59
default
:
throw
std::runtime_error(
"Unknown field"
);
60
}
61
}
62
}
63
64
void
Print()
const
noexcept
override
;
65
66
protected
:
67
Floating_t signal_{0.f};
68
ShortInt_t number_{UndefValueShort};
69
70
ClassDefOverride(Module, 2)
71
};
72
73
class
ModulePosition :
public
IndexedObject {
74
75
public
:
76
ModulePosition()
noexcept
=
default
;
77
ModulePosition(
const
ModulePosition& otherModulePosition) =
default
;
78
ModulePosition(ModulePosition&& otherModulePosition)
noexcept
=
default
;
79
ModulePosition& operator=(ModulePosition&&)
noexcept
=
default
;
80
ModulePosition& operator=(
const
ModulePosition& part) =
default
;
81
82
explicit
ModulePosition(
size_t
id
) : IndexedObject(
id
) {}
83
ModulePosition(
size_t
id
, Double_t x, Double_t y, Double_t z) : IndexedObject(
id
), x_(x), y_(y), z_(z) {}
84
85
ANALYSISTREE_ATTR_NODISCARD TVector3 GetPosition()
const
noexcept
{
86
return
TVector3(x_, y_, z_);
87
}
88
89
void
SetPosition(
const
TVector3& position)
noexcept
{
90
x_ = position.X();
91
y_ = position.Y();
92
z_ = position.Z();
93
}
94
95
void
SetPosition(Double_t x, Double_t y, Double_t z)
noexcept
{
96
x_ = x;
97
y_ = y;
98
z_ = z;
99
}
100
101
ANALYSISTREE_ATTR_NODISCARD
inline
Floating_t GetX()
const
noexcept
{
return
x_; }
102
ANALYSISTREE_ATTR_NODISCARD
inline
Floating_t GetY()
const
noexcept
{
return
y_; }
103
ANALYSISTREE_ATTR_NODISCARD
inline
Floating_t GetZ()
const
noexcept
{
return
z_; }
104
ANALYSISTREE_ATTR_NODISCARD
inline
Floating_t GetPhi()
const
noexcept
{
return
atan2(y_, x_); }
105
106
void
Print()
const
;
107
108
protected
:
109
Floating_t x_{UndefValueFloat};
110
Floating_t y_{UndefValueFloat};
111
Floating_t z_{UndefValueFloat};
112
};
113
}
// namespace AnalysisTree
114
115
#endif
AnalysisTree::BranchConfig
A class to store configuration of the Container.
Definition
BranchConfig.hpp:89
AnalysisTree
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition
BranchConfig.cpp:10
Generated by
1.17.0