Skip to content

Commit

Permalink
Revert "Generalize the functionality of converting parameters (#102)" (
Browse files Browse the repository at this point in the history
…#105)

This reverts commit 9a0ae14.
  • Loading branch information
jmcarcell authored Jan 31, 2025
1 parent 9a0ae14 commit 24254ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,33 +159,12 @@ std::unique_ptr<podio::CollectionBase> fillSubset(EVENT::LCCollection* LCCollect
template <typename LCVecType>
std::vector<CollNamePair> convertLCVec(const std::string& name, EVENT::LCCollection* LCCollection);

/**
* Converting all parameters of an LCIO Object and passing them to the PutParamF
* function that takes care of storing them appropriately.
*
* The indirection is necessary for better integration with k4FWCore where
* direct access to a Frame is not possible, but a putParameter method is
* available instead.
*
* The PutParamF has to provide the following interface
*
* template<typename T>
* void(std::string const&, T const&)
*
* It will be called for all T that are currently supported as parameters (int,
* float, double, std::string resp. std::vector of those).
*/
template <typename LCIOType, typename PutParamF>
void convertObjectParameters(LCIOType* lcioobj, PutParamF putParamFun);

/**
* Converting all parameters of an LCIO Object and attaching them to the
* passed podio::Frame.
*/
template <typename LCIOType>
void convertObjectParameters(LCIOType* lcioobj, podio::Frame& event) {
convertObjectParameters(lcioobj, [&event](const std::string& key, const auto& v) { event.putParameter(key, v); });
}
void convertObjectParameters(LCIOType* lcioobj, podio::Frame& event);

inline edm4hep::Vector3f Vector3fFrom(const double* v) { return edm4hep::Vector3f(v[0], v[1], v[2]); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,40 @@
#include <edm4hep/RecDqdxCollection.h>

namespace LCIO2EDM4hepConv {

template <typename LCIOType, typename PutParamF>
void convertObjectParameters(LCIOType* lcioobj, PutParamF putParamFun) {
template <typename LCIOType>
void convertObjectParameters(LCIOType* lcioobj, podio::Frame& event) {
const auto& params = lcioobj->getParameters();

// handle srting params
EVENT::StringVec keys;
const auto stringKeys = params.getStringKeys(keys);
for (auto i = 0u; i < stringKeys.size(); i++) {
EVENT::StringVec sValues;
const auto stringVals = params.getStringVals(stringKeys[i], sValues);
putParamFun(stringKeys[i], stringVals);
event.putParameter(stringKeys[i], stringVals);
}
// handle float params
EVENT::StringVec fkeys;
const auto floatKeys = params.getFloatKeys(fkeys);
for (auto i = 0u; i < floatKeys.size(); i++) {
EVENT::FloatVec fValues;
const auto floatVals = params.getFloatVals(floatKeys[i], fValues);
putParamFun(floatKeys[i], floatVals);
event.putParameter(floatKeys[i], floatVals);
}
// handle int params
EVENT::StringVec ikeys;
const auto intKeys = params.getIntKeys(ikeys);
for (auto i = 0u; i < intKeys.size(); i++) {
EVENT::IntVec iValues;
const auto intVals = params.getIntVals(intKeys[i], iValues);
putParamFun(intKeys[i], intVals);
event.putParameter(intKeys[i], intVals);
}
// handle double params
EVENT::StringVec dkeys;
const auto dKeys = params.getDoubleKeys(dkeys);
for (auto i = 0u; i < dKeys.size(); i++) {
EVENT::DoubleVec dValues;
const auto dVals = params.getDoubleVals(dKeys[i], dValues);
putParamFun(dKeys[i], dVals);
event.putParameter(dKeys[i], dVals);
}
}

Expand Down

0 comments on commit 24254ea

Please sign in to comment.