Skip to content

Commit 7393582

Browse files
authored
[Common] Add LPMProduction to mc generator map to autodetect generator from metadata in the MultModule (#18549)
1 parent 8a4077f commit 7393582

3 files changed

Lines changed: 38 additions & 11 deletions

File tree

‎Common/Core/MetadataHelper.cxx‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <TSystem.h>
2626

2727
#include <array>
28+
#include <map>
2829
#include <string>
2930

3031
using namespace o2::common::core;
@@ -153,6 +154,34 @@ std::string MetadataHelper::getO2Version() const
153154
return get("O2Version");
154155
}
155156

157+
std::string MetadataHelper::getGenerator() const
158+
{
159+
if (!isMC()) {
160+
return {};
161+
}
162+
163+
// MC production tag (LPMProductionTag) -> generator name, for AO2Ds without the generator in the metadata
164+
static const std::map<std::string, std::string> mcGeneratorMap = {
165+
{"LHC26f3", "EPOS"},
166+
{"LHC26k3", "EPOS"}};
167+
168+
// FIXME: use the "Generator" key first once it is available in AO2Ds (it must also be added to the key list in the constructor)
169+
// if (isKeyDefined("Generator")) {
170+
// return get("Generator");
171+
// }
172+
173+
// older AO2Ds: rely on the LPMProductionTag to generator map
174+
if (isKeyDefined("LPMProductionTag")) {
175+
auto it = mcGeneratorMap.find(get("LPMProductionTag"));
176+
if (it != mcGeneratorMap.end()) {
177+
return it->second;
178+
}
179+
}
180+
181+
// no generator found in the metadata, fall back to PYTHIA
182+
return "PYTHIA";
183+
}
184+
156185
bool MetadataHelper::isCommitInSoftwareTag(const std::string& commitHash, const std::string& ccdbUrl) const
157186
{
158187
const std::string softwareTag = getO2Version();

‎Common/Core/MetadataHelper.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ struct MetadataHelper {
5555
/// @return the O2 version from the metadata
5656
std::string getO2Version() const;
5757

58+
/// @brief Function to get the MC generator name from the metadata
59+
/// @return the generator name (e.g. "PYTHIA", "EPOS"), "PYTHIA" for MC if it cannot be determined, or an empty string for data
60+
std::string getGenerator() const;
61+
5862
/// @brief Function to get the metadata value for a given key
5963
/// @param key the key of the metadata
6064
/// @return the value of the metadata. Throws an exception if the key is not found

‎Common/Tools/Multiplicity/MultModule.h‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ struct standardConfigurables : o2::framework::ConfigurableGroup {
346346
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."}};
347347

348348
// centrality operation
349-
o2::framework::Configurable<std::string> generatorName{"generatorName", "", {"Specify if and only if this is MC. Typical: PYTHIA"}};
349+
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"}};
350350
o2::framework::Configurable<bool> embedINELgtZEROselection{"embedINELgtZEROselection", false, {"Option to do percentile 100.5 if not INELgtZERO"}};
351351
};
352352

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

1202-
// capture the need for PYTHIA calibration in Pb-Pb runs
1203-
if (metadataInfo.isMC() && mRunNumber >= 544013 && mRunNumber <= 545367 && internalOpts.generatorName.value.empty()) {
1204-
LOGF(info, "This is MC for Pb-Pb. Setting generatorName automatically to PYTHIA");
1205-
internalOpts.generatorName.value = "PYTHIA";
1206-
}
1207-
1208-
// capture the need for PYTHIA calibration in light ion runs automatically
1209-
if (metadataInfo.isMC() && mRunNumber >= 564250 && mRunNumber <= 564472 && internalOpts.generatorName.value.empty()) {
1210-
LOGF(info, "This is MC for light ion runs. Setting generatorName automatically to PYTHIA");
1211-
internalOpts.generatorName.value = "PYTHIA";
1202+
// autodetect the generator from the metadata if not explicitly configured
1203+
if (metadataInfo.isMC() && internalOpts.generatorName.value.empty()) {
1204+
internalOpts.generatorName.value = metadataInfo.getGenerator();
1205+
LOGF(info, "Setting generatorName automatically from metadata to %s", internalOpts.generatorName.value);
12121206
}
12131207

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

0 commit comments

Comments
 (0)