ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoConfig
Root
L1TopoConfigAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
L1TopoConfig/L1TopoConfigAlg.h
"
6
#include "
L1TopoCommon/Exception.h
"
7
8
#include <iostream>
9
#include <iomanip>
10
#include <algorithm>
11
12
using namespace
std
;
13
using namespace
TXC
;
14
15
namespace
{
16
struct
ios_state_guard {
17
std::ostream& os;
18
std::ios::fmtflags flags;
19
char
fill;
20
std::streamsize width;
21
22
explicit
ios_state_guard(std::ostream& o)
23
: os(o), flags(o.flags()), fill(o.fill()), width(o.width()) {}
24
25
~ios_state_guard() {
26
os.flags(flags);
27
os.fill(fill);
28
os.width(width);
29
}
30
};
31
}
32
33
34
namespace
TXC
{
35
36
ostream&
37
operator<<
(ostream& o,
const
InputElement
& ie) {
38
o <<
"name: "
<< ie.name <<
", value: "
<< ie.value <<
", pos: "
<< ie.position;
39
return
o;
40
}
41
42
ostream&
operator<<
(ostream& o,
const
OutputElement
& oe) {
43
o <<
"name: "
<< oe.
name
<<
", value: "
<< oe.
value
<<
", nbits: "
<< oe.
nbits
<<
", outname: "
<< oe.
outname
<<
", position: "
<< oe.
position
;
44
return
o;
45
}
46
47
ostream&
48
operator<<
(ostream& o,
const
FixedParameter
& ge) {
49
o <<
"name: "
<< ge.
name
<<
", value: "
<< ge.
value
;
50
return
o;
51
}
52
53
ostream&
54
operator<<
(ostream& o,
const
RegisterParameter
& pe) {
55
o <<
"name: "
<< pe.name <<
", value: "
<< pe.value <<
", pos: "
<< pe.position <<
", sel: "
<< pe.selection;
56
return
o;
57
}
58
59
60
}
// namespace TXC
61
62
66
67
TXC::L1TopoConfigAlg::L1TopoConfigAlg
(
const
string
&
name
,
const
string
&
type
) :
68
m_name
(
name
),
69
m_type
(
type
)
70
{}
71
72
73
TXC::L1TopoConfigAlg::~L1TopoConfigAlg
() {}
74
75
string
76
TXC::L1TopoConfigAlg::fullname
()
const
{
77
return
type
() +
"/"
+
name
();
78
}
79
80
81
vector<string>
82
L1TopoConfigAlg::getInputNames
()
const
{
83
vector<string> names;
84
for
(
auto
&
x
:
m_inputElements
)
85
names.push_back(
x
.value);
86
return
names;
87
}
88
89
vector<string>
90
L1TopoConfigAlg::getOutputNames
()
const
{
91
vector<string> names;
92
for
(
auto
&
x
:
m_outputElements
)
93
names.push_back(
isSortAlg
() ?
x
.value :
x
.outname );
94
return
names;
95
}
96
97
98
99
void
100
TXC::L1TopoConfigAlg::addInput
(
const
string
&
name
,
const
string
&value,
unsigned
int
position) {
101
m_inputElements
.push_back(
InputElement
(
name
, value, position) );
102
std::sort
(
m_inputElements
.begin(),
m_inputElements
.end(),[](
const
TXC::InputElement
& i,
const
TXC::InputElement
& i2){ return (i.position < i2.position);});
103
}
104
105
106
void
TXC::L1TopoConfigAlg::addOutput
(
const
string
&
name
,
const
string
&value,
unsigned
int
bits,
const
string
& outname,
unsigned
int
position) {
107
m_outputElements
.push_back(
OutputElement
(
name
, value, bits, outname, position));
108
std::sort
(
m_outputElements
.begin(),
m_outputElements
.end(),[](
const
TXC::OutputElement
& o,
const
TXC::OutputElement
& o2){ return (o.position < o2.position);});
109
}
110
111
void
TXC::L1TopoConfigAlg::addFixedParameter
(
const
std::string &
name
,
const
std::string &value) {
112
m_fixedParameters
.push_back(
FixedParameter
(
name
, value));
113
}
114
115
void
TXC::L1TopoConfigAlg::addParameter
(
const
std::string &
name
,
const
std::string &value,
unsigned
int
position,
unsigned
int
selection
) {
116
m_variableParameters
.push_back(
RegisterParameter
(
name
, value, position,
selection
));
117
std::sort
(
m_variableParameters
.begin(),
m_variableParameters
.end(),[](
const
TXC::RegisterParameter
&
r
,
const
TXC::RegisterParameter
& r2){ return (r.position < r2.position);});
118
}
119
120
121
namespace
TXC
{
122
123
std::ostream &
operator<<
(std::ostream &o,
const
L1TopoConfigAlg
&alg) {
124
ios_state_guard guard{o};
125
if
(alg.isSortAlg()) {
126
o <<
"Sorting algorithm "
<< alg.algoID() <<
" : "
<< alg.type() <<
"/"
<< alg.name() << endl;
127
o <<
" Input : "
<< alg.m_inputElements[0].value << endl;
128
o <<
" Output : "
<< alg.m_outputElements[0].value << endl;
129
}
else
{
130
o <<
"Decision algorithm "
<< alg.algoID() <<
" : "
<< alg.type() <<
"/"
<< alg.name() << endl;
131
for
(
const
TXC::InputElement
& ie: alg.m_inputElements)
132
o <<
" Input "
<< ie.position <<
" : "
<< ie.value << endl;
133
for
(
const
TXC::OutputElement
& oe: alg.m_outputElements)
134
o <<
" Output "
<< oe.
position
<<
" : "
<< oe.
outname
<< endl;
135
}
136
o <<
" Fixed paramters: "
<< alg.getFixedParameters().size() << endl;
137
for
(
const
TXC::FixedParameter
& ge: alg.m_fixedParameters)
138
o <<
" "
<< setw(15) << left << ge.
name
<<
" : "
<< ge.
value
<< endl;
139
o <<
" Parameters: "
<< alg.getParameters().size() << endl;
140
for
(
const
TXC::RegisterParameter
& pe: alg.m_variableParameters)
141
o <<
" "
<< setw(15) << left << pe.name <<
" : "
<< pe.value << endl;
142
return
o;
143
}
144
145
146
}
// namespace TXC
L1TopoConfigAlg.h
Exception.h
x
#define x
TXC::L1TopoConfigAlg::~L1TopoConfigAlg
virtual ~L1TopoConfigAlg()
Definition
L1TopoConfigAlg.cxx:73
TXC::L1TopoConfigAlg::addFixedParameter
void addFixedParameter(const std::string &name, const std::string &value)
Definition
L1TopoConfigAlg.cxx:111
TXC::L1TopoConfigAlg::name
const std::string & name() const
Definition
L1TopoConfigAlg.h:72
TXC::L1TopoConfigAlg::m_fixedParameters
std::vector< TXC::FixedParameter > m_fixedParameters
Definition
L1TopoConfigAlg.h:125
TXC::L1TopoConfigAlg::isSortAlg
bool isSortAlg() const
Definition
L1TopoConfigAlg.h:78
TXC::L1TopoConfigAlg::getOutputNames
std::vector< std::string > getOutputNames() const
Definition
L1TopoConfigAlg.cxx:90
TXC::L1TopoConfigAlg::L1TopoConfigAlg
L1TopoConfigAlg()
Definition
L1TopoConfigAlg.h:111
TXC::L1TopoConfigAlg::addOutput
void addOutput(const std::string &name, const std::string &value, unsigned int bits, const std::string &outname, unsigned int position)
Definition
L1TopoConfigAlg.cxx:106
TXC::L1TopoConfigAlg::addInput
void addInput(const std::string &name, const std::string &value, unsigned int position)
Definition
L1TopoConfigAlg.cxx:100
TXC::L1TopoConfigAlg::m_inputElements
std::vector< TXC::InputElement > m_inputElements
Definition
L1TopoConfigAlg.h:123
TXC::L1TopoConfigAlg::fullname
std::string fullname() const
Definition
L1TopoConfigAlg.cxx:76
TXC::L1TopoConfigAlg::m_variableParameters
std::vector< TXC::RegisterParameter > m_variableParameters
Definition
L1TopoConfigAlg.h:126
TXC::L1TopoConfigAlg::m_type
std::string m_type
Definition
L1TopoConfigAlg.h:117
TXC::L1TopoConfigAlg::getInputNames
std::vector< std::string > getInputNames() const
Definition
L1TopoConfigAlg.cxx:82
TXC::L1TopoConfigAlg::type
const std::string & type() const
Definition
L1TopoConfigAlg.h:76
TXC::L1TopoConfigAlg::L1TopoConfigAlg
L1TopoConfigAlg(const std::string &name, const std::string &type)
class L1TopoConfigAlg
Definition
L1TopoConfigAlg.cxx:67
TXC::L1TopoConfigAlg::m_name
std::string m_name
Definition
L1TopoConfigAlg.h:116
TXC::L1TopoConfigAlg::m_outputElements
std::vector< TXC::OutputElement > m_outputElements
Definition
L1TopoConfigAlg.h:124
TXC::L1TopoConfigAlg::addParameter
void addParameter(const std::string &name, const std::string &value, unsigned int position, unsigned int selection)
Definition
L1TopoConfigAlg.cxx:115
selection
const std::string selection
Definition
fbtTestBasics.cxx:75
r
int r
Definition
globals.cxx:22
TXC
Definition
Run2toRun3ConvertersL1.h:5
TXC::operator<<
std::ostream & operator<<(std::ostream &, const TXC::L1TopoConfigAlg &)
Definition
L1TopoConfigAlg.cxx:123
std
STL namespace.
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
TXC::FixedParameter
Definition
L1TopoConfigAlg.h:38
TXC::FixedParameter::name
std::string name
Definition
L1TopoConfigAlg.h:41
TXC::FixedParameter::value
std::string value
Definition
L1TopoConfigAlg.h:42
TXC::InputElement
Definition
L1TopoConfigAlg.h:20
TXC::OutputElement
Definition
L1TopoConfigAlg.h:28
TXC::OutputElement::position
unsigned int position
Definition
L1TopoConfigAlg.h:35
TXC::OutputElement::name
std::string name
Definition
L1TopoConfigAlg.h:31
TXC::OutputElement::outname
std::string outname
Definition
L1TopoConfigAlg.h:34
TXC::OutputElement::nbits
unsigned int nbits
Definition
L1TopoConfigAlg.h:33
TXC::OutputElement::value
std::string value
Definition
L1TopoConfigAlg.h:32
TXC::RegisterParameter
Definition
L1TopoConfigAlg.h:45
Generated on
for ATLAS Offline Software by
1.17.0