Skip to content

Commit

Permalink
[SimWF,WIP] Fetch MaterialManager file from CCDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Volkel committed May 24, 2024
1 parent d66f838 commit 52a90a5
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion MC/bin/o2dpg_sim_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import importlib.util
import argparse
from os import environ, mkdir
from os.path import join, dirname, isdir, isabs
from os.path import join, dirname, isdir, isabs, abspath
import random
import json
import itertools
Expand Down Expand Up @@ -257,6 +257,19 @@ def retrieve_sor(run_number):
return int(SOR)


def get_medium_params_from_ccdb(target_path, timestamp='1716541100245'):
url = f'http://ccdb-test.cern.ch:8080/SIM_TEST/ALIBI/SIM_CUTS/{timestamp}'
resp_medium_params = requests.get(url)
if (status := resp_medium_params.status_code) != 200:
print(f'ERROR: Could not fetch medium parameters for timestamp {timestamp}; status code is {status}')
return False

with open(target_path, 'w') as f:
json.dump(resp_medium_params.json, f)

return True


# check and sanitize config-key values (extract and remove diamond vertex arguments into finalDiamondDict)
def extractVertexArgs(configKeyValuesStr, finalDiamondDict):
# tokenize configKeyValueStr on ;
Expand Down Expand Up @@ -362,6 +375,30 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
if (includeLocalQC or includeFullQC) and not isdir(qcdir):
mkdir(qcdir)

# adjust material manager params
confKeysSgn = create_geant_config(args, args.confKey)
confKeysBkg = create_geant_config(args, args.confKeyBkg)

# MaterialManagerParam only has an effect when given to signal confKey
mat_mgr_params = confKeysSgn.get("MaterialManagerParam", {}).get('inputFile', None)

if mat_mgr_params == 'ccdb':
mat_mgr_params = abspath('material_manager_params.json')
if not get_medium_params_from_ccdb(mat_mgr_params, '1716541100245'):
sys.exit(1)
elif mat_mgr_params is not None:
mat_mgr_params = abspath(mat_mgr_params)

if mat_mgr_params:
confKeysSgn['MaterialManagerParam']['inputFile'] = mat_mgr_params
bkg = confKeysBkg.get('MaterialManager', {})
bkg['inputFile'] = mat_mgr_params
confKeysBkg['MaterrialManager'] = bkg

args.confKey = constructConfigKeyArg(confKeysSgn)
args.confKeyBkg = constructConfigKeyArg(confKeysBkg)


# 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

0 comments on commit 52a90a5

Please sign in to comment.