ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConf::L1TopoAlgorithm Class Referencefinal

L1Topo algorithm configuration. More...

#include <L1TopoAlgorithm.h>

Inheritance diagram for TrigConf::L1TopoAlgorithm:
Collaboration diagram for TrigConf::L1TopoAlgorithm:

Classes

struct  VariableParameter

Public Types

enum class  AlgorithmType { SORTING , DECISION , MULTIPLICITY , UNKNOWN }
using ptree = boost::property_tree::ptree

Public Member Functions

 L1TopoAlgorithm ()=default
 Constructor.
 L1TopoAlgorithm (const L1TopoAlgorithm &)=delete
L1TopoAlgorithmoperator= (const L1TopoAlgorithm &)=delete
 L1TopoAlgorithm (L1TopoAlgorithm &&)=default
 L1TopoAlgorithm (const std::string &algoName, AlgorithmType algoType, const std::string &algoCategory, const ptree &data)
 Constructor initialized with configuration data.
virtual ~L1TopoAlgorithm () override=default
 Destructor.
virtual std::string className () const override
 A string that is the name of the class.
AlgorithmType type () const
const std::string & category () const
const std::string & klass () const
 Accessor to algorithm class type.
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< std::string > fullOutputs () const
DataStructure generics () const
 Accessors to generic parameters.
std::string genericParameter (const std::string &parName) const
template<class T>
genericParameter (const std::string &parName) const
const std::vector< VariableParameter > & parameters () const
 Accessor to register parameters which can change for each algorithm instance.
void print (std::ostream &os=std::cout) const override
 print main info
void setData (const ptree &data)
 Setting the configuration data.
void setData (ptree &&data)
void setName (const std::string &n)
 Setting the configuration element name.
virtual const std::string & name () const final
virtual void clear ()
 Clearing the configuration data.
const ptreedata () const
 Access to the underlying data, if needed.
bool isValue () const
 Check for attribute.
std::string getValue () const
 Access to simple content.
template<class T>
getValue () const
template<class T>
std::optional< T > getValue_optional () const
 access to content of the note Will return false if the value could not be converted into T
bool hasAttribute (const std::string &key) const
 Check for attribute.
bool isNull (const std::string &key) const
 Check if an attribute is null.
bool hasChild (const std::string &path) const
 Check if child exists.
std::string operator[] (const std::string &key) const
 Access to simple attribute.
template<class T>
getAttribute (const std::string &key, bool ignoreIfMissing=false, const T &def=T()) const
 Access to simple attribute.
const std::string & getAttribute (const std::string &key, bool ignoreIfMissing=false, const std::string &def="") const
template<class T>
std::optional< T > getAttribute_optional (const std::string &key) const
std::vector< DataStructuregetList (const std::string &pathToChild, bool ignoreIfMissing=false) const
 Access to array structure.
std::optional< std::vector< DataStructure > > getList_optional (const std::string &pathToChild) const
DataStructure getObject (const std::string &pathToChild, bool ignoreIfMissing=false) const
 Access to configuration object.
std::optional< TrigConf::DataStructuregetObject_optional (const std::string &pathToChild) const
std::vector< std::string > getKeys () const
 Access to the keys of an DataStructure which presents a dictionary.
 operator bool () const
 Access to initialized state.
bool isValid () const
bool isInitialized () const
bool empty () const
 Check if children exist.
void printRaw (std::ostream &os=std::cout) const
bool ownsData () const

Static Public Member Functions

static void printElement (const std::string &key, const ptree &data, uint level=0, std::ostream &os=std::cout)
 Static function to print a ptree object.

Protected Member Functions

virtual void update () override
 Update the internal data after modification of the data object.

Protected Attributes

bool m_initialized { false }
 if initialized, the underlying ptree is has been assigned to (can be empty)
std::shared_ptr< ptreem_dataSPtr { nullptr }
const ptreem_dataPtr { nullptr }
std::string m_name {""}

Private Member Functions

void load ()
 Update the internal data after modification of the data object.

Private Attributes

