29
29
#include < GaudiKernel/GaudiException.h>
30
30
31
31
#include " podio/CollectionBase.h"
32
+ #include < podio/CollectionIDTable.h>
32
33
33
34
#include " k4FWCore/DataWrapper.h"
34
35
@@ -208,6 +209,21 @@ namespace details {
208
209
}
209
210
}
210
211
212
+ inline auto getCollectionID (const std::string& name) {
213
+ podio::CollectionIDTable tbl;
214
+ return tbl.add (name);
215
+ }
216
+
217
+ void putCollectionSetID (std::unique_ptr<podio::CollectionBase> coll,
218
+ const DataObjectWriteHandle<std::unique_ptr<podio::CollectionBase>>& handle, auto thisClass) {
219
+ podio::CollectionIDTable tbl;
220
+ coll->setID (getCollectionID (handle.objKey ()));
221
+ thisClass->verbose () << fmt::format (" Assigning collection id {:0>8x} to collection '{}'" , coll->getID (),
222
+ handle.objKey ())
223
+ << endmsg;
224
+ Gaudi::Functional::details::put (handle, std::move (coll));
225
+ }
226
+
211
227
template <size_t Index, typename ... Out, typename ... Handles>
212
228
void putVectorOutputs (std::tuple<Handles...>&& handles, const auto & m_outputs, auto thisClass) {
213
229
if constexpr (Index < sizeof ...(Handles)) {
@@ -221,12 +237,12 @@ namespace details {
221
237
throw GaudiException (thisClass->name (), msg, StatusCode::FAILURE);
222
238
}
223
239
for (auto & val : std::get<Index>(handles)) {
224
- Gaudi::Functional::details::put ( std::get<Index>(m_outputs)[i], convertToUniquePtr ( std::move (val)) );
240
+ putCollectionSetID ( convertToUniquePtr ( std::move (val)), std::get<Index>(m_outputs)[i], thisClass );
225
241
i++;
226
242
}
227
243
} else {
228
- Gaudi::Functional::details::put ( std::get<Index>(m_outputs)[0 ],
229
- convertToUniquePtr ( std::move (std::get<Index>(handles))) );
244
+ putCollectionSetID ( convertToUniquePtr ( std::move (std::get<Index>(handles))), std::get<Index>(m_outputs)[0 ],
245
+ thisClass );
230
246
}
231
247
232
248
// Recursive call for the next index
0 commit comments