@@ -223,16 +223,15 @@ struct DiscoverMetadataInAOD : o2::framework::ConfigDiscoveryPlugin {
223223 return results;
224224 }
225225
226- // Lets try in parent file.
227- auto parentFiles = currentFile->parentFiles ();
228- if (parentFiles.empty ()) {
229- LOGP (info, " No metadata found in file \" {}\" " , filename);
230- results.push_back (ConfigParamSpec{" aod-metadata-disable" , VariantType::String, " 1" , {" Metadata not found in AOD" }});
231- return results;
232- }
233- LOGP (info, " No metadata found in file \" {}\" , checking in its parents." , filename);
234- for (auto & [df, parentFilenameInFile] : parentFiles) {
235- std::string parentFilename = parentFilenameInFile;
226+ // Lets try in the parent files, up to the allowed parent level.
227+ auto childFile = currentFile;
228+ for (int level = 1 ; level <= registry.get <int >(" aod-parent-access-level" ); ++level) {
229+ auto parentFiles = childFile->parentFiles ();
230+ if (parentFiles.empty ()) {
231+ break ;
232+ }
233+ LOGP (info, " No metadata found in file \" {}\" , checking in its parents." , childFile->name ());
234+ std::string parentFilename = parentFiles.begin ()->second ;
236235 // Do the replacement. Notice this will require changing aod-parent-base-path-replacement to be
237236 // a workflow option (because the metadata itself is potentially changing the topology).
238237 if (registry.isSet (" aod-parent-base-path-replacement" )) {
@@ -267,9 +266,10 @@ struct DiscoverMetadataInAOD : o2::framework::ConfigDiscoveryPlugin {
267266 results.push_back (ConfigParamSpec{" aod-metadata-source" , VariantType::String, filename, {" File from which the metadata was extracted." }});
268267 return results;
269268 }
270- LOGP (info, " No metadata found in file \" {}\" nor in its parent file \" {} \" " , filename, parentFilename );
271- break ;
269+ LOGP (info, " No metadata found in parent file \" {}\" at level {} " , parentFilename, level );
270+ childFile = parentFile ;
272271 }
272+ LOGP (info, " No metadata found in file \" {}\" nor in its parents" , filename);
273273 results.push_back (ConfigParamSpec{" aod-metadata-disable" , VariantType::String, " 1" , {" Metadata not found in AOD" }});
274274 return results;
275275 }};
0 commit comments