ATLAS Offline Software
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 
12 using namespace std;
13 using namespace TXC;
14 
15 namespace TXC {
16 
17 ostream&
18 operator<<(ostream& o, const InputElement& ie) {
19  o << "name: " << ie.name << ", value: " << ie.value << ", pos: " << ie.position;
20  return o;
21 }
22 
23 ostream& 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 
28 ostream&
29 operator<<(ostream& o, const FixedParameter& ge) {
30  o << "name: " << ge.name << ", value: " << ge.value;
31  return o;
32 }
33 
34 ostream&
35 operator<<(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 
48 TXC::L1TopoConfigAlg::L1TopoConfigAlg(const string & name, const string & type) :
49  m_name(name),
50  m_type(type)
51 {}
52 
53 
55 
56 string
58  return type() + "/" + name();
59 }
60 
61 
62 vector<string>
64  vector<string> names;
65  for(auto & x : m_inputElements)
66  names.push_back(x.value);
67  return names;
68 }
69 
70 vector<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 
80 void
81 TXC::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 
87 void 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 
92 void TXC::L1TopoConfigAlg::addFixedParameter(const std::string &name, const std::string &value) {
93  m_fixedParameters.push_back(FixedParameter( name, value));
94 }
95 
96 void 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 
102 namespace TXC {
103 
104 std::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
beamspotman.r
def r
Definition: beamspotman.py:676
TXC::operator<<
std::ostream & operator<<(std::ostream &, const TXC::L1TopoConfigAlg &)
Definition: L1TopoConfigAlg.cxx:104
TXC::L1TopoConfigAlg::m_outputElements
std::vector< TXC::OutputElement > m_outputElements
Definition: L1TopoConfigAlg.h:124
L1TopoConfigAlg.h
TXC::L1TopoConfigAlg::getOutputNames
std::vector< std::string > getOutputNames() const
Definition: L1TopoConfigAlg.cxx:71
SGout2dot.alg
alg
Definition: SGout2dot.py:243
TXC::FixedParameter::name
std::string name
Definition: L1TopoConfigAlg.h:41
TXC::OutputElement::value
std::string value
Definition: L1TopoConfigAlg.h:32
athena.value
value
Definition: athena.py:124
x
#define x
LArG4AODNtuplePlotter.pe
pe
Definition: LArG4AODNtuplePlotter.py:116
TXC::L1TopoConfigAlg::addParameter
void addParameter(const std::string &name, const std::string &value, unsigned int position, unsigned int selection)
Definition: L1TopoConfigAlg.cxx:96
PlotCalibFromCool.ie
ie
Definition: PlotCalibFromCool.py:420
TXC::L1TopoConfigAlg::getInputNames
std::vector< std::string > getInputNames() const
Definition: L1TopoConfigAlg.cxx:63
TXC::L1TopoConfigAlg::isSortAlg
bool isSortAlg() const
Definition: L1TopoConfigAlg.h:78
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
lumiFormat.i
int i
Definition: lumiFormat.py:85
TXC::OutputElement::outname
std::string outname
Definition: L1TopoConfigAlg.h:34
python.subdetectors.mmg.names
names
Definition: mmg.py:8
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:87
TXC::OutputElement::name
std::string name
Definition: L1TopoConfigAlg.h:31
TXC::OutputElement::nbits
unsigned int nbits
Definition: L1TopoConfigAlg.h:33
selection
std::string selection
Definition: fbtTestBasics.cxx:75
TXC::L1TopoConfigAlg::L1TopoConfigAlg
L1TopoConfigAlg()
Definition: L1TopoConfigAlg.h:111
TXC
Definition: IL1TopoMenuLoader.h:10
beamspotman.outname
outname
Definition: beamspotman.py:414
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TXC::L1TopoConfigAlg::addInput
void addInput(const std::string &name, const std::string &value, unsigned int position)
Definition: L1TopoConfigAlg.cxx:81
TXC::InputElement
Definition: L1TopoConfigAlg.h:20
TXC::RegisterParameter
Definition: L1TopoConfigAlg.h:45
operator<<
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
Definition: TestGaudiProperty.cxx:69
python.changerun.o2
o2
Definition: changerun.py:45
TXC::L1TopoConfigAlg
Definition: L1TopoConfigAlg.h:56
TXC::L1TopoConfigAlg::~L1TopoConfigAlg
virtual ~L1TopoConfigAlg()
Definition: L1TopoConfigAlg.cxx:54
TXC::OutputElement::position
unsigned int position
Definition: L1TopoConfigAlg.h:35
TXC::L1TopoConfigAlg::fullname
std::string fullname() const
Definition: L1TopoConfigAlg.cxx:57
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TXC::FixedParameter
Definition: L1TopoConfigAlg.h:38
TXC::L1TopoConfigAlg::addFixedParameter
void addFixedParameter(const std::string &name, const std::string &value)
Definition: L1TopoConfigAlg.cxx:92
TXC::FixedParameter::value
std::string value
Definition: L1TopoConfigAlg.h:42
TXC::L1TopoConfigAlg::m_inputElements
std::vector< TXC::InputElement > m_inputElements
Definition: L1TopoConfigAlg.h:123
Exception.h
TXC::OutputElement
Definition: L1TopoConfigAlg.h:28