@@ -173,6 +173,9 @@ struct Builder {
173173
174174 std::shared_ptr<arrow::Table> materialize (ProcessingContext& pc);
175175};
176+
177+ ConfigParamSpec replaceOrigin (ConfigParamSpec& source, std::string const & originStr);
178+ ConcreteDataMatcher replaceOrigin (ConcreteDataMatcher& matcher, const header::DataOrigin& newOrigin);
176179} // namespace o2::framework
177180
178181namespace o2 ::soa
@@ -274,19 +277,23 @@ consteval IndexKind getIndexKind()
274277}
275278
276279template <soa::with_index_pack T>
277- inline constexpr auto getIndexMapping ()
280+ inline constexpr auto getIndexMapping (header::DataOrigin newOrigin = header::DataOrigin{ " AOD " } )
278281{
279282 std::vector<IndexRecord> idx;
280283 using indices = T::index_pack_t ;
281284 using Key = T::Key;
282- [&idx]<size_t ... Is>(std::index_sequence<Is...>) mutable {
285+ [&idx, &newOrigin ]<size_t ... Is>(std::index_sequence<Is...>) mutable {
283286 constexpr auto refs = T::generateSources ();
284- ([&idx]<TableRef ref, typename C>() mutable {
287+ ([&idx, &newOrigin ]<TableRef ref, typename C>() mutable {
285288 constexpr auto pos = o2::aod::MetadataTrait<o2::aod::Hash<ref.desc_hash >>::metadata::template getIndexPosToKey<Key>();
289+ auto matcher = o2::aod::matcher<ref>();
290+ if ((ref.origin_hash == " AOD" _h) && (newOrigin != header::DataOrigin{" AOD" })) {
291+ matcher = replaceOrigin (matcher, newOrigin);
292+ }
286293 if constexpr (pos == -1 ) {
287- idx.emplace_back (o2::aod::label<ref>(), o2::aod:: matcher<ref>() , C::columnLabel (), IndexKind::IdxSelf, pos);
294+ idx.emplace_back (o2::aod::label<ref>(), matcher, C::columnLabel (), IndexKind::IdxSelf, pos);
288295 } else {
289- idx.emplace_back (o2::aod::label<ref>(), o2::aod:: matcher<ref>() , C::columnLabel (), getIndexKind<typename C::type>(), pos);
296+ idx.emplace_back (o2::aod::label<ref>(), matcher, C::columnLabel (), getIndexKind<typename C::type>(), pos);
290297 }
291298 }.template operator ()<refs[Is], typename framework::pack_element_t <Is, indices>>(),
292299 ...);
@@ -381,24 +388,24 @@ constexpr auto getExpressionMetadata() -> std::vector<framework::ConfigParamSpec
381388}
382389
383390template <soa::with_index_pack T>
384- constexpr auto getIndexMetadata () -> std::vector<framework::ConfigParamSpec>
391+ constexpr auto getIndexMetadata (header::DataOrigin newOrigin = header::DataOrigin{ " AOD " } ) -> std::vector<framework::ConfigParamSpec>
385392{
386- auto map = getIndexMapping<T>();
393+ auto map = getIndexMapping<T>(newOrigin );
387394 return {framework::ConfigParamSpec{" index-records" , framework::VariantType::String, framework::serializeIndexRecords (map), {" \"\" " }},
388395 {framework::ConfigParamSpec{" index-exclusive" , framework::VariantType::Bool, T::exclusive, {" \"\" " }}}};
389396}
390397
391398template <typename T>
392399 requires (!soa::with_index_pack<T>)
393- constexpr auto getIndexMetadata () -> std::vector<framework::ConfigParamSpec>
400+ constexpr auto getIndexMetadata (header::DataOrigin ) -> std::vector<framework::ConfigParamSpec>
394401{
395402 return {};
396403}
397404
398405} // namespace
399406
400407template <TableRef R>
401- constexpr auto tableRef2InputSpec ()
408+ constexpr auto tableRef2InputSpec (header::DataOrigin newOrigin = header::DataOrigin{ " AOD " } )
402409{
403410 std::vector<framework::ConfigParamSpec> metadata;
404411 std::vector<framework::ConfigParamSpec> sources;
@@ -407,24 +414,29 @@ constexpr auto tableRef2InputSpec()
407414 } else if constexpr (soa::with_sources_generator<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash >>::metadata>) {
408415 sources = getInputMetadata<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash >>::metadata, o2::aod::Hash<R.origin_hash >>();
409416 }
417+ if ((R.origin_hash == " AOD" _h) && (newOrigin != header::DataOrigin{" AOD" })) {
418+ std::ranges::transform (sources, sources.begin (), [originStr = newOrigin.as <std::string>()](framework::ConfigParamSpec& source){
419+ return replaceOrigin (source, originStr);
420+ });
421+ }
410422 metadata.insert (metadata.end (), sources.begin (), sources.end ());
411423 auto ccdbURLs = getCCDBMetadata<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash >>::metadata>();
412424 metadata.insert (metadata.end (), ccdbURLs.begin (), ccdbURLs.end ());
413425 auto expressions = getExpressionMetadata<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash >>::metadata>();
414426 metadata.insert (metadata.end (), expressions.begin (), expressions.end ());
415- auto indices = getIndexMetadata<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash >>::metadata>();
427+ auto indices = getIndexMetadata<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash >>::metadata>(newOrigin );
416428 metadata.insert (metadata.end (), indices.begin (), indices.end ());
417429 if constexpr (!soa::with_ccdb_urls<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash >>::metadata>) {
418430 metadata.emplace_back (framework::ConfigParamSpec{" schema" , framework::VariantType::String, framework::serializeSchema (o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash >>::metadata::getSchema ()), {" \"\" " }});
419431 }
420432
421433 return framework::InputSpec{
422- o2::aod::label<R>(),
423- o2::aod::origin<R>(),
424- o2::aod::description (o2::aod::signature<R>()),
425- R.version ,
426- framework::Lifetime::Timeframe,
427- metadata};
434+ o2::aod::label<R>(),
435+ ((R. origin_hash == " AOD " _h) && (newOrigin != header::DataOrigin{ " AOD " })) ? newOrigin : o2::aod::origin<R>(),
436+ o2::aod::description (o2::aod::signature<R>()),
437+ R.version ,
438+ framework::Lifetime::Timeframe,
439+ metadata};
428440}
429441
430442template <TableRef R>
0 commit comments