Skip to content

Commit

Permalink
DPL Analysis: provide dpl-metadata-tables
Browse files Browse the repository at this point in the history
ArrayString of tables in the first AOD to be read.
  • Loading branch information
ktf committed Jun 12, 2024
1 parent 44f6af3 commit 9e0af1b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Framework/AnalysisSupport/src/Plugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ struct RunSummary : o2::framework::ServicePlugin {
}
};

std::vector<std::string> getListOfTables(TFile* f)
{
std::vector<std::string> r;
TList* keyList = f->GetListOfKeys();

for (auto key : *keyList) {
if (!std::string_view(key->GetName()).starts_with("DF_")) {
continue;
}
auto* d = (TDirectory*)f->Get(key->GetName());
TList* branchList = d->GetListOfKeys();
for (auto b : *branchList) {
r.emplace_back(b->GetName());
}
break;
}
return r;
}

struct DiscoverMetadataInAOD : o2::framework::ConfigDiscoveryPlugin {
ConfigDiscovery* create() override
{
Expand Down Expand Up @@ -118,6 +137,11 @@ struct DiscoverMetadataInAOD : o2::framework::ConfigDiscoveryPlugin {
char const* value = strdup(objString->String());
results.push_back(ConfigParamSpec{key, VariantType::String, value, {"Metadata in AOD"}});
}

auto tables = getListOfTables(currentFile);
if (tables.empty() == false) {
results.push_back(ConfigParamSpec{"aod-metadata-tables", VariantType::ArrayString, tables, {"Tables in first AOD"}});
}
return results;
}};
}
Expand Down
13 changes: 12 additions & 1 deletion Framework/TestWorkflows/src/o2TestHistograms.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,23 @@ struct EtaAndClsHistogramsFull {
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
std::string runType = "3";
std::vector<std::string> tables;
if (cfgc.options().hasOption("aod-metadata-Run")) {
runType = cfgc.options().get<std::string>("aod-metadata-Run");
}
if (cfgc.options().hasOption("aod-metadata-tables")) {
tables = cfgc.options().get<std::vector<std::string>>("aod-metadata-tables");
}
LOGP(info, "Runtype is {}", runType);
bool hasTrackCov = false;
for (auto& table : tables) {
if (table.starts_with("O2trackcov")) {
hasTrackCov = true;
}
LOGP(info, "- {} present.", table);
}
// Notice it's important for the tasks to use the same name, otherwise topology generation will be confused.
if (runType == "2") {
if (runType == "2" || !hasTrackCov) {
LOGP(info, "Using only tracks {}", runType);
return WorkflowSpec{
adaptAnalysisTask<EtaAndClsHistogramsSimple>(cfgc, TaskName{"simple-histos"}),
Expand Down

0 comments on commit 9e0af1b

Please sign in to comment.