Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Common/Core/MetadataHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <TSystem.h>

#include <array>
#include <map>
#include <string>

using namespace o2::common::core;
Expand Down Expand Up @@ -153,6 +154,34 @@ std::string MetadataHelper::getO2Version() const
return get("O2Version");
}

std::string MetadataHelper::getGenerator() const
{
if (!isMC()) {
return {};
}

// MC production tag (LPMProductionTag) -> generator name, for AO2Ds without the generator in the metadata
static const std::map<std::string, std::string> mcGeneratorMap = {
{"LHC26f3", "EPOS"},
{"LHC26k3", "EPOS"}};

// FIXME: use the "Generator" key first once it is available in AO2Ds (it must also be added to the key list in the constructor)
// if (isKeyDefined("Generator")) {
// return get("Generator");
// }

// older AO2Ds: rely on the LPMProductionTag to generator map
if (isKeyDefined("LPMProductionTag")) {
auto it = mcGeneratorMap.find(get("LPMProductionTag"));
if (it != mcGeneratorMap.end()) {
return it->second;
}
}

// no generator found in the metadata, fall back to PYTHIA
return "PYTHIA";
}

bool MetadataHelper::isCommitInSoftwareTag(const std::string& commitHash, const std::string& ccdbUrl) const
{
const std::string softwareTag = getO2Version();
Expand Down
4 changes: 4 additions & 0 deletions Common/Core/MetadataHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ struct MetadataHelper {
/// @return the O2 version from the metadata
std::string getO2Version() const;

/// @brief Function to get the MC generator name from the metadata
/// @return the generator name (e.g. "PYTHIA", "EPOS"), "PYTHIA" for MC if it cannot be determined, or an empty string for data
std::string getGenerator() const;

/// @brief Function to get the metadata value for a given key
/// @param key the key of the metadata
/// @return the value of the metadata. Throws an exception if the key is not found
Expand Down
16 changes: 5 additions & 11 deletions Common/Tools/Multiplicity/MultModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ struct standardConfigurables : o2::framework::ConfigurableGroup {
o2::framework::Configurable<std::string> reconstructionPass{"reconstructionPass", "", {"Apass to use when fetching the calibration tables. Empty (default) does not check for any pass. Use `metadata` to fetch it from the AO2D metadata. Otherwise it will override the metadata."}};

// centrality operation
o2::framework::Configurable<std::string> generatorName{"generatorName", "", {"Specify if and only if this is MC. Typical: PYTHIA"}};
o2::framework::Configurable<std::string> generatorName{"generatorName", "", {"MC generator name for centrality calibration (e.g. PYTHIA, EPOS). Empty: autodetect from metadata in Run 3, falling back to PYTHIA. Specify if and only if this is MC to override autodetect from metadata"}};
o2::framework::Configurable<bool> embedINELgtZEROselection{"embedINELgtZEROselection", false, {"Option to do percentile 100.5 if not INELgtZERO"}};
};

Expand Down Expand Up @@ -1199,16 +1199,10 @@ class MultModule
mRunNumberCentrality = bc.runNumber(); // mark that this run has been attempted already regardless of outcome
LOGF(info, "centrality loading procedure for timestamp=%llu, run number=%d", bc.timestamp(), bc.runNumber());

// capture the need for PYTHIA calibration in Pb-Pb runs
if (metadataInfo.isMC() && mRunNumber >= 544013 && mRunNumber <= 545367 && internalOpts.generatorName.value.empty()) {
LOGF(info, "This is MC for Pb-Pb. Setting generatorName automatically to PYTHIA");
internalOpts.generatorName.value = "PYTHIA";
}

// capture the need for PYTHIA calibration in light ion runs automatically
if (metadataInfo.isMC() && mRunNumber >= 564250 && mRunNumber <= 564472 && internalOpts.generatorName.value.empty()) {
LOGF(info, "This is MC for light ion runs. Setting generatorName automatically to PYTHIA");
internalOpts.generatorName.value = "PYTHIA";
// autodetect the generator from the metadata if not explicitly configured
if (metadataInfo.isMC() && internalOpts.generatorName.value.empty()) {
internalOpts.generatorName.value = metadataInfo.getGenerator();
LOGF(info, "Setting generatorName automatically from metadata to %s", internalOpts.generatorName.value);
}

LOGF(info, "centrality loading procedure for timestamp=%llu, run number=%d", bc.timestamp(), bc.runNumber());
Expand Down
Loading