Skip to content

Commit 9ceeed7

Browse files
committed
Tuning process function autoswitching
1 parent d964100 commit 9ceeed7

File tree

1 file changed

+61
-5
lines changed

1 file changed

+61
-5
lines changed

PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx

Lines changed: 61 additions & 5 deletions
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", true, "if true, will configure process function switches based on metadata"};
306+
304307
// V0 building options
305308
struct : ConfigurableGroup {
306309
std::string prefix = "v0BuilderOpts";
@@ -2655,12 +2658,65 @@ struct strangenessbuilderInitializer {
26552658

26562659
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
26572660
{
2658-
LOGF(info, "Strangeness builder pre-initializing now...");
2659-
26602661
auto strangenessBuilderTask = adaptAnalysisTask<StrangenessBuilder>(cfgc);
2661-
2662-
for(auto const& option : strangenessBuilderTask.options){
2663-
LOGF(info, "option identified: %s", option.name);
2662+
2663+
bool isRun3 = true;
2664+
bool isMC = false;
2665+
if(cfgc.options().hasOption("aod-metadata-Run") && cfgc.options().get<std::string>("aod-metadata-Run") == "2"){
2666+
isRun3 = false;
2667+
}
2668+
if(cfgc.options().hasOption("aod-metadata-DataType") && cfgc.options().get<std::string>("aod-metadata-DataType") == "MC"){
2669+
isMC = true;
2670+
}
2671+
2672+
int idxSwitches[8]; //8 switches (real / real r2 / MC / MC r2 + PID)
2673+
bool autoConfigureProcess = true;
2674+
bool withPID = false;
2675+
2676+
for(size_t ipar = 0; ipar<strangenessBuilderTask.options.size(); ipar++){
2677+
auto option = strangenessBuilderTask.options[ipar];
2678+
if(option.name == "processRealData"){
2679+
idxSwitches[0] = ipar;
2680+
}
2681+
if(option.name == "processRealDataRun2"){
2682+
idxSwitches[1] = ipar;
2683+
}
2684+
if(option.name == "processMonteCarlo"){
2685+
idxSwitches[2] = ipar;
2686+
}
2687+
if(option.name == "processMonteCarloRun2"){
2688+
idxSwitches[3] = ipar;
2689+
}
2690+
if(option.name == "processRealDataWithPID"){
2691+
idxSwitches[4] = ipar;
2692+
}
2693+
if(option.name == "processRealDataRun2WithPID"){
2694+
idxSwitches[5] = ipar;
2695+
}
2696+
if(option.name == "processMonteCarloWithPID"){
2697+
idxSwitches[6] = ipar;
2698+
}
2699+
if(option.name == "processMonteCarloRun2WithPID"){
2700+
idxSwitches[7] = ipar;
2701+
}
2702+
if(option.name == "autoConfigureProcess"){
2703+
autoConfigureProcess = option.defaultValue.get<bool>(); // check if autoconfig requested
2704+
}
2705+
// use withPID in case preselection is requested
2706+
if(option.name == "preSelectOpts.preselectOnlyDesiredV0s" || option.name == "preSelectOpts.preselectOnlyDesiredCascades" ){
2707+
withPID = withPID || option.defaultValue.get<bool>();
2708+
}
2709+
}
2710+
2711+
// positions of switches known - flip if asked for
2712+
if(autoConfigureProcess){
2713+
int relevantProcess = static_cast<int>(isMC) + 2*static_cast<int>(!isRun3) + 4*static_cast<int>(withPID);
2714+
LOGF(info, "Automatic configuration of process switches requested! Bools: isRun3? %i, isMC? %i, withPID? %i (switch #%i)", isRun3, isMC, withPID, relevantProcess);
2715+
for(size_t idx = 0; idx < 8; idx ++){
2716+
auto option = strangenessBuilderTask.options[idxSwitches[idx]];
2717+
option.defaultValue = false; // switch all off
2718+
}
2719+
strangenessBuilderTask.options[idxSwitches[relevantProcess]].defaultValue = true;
26642720
}
26652721

26662722
return WorkflowSpec{

0 commit comments

Comments
 (0)