AlgorithmType m_type { AlgorithmType::UNKNOWN }
std::string m_category {}
std::vector< std::string > m_inputs {}
std::vector< std::string > m_outputs {}
std::vector< VariableParameterm_parameters

Detailed Description

L1Topo algorithm configuration.

Provides access to the L1Topo algorithm name and type and the selection parameters, input and output collections. Can hold sorting and decision algorithms

Definition at line 20 of file L1TopoAlgorithm.h.

Member Typedef Documentation

◆ ptree

using TrigConf::DataStructure::ptree = boost::property_tree::ptree
inherited

Definition at line 40 of file DataStructure.h.

Member Enumeration Documentation

◆ AlgorithmType

Enumerator
SORTING 
DECISION 
MULTIPLICITY 
UNKNOWN 

Definition at line 23 of file L1TopoAlgorithm.h.

23{ SORTING, DECISION, MULTIPLICITY, UNKNOWN };

Constructor & Destructor Documentation

◆ L1TopoAlgorithm() [1/4]

TrigConf::L1TopoAlgorithm::L1TopoAlgorithm ( )
default

Constructor.

◆ L1TopoAlgorithm() [2/4]

TrigConf::L1TopoAlgorithm::L1TopoAlgorithm ( const L1TopoAlgorithm & )
delete

◆ L1TopoAlgorithm() [3/4]

TrigConf::L1TopoAlgorithm::L1TopoAlgorithm ( L1TopoAlgorithm && )
default

◆ L1TopoAlgorithm() [4/4]

TrigConf::L1TopoAlgorithm::L1TopoAlgorithm ( const std::string & algoName,
AlgorithmType algoType,
const std::string & algoCategory,
const ptree & data )

Constructor initialized with configuration data.

Parameters
dataThe data containing the L1Topo menu

Definition at line 8 of file L1TopoAlgorithm.cxx.

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}
const ptree & data() const
Access to the underlying data, if needed.
DataStructure()
Default constructor, leading to an uninitialized configuration object.
void load()
Update the internal data after modification of the data object.

◆ ~L1TopoAlgorithm()

virtual TrigConf::L1TopoAlgorithm::~L1TopoAlgorithm ( )
overridevirtualdefault

Destructor.

Member Function Documentation

◆ category()

const std::string & TrigConf::L1TopoAlgorithm::category ( ) const

Definition at line 92 of file L1TopoAlgorithm.cxx.

93{
94 return m_category;
95}

◆ className()

std::string TrigConf::L1TopoAlgorithm::className ( ) const
overridevirtual

A string that is the name of the class.

Reimplemented from TrigConf::DataStructure.

Definition at line 21 of file L1TopoAlgorithm.cxx.

21 {
22 return "L1TopoAlgorithm";
23}

◆ clear()

void TrigConf::DataStructure::clear ( )
virtualinherited

Clearing the configuration data.

should be overloaded by derived object that have to clear data

leads to an uninitialized object

Reimplemented in L1BunchGroupSet, TrigConf::HLTMenu, TrigConf::HLTMonitoring, TrigConf::HLTPrescalesSet, TrigConf::L1BunchGroupSet, TrigConf::L1CTP, TrigConf::L1Menu, and TrigConf::L1PrescalesSet.

Definition at line 65 of file DataStructure.cxx.

66{
67 m_initialized = false;
68 m_dataSPtr = nullptr;
69 m_dataPtr = nullptr;
70}
std::shared_ptr< ptree > m_dataSPtr
bool m_initialized
if initialized, the underlying ptree is has been assigned to (can be empty)

◆ data()

const ptree & TrigConf::DataStructure::data ( ) const
inlineinherited

Access to the underlying data, if needed.

Definition at line 83 of file DataStructure.h.

83 {
84 if( ! isInitialized() ) {
85 throw std::runtime_error("Trying to access data of uninitialized object of type " + className());
86 }
87 // Don't use ?: operator here: it confuses cppcheck.
88 if (ownsData()) {
89 return *m_dataSPtr.get();
90 }
91 return *m_dataPtr;
92 }
virtual std::string className() const
A string that is the name of the class.

◆ empty()

