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 for( auto & inp : getList("fixedParameters.inputs")) {
38 m_inputs.push_back(inp["value"]);
39 }
40 }
41 for( auto & o : getList("output")) {
42 m_outputs.push_back(o.getValue());
43 }
44 } else if( m_type == AlgorithmType::MULTIPLICITY ) { // MULTIPLICITY algo
45
46 if(auto & input = getAttribute("input"); input!="null") {
47 m_inputs.push_back(input);
48 }
49 if(hasAttribute("flavour")){ // EnergyThreshold
50 m_parameters.emplace_back("flavour", TrigConf::XEFlavour::flavourStrToInt(getAttribute("flavour")));
51 }
52 m_outputs.push_back(getAttribute("output"));
53 } else { // SORTING algo
54 if( hasAttribute("input") ) {
55 m_inputs.push_back( getAttribute("input") );
56 } else if( hasChild("fixedParameters.input") ) { // backwards compatibility, to be removed when we stop using DEV db
57 auto inp = getObject("fixedParameters.input");
58 //exits on first iteration; increment is not reached
59 //coverity[UNREACHABLE]
60 for( auto & k : inp.getKeys() ) {
61 m_inputs.push_back(inp[k]);
62 break;
63 }
64 }
65 m_outputs.push_back(getAttribute("output"));
66 }
67
69 for( auto & p : getList("variableParameters") ) {
70 if (p["name"] == "MaxMSqr") {
71 unsigned int val = p.getAttribute<unsigned int>("value");
72 // Work around overflow in the database...
73 if (val >= 1u<<31) {
74 // Expected maximum value of Inv M^2 in 100 MeV unit
75 val = 1024*1024*10*10*10;
76 }
77 m_parameters.emplace_back(p["name"], val, p.getAttribute_optional<unsigned int>("selection"));
78 }
79 else {
80 m_parameters.emplace_back(p["name"], p.getAttribute<int>("value"), p.getAttribute_optional<unsigned int>("selection"));
81 }
82 }
83 }
84
85}
86
89{
90 return m_type;
91}
92
93const std::string &
98
99const std::string &
101{
102 if(hasAttribute("klass")) {
103 return getAttribute("klass");
104 }
105 return getAttribute("type");
106}
107
108const std::vector<std::string> &
110{
111 return m_inputs;
112}
113
114const std::vector<std::string> &
116{
117 return m_outputs;
118}
119
120std::vector<std::string>
122{
123 std::vector<std::string> out;
124 for( auto & s : m_outputs ) {
125 out.push_back(m_category + "_" + s);
126 }
127 return out;
128}
129
130std::string
131TrigConf::L1TopoAlgorithm::genericParameter(const std::string & parName) const
132{
133 return operator[]("fixedParameters.generics." + parName + ".value");
134}
135
138{
139 return getObject("fixedParameters.generics");
140}
141
142const std::vector<TrigConf::L1TopoAlgorithm::VariableParameter> &
147
148
149void
150TrigConf::L1TopoAlgorithm::print(std::ostream & os) const
151{
152 os << "Algorithm " << name() << " (class " << klass() << ", category " << m_category << ")" << std::endl;
153 os << " input:" << std::endl;
154 for( auto & input : inputs() ) {
155 os << " " << input << std::endl;
156 }
157 os << " output:" << std::endl;
158 for( auto & output : outputs() ) {
159 os << " " << output << std::endl;
160 }
161 os << " full output:" << std::endl;
162 for( auto & output : fullOutputs() ) {
163 os << " " << output << std::endl;
164 }
166 os << " threshold definition: " << getAttribute("threshold") << std::endl;
167 os << " number of output bits: " << getAttribute<unsigned int>("nbits") << std::endl;
168 } else {
169 os << " generic parameters:" << std::endl;
170 auto genPars = generics();
171 for( auto & k : genPars.getKeys() ) {
172 os << " " << k << " ==> " << genericParameter(k) << std::endl;
173 }
174 os << " parameters:" << std::endl;
175 auto pars = parameters();
176 unsigned int idx{0};
177 for( auto & p : pars ) {
178 os << " " << idx++ << " " << p.name() << "[" << p.selection() << "] ==> " << p.value() << std::endl;
179 }
180 }
181 os << std::endl;
182}
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)