diff --git a/MC/bin/o2dpg_sim_config.py b/MC/bin/o2dpg_sim_config.py index 59e161c46..1beb0262b 100755 --- a/MC/bin/o2dpg_sim_config.py +++ b/MC/bin/o2dpg_sim_config.py @@ -212,4 +212,14 @@ def get_dpl_options_for_executable(executable, envfile): def option_if_available(executable, option, envfile = None): """Checks if an option is available for a given executable and returns it as a string. Otherwise empty string""" _, inverse_lookup = get_dpl_options_for_executable(executable, envfile) - return ' ' + option if option in inverse_lookup else '' \ No newline at end of file + return ' ' + option if option in inverse_lookup else '' + + +# helper function to overwrite some values; prints out stuff that it changes +def overwrite_config(config, mainkey, subkey, value): + oldvalue = config.get(mainkey,{}).get(subkey, None) + print (f"Overwriting {mainkey}.{subkey}: {'None' if oldvalue is None else oldvalue} -> {value}") + if mainkey not in config: + # Initialize the main key in the dictionary if it does not already exist + config[mainkey] = {} + config[mainkey][subkey] = value \ No newline at end of file diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index bfcb2ca6f..b9d1fc084 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -42,7 +42,7 @@ from o2dpg_workflow_utils import createTask, createGlobalInitTask, dump_workflow, adjust_RECO_environment, isActive, activate_detector, deactivate_detector, compute_n_workers, merge_dicts from o2dpg_qc_finalization_workflow import include_all_QC_finalization -from o2dpg_sim_config import create_sim_config, create_geant_config, constructConfigKeyArg, option_if_available +from o2dpg_sim_config import create_sim_config, create_geant_config, constructConfigKeyArg, option_if_available, overwrite_config from o2dpg_dpl_config_tools import parse_command_string, modify_dpl_command, dpl_option_from_config, TaskFinalizer parser = argparse.ArgumentParser(description='Create an ALICE (Run3) MC simulation workflow') @@ -219,6 +219,19 @@ def load_external_config(configfile): # merge the dictionaries into anchorConfig, the latter takes precedence merge_dicts(anchorConfig, config_overwrite) +# We still may need adjust configurations manually for consistency: +# +# * Force simpler TPC digitization of if TPC reco does not have the mc-time-gain option: +tpc_envfile = 'env_async.env' if environ.get('ALIEN_JDL_O2DPG_ASYNC_RECO_TAG') is not None else None +tpcreco_mctimegain = option_if_available('o2-tpc-reco-workflow', '--tpc-mc-time-gain', envfile=tpc_envfile) +if tpcreco_mctimegain == '': + # this was communicated by Jens Wiechula@TPC; avoids dEdX issue https://its.cern.ch/jira/browse/O2-5486 for the 2tag mechanism + print ("TPC reco does not support --tpc-mc-time-gain. Adjusting some config for TPC digitization") + overwrite_config(anchorConfig['ConfigParams'],'TPCGasParam','OxygenCont',5e-5) + overwrite_config(anchorConfig['ConfigParams'],'TPCGEMParam','TotalGainStack',2000) + overwrite_config(anchorConfig['ConfigParams'],'GPU_global','dEdxDisableResidualGain',1) +# TODO: put into it's own function for better modularity + # with the config, we'll create a task_finalizer functor # this object takes care of customizing/finishing task command with externally given (anchor) config task_finalizer = TaskFinalizer(anchorConfig, logger="o2dpg_config_replacements.log") @@ -1169,7 +1182,6 @@ def getDigiTaskName(det): # tpc_corr_scaling_options = ('--lumi-type 1', '')[tpcDistortionType != 0] #<--------- TPC reco task - tpc_envfile = 'env_async.env' if environ.get('ALIEN_JDL_O2DPG_ASYNC_RECO_TAG') is not None else None TPCRECOtask=createTask(name='tpcreco_'+str(tf), needs=tpcreconeeds, tf=tf, cwd=timeframeworkdir, lab=["RECO"], relative_cpu=3/8, mem='16000') TPCRECOtask['cmd'] = task_finalizer([ '${O2_ROOT}/bin/o2-tpc-reco-workflow', @@ -1185,7 +1197,7 @@ def getDigiTaskName(det): ('',' --disable-mc')[args.no_mc_labels], tpc_corr_scaling_options, tpc_corr_options_mc, - option_if_available('o2-tpc-reco-workflow', '--tpc-mc-time-gain', envfile=tpc_envfile)]) + tpcreco_mctimegain]) workflow['stages'].append(TPCRECOtask) #<--------- ITS reco task