12#include <nlohmann/json.hpp>
13using json = nlohmann::json;
25 using ptree = boost::property_tree::ptree;
26 std::vector<T> return_vector;
27 for(
const ptree::value_type& entry : ds.data().get_child(child) ) {
28 return_vector.push_back( entry.second.get_value<T>() );
36 using ptree = boost::property_tree::ptree;
37 std::vector<std::vector<T>> return_vector;
38 for(
const ptree::value_type& outer : ds.data().get_child(child) ) {
39 return_vector.push_back(std::vector<T>());
40 for (
const ptree::value_type& inner : outer.second) {
41 return_vector.back().push_back( inner.second.get_value<T>() );
52 for (
const auto & chain :
menu ) {
54 jChain[
"counter"] = chain.counter();
55 jChain[
"nameHash"] = chain.namehash();
56 jChain[
"l1item"] = chain.l1item();
57 jChain[
"legMultiplicities"] = chain.legMultiplicities();
58 jChain[
"l1thresholds"] = chain.l1thresholds();
59 jChain[
"groups"] = chain.groups();
60 jChain[
"streams"] = chain.streams();
61 jChain[
"seqeuncers"] = chain.sequencers();
64 if (chain.hasChild(
"signature")) {
70 jChain[
"signature"] = std::move(jSig);
73 chains[chain.name()] = std::move(jChain);
77 for (
const auto& [seqName, algsList]:
menu.sequencers() ) {
78 json jSeq( algsList );
79 sequencers[seqName] = std::move(jSeq);
82 for (
const auto& stream:
menu.streams() ) {
84 jStream[
"name"] = stream[
"name"];
85 jStream[
"type"] = stream[
"type"];
86 jStream[
"obeyLB"] = stream.getAttribute<
bool>(
"obeyLB");
87 jStream[
"forceFullEventBuilding"] = stream.getAttribute<
bool>(
"forceFullEventBuilding");
88 streams[stream[
"name"]] = std::move(jStream);
93 j[
"filetype"] =
"hltmenu";
94 j[
"name"] =
menu.name();
95 j[
"chains"] = std::move(chains);
96 j[
"sequencers"] = std::move(sequencers);
97 j[
"streams"] = std::move(streams);
100 if (
menu.hasChild(
"sequence_run2")) {
105 j[
"sequence_run2"] = std::move(jSequence);
108 std::ofstream outfile(filename);
109 outfile << std::setw(4) << j << std::endl;
118 for (
const auto & chain :
menu ) {
120 jChain[
"name"] = chain.name();
121 jChain[
"counter"] = chain.counter();
122 jChain[
"hash"] = chain.namehash();
123 jChain[
"prescale"] = ps.prescale(chain.name()).prescale;
124 jChain[
"enabled"] = ps.prescale(chain.name()).enabled;
125 chains[chain.name()] = std::move(jChain);
128 j[
"filetype"] =
"hltprescale";
129 j[
"name"] = ps.name();
130 j[
"prescales"] = std::move(chains);
131 std::ofstream outfile(filename);
132 outfile << std::setw(4) << j << std::endl;
boost::property_tree::ptree ptree
Base class for Trigger configuration data and wrapper around underlying representation.
JsonFileWriterHLT()
Constructor.
bool writeJsonFile(const std::string &filename, const HLTMenu &menu) const
TrigConfMessaging(const std::string &name)
Constructor with parameters.
std::vector< std::vector< T > > ToVectorVector(const TrigConf::DataStructure &ds, const std::string &child)
Helper function ptree key->[[]] to std::vector<std::vector<T>>
std::vector< T > ToVector(const TrigConf::DataStructure &ds, const std::string &child)
Helper function ptree key->[] to std::vector<T>