Skip to content

Commit

Permalink
[SimWF,WIP] Enable MaterialManager input from CCDB
Browse files Browse the repository at this point in the history
* first demonstrator
  • Loading branch information
Benedikt Volkel committed Jun 20, 2024
1 parent d66f838 commit cf6f273
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
7 changes: 3 additions & 4 deletions MC/bin/o2dpg_sim_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) + '"'
23 changes: 21 additions & 2 deletions MC/bin/o2dpg_sim_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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) \
Expand Down Expand Up @@ -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'])

Expand Down

0 comments on commit cf6f273

Please sign in to comment.