AnalysisTree
Toggle main menu visibility
Loading...
Searching...
No Matches
infra
Field.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
5
#ifndef ANALYSISTREE_INFRA_FIELD_H_
6
#define ANALYSISTREE_INFRA_FIELD_H_
7
8
#include <stdexcept>
9
#include <string>
10
11
#include "Constants.hpp"
12
#include "Utils.hpp"
13
14
namespace
AnalysisTree
{
15
16
class
Configuration
;
17
class
Branch
;
18
22
class
Field {
23
public
:
24
Field() =
default
;
25
Field(
const
Field&) =
default
;
26
Field(Field&&) =
default
;
27
Field& operator=(Field&&) =
default
;
28
Field& operator=(
const
Field&) =
default
;
29
virtual
~Field() =
default
;
30
31
explicit
Field(std::string name) : field_(std::move(name)){};
32
33
Field(std::string branch, std::string field) : branch_(std::move(branch)),
34
field_(std::move(field)){};
35
36
friend
bool
operator==(
const
Field& that,
const
Field& other);
37
friend
bool
operator>(
const
Field& that,
const
Field& other);
38
friend
bool
operator<(
const
Field& that,
const
Field& other);
39
44
void
Init
(
const
Configuration
& conf);
45
void
Init
(
const
BranchConfig
& conf);
46
47
ANALYSISTREE_ATTR_NODISCARD
const
std::string& GetName()
const
{
return
field_; }
48
ANALYSISTREE_ATTR_NODISCARD
const
std::string& GetBranchName()
const
{
return
branch_; }
49
50
ANALYSISTREE_ATTR_NODISCARD
size_t
GetBranchId()
const
{
return
branch_id_; }
51
ANALYSISTREE_ATTR_NODISCARD
short
GetFieldId()
const
{
return
field_id_; }
52
53
ANALYSISTREE_ATTR_NODISCARD DetType GetBranchType()
const
{
return
branch_type_; }
54
ANALYSISTREE_ATTR_NODISCARD Types GetFieldType()
const
{
return
field_type_; }
55
62
template
<
class
T>
63
double
GetValue
(
const
T&
object
)
const
{
64
if
(!is_init_) {
65
throw
std::runtime_error(
"Field::Fill - Field "
+ field_ +
" is not initialized"
);
66
}
67
switch
(field_type_) {
68
case
Types::kFloat:
return
object
.template GetField<float>(field_id_);
69
case
(Types::kInteger):
return
object
.template GetField<int>(field_id_);
70
case
Types::kBool:
return
object
.template GetField<bool>(field_id_);
71
default
:
throw
std::runtime_error(
"Unknown field type"
);
72
}
73
}
74
75
void
Print()
const
;
76
77
ANALYSISTREE_ATTR_NODISCARD
const
Branch
* GetParentBranch()
const
{
return
parent_branch_; }
78
ANALYSISTREE_ATTR_NODISCARD
bool
IsInitialized()
const
{
return
is_init_; }
79
explicit
operator
bool()
const
{
return
IsInitialized(); }
80
81
private
:
82
friend
Branch;
83
84
const
Branch* parent_branch_{
nullptr
};
85
86
std::string branch_;
87
std::string field_;
88
89
short
field_id_{0};
90
Types field_type_{Types::kNumberOfTypes};
91
92
size_t
branch_id_{0};
93
DetType branch_type_{DetType(UndefValueShort)};
94
95
bool
is_init_{
false
};
96
97
ClassDef(Field, 0);
98
};
99
100
}
// namespace AnalysisTree
101
102
#endif
//ANALYSISTREE_INFRA_FIELD_H_
AnalysisTree::BranchConfig
A class to store configuration of the Container.
Definition
BranchConfig.hpp:89
AnalysisTree::Branch
Definition
Branch.hpp:23
AnalysisTree::Configuration
A class to store configuration of the whole AnalysisTree object.
Definition
Configuration.hpp:58
AnalysisTree::Field::Init
void Init(const Configuration &conf)
Initializes branchId and fieldId.
Definition
Field.cpp:39
AnalysisTree::Field::GetValue
double GetValue(const T &object) const
Gets numerical value from data-object associated with TTree.
Definition
Field.hpp:63
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