bool TrigConf::DataStructure::empty ( ) const
inlineinherited

Check if children exist.

Definition at line 219 of file DataStructure.h.

219{ return data().empty(); }

◆ fullOutputs()

std::vector< std::string > TrigConf::L1TopoAlgorithm::fullOutputs ( ) const

Definition at line 119 of file L1TopoAlgorithm.cxx.

120{
121 std::vector<std::string> out;
122 for( auto & s : m_outputs ) {
123 out.push_back(m_category + "_" + s);
124 }
125 return out;
126}
std::vector< std::string > m_outputs

◆ genericParameter() [1/2]

std::string TrigConf::L1TopoAlgorithm::genericParameter ( const std::string & parName) const

Definition at line 129 of file L1TopoAlgorithm.cxx.

130{
131 return operator[]("fixedParameters.generics." + parName + ".value");
132}
std::string operator[](const std::string &key) const
Access to simple attribute.

◆ genericParameter() [2/2]

template<class T>
T TrigConf::L1TopoAlgorithm::genericParameter ( const std::string & parName) const
inline

Definition at line 80 of file L1TopoAlgorithm.h.

80 {
81 return getAttribute<T>("fixedParameters.generics." + parName + ".value");
82 }
T getAttribute(const std::string &key, bool ignoreIfMissing=false, const T &def=T()) const
Access to simple attribute.

◆ generics()

TrigConf::DataStructure TrigConf::L1TopoAlgorithm::generics ( ) const

Accessors to generic parameters.

Definition at line 135 of file L1TopoAlgorithm.cxx.

