Skip to content

Commit b3abf9d

Browse files
ddobrigkalibuild
andauthored
[PWGLF] Full process function autoconfigure for strangeness builder service (#11467)
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
1 parent 296df02 commit b3abf9d

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ struct StrangenessBuilder {
301301

302302
Configurable<int> mc_findableMode{"mc_findableMode", 0, "0: disabled; 1: add findable-but-not-found to existing V0s from AO2D; 2: reset V0s and generate only findable-but-not-found"};
303303

304+
// Autoconfigure process functions
305+
Configurable<bool> autoConfigureProcess{"autoConfigureProcess", false, "if true, will configure process function switches based on metadata"};
306+
304307
// V0 building options
305308
struct : ConfigurableGroup {
306309
std::string prefix = "v0BuilderOpts";
@@ -2646,6 +2649,75 @@ struct StrangenessBuilder {
26462649

26472650
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
26482651
{
2652+
auto strangenessBuilderTask = adaptAnalysisTask<StrangenessBuilder>(cfgc);
2653+
bool isRun3 = true, hasRunInfo = false;
2654+
bool isMC = false, hasDataTypeInfo = false;
2655+
if (cfgc.options().hasOption("aod-metadata-Run") == true) {
2656+
hasRunInfo = true;
2657+
if (cfgc.options().get<std::string>("aod-metadata-Run") == "2") {
2658+
isRun3 = false;
2659+
}
2660+
}
2661+
if (cfgc.options().hasOption("aod-metadata-DataType") == true) {
2662+
hasDataTypeInfo = true;
2663+
if (cfgc.options().get<std::string>("aod-metadata-DataType") == "MC") {
2664+
isMC = true;
2665+
}
2666+
}
2667+
2668+
int idxSwitches[8]; // 8 switches (real / real r2 / MC / MC r2 + PID)
2669+
bool autoConfigureProcessConfig = true;
2670+
bool withPID = false;
2671+
2672+
for (size_t ipar = 0; ipar < strangenessBuilderTask.options.size(); ipar++) {
2673+
auto option = strangenessBuilderTask.options[ipar];
2674+
if (option.name == "processRealData") {
2675+
idxSwitches[0] = ipar;
2676+
}
2677+
if (option.name == "processRealDataRun2") {
2678+
idxSwitches[1] = ipar;
2679+
}
2680+
if (option.name == "processMonteCarlo") {
2681+
idxSwitches[2] = ipar;
2682+
}
2683+
if (option.name == "processMonteCarloRun2") {
2684+
idxSwitches[3] = ipar;
2685+
}
2686+
if (option.name == "processRealDataWithPID") {
2687+
idxSwitches[4] = ipar;
2688+
}
2689+
if (option.name == "processRealDataRun2WithPID") {
2690+
idxSwitches[5] = ipar;
2691+
}
2692+
if (option.name == "processMonteCarloWithPID") {
2693+
idxSwitches[6] = ipar;
2694+
}
2695+
if (option.name == "processMonteCarloRun2WithPID") {
2696+
idxSwitches[7] = ipar;
2697+
}
2698+
if (option.name == "autoConfigureProcess") {
2699+
autoConfigureProcessConfig = option.defaultValue.get<bool>(); // check if autoconfig requested
2700+
}
2701+
// use withPID in case preselection is requested
2702+
if (option.name == "preSelectOpts.preselectOnlyDesiredV0s" || option.name == "preSelectOpts.preselectOnlyDesiredCascades") {
2703+
withPID = withPID || option.defaultValue.get<bool>();
2704+
}
2705+
}
2706+
if ((!hasRunInfo || !hasDataTypeInfo) && autoConfigureProcessConfig) {
2707+
throw std::runtime_error("Autoconfigure requested but no metadata information found! Please check if --aod-file <file> was used in the last workflow added in the execution and if the AO2D in question has metadata saved in it.");
2708+
}
2709+
2710+
// positions of switches are known. Next: flip if asked for
2711+
if (autoConfigureProcessConfig) {
2712+
int relevantProcess = static_cast<int>(!isRun3) + 2 * static_cast<int>(isMC) + 4 * static_cast<int>(withPID);
2713+
LOGF(info, "Automatic configuration of process switches requested! Autodetected settings: isRun3? %i, isMC? %i, withPID? %i (switch #%i)", hasRunInfo, hasDataTypeInfo, isRun3, isMC, withPID, relevantProcess);
2714+
for (size_t idx = 0; idx < 8; idx++) {
2715+
auto option = strangenessBuilderTask.options[idxSwitches[idx]];
2716+
option.defaultValue = false; // switch all off
2717+
}
2718+
strangenessBuilderTask.options[idxSwitches[relevantProcess]].defaultValue = true;
2719+
}
2720+
26492721
return WorkflowSpec{
2650-
adaptAnalysisTask<StrangenessBuilder>(cfgc)};
2722+
strangenessBuilderTask};
26512723
}

0 commit comments

Comments
 (0)