From cf6f27392d9420ea18072cc6bb2962c08b7f0deb Mon Sep 17 00:00:00 2001 From: Benedikt Volkel Date: Fri, 24 May 2024 14:19:36 +0200 Subject: [PATCH] [SimWF,WIP] Enable MaterialManager input from CCDB * first demonstrator --- MC/bin/o2dpg_sim_config.py | 7 +++---- MC/bin/o2dpg_sim_workflow.py | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/MC/bin/o2dpg_sim_config.py b/MC/bin/o2dpg_sim_config.py index 22017086d..24efa3935 100755 --- a/MC/bin/o2dpg_sim_config.py +++ b/MC/bin/o2dpg_sim_config.py @@ -125,9 +125,8 @@ def constructConfigKeyArg(config): # and constructs the --configKeyValues options for simulation if len(config) == 0: return '' - arg = '--configKeyValues "' + arg_tokens = [] for mainkey in config: for subkey in config[mainkey]: - arg = arg + mainkey + '.' + subkey + '=' + config[mainkey][subkey] + ';' - arg = arg + '"' - return arg + arg_tokens.append(mainkey + '.' + subkey + '=' + config[mainkey][subkey]) + return '--configKeyValues "' + ';'.join(arg_tokens) + '"' diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index 0cec2d02f..34a36d568 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -61,6 +61,7 @@ parser.add_argument('-ini',help='generator init parameters file (full paths required), for example: ${O2DPG_ROOT}/MC/config/PWGHF/ini/GeneratorHF.ini', default='') parser.add_argument('-confKey',help='generator or trigger configuration key values, for example: "GeneratorPythia8.config=pythia8.cfg;A.x=y"', default='') parser.add_argument('--readoutDets',help='comma separated string of detectors readout (does not modify material budget - only hit creation)', default='all') +parser.add_argument('--material-params-ccdb', dest='material_params_ccdb', action='store_true', help='to fetch the material parameters used during transport from CCDB') parser.add_argument('-interactionRate',help='Interaction rate, used in digitization', default=-1) parser.add_argument('-bcPatternFile',help='Bunch crossing pattern file, used in digitization (a file name or "ccdb")', default='') @@ -362,6 +363,24 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True): if (includeLocalQC or includeFullQC) and not isdir(qcdir): mkdir(qcdir) +# prepare fetching and configuration for MaterialManagerParam +transport_needs = [] +if args.material_params_ccdb: + # the target file name + mat_mgr_file_name = 'material_manager_params.json' + # the path on CCDB + ccdb_path = 'SIM_TEST/ALIBI/SIM_CUTS' + # this is the full local path of where the parameter file will be copied to + mat_mgr_file_path = f'${{ALICEO2_CCDB_LOCALCACHE}}/{ccdb_path}/{mat_mgr_file_name}' + # simply append, the last one takes precedence + args.confKey += f';MaterialManagerParam.inputFile={mat_mgr_file_path}' + args.confKeyBkg += f';MaterialManagerParam.inputFile={mat_mgr_file_path}' + + MAT_PARAMS_DOWNLOADER_TASK = createTask(name='download_mat_mgr_params', cpu=0) + MAT_PARAMS_DOWNLOADER_TASK['cmd'] = f'${{O2_ROOT}}/bin/o2-ccdb-downloadccdbfile --host http://ccdb-test.cern.ch:8080 -p {ccdb_path} --timestamp -1 -d ${{ALICEO2_CCDB_LOCALCACHE}} -o {mat_mgr_file_name}' + workflow['stages'].append(MAT_PARAMS_DOWNLOADER_TASK) + transport_needs.append(MAT_PARAMS_DOWNLOADER_TASK['name']) + # create/publish the GRPs and other GLO objects for consistent use further down the pipeline orbitsPerTF=int(args.orbitsPerTF) GRP_TASK = createTask(name='grpcreate', cpu='0') @@ -455,7 +474,7 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True): # determine final configKey values for background transport CONFKEYBKG = constructConfigKeyArg(create_geant_config(args, args.confKeyBkg)) - BKGtask=createTask(name='bkgsim', lab=["GEANT"], needs=[BKG_CONFIG_task['name'], GRP_TASK['name']], cpu=NWORKERS ) + BKGtask=createTask(name='bkgsim', lab=["GEANT"], needs=[BKG_CONFIG_task['name'], GRP_TASK['name']] + transport_needs, cpu=NWORKERS ) BKGtask['cmd']='${O2_ROOT}/bin/o2-sim -e ' + SIMENGINE + ' -j ' + str(NWORKERS) + ' -n ' + str(NBKGEVENTS) \ + ' -g ' + str(GENBKG) + ' ' + str(MODULES) + ' -o bkg ' + str(INIBKG) \ + ' --field ccdb ' + str(CONFKEYBKG) \ @@ -700,7 +719,7 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True): # ----------------- # transport signals # ----------------- - signalneeds=[ SGN_CONFIG_task['name'], GRP_TASK['name'] ] + signalneeds=[ SGN_CONFIG_task['name'], GRP_TASK['name'] ] + transport_needs if (args.pregenCollContext == True): signalneeds.append(PreCollContextTask['name'])