136{
137 return getObject("fixedParameters.generics");
138}
DataStructure getObject(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to configuration object.

◆ getAttribute() [1/2]

const std::string & TrigConf::DataStructure::getAttribute ( const std::string & key,
bool ignoreIfMissing = false,
const std::string & def = "" ) const
inherited

Definition at line 135 of file DataStructure.cxx.

136{
137 const auto & obj = data().get_child_optional(key);
138 if( !obj ) {
139 if( ignoreIfMissing ) {
140 return def;
141 } else {
142 throw std::runtime_error(className() + "#" + name() + ": structure '" + key + "' does not exist" );
143 }
144 }
145 // check if the key points to a plain string value
146 if ( !obj.get().empty() ) {
147 if ( obj.get().front().first.empty() ) {
148 throw std::runtime_error(className() + "#" + name() + ": structure '" + key + "' is not a simple attribute but a list [], it needs to be accessed via getList(\"" + key + "\") -> vector<DataStructure>");
149 } else {
150 throw std::runtime_error(className() + "#" + name() + ": structure '" + key + "' is not a simple attribute but an object {}, it needs to be accessed via getObject(\"" + key + "\") -> DataStructure");
151 }
152 }
153 return obj.get().data();
154}
virtual const std::string & name() const final

◆ getAttribute() [2/2]

template<class T>
T TrigConf::DataStructure::getAttribute ( const std::string & key,
bool ignoreIfMissing = false,
const T & def = T() ) const
inlineinherited

Access to simple attribute.

Parameters
keyThe path to the attribute name, relative to the current one in form "path.to.child"
ignoreIfMissingControls the behavior in case of missing configuration child

Definition at line 152 of file DataStructure.h.

152 {
153 const auto & obj = data().get_child_optional(key);
154 if( !obj ) {
155 if( ignoreIfMissing ) {
156 return def;
157 } else {
158 throw std::runtime_error(className() + "#" + name() + ": structure '" + key + "' does not exist" );
159 }
160 }
161 return obj.get().get_value<T>();
162 }
unsigned long long T

◆ getAttribute_optional()

template<class T>
std::optional< T > TrigConf::DataStructure::getAttribute_optional ( const std::string & key) const
inlineinherited

Definition at line 165 of file DataStructure.h.

165 {
166 const auto & obj = data().get_child_optional(key);
167 if( ! obj ) {
168 return std::nullopt;
169 }
170 auto v = obj.get().get_value_optional<T>();
171 return v ? std::optional(std::move(*v)) : std::nullopt;
172 }

◆ getKeys()

std::vector< std::string > TrigConf::DataStructure::getKeys ( ) const
inherited

Access to the keys of an DataStructure which presents a dictionary.

In case the DataStructure is a list or a simple attribute, an empty vector is returned

Definition at line 249 of file DataStructure.cxx.

250{
251 std::vector<std::string> keys;
252 if ( ! data().empty() &&
253 ! data().front().first.empty() )
254 {
255 keys.reserve(data().size());
256 for( auto & entry : data() ) {
257 keys.push_back(entry.first);
258 }
259 }
260 return keys;
261}
bool empty() const
Check if children exist.
bool first
Definition DeMoScan.py:534

◆ getList()

std::vector< TrigConf::DataStructure > TrigConf::DataStructure::getList ( const std::string & pathToChild,
bool ignoreIfMissing = false ) const
inherited

Access to array structure.

Parameters
pathToChildThe path to the configuration child, relative to the current one in form "path.to.child"
ignoreIfMissingControls the behavior in case of missing configuration child

In case the child is missing and ignoreIfMissing is set to true, and empty vector will be returned. Otherwise a runtime exception will be thrown.

Definition at line 157 of file DataStructure.cxx.

158{
159 std::vector<TrigConf::DataStructure> childList;
160 const auto & list = data().get_child_optional(pathToChild);
161 if( ! list ) {
162 if ( ignoreIfMissing ) {
163 return childList;
164 } else {
165 throw std::runtime_error(className() + "#" + name() + ": structure '" + pathToChild + "' does not exist.");
166 }
167 }
168
169 // check if the pathToChild points to a list
170
171 // this check is not complete, because boost::ptree can not
172 // distinguish between and empty list and an empty string. In both cases
173 // the value is empty and there are no children
174
175 if ( list.get().empty() ) {
176 if ( list.get().get_value<std::string>() != "" ) {
177 // if the value is not empty, then it is for sure an attribute ("key" : "value")
178 throw std::runtime_error(className() + "#" + name() + ": structure '" + pathToChild + "' is not a list [] but a simple attribute, it needs to be accessed via [\"" + pathToChild + "\"] -> string");
179 }
180 // else: if the value is empty, we can not say for sure and will not
181 // give this debugging hint (an empty list will be returned
182 } else if ( ! list.get().front().first.empty() ) {
183 throw std::runtime_error(className() + "#" + name() + ": structure '" + pathToChild + "' is not a list [] but an object {}, it needs to be accessed via getObject(\"" + pathToChild + "\") -> DataStructure");
184 }
185
186 childList.reserve(list.get().size());
187
188 for( auto & childData : list.get() )
189 childList.emplace_back( childData.second );
190
191 return childList;
192}
list(name, path='/')
Definition histSizes.py:38

◆ getList_optional()

std::optional< std::vector< TrigConf::DataStructure > > TrigConf::DataStructure::getList_optional ( const std::string & pathToChild) const
inherited

Definition at line 196 of file DataStructure.cxx.

197{
198 if(data().find(pathToChild) == data().not_found()) {
199 return std::nullopt;
200 }
201 return std::optional<std::vector<TrigConf::DataStructure> >(getList(pathToChild));
202}
std::vector< DataStructure > getList(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to array structure.
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138

◆ getObject()

TrigConf::DataStructure TrigConf::DataStructure::getObject ( const std::string & pathToChild,
bool ignoreIfMissing = false ) const
inherited

Access to configuration object.

Parameters
pathToChildThe path to the configuration child, relative to the current one
ignoreIfMissingControls the behavior in case of missing configuration child

In case the child is missing and ignoreIfMissing is set to true, an uninitialized DataStructure will be returned. Otherwise a runtime exception will be thrown.

*bool ignoreIfMissing = true;
*if( const DataStructure & child = ds.getObject("path.to.child", ignoreIfMissing) ) {
cout << child["key"] << endl;
}

Definition at line 206 of file DataStructure.cxx.

207{
208 const auto & obj = data().get_child_optional(pathToChild);
209 if( ! obj ) {
210 if ( ignoreIfMissing ) {
211 return DataStructure();
212 } else {
213 throw std::runtime_error(className() + "#" + name() + ": structure '" + pathToChild + "' does not exist.");
214 }
215 }
216 // check if the pathToChild is an attribute
217 if( obj.get().get_value<std::string>() != "" ) {
218 throw std::runtime_error(className() + "#" + name() + ": structure '" + pathToChild + "' is not an object {} but a simple attribute, it needs to be accessed via [\"" + pathToChild + "\"] -> string");
219 }
220 // check if the pathToChild points to a list
221 if ( obj.get().front().first.empty() ) {
222 throw std::runtime_error(className() + "#" + name() + ": structure '" + pathToChild + "' is not an object {} but a list [], it needs to be accessed via getList(\"" + pathToChild + "\") -> vector<DataStructure>");
223 }
224 return { obj.get() };
225}

◆ getObject_optional()

std::optional< TrigConf::DataStructure > TrigConf::DataStructure::getObject_optional ( const std::string & pathToChild) const
inherited

Definition at line 229 of file DataStructure.cxx.

230{
231
232 if(const auto & obj = data().get_child_optional(pathToChild)) {
233 // check if the pathToChild is an attribute
234 if( obj.get().get_value<std::string>() != "" ) {
235 throw std::runtime_error(className() + "#" + name() + ": structure '" + pathToChild + "' is not an object {} but a simple attribute, it needs to be accessed via [\"" + pathToChild + "\"] -> string");
236 }
237 // check if the pathToChild points to a list
238 if ( obj.get().front().first.empty() ) {
239 throw std::runtime_error(className() + "#" + name() + ": structure '" + pathToChild + "' is not an object {} but a list [], it needs to be accessed via getList(\"" + pathToChild + "\") -> vector<DataStructure>");
240 }
241 return std::optional<TrigConf::DataStructure>(obj.get());
242 }
243 return std::nullopt;
244}

◆ getValue() [1/2]

std::string TrigConf::DataStructure::getValue ( ) const
inherited

Access to simple content.

Returns
string that is the content of the structure

For instance when the json structure contains an array of values (ptree only works with strings) which one retrieved via getList, then the values in the vector<DataStructure> can be accessed using getValue

Definition at line 80 of file DataStructure.cxx.

80 {
81 return data().get_value<std::string>();
82}

◆ getValue() [2/2]

template<class T>
T TrigConf::DataStructure::getValue ( ) const
inlineinherited

Definition at line 108 of file DataStructure.h.

108 {
109 return data().get_value<T>();
110 }

◆ getValue_optional()

template<class T>
std::optional< T > TrigConf::DataStructure::getValue_optional ( ) const
inlineinherited

access to content of the note Will return false if the value could not be converted into T

Definition at line 116 of file DataStructure.h.

116 {
117 auto v = data().get_value_optional<T>();
118 return v ? std::optional<T>(std::move(*v)) : std::nullopt;
119 }

◆ hasAttribute()

bool TrigConf::DataStructure::hasAttribute ( const std::string & key) const
inherited

Check for attribute.

Parameters
keyThe path to the attribute name, relative to the current one in form "path.to.child"
Returns
true if path key exists and is an attribute

Definition at line 85 of file DataStructure.cxx.

85 {
86 const auto & child = data().get_child_optional( key );
87 if( ! bool(child) ) // key does not exist
88 return false;
89 return child.get().empty(); // if empty then it is an attribute, otherwise a child note
90}

◆ hasChild()

bool TrigConf::DataStructure::hasChild ( const std::string & path) const
inherited

Check if child exists.

Parameters
pathThe path to the child, relative to the current one in form "path.to.child"
Returns
true if path exists

Definition at line 113 of file DataStructure.cxx.

113 {
114 const auto & child = data().get_child_optional( path );
115 return bool(child);
116}
setBGCode setTAP setLVL2ErrorBits bool

◆ inputs()

const std::vector< std::string > & TrigConf::L1TopoAlgorithm::inputs ( ) const

Accessor to input collections Sorting and Multiplicity algorithms have only one input.

Definition at line 107 of file L1TopoAlgorithm.cxx.

108{
109 return m_inputs;
110}
std::vector< std::string > m_inputs

◆ isInitialized()

bool TrigConf::DataStructure::isInitialized ( ) const
inlineinherited

Definition at line 216 of file DataStructure.h.

216{ return m_initialized; }

◆ isNull()

bool TrigConf::DataStructure::isNull ( const std::string & key) const
inherited

Check if an attribute is null.

Parameters
keyThe path to the attribute name, relative to the current one in form "path.to.child"
Returns
true if path key exists and is null

If the attribute doesn't exist, the function returns false. To check if an attribute exists and is null, use it together with hasAttribute.

Definition at line 93 of file DataStructure.cxx.

93 {
94 auto child = data().get_child_optional( key );
95 if( ! child ) {
96 return false;
97 }
98 return child->get_value<std::string>() == "null";
99}

◆ isValid()

bool TrigConf::DataStructure::isValid ( ) const
inlineinherited

Definition at line 215 of file DataStructure.h.

215{ return m_initialized; }

◆ isValue()

bool TrigConf::DataStructure::isValue ( ) const
inherited

Check for attribute.

Returns
true if the structure is just a value

Definition at line 74 of file DataStructure.cxx.

74 {
75 return data().empty(); // just a key->value pair, no children
76}

◆ klass()

const std::string & TrigConf::L1TopoAlgorithm::klass ( ) const

Accessor to algorithm class type.

Definition at line 98 of file L1TopoAlgorithm.cxx.

99{
100 if(hasAttribute("klass")) {
101 return getAttribute("klass");
102 }
103 return getAttribute("type");
104}
bool hasAttribute(const std::string &key) const
Check for attribute.

◆ load()

void TrigConf::L1TopoAlgorithm::load ( )
private

Update the internal data after modification of the data object.

Definition at line 26 of file L1TopoAlgorithm.cxx.

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 for( auto & k : inp.getKeys() ) {
59 m_inputs.push_back(inp[k]);
60 break;
61 }
62 }
63 m_outputs.push_back(getAttribute("output"));
64 }
65
67 for( auto & p : getList("variableParameters") ) {
68 if (p["name"] == "MaxMSqr") {
69 unsigned int val = p.getAttribute<unsigned int>("value");
70 // Work around overflow in the database...
71 if (val >= 1u<<31) {
72 // Expected maximum value of Inv M^2 in 100 MeV unit
73 val = 1024*1024*10*10*10;
74 }
75 m_parameters.emplace_back(p["name"], val, p.getAttribute_optional<unsigned int>("selection"));
76 }
77 else {
78 m_parameters.emplace_back(p["name"], p.getAttribute<int>("value"), p.getAttribute_optional<unsigned int>("selection"));
79 }
80 }
81 }
82
83}
bool hasChild(const std::string &path) const
Check if child exists.
std::vector< VariableParameter > m_parameters
static unsigned int flavourStrToInt(const std::string &flavStr)

