File indexing completed on 2025-06-03 08:33:24
0001 #ifndef EDM4HEP_GENERATORTOOLINFO_H
0002 #define EDM4HEP_GENERATORTOOLINFO_H
0003
0004 #include "edm4hep/Constants.h"
0005 #include "podio/Frame.h"
0006 #include <string>
0007 #include <vector>
0008
0009 namespace edm4hep {
0010
0011
0012
0013
0014
0015
0016
0017
0018 struct GeneratorToolInfo {
0019 std::string name{};
0020 std::string version{};
0021 std::string description{};
0022
0023
0024 GeneratorToolInfo() = default;
0025
0026
0027
0028
0029
0030
0031 GeneratorToolInfo(const std::string& nameTool, const std::string& versionTool, const std::string& descrTool) :
0032 name(nameTool), version(versionTool), description(descrTool){};
0033 };
0034
0035 namespace utils {
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 const inline std::vector<GeneratorToolInfo> getGenToolInfos(const podio::Frame& frame) {
0049 using namespace edm4hep::labels;
0050 auto toolInfos = std::vector<GeneratorToolInfo>();
0051 const auto names =
0052 frame.getParameter<std::vector<std::string>>(GeneratorToolNames).value_or(std::vector<std::string>{});
0053 const auto versions =
0054 frame.getParameter<std::vector<std::string>>(GeneratorToolVersions).value_or(std::vector<std::string>{});
0055 const auto descriptions =
0056 frame.getParameter<std::vector<std::string>>(GeneratorToolDescriptions).value_or(std::vector<std::string>{});
0057 for (unsigned int i = 0; i < names.size(); ++i) {
0058 toolInfos.emplace_back(names[i], versions[i], descriptions[i]);
0059 }
0060 return toolInfos;
0061 };
0062
0063
0064
0065
0066
0067
0068
0069
0070 void inline putGenToolInfos(podio::Frame& frame, const std::vector<GeneratorToolInfo>& toolInfos) {
0071 auto names = std::vector<std::string>();
0072 auto versions = std::vector<std::string>();
0073 auto descriptions = std::vector<std::string>();
0074 for (auto& toolInfo : toolInfos) {
0075 names.push_back(toolInfo.name);
0076 versions.push_back(toolInfo.version);
0077 descriptions.push_back(toolInfo.description);
0078 }
0079
0080 using namespace edm4hep::labels;
0081 frame.putParameter(GeneratorToolNames, std::move(names));
0082 frame.putParameter(GeneratorToolVersions, std::move(versions));
0083 frame.putParameter(GeneratorToolDescriptions, std::move(descriptions));
0084 };
0085 }
0086 }
0087
0088 #endif