Skip to content

Commit

Permalink
Remove unnecessary struct
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jan 17, 2025
1 parent 2f59311 commit 2db7e16
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,33 +159,23 @@ std::unique_ptr<podio::CollectionBase> fillSubset(EVENT::LCCollection* LCCollect
template <typename LCVecType>
std::vector<CollNamePair> convertLCVec(const std::string& name, EVENT::LCCollection* LCCollection);

/**
* Helper struct to wrap the functionality of putting parameters into a Frame in
* a semi type-erases way, such that it can easily be used as a template
* parameter
*/
struct ParamFramePutter {
ParamFramePutter() = delete;
ParamFramePutter(podio::Frame& f) : m_frame(f) {}

template <typename T>
void operator()(const std::string& key, const T& value) {
m_frame.putParameter(key, value);
}

private:
podio::Frame& m_frame;
};

/**
* 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 = ParamFramePutter>
template <typename LCIOType, typename PutParamF>
void convertObjectParameters(LCIOType* lcioobj, PutParamF putParamFun);

/**
Expand All @@ -194,7 +184,7 @@ void convertObjectParameters(LCIOType* lcioobj, PutParamF putParamFun);
*/
template <typename LCIOType>
void convertObjectParameters(LCIOType* lcioobj, podio::Frame& event) {
convertObjectParameters(lcioobj, ParamFramePutter{event});
convertObjectParameters(lcioobj, [&event](const std::string& key, const auto& v) { event.putParameter(key, v); });
}

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

0 comments on commit 2db7e16

Please sign in to comment.