◆ name()

const std::string & TrigConf::DataStructure::name ( ) const
finalvirtualinherited

Definition at line 108 of file DataStructure.cxx.

108 {
109 return m_name;
110}

◆ operator bool()

TrigConf::DataStructure::operator bool ( ) const
inlineexplicitinherited

Access to initialized state.

Definition at line 214 of file DataStructure.h.

214{ return m_initialized; }

◆ operator=()

L1TopoAlgorithm & TrigConf::L1TopoAlgorithm::operator= ( const L1TopoAlgorithm & )
delete

◆ operator[]()

std::string TrigConf::DataStructure::operator[] ( const std::string & key) const
inherited

Access to simple attribute.

Parameters
keyThe path to the attribute name, relative to the current one in form "path.to.child"

Definition at line 120 of file DataStructure.cxx.

121{
122 const auto & obj = data().get_child(key);
123 // check if the key points to a plain string value
124 if ( !obj.empty() ) {
125 if ( obj.front().first.empty() ) {
126 throw std::runtime_error(className() + "#" + name() + ": structure '" + key + "' is not a simple attribute but a list [], it needs to be accessed via getList(\"" + key + "\") -> vector<DataStructure>");
127 } else {
128 throw std::runtime_error(className() + "#" + name() + ": structure '" + key + "' is not a simple attribute but an object {}, it needs to be accessed via getObject(\"" + key + "\") -> DataStructure");
129 }
130 }
131 return obj.data();
132}

