22 if(! isInitialized() ||
empty() ) {
26 m_run = getAttribute_optional<int>(
"run").value_or(3);
30 m_name = getAttribute(
"name");
31 for(
const std::string
path : {
"thresholds",
"thresholds.legacyCalo" } ) {
32 for(
auto & thrByType :
data().get_child(
path ) ) {
33 const std::string & thrType = thrByType.first;
34 if (thrType ==
"legacyCalo")
38 auto extraInfo = m_thrExtraInfo.addExtraInfo(thrByType.first,thrByType.second);
40 auto &
v = m_thresholdsByType[thrType] = std::vector<std::shared_ptr<TrigConf::L1Threshold>>();
41 if(thrType ==
"internal") {
42 for(
auto & thr :
data().get_child(
path +
".internal.names") ) {
43 const std::string thrName = thr.second.data();
47 for(
auto & thr :
data().get_child(
path +
"." + thrType +
".thresholds") ) {
48 const std::string thrName = thr.first;
52 for(
auto & thr :
v ) {
53 m_thresholdsByName[ thr->name() ] = thr;
56 m_thresholdsByTypeAndMapping[thrType][thr->mapping()] = thr;
62 std::cerr <<
"ERROR: problem when building L1 menu structure (thresholds). " << ex.what() << std::endl;
68 for(
auto & board :
data().get_child(
"boards" ) ) {
69 m_boards.emplace( std::piecewise_construct,
70 std::forward_as_tuple(board.first),
71 std::forward_as_tuple(board.first, board.second) );
75 std::cerr <<
"ERROR: problem when building L1 menu structure (boards). " << ex.what() << std::endl;
81 for(
auto &
conn :
data().get_child(
"connectors" ) ) {
82 auto res = m_connectors.emplace( std::piecewise_construct,
83 std::forward_as_tuple(
conn.first),
84 std::forward_as_tuple(
conn.first,
conn.second) );
85 for(
auto &
tl :
res.first->second.triggerLineNames() ) {
86 m_threshold2ConnectorName.emplace( std::piecewise_construct,
87 std::forward_as_tuple(
tl),
88 std::forward_as_tuple(
conn.first));
93 std::cerr <<
"ERROR: problem when building L1 menu structure (connectors). " << ex.what() << std::endl;
100 auto topoCategories =
isRun2() ? std::vector<std::string> {
"R2TOPO"} : std::vector<std::string> {
"TOPO",
"MUTOPO",
"MULTTOPO",
"R2TOPO"};
101 for(
const std::string& algoCategory : topoCategories ) {
102 auto &
v = m_algorithmsByCategory[algoCategory] = std::vector<TrigConf::L1TopoAlgorithm>();
103 m_algorithmsByName.emplace(algoCategory, std::map<std::string, TrigConf::L1TopoAlgorithm*>());
104 m_algorithmsByOutput.emplace(algoCategory, std::map<std::string, TrigConf::L1TopoAlgorithm*>());
105 if(algoCategory ==
"MULTTOPO") {
106 for(
auto &
alg :
data().get_child(
"topoAlgorithms." + algoCategory +
".multiplicityAlgorithms" ) ) {
117 for(
auto & algo :
v ) {
118 if( m_algorithmsByName[algoCategory].
count(algo.name()) > 0 ) {
119 std::cerr <<
"ERROR : Topo algorithm with name " << algo.name() <<
" and of type " << algoCategory <<
" already exists" << std::endl;
120 throw std::runtime_error(
"Found duplicate topo algorithm name " + algo.name() +
" of type " + algoCategory);
122 m_algorithmsByName[ algoCategory ][ algo.name() ] = & algo;
123 for(
const std::string &
output : algo.outputs() ) {
124 if( m_algorithmsByOutput[algoCategory].
count(
output) > 0 ) {
125 std::cerr <<
"ERROR : Topo algorithm output " <<
output <<
" already exists" << std::endl;
126 throw std::runtime_error(
"Found duplicate topo algorithm output " +
output +
" of type " + algoCategory);
128 m_algorithmsByOutput[algoCategory][
output] = & algo;
134 std::cerr <<
"ERROR: problem when building L1 menu structure (algorithms). " << ex.what() << std::endl;
141 m_ctp.setData(
data().get_child(
"ctp"));
144 std::cerr <<
"ERROR: problem when building L1 menu structure (CTP). " << ex.what() << std::endl;
156 m_connectors.clear();
157 m_threshold2ConnectorName.clear();
159 m_thresholdsByType.clear();
160 m_thresholdsByName.clear();
161 m_thresholdsByTypeAndMapping.clear();
163 m_thrExtraInfo.clear();
165 m_algorithmsByCategory.clear();
166 m_algorithmsByName.clear();
167 m_algorithmsByOutput.clear();
175 return getAttribute<unsigned int>(
"version");
181 return getAttribute<unsigned int>(
"ctpVersion");
187 return data().get_child(
"items").size();
204 throw std::runtime_error(
"L1Menu::item() was called with empty itemName");
208 pt = &
data().get_child(ptree::path_type(
"items/"+itemName,
'/'));
209 }
catch(boost::property_tree::ptree_bad_path & ex) {
210 throw std::runtime_error(
"L1Item " + itemName +
" does not exist in the menu");
218 return {
data().get_child(
"items"), 0, [](
auto &
x){
return L1Item(
x.second);}};
225 const auto &
items =
data().get_child(
"items");
230 std::vector<std::string>
233 std::vector<std::string> thrTypeNames;
234 thrTypeNames.reserve(m_thresholdsByType.size());
235 for(
auto x : m_thresholdsByType ) {
236 thrTypeNames.emplace_back(
x.first);
241 std::vector<std::string>
244 std::vector<std::string> thrNames;
245 thrNames.reserve(m_thresholdsByName.size());
246 for(
auto x : m_thresholdsByName ) {
247 thrNames.emplace_back(
x.first);
253 const std::vector<std::shared_ptr<TrigConf::L1Threshold>> &
257 return m_thresholdsByType.at(
typeName);
260 std::cerr <<
"No threshold type '" <<
typeName <<
"' defined in the thresholds section of the L1 menu" << std::endl;
266 std::vector<std::shared_ptr<TrigConf::L1Threshold>>
269 std::vector<std::shared_ptr<TrigConf::L1Threshold>> thrlist;
270 for (
const std::string &
type : thresholdTypes() ) {
271 const auto & thrOfType = thresholds(
type);
272 std::copy(thrOfType.begin(), thrOfType.end(), std::back_inserter(thrlist));
282 return * m_thresholdsByName.at(thresholdName);
285 std::cerr <<
"No threshold '" << thresholdName <<
"' defined in the thresholds section of the L1 menu" << std::endl;
300 std::cerr <<
"No threshold of type '" <<
typeName <<
"' with mapping " <<
mapping
301 <<
" defined in the thresholds section of the L1 menu" << std::endl;
309 return m_thrExtraInfo;
316 return m_threshold2ConnectorName.at(thresholdName);
319 std::cerr <<
"Threshold '" << thresholdName <<
"' not defined as triggerline in the L1 menu" << std::endl;
324 std::vector<std::string>
326 std::vector<std::string> connNames;
327 connNames.reserve(m_connectors.size());
328 for(
auto &
x : m_connectors ) {
329 connNames.emplace_back(
x.first);
337 return m_connectors.at(connectorName);
340 std::cerr <<
"No connector " << connectorName <<
" defined in the L1 menu" << std::endl;
346 std::vector<std::string>
349 std::vector<std::string> algoNames;
352 algoNames.push_back(
entry.first);
356 std::cerr <<
"No algorithm category '" <<
category <<
"' defined in the L1 menu" << std::endl;
363 std::vector<std::string>
373 std::cerr <<
"No algorithm category '" <<
category <<
"' defined in the L1 menu" << std::endl;
385 return * m_algorithmsByName.at(
category).at(algoName);
388 std::cerr <<
"No algorithm " << algoName <<
" of category " <<
category <<
" defined in the L1 menu" << std::endl;
398 if( std::size_t
pos = triggerlineName.find(
'_');
pos != std::string::npos ) {
402 const static std::vector<string> topoTypes {
"TOPO",
"R2TOPO",
"MULTTOPO",
"MUTOPO"};
403 if( std::none_of(cbegin(topoTypes), cend(topoTypes), [&
category](
const std::string &
str){
return str==
category;}) ) {
404 std::string
msg =
"L1Menu::algorithmFromTriggerLine(" + triggerlineName +
"): triggerline " + triggerlineName +
" is not produced by a topo algorithm.";
405 throw std::runtime_error(
msg);
411 std::cerr <<
"L1Menu::algorithmFromTriggerLine(): No output " <<
outputName <<
" defined by any algorithm of category " <<
category <<
" in the L1 menu. (It was asked for " << triggerlineName <<
")" << std::endl;
420 return * m_algorithmsByOutput.at(
type).at(bareOutputName);
423 std::cerr <<
"No output " << bareOutputName <<
" defined by any algorithm of type " <<
type <<
" in the L1 menu" << std::endl;
432 return m_boards.at(boardName);
435 std::cerr <<
"No board " << boardName <<
" defined in the L1 menu" << std::endl;
440 std::vector<std::string>
443 std::vector<std::string> boardNames;
444 boardNames.reserve(m_boards.size());
445 for(
auto & board : m_boards) {
446 boardNames.emplace_back(board.first);
457 cout <<
"L1 menu '" <<
name() <<
"'" << endl;
458 cout <<
"Items: " <<
size() << endl;
462 cout <<
" " <<
c++ <<
": " <<
item.name() << endl;
465 cout <<
"Thresholds: " << thresholds().size() <<
"(of " << thresholdTypes().size() <<
" different types)" << endl;
468 for(
const std::string & thrType : thresholdTypes() ) {
469 cout << thrType <<
" :" << endl;
470 for(
auto & thr : thresholds(thrType)) {
471 cout <<
" " <<
c++ <<
": " << thr->name() <<
"[" << thr->type() <<
"]" << endl;
476 cout <<
"Topo algorithms: " << endl;
477 cout <<
" new : " <<
data().get_child(
"topoAlgorithms.TOPO.decisionAlgorithms").size() << endl;
478 cout <<
" muon : " <<
data().get_child(
"topoAlgorithms.MUTOPO.decisionAlgorithms").size() << endl;
479 cout <<
" mult : " <<
data().get_child(
"topoAlgorithms.MULTTOPO.multiplicityAlgorithms").size() << endl;
480 cout <<
" legacy: " <<
data().get_child(
"topoAlgorithms.R2TOPO.decisionAlgorithms").size() << endl;
482 cout <<
"Boards: " <<
data().get_child(
"boards").size() << endl;
483 cout <<
"Connectors: " <<
data().get_child(
"connectors").size() << endl;
484 unsigned int ctpinputs =
data().get_child(
"ctp.inputs.optical").size();
485 ctpinputs +=
data().get_child(
"ctp.inputs.electrical").size();
486 ctpinputs +=
data().get_child(
"ctp.inputs.ctpin.slot7").size();
487 ctpinputs +=
data().get_child(
"ctp.inputs.ctpin.slot8").size();
488 ctpinputs +=
data().get_child(
"ctp.inputs.ctpin.slot9").size();
489 cout <<
"CTP connections: " << ctpinputs << endl;