ATLAS Offline Software
L1TopoAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <map>
7 
8 TrigConf::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 
20 std::string
22  return "L1TopoAlgorithm";
23 }
24 
25 void
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 
66  if( m_type == AlgorithmType::DECISION || m_type == AlgorithmType::SORTING ) {
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 }
84 
87 {
88  return m_type;
89 }
90 
91 const std::string &
93 {
94  return m_category;
95 }
96 
97 const std::string &
99 {
100  if(hasAttribute("klass")) {
101  return getAttribute("klass");
102  }
103  return getAttribute("type");
104 }
105 
106 const std::vector<std::string> &
108 {
109  return m_inputs;
110 }
111 
112 const std::vector<std::string> &
114 {
115  return m_outputs;
116 }
117 
118 std::vector<std::string>
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 }
127 
128 std::string
130 {
131  return operator[]("fixedParameters.generics." + parName + ".value");
132 }
133 
136 {
137  return getObject("fixedParameters.generics");
138 }
139 
140 const std::vector<TrigConf::L1TopoAlgorithm::VariableParameter> &
142 {
143  return m_parameters;
144 }
145 
146 
147 void
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  }
163  if(type() == AlgorithmType::MULTIPLICITY) {
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 }
TrigConf::L1TopoAlgorithm::fullOutputs
std::vector< std::string > fullOutputs() const
Definition: L1TopoAlgorithm.cxx:119
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.PyAthena.klass
klass
Definition: PyAthena.py:133
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
TrigConf::L1TopoAlgorithm::generics
DataStructure generics() const
Accessors to generic parameters.
Definition: L1TopoAlgorithm.cxx:135
TrigConf::L1TopoAlgorithm::klass
const std::string & klass() const
Accessor to algorithm class type.
Definition: L1TopoAlgorithm.cxx:98
TrigConf::DataStructure::m_name
std::string m_name
Definition: DataStructure.h:259
TrigConf::L1TopoAlgorithm::L1TopoAlgorithm
L1TopoAlgorithm()=default
Constructor.
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigConf::L1TopoAlgorithm::print
void print(std::ostream &os=std::cout) const override
print main info
Definition: L1TopoAlgorithm.cxx:148
TrigConf::L1TopoAlgorithm::genericParameter
std::string genericParameter(const std::string &parName) const
Definition: L1TopoAlgorithm.cxx:129
TrigConf::L1TopoAlgorithm::type
AlgorithmType type() const
Definition: L1TopoAlgorithm.cxx:86
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TrigConf::L1TopoAlgorithm::parameters
const std::vector< VariableParameter > & parameters() const
Accessor to register parameters which can change for each algorithm instance.
Definition: L1TopoAlgorithm.cxx:141
TrigConf::L1TopoAlgorithm::outputs
const std::vector< std::string > & outputs() const
Accessor to output collections Sorting and Multiplicity algorithms have only one output.
Definition: L1TopoAlgorithm.cxx:113
TrigConf::L1TopoAlgorithm::category
const std::string & category() const
Definition: L1TopoAlgorithm.cxx:92
beamspotnt.parName
list parName
Definition: bin/beamspotnt.py:1287
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
python.CreateTierZeroArgdict.outputs
outputs
Definition: CreateTierZeroArgdict.py:189
merge.output
output
Definition: merge.py:17
TrigConf::L1TopoAlgorithm::m_category
std::string m_category
Definition: L1TopoAlgorithm.h:101
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigConf::L1TopoAlgorithm::load
void load()
Update the internal data after modification of the data object.
Definition: L1TopoAlgorithm.cxx:26
TrigConf::L1TopoAlgorithm::className
virtual std::string className() const override
A string that is the name of the class.
Definition: L1TopoAlgorithm.cxx:21
TrigConf::DataStructure
Base class for Trigger configuration data and wrapper around underlying representation.
Definition: DataStructure.h:37
TrigConf::XEFlavour::flavourStrToInt
static unsigned int flavourStrToInt(const std::string &flavStr)
Definition: L1TopoAlgorithm.h:145
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
TrigConf::L1TopoAlgorithm::AlgorithmType
AlgorithmType
Definition: L1TopoAlgorithm.h:23
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
L1TopoAlgorithm.h
fitman.k
k
Definition: fitman.py:528
TrigConf::L1TopoAlgorithm::inputs
const std::vector< std::string > & inputs() const
Accessor to input collections Sorting and Multiplicity algorithms have only one input.
Definition: L1TopoAlgorithm.cxx:107