ATLAS Offline Software
Loading...
Searching...
No Matches
L1TopoAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <map>
7
8TrigConf::L1TopoAlgorithm::L1TopoAlgorithm(const std::string & algoName, AlgorithmType algoType, const std::string & algoCategory, const boost::property_tree::ptree & data)
10 m_type(algoType),
11 m_category(algoCategory)
12{
13 if( m_category != "TOPO" && m_category != "MUTOPO" && m_category != "R2TOPO" && m_category != "MULTTOPO") {
14 throw std::runtime_error("Algorithm category must be TOPO, R2TOPO, MUTOPO or MULTTOPO, but is '" + algoCategory + "'");
15 }
16 m_name = algoName;
17 load();
18}
19
20std::string
22 return "L1TopoAlgorithm";
23}
24
25void
27{
28 if(! isInitialized() || empty() ) {
29 return;
30 }
31 if( m_type == AlgorithmType::DECISION ) { // DECISION algo
32 if( hasChild("input") ) {
33 for( auto & inp : getList("input")) {
34 m_inputs.push_back(inp.getValue());
35 }
36 } else if( hasChild("fixedParameters.inputs") ) { // backwards compatibility, to be removed when we stop using DEV db
37 const std::string valueStr{"value"};
38 for( auto & inp : getList("fixedParameters.inputs")) {
39 m_inputs.push_back(inp[valueStr]);
40 }
41 }
42 for( auto & o : getList("output")) {
43 m_outputs.push_back(o.getValue());
44 }
45 } else if( m_type == AlgorithmType::MULTIPLICITY ) { // MULTIPLICITY algo
46
47 if(auto & input = getAttribute("input"); input!="null") {
48 m_inputs.push_back(input);
49 }
50 if(hasAttribute("flavour")){ // EnergyThreshold
51 m_parameters.emplace_back("flavour", TrigConf::XEFlavour::flavourStrToInt(getAttribute("flavour")));
52 }
53 m_outputs.push_back(getAttribute("output"));
54 } else { // SORTING algo
55 if( hasAttribute("input") ) {
56 m_inputs.push_back( getAttribute("input") );
57 } else if( hasChild("fixedParameters.input") ) { // backwards compatibility, to be removed when we stop using DEV db
58 auto inp = getObject("fixedParameters.input");
59 //exits on first iteration; increment is not reached
60 //coverity[UNREACHABLE]
61 for( auto & k : inp.getKeys() ) {
62 m_inputs.push_back(inp[k]);
63 break;
64 }
65 }
66 m_outputs.push_back(getAttribute("output"));
67 }
68
70 for( auto & p : getList("variableParameters") ) {
71 if (p["name"] == "MaxMSqr") {
72 unsigned int val = p.getAttribute<unsigned int>("value");
73 // Work around overflow in the database...
74 if (val >= 1u<<31) {
75 // Expected maximum value of Inv M^2 in 100 MeV unit
76 val = 1024*1024*10*10*10;
77 }
78 m_parameters.emplace_back(p["name"], val, p.getAttribute_optional<unsigned int>("selection"));
79 }
80 else {
81 m_parameters.emplace_back(p["name"], p.getAttribute<int>("value"), p.getAttribute_optional<unsigned int>("selection"));
82 }
83 }
84 }
85
86}
87
90{
91 return m_type;
92}
93
94const std::string &
99
100const std::string &
102{
103 if(hasAttribute("klass")) {
104 return getAttribute("klass");
105 }
106 return getAttribute("type");
107}
108
109const std::vector<std::string> &
111{
112 return m_inputs;
113}
114
115const std::vector<std::string> &
117{
118 return m_outputs;
119}
120
121std::vector<std::string>
123{
124 std::vector<std::string> out;
125 for( auto & s : m_outputs ) {
126 out.push_back(m_category + "_" + s);
127 }
128 return out;
129}
130
131std::string
132TrigConf::L1TopoAlgorithm::genericParameter(const std::string & parName) const
133{
134 return operator[]("fixedParameters.generics." + parName + ".value");
135}
136
139{
140 return getObject("fixedParameters.generics");
141}
142
143const std::vector<TrigConf::L1TopoAlgorithm::VariableParameter> &
148
149
150void
151TrigConf::L1TopoAlgorithm::print(std::ostream & os) const
152{
153 os << "Algorithm " << name() << " (class " << klass() << ", category " << m_category << ")" << std::endl;
154 os << " input:" << std::endl;
155 for( auto & input : inputs() ) {
156 os << " " << input << std::endl;
157 }
158 os << " output:" << std::endl;
159 for( auto & output : outputs() ) {
160 os << " " << output << std::endl;
161 }
162 os << " full output:" << std::endl;
163 for( auto & output : fullOutputs() ) {
164 os << " " << output << std::endl;
165 }
167 os << " threshold definition: " << getAttribute("threshold") << std::endl;
168 os << " number of output bits: " << getAttribute<unsigned int>("nbits") << std::endl;
169 } else {
170 os << " generic parameters:" << std::endl;
171 auto genPars = generics();
172 for( auto & k : genPars.getKeys() ) {
173 os << " " << k << " ==> " << genericParameter(k) << std::endl;
174 }
175 os << " parameters:" << std::endl;
176 auto pars = parameters();
177 unsigned int idx{0};
178 for( auto & p : pars ) {
179 os << " " << idx++ << " " << p.name() << "[" << p.selection() << "] ==> " << p.value() << std::endl;
180 }
181 }
182 os << std::endl;
183}
static const Attributes_t empty
Base class for Trigger configuration data and wrapper around underlying representation.
virtual const std::string & name() const final
std::vector< DataStructure > getList(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to array structure.
const ptree & data() const
Access to the underlying data, if needed.
bool hasAttribute(const std::string &key) const
Check for attribute.
DataStructure()
Default constructor, leading to an uninitialized configuration object.
T getAttribute(const std::string &key, bool ignoreIfMissing=false, const T &def=T()) const
Access to simple attribute.
bool hasChild(const std::string &path) const
Check if child exists.
DataStructure getObject(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to configuration object.
std::string operator[](const std::string &key) const
Access to simple attribute.
virtual std::string className() const override
A string that is the name of the class.
L1TopoAlgorithm()=default
Constructor.
DataStructure generics() const
Accessors to generic parameters.
std::vector< std::string > fullOutputs() const
void print(std::ostream &os=std::cout) const override
print main info
std::string genericParameter(const std::string &parName) const
const std::vector< std::string > & inputs() const
Accessor to input collections Sorting and Multiplicity algorithms have only one input.
const std::vector< std::string > & outputs() const
Accessor to output collections Sorting and Multiplicity algorithms have only one output.
std::vector< VariableParameter > m_parameters
const std::vector< VariableParameter > & parameters() const
Accessor to register parameters which can change for each algorithm instance.
const std::string & category() const
void load()
Update the internal data after modification of the data object.
AlgorithmType type() const
std::vector< std::string > m_inputs
std::vector< std::string > m_outputs
const std::string & klass() const
Accessor to algorithm class type.
static unsigned int flavourStrToInt(const std::string &flavStr)