|
4 | 4 | #include <IOIMPL/LCFactory.h> |
5 | 5 | #include <UTIL/CheckCollections.h> |
6 | 6 |
|
| 7 | +#include <edm4hep/Constants.h> |
7 | 8 | #include <edm4hep/utils/ParticleIDUtils.h> |
8 | 9 |
|
9 | 10 | #include "podio/ROOTWriter.h" |
10 | 11 |
|
| 12 | +#include <array> |
11 | 13 | #include <cstdlib> |
12 | 14 | #include <fstream> |
13 | 15 | #include <iostream> |
@@ -147,6 +149,24 @@ ParsedArgs parseArgs(std::vector<std::string> argv) { |
147 | 149 | return args; |
148 | 150 | } |
149 | 151 |
|
| 152 | +const static std::array<std::tuple<std::string, std::string>, 1> STRING_PARAMS_TO_CONVERT = { |
| 153 | + {{EVENT::LCIO::CellIDEncoding, edm4hep::labels::CellIDEncoding}}}; |
| 154 | + |
| 155 | +void attachCollectionParamters(podio::Frame& metadata, const EVENT::LCCollection* coll, const std::string& name) { |
| 156 | + const auto& collParams = coll->getParameters(); |
| 157 | + std::vector<std::string> stringKeys; |
| 158 | + collParams.getStringKeys(stringKeys); |
| 159 | + |
| 160 | + for (const auto& [lcioParam, edm4hepParam] : STRING_PARAMS_TO_CONVERT) { |
| 161 | + if (std::ranges::find(stringKeys, lcioParam) != stringKeys.end()) { |
| 162 | + // We copy the full vector because in both cases that is what actually is persisted |
| 163 | + std::vector<std::string> vals{}; |
| 164 | + collParams.getStringVals(lcioParam, vals); |
| 165 | + metadata.putParameter(podio::collMetadataParamName(name, edm4hepParam), std::move(vals)); |
| 166 | + } |
| 167 | + } |
| 168 | +} |
| 169 | + |
150 | 170 | int main(int argc, char* argv[]) { |
151 | 171 | const auto args = parseArgs({argv, argv + argc}); |
152 | 172 |
|
@@ -226,10 +246,15 @@ int main(int argc, char* argv[]) { |
226 | 246 | } |
227 | 247 |
|
228 | 248 | // For the first event we also convert some meta information for the |
229 | | - // ParticleID handling |
| 249 | + // ParticleID handling as well as for the collection level parameters |
230 | 250 | if (i == 0) { |
231 | 251 | for (const auto& name : *evt->getCollectionNames()) { |
232 | 252 | auto coll = evt->getCollection(name); |
| 253 | + const auto edm4hepName = k4EDM4hep2LcioConv::detail::mapLookupFrom(name, collsToConvert); |
| 254 | + if (edm4hepName.has_value()) { |
| 255 | + attachCollectionParamters(metadata, coll, edm4hepName.value()); |
| 256 | + } |
| 257 | + |
233 | 258 | if (coll->getTypeName() == "ReconstructedParticle") { |
234 | 259 | for (const auto& pidInfo : LCIO2EDM4hepConv::getPIDMetaInfo(coll)) { |
235 | 260 | edm4hep::utils::PIDHandler::setAlgoInfo(metadata, LCIO2EDM4hepConv::getPIDCollName(name, pidInfo.algoName), |
|
0 commit comments