◆ outputs()

const std::vector< std::string > & TrigConf::L1TopoAlgorithm::outputs ( ) const

Accessor to output collections Sorting and Multiplicity algorithms have only one output.

Definition at line 113 of file L1TopoAlgorithm.cxx.

114{
115 return m_outputs;
116}

◆ ownsData()

bool TrigConf::DataStructure::ownsData ( ) const
inlineinherited

Definition at line 242 of file DataStructure.h.

242 {
243 return (bool)m_dataSPtr;
244 }

◆ parameters()

const std::vector< TrigConf::L1TopoAlgorithm::VariableParameter > & TrigConf::L1TopoAlgorithm::parameters ( ) const

Accessor to register parameters which can change for each algorithm instance.

Definition at line 141 of file L1TopoAlgorithm.cxx.

142{
143 return m_parameters;
144}

◆ print()

void TrigConf::L1TopoAlgorithm::print ( std::ostream & os = std::cout) const
overridevirtual

print main info

Reimplemented from TrigConf::DataStructure.

Definition at line 148 of file L1TopoAlgorithm.cxx.

149{
150 os << "Algorithm " << name() << " (class " << klass() << ", category " << m_category << ")" << std::endl;
151 os << " input:" << std::endl;
152 for( auto & input : inputs() ) {
153 os << " " << input << std::endl;
154 }
155 os << " output:" << std::endl;
156 for( auto & output : outputs() ) {
157 os << " " << output << std::endl;
158 }
159 os << " full output:" << std::endl;
160 for( auto & output : fullOutputs() ) {
161 os << " " << output << std::endl;
162 }
164 os << " threshold definition: " << getAttribute("threshold") << std::endl;
165 os << " number of output bits: " << getAttribute<unsigned int>("nbits") << std::endl;
166 } else {
167 os << " generic parameters:" << std::endl;
168 auto genPars = generics();
169 for( auto & k : genPars.getKeys() ) {
170 os << " " << k << " ==> " << genericParameter(k) << std::endl;
171 }
172 os << " parameters:" << std::endl;
173 auto pars = parameters();
174 unsigned int idx{0};
175 for( auto & p : pars ) {
176 os << " " << idx++ << " " << p.name() << "[" << p.selection() << "] ==> " << p.value() << std::endl;
177 }
178 }
179 os << std::endl;
180}
DataStructure generics() const
Accessors to generic parameters.
std::vector< std::string > fullOutputs() const
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.
const std::vector< VariableParameter > & parameters() const
Accessor to register parameters which can change for each algorithm instance.
AlgorithmType type() const
const std::string & klass() const
Accessor to algorithm class type.
output
Definition merge.py:16

