ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfData
src
L1Connector.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrigConfData/L1Connector.h
"
6
using namespace
std
;
7
8
#include <stdexcept>
9
10
TrigConf::L1Connector::L1Connector
()
11
{}
12
13
TrigConf::L1Connector::L1Connector
(
const
std::string & connName,
const
boost::property_tree::ptree &
data
)
14
:
DataStructure
(
data
)
15
{
16
m_name
= connName;
17
L1Connector::update
();
18
}
19
20
std::string
21
TrigConf::L1Connector::className
()
const
{
22
return
"L1Connector"
;
23
}
24
25
void
26
TrigConf::L1Connector::update
()
27
{
28
m_name
=
getAttribute
(
"name"
,
true
,
m_name
);
29
30
std::string connType(
getAttribute
(
"type"
));
31
if
( connType ==
"electrical"
) {
32
m_type
=
ConnectorType::ELECTRICAL
;
33
}
else
if
( connType ==
"optical"
) {
34
m_type
=
ConnectorType::OPTICAL
;
35
}
else
if
( connType ==
"ctpin"
) {
36
m_type
=
ConnectorType::CTPIN
;
37
}
else
{
38
throw
std::runtime_error(
"Unknown connector type "
+ connType);
39
}
40
41
// triggerlines
42
bool
oldConfiguration =
hasChild
(
"triggerlines.clock0"
) ||
hasChild
(
"triggerlines.fpga0"
);
43
// old configuration
44
if
(oldConfiguration){
45
bool
hasMultipleFPGAs = !
hasChild
(
"triggerlines.clock0"
);
// connector from merger board (no fpga)
46
if
(
m_type
==
ConnectorType::ELECTRICAL
) {
47
m_maxClock
= 2;
48
m_maxFpga
= hasMultipleFPGAs ? 2 : 1;
49
}
50
51
for
(
size_t
fpga = 0; fpga <
m_maxFpga
; ++fpga ) {
52
for
(
size_t
clock = 0; clock <
m_maxClock
; ++clock ) {
53
std::string path =
"triggerlines"
;
54
if
(
m_type
==
ConnectorType::ELECTRICAL
) {
55
if
(hasMultipleFPGAs) {
56
path +=
".fpga"
;
57
path += std::to_string(fpga);
58
}
59
path +=
".clock"
;
60
path += std::to_string(clock);
61
}
62
const
auto
& triggerlines =
data
().get_child(path);
63
m_triggerLines
[fpga][clock].reserve(triggerlines.size());
64
for
(
auto
& tl : triggerlines ) {
65
const
std::string &
name
= tl.second.get_child(
"name"
).data();
66
m_triggerLines
[fpga][clock].emplace_back(
name
,
67
tl.second.get_child(
"startbit"
).get_value<
unsigned
int
>(),
68
tl.second.get_child(
"nbits"
).get_value<
unsigned
int
>(),
69
tl.second.get_child(
"startbit"
).get_value<
unsigned
int
>(),
70
fpga, clock,
m_name
);
71
m_lineByName
[
name
] = &
m_triggerLines
[fpga][clock].back();
72
}
73
}
74
}
75
}
76
// new configuration
77
else
{
78
std::string path =
"triggerlines"
;
79
int
ntl[2][2] = {{0,0},{0,0}};
80
if
(
m_type
==
ConnectorType::ELECTRICAL
) {
81
m_maxClock
= 2;
82
}
83
const
auto
& triggerlines =
data
().get_child(path);
84
for
(
auto
& tl : triggerlines ) {
85
unsigned
int
fpga = 0;
86
unsigned
int
clock = 0;
87
if
(
m_type
==
ConnectorType::ELECTRICAL
) {
88
if
(
m_name
.find(
"MuCTPiEl"
) != std::string::npos ||
m_name
.find(
"Topo2El"
) != std::string::npos ||
m_name
.find(
"Topo3El"
) != std::string::npos ||
m_name
.find(
"LegacyTopo0"
) != std::string::npos ||
m_name
.find(
"LegacyTopo1"
) != std::string::npos){
89
fpga = tl.second.get_child(
"fpga"
).get_value<
unsigned
int
>();
90
m_maxFpga
= 2;
91
}
92
clock = tl.second.get_child(
"clock"
).get_value<
unsigned
int
>();
93
}
94
ntl[fpga][clock] += 1;
95
}
96
for
(
size_t
fpga = 0; fpga <
m_maxFpga
; ++fpga ) {
97
for
(
size_t
clock = 0; clock <
m_maxClock
; ++clock ) {
98
m_triggerLines
[fpga][clock].reserve(ntl[fpga][clock]);
99
}
100
}
101
for
(
auto
& tl : triggerlines ) {
102
unsigned
int
fpga = 0;
103
unsigned
int
clock = 0;
104
unsigned
int
flatindex = 0;
105
if
(
m_type
==
ConnectorType::ELECTRICAL
) {
106
if
(
m_maxFpga
==2) fpga = tl.second.get_child(
"fpga"
).get_value<
unsigned
int
>();
107
clock = tl.second.get_child(
"clock"
).get_value<
unsigned
int
>();
108
}
109
flatindex = tl.second.get_optional<
unsigned
int
>(
"flatindex"
).get_value_or(0);
110
const
std::string &
name
= tl.second.get_child(
"name"
).data();
111
m_triggerLines
[fpga][clock].emplace_back(
name
,
112
tl.second.get_child(
"startbit"
).get_value<
unsigned
int
>(),
113
tl.second.get_child(
"nbits"
).get_value<
unsigned
int
>(),
114
flatindex, fpga, clock,
m_name
);
115
m_lineByName
[
name
] = &
m_triggerLines
[fpga][clock].back();
116
}
117
}
118
m_isLegacy
=
getAttribute<bool>
(
"legacy"
,
true
,
false
);
119
}
120
121
122
std::string
123
TrigConf::L1Connector::type
()
const
124
{
125
switch
(
m_type
) {
126
case
ConnectorType::ELECTRICAL
:
127
return
"electrical"
;
128
case
ConnectorType::OPTICAL
:
129
return
"optical"
;
130
case
ConnectorType::CTPIN
:
131
return
"ctpin"
;
132
default
:
133
return
""
;
134
}
135
}
136
137
TrigConf::L1Connector::ConnectorType
138
TrigConf::L1Connector::connectorType
()
const
139
{
140
return
m_type
;
141
}
142
143
std::size_t
144
TrigConf::L1Connector::size
()
const
145
{
146
size_t
nlines{0};
147
for
(
size_t
fpga = 0; fpga<
m_maxFpga
; ++fpga) {
148
for
(
size_t
clock = 0; clock<
m_maxClock
; ++clock) {
149
nlines +=
m_triggerLines
[fpga][clock].size();
150
}
151
}
152
return
nlines;
153
}
154
155
std::vector<std::string>
156
TrigConf::L1Connector::triggerLineNames
()
const
157
{
158
std::vector<std::string> tln{};
159
for
(
size_t
fpga = 0; fpga<
m_maxFpga
; ++fpga) {
160
for
(
size_t
clock = 0; clock<
m_maxClock
; ++clock) {
161
for
(
auto
& tl :
m_triggerLines
[fpga][clock] ) {
162
tln.emplace_back(tl.name());
163
}
164
}
165
}
166
return
tln;
167
}
168
169
const
std::vector<TrigConf::TriggerLine> &
170
TrigConf::L1Connector::triggerLines
(
unsigned
int
fpga,
unsigned
int
clock)
const
171
{
172
return
m_triggerLines
[fpga][clock];
173
}
174
175
bool
176
TrigConf::L1Connector::hasLine
(
const
std::string & lineName )
const
177
{
178
return
m_lineByName
.count(lineName);
179
}
180
181
const
TrigConf::TriggerLine
&
182
TrigConf::L1Connector::triggerLine
(
const
std::string & lineName )
const
183
{
184
return
*
m_lineByName
.at(lineName);
185
}
L1Connector.h
TrigConf::DataStructure::name
virtual const std::string & name() const final
Definition
DataStructure.cxx:108
TrigConf::DataStructure::data
const ptree & data() const
Access to the underlying data, if needed.
Definition
DataStructure.h:83
TrigConf::DataStructure::DataStructure
DataStructure()
Default constructor, leading to an uninitialized configuration object.
Definition
DataStructure.cxx:11
TrigConf::DataStructure::m_name
std::string m_name
Definition
DataStructure.h:259
TrigConf::DataStructure::getAttribute
T getAttribute(const std::string &key, bool ignoreIfMissing=false, const T &def=T()) const
Access to simple attribute.
Definition
DataStructure.h:152
TrigConf::DataStructure::hasChild
bool hasChild(const std::string &path) const
Check if child exists.
Definition
DataStructure.cxx:113
TrigConf::L1Connector::m_triggerLines
std::vector< TrigConf::TriggerLine > m_triggerLines[2][2]
Definition
L1Connector.h:109
TrigConf::L1Connector::m_maxFpga
std::size_t m_maxFpga
Definition
L1Connector.h:111
TrigConf::L1Connector::hasLine
bool hasLine(const std::string &lineName) const
Definition
L1Connector.cxx:176
TrigConf::L1Connector::ConnectorType
ConnectorType
Definition
L1Connector.h:49
TrigConf::L1Connector::ConnectorType::ELECTRICAL
@ ELECTRICAL
Definition
L1Connector.h:49
TrigConf::L1Connector::ConnectorType::CTPIN
@ CTPIN
Definition
L1Connector.h:49
TrigConf::L1Connector::ConnectorType::OPTICAL
@ OPTICAL
Definition
L1Connector.h:49
TrigConf::L1Connector::type
std::string type() const
Definition
L1Connector.cxx:123
TrigConf::L1Connector::connectorType
ConnectorType connectorType() const
Accessor to the connector type.
Definition
L1Connector.cxx:138
TrigConf::L1Connector::className
virtual std::string className() const override
A string that is the name of the class.
Definition
L1Connector.cxx:21
TrigConf::L1Connector::triggerLine
const TrigConf::TriggerLine & triggerLine(const std::string &lineName) const
Definition
L1Connector.cxx:182
TrigConf::L1Connector::triggerLines
const std::vector< TrigConf::TriggerLine > & triggerLines(unsigned int fpga=0, unsigned int clock=0) const
Accessor to the triggerlines on the connector.
Definition
L1Connector.cxx:170
TrigConf::L1Connector::m_isLegacy
bool m_isLegacy
Definition
L1Connector.h:114
TrigConf::L1Connector::size
std::size_t size() const
Accessor to the number of trigger lines.
Definition
L1Connector.cxx:144
TrigConf::L1Connector::m_type
ConnectorType m_type
Definition
L1Connector.h:108
TrigConf::L1Connector::m_lineByName
std::map< std::string, TrigConf::TriggerLine * > m_lineByName
Definition
L1Connector.h:110
TrigConf::L1Connector::update
virtual void update() override
Update the internal members.
Definition
L1Connector.cxx:26
TrigConf::L1Connector::m_maxClock
std::size_t m_maxClock
Definition
L1Connector.h:112
TrigConf::L1Connector::L1Connector
L1Connector()
Constructor.
Definition
L1Connector.cxx:10
TrigConf::L1Connector::triggerLineNames
std::vector< std::string > triggerLineNames() const
names of all trigger lines
Definition
L1Connector.cxx:156
TrigConf::TriggerLine
a TriggerLine entry describes the location of a threshold multiplicity on a cable (connector)
Definition
L1Connector.h:22
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0