ATLAS Offline Software
Loading...
Searching...
No Matches
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
7
8#include <iostream>
9#include <iomanip>
10#include <algorithm>
11
12using namespace std;
13using namespace TXC;
14
15namespace TXC {
16
17ostream&
18operator<<(ostream& o, const InputElement& ie) {
19 o << "name: " << ie.name << ", value: " << ie.value << ", pos: " << ie.position;
20 return o;
21}
22
23ostream& operator<<(ostream& o, const OutputElement& oe) {
24 o << "name: " << oe.name << ", value: " << oe.value << ", nbits: " << oe.nbits << ", outname: " << oe.outname << ", position: " << oe.position;
25 return o;
26}
27
28ostream&
29operator<<(ostream& o, const FixedParameter& ge) {
30 o << "name: " << ge.name << ", value: " << ge.value;
31 return o;
32}
33
34ostream&
35operator<<(ostream& o, const RegisterParameter& pe) {
36 o << "name: " << pe.name << ", value: " << pe.value << ", pos: " << pe.position << ", sel: " << pe.selection;
37 return o;
38}
39
40
41} // namespace TXC
42
43
47
48TXC::L1TopoConfigAlg::L1TopoConfigAlg(const string & name, const string & type) :
49 m_name(name),
51{}
52
53
55
56string
58 return type() + "/" + name();
59}
60
61
62vector<string>
64 vector<string> names;
65 for(auto & x : m_inputElements)
66 names.push_back(x.value);
67 return names;
68}
69
70vector<string>
72 vector<string> names;
73 for(auto & x : m_outputElements)
74 names.push_back( isSortAlg() ? x.value : x.outname );
75 return names;
76}
77
78
79
80void
81TXC::L1TopoConfigAlg::addInput(const string &name, const string &value, unsigned int position) {
82 m_inputElements.push_back( InputElement( name, value, position) );
83 std::sort( m_inputElements.begin(), m_inputElements.end(),[](const TXC::InputElement& i, const TXC::InputElement& i2){ return (i.position < i2.position);});
84}
85
86
87void TXC::L1TopoConfigAlg::addOutput(const string &name, const string &value, unsigned int bits, const string & outname, unsigned int position) {
88 m_outputElements.push_back(OutputElement( name, value, bits, outname, position));
89 std::sort( m_outputElements.begin(), m_outputElements.end(),[](const TXC::OutputElement& o, const TXC::OutputElement& o2){ return (o.position < o2.position);});
90}
91
92void TXC::L1TopoConfigAlg::addFixedParameter(const std::string &name, const std::string &value) {
93 m_fixedParameters.push_back(FixedParameter( name, value));
94}
95
96void TXC::L1TopoConfigAlg::addParameter(const std::string &name, const std::string &value, unsigned int position, unsigned int selection) {
97 m_variableParameters.push_back( RegisterParameter( name, value, position, selection));
98 std::sort(m_variableParameters.begin(),m_variableParameters.end(),[](const TXC::RegisterParameter& r, const TXC::RegisterParameter& r2){ return (r.position < r2.position);});
99}
100
101
102namespace TXC {
103
104std::ostream & operator<<(std::ostream &o, const L1TopoConfigAlg &alg) {
105
106 if(alg.isSortAlg()) {
107 o << "Sorting algorithm " << alg.algoID() << " : " << alg.type() << "/" << alg.name() << endl;
108 o << " Input : " << alg.m_inputElements[0].value << endl;
109 o << " Output : " << alg.m_outputElements[0].value << endl;
110 } else {
111 o << "Decision algorithm " << alg.algoID() << " : " << alg.type() << "/" << alg.name() << endl;
112 for(const TXC::InputElement& ie: alg.m_inputElements)
113 o << " Input " << ie.position << " : " << ie.value << endl;
114 for(const TXC::OutputElement& oe: alg.m_outputElements)
115 o << " Output " << oe.position << " : " << oe.outname << endl;
116 }
117 o << " Fixed paramters: " << alg.getFixedParameters().size() << endl;
118 for(const TXC::FixedParameter& ge: alg.m_fixedParameters)
119 o << " " << setw(15) << left << ge.name << " : " << ge.value << endl;
120 o << " Parameters: " << alg.getParameters().size() << endl;
121 for(const TXC::RegisterParameter& pe: alg.m_variableParameters)
122 o << " " << setw(15) << left << pe.name << " : " << pe.value << endl;
123 return o;
124}
125
126
127} // namespace TXC
#define x
void addFixedParameter(const std::string &name, const std::string &value)
const std::string & name() const
std::vector< TXC::FixedParameter > m_fixedParameters
std::vector< std::string > getOutputNames() const
void addOutput(const std::string &name, const std::string &value, unsigned int bits, const std::string &outname, unsigned int position)
void addInput(const std::string &name, const std::string &value, unsigned int position)
std::vector< TXC::InputElement > m_inputElements
std::string fullname() const
std::vector< TXC::RegisterParameter > m_variableParameters
std::vector< std::string > getInputNames() const
const std::string & type() const
L1TopoConfigAlg(const std::string &name, const std::string &type)
class L1TopoConfigAlg
std::vector< TXC::OutputElement > m_outputElements
void addParameter(const std::string &name, const std::string &value, unsigned int position, unsigned int selection)
const std::string selection
int r
Definition globals.cxx:22
std::ostream & operator<<(std::ostream &, const TXC::L1TopoConfigAlg &)
STL namespace.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
unsigned int position