◆ printElement()

void TrigConf::DataStructure::printElement ( const std::string & key,
const ptree & data,
uint level = 0,
std::ostream & os = std::cout )
staticinherited

Static function to print a ptree object.

Parameters
keyThe key of this data as found in the parent structure
dataThe ptree to print
levelThe substruture level used to indent the output
osThe output stream

Definition at line 278 of file DataStructure.cxx.

279{
280 constexpr char del = '"';
281
282 const std::string value = data.get_value<std::string>();
283
284 if( data.empty() ) { // no children, so just a key->value pair
285 uint n(4*level); while(n--) os << " ";
286 os << del << key << del << ": " << del << value << del;
287 return;
288 }
289
290
291 bool isArray ( data.begin()->first.empty() ); // dictionaries have keys, arrays don't
292 { uint n(4*level); while(n--) os << " "; }
293 if ( ! key.empty() )
294 os << del << key << del << ": ";
295 os << (isArray ? "[" : "{") << std::endl;
296
297 size_t childCounter = data.size();
298 for( const boost::property_tree::ptree::value_type & x : data ) {
299 printElement(x.first, x.second, level + 1, os);
300 if( --childCounter ) os << ",";
301 os << std::endl;
302 }
303 { uint n(4*level); while(n--) os << " "; }
304 os << (isArray ? "]" : "}");
305
306}
unsigned int uint
#define x
static void printElement(const std::string &key, const ptree &data, uint level=0, std::ostream &os=std::cout)
Static function to print a ptree object.

◆ printRaw()

void TrigConf::DataStructure::printRaw ( std::ostream & os = std::cout) const
inherited

Definition at line 264 of file DataStructure.cxx.

265{
266 boost::property_tree::json_parser::write_json( os, data() );
267}

◆ setData() [1/2]

void TrigConf::DataStructure::setData ( const ptree & data)
inherited

Setting the configuration data.

Definition at line 39 of file DataStructure.cxx.

40{
41 clear();
42 m_initialized = true;
43 m_dataSPtr.reset();
44 m_dataPtr = &data;
45 update();
46}
virtual void clear()
Clearing the configuration data.
virtual void update()
Update the internal data after modification of the data object.

◆ setData() [2/2]

void TrigConf::DataStructure::setData ( ptree && data)
inherited

Definition at line 50 of file DataStructure.cxx.

51{
52 clear();
53 m_initialized = true;
54 m_dataSPtr = std::make_shared<ptree>(std::move(data));
55 m_dataPtr = nullptr;
56 update();
57}

◆ setName()

void TrigConf::DataStructure::setName ( const std::string & n)
inherited

Setting the configuration element name.

Definition at line 59 of file DataStructure.cxx.

59 {
60 m_name = n;
61}

◆ type()

TrigConf::L1TopoAlgorithm::AlgorithmType TrigConf::L1TopoAlgorithm::type ( ) const

Definition at line 86 of file L1TopoAlgorithm.cxx.

87{
88 return m_type;
89}

◆ update()

virtual void TrigConf::L1TopoAlgorithm::update ( )
inlineoverrideprotectedvirtual

Update the internal data after modification of the data object.

to be implemented by the derived class

Reimplemented from TrigConf::DataStructure.

Definition at line 92 of file L1TopoAlgorithm.h.

92{ load(); }

Member Data Documentation

◆ m_category

std::string TrigConf::L1TopoAlgorithm::m_category {}
private

Definition at line 101 of file L1TopoAlgorithm.h.

101{};

◆ m_dataPtr

const ptree* TrigConf::DataStructure::m_dataPtr { nullptr }
protectedinherited

Definition at line 257 of file DataStructure.h.

257{ nullptr }; // used when not owning the tree

◆ m_dataSPtr

std::shared_ptr<ptree> TrigConf::DataStructure::m_dataSPtr { nullptr }
protectedinherited

Definition at line 256 of file DataStructure.h.

256{ nullptr }; // used when owning the tree

◆ m_initialized

bool TrigConf::DataStructure::m_initialized { false }
protectedinherited

if initialized, the underlying ptree is has been assigned to (can be empty)

Definition at line 254 of file DataStructure.h.

254{ false };

◆ m_inputs

std::vector<std::string> TrigConf::L1TopoAlgorithm::m_inputs {}
private

Definition at line 103 of file L1TopoAlgorithm.h.

103{};

◆ m_name

std::string TrigConf::DataStructure::m_name {""}
protectedinherited

Definition at line 259 of file DataStructure.h.

259{""}; // most objects are named

◆ m_outputs

std::vector<std::string> TrigConf::L1TopoAlgorithm::m_outputs {}
private

Definition at line 104 of file L1TopoAlgorithm.h.

104{};

◆ m_parameters

std::vector<VariableParameter> TrigConf::L1TopoAlgorithm::m_parameters
private

Definition at line 106 of file L1TopoAlgorithm.h.

◆ m_type

AlgorithmType TrigConf::L1TopoAlgorithm::m_type { AlgorithmType::UNKNOWN }
private

The documentation for this class was generated from the following files: