Skip to content

Commit a098206

Browse files
committed
Possibility to take external config for Pythia8
In case of generator pythia8, we have so far always constructed a Pythia8 config file from the parameters given to o2dpg_sim_workflow.py However, some expert users may want to use an external configuration for Pythia8. This commit provides the possibility to do so via sensitivity to the `GeneratorPythia8.config` ConfigurableParam (so far ignored). An example is: ``` ${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 14000 -col pp -gen pythia8 -proc cdiff -tf 2 \ -ns 20 -e ${SIMENGINE} \ -j ${NWORKERS} -interactionRate 500000 \ -run 302000 -seed 624 \ -confKey "GeneratorPythia8.config=/SOMEPATH/pythia8_powheg.cfg" ``` The new feature allows expert studies with specially setup Pythia8 configs. The development was motivated from https://its.cern.ch/jira/browse/O2-4549 However, note that options `-proc` `-eCM` etc. might have no effect or are ignored in such cases.
1 parent 224e43d commit a098206

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

MC/bin/o2dpg_sim_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ def create_geant_config(args, externalConfigString):
9797
# creates generic transport simulation config key values
9898
# based on arguments args (run number, energy, ...) originally passed
9999
# to o2dpg_sim_workflow.py
100+
#
101+
# returns a dictionary of mainkey -> dictionary of subkey : values
100102
config = {}
101103
def add(cfg, flatconfig):
102104
for entry in flatconfig:

MC/bin/o2dpg_sim_workflow.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
505505
workflow['stages'].append(TPC_SPACECHARGE_DOWNLOADER_TASK)
506506

507507

508+
# query initial configKey args for signal transport; mainly used to setup generators
509+
simInitialConfigKeys = create_geant_config(args, args.confKey)
510+
508511
# loop over timeframes
509512
for tf in range(1, NTIMEFRAMES + 1):
510513
TFSEED = SIMSEED + tf
@@ -627,38 +630,46 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
627630
SGN_CONFIG_task=createTask(name='gensgnconf_'+str(tf), tf=tf, cwd=timeframeworkdir)
628631
SGN_CONFIG_task['cmd'] = 'echo "placeholder / dummy task"'
629632
if GENERATOR == 'pythia8':
630-
SGN_CONFIG_task['cmd'] = '${O2DPG_ROOT}/MC/config/common/pythia8/utils/mkpy8cfg.py \
631-
--output=pythia8.cfg \
632-
--seed='+str(TFSEED)+' \
633-
--idA='+str(PDGA)+' \
634-
--idB='+str(PDGB)+' \
635-
--eCM='+str(ECMS)+' \
636-
--eA='+str(EBEAMA)+' \
637-
--eB='+str(EBEAMB)+' \
638-
--process='+str(PROCESS)+' \
639-
--ptHatMin='+str(PTHATMIN)+' \
640-
--ptHatMax='+str(PTHATMAX)
641-
if WEIGHTPOW > 0:
642-
SGN_CONFIG_task['cmd'] = SGN_CONFIG_task['cmd'] + ' --weightPow=' + str(WEIGHTPOW)
633+
# see if config is given externally
634+
externalPythia8Config = simInitialConfigKeys.get("GeneratorPythia8", {}).get("config", None)
635+
if externalPythia8Config != None:
636+
print ("Using external Pythia8 configuration " + str(externalPythia8Config))
637+
# in this case, we copy the external config to the local dir (maybe not even necessary)
638+
SGN_CONFIG_task['cmd'] = 'cp ' + externalPythia8Config + ' pythia8.cfg'
639+
else:
640+
SGN_CONFIG_task['cmd'] = '${O2DPG_ROOT}/MC/config/common/pythia8/utils/mkpy8cfg.py \
641+
--output=pythia8.cfg \
642+
--seed='+str(TFSEED)+' \
643+
--idA='+str(PDGA)+' \
644+
--idB='+str(PDGB)+' \
645+
--eCM='+str(ECMS)+' \
646+
--eA='+str(EBEAMA)+' \
647+
--eB='+str(EBEAMB)+' \
648+
--process='+str(PROCESS)+' \
649+
--ptHatMin='+str(PTHATMIN)+' \
650+
--ptHatMax='+str(PTHATMAX)
651+
if WEIGHTPOW > 0:
652+
SGN_CONFIG_task['cmd'] = SGN_CONFIG_task['cmd'] + ' --weightPow=' + str(WEIGHTPOW)
653+
643654
# if we configure pythia8 here --> we also need to adjust the configuration
644655
# TODO: we need a proper config container/manager so as to combine these local configs with external configs etc.
645656
args.confKey = args.confKey + ";GeneratorPythia8.config=pythia8.cfg"
646657

647658
# elif GENERATOR == 'extgen': what do we do if generator is not pythia8?
648659
# NOTE: Generator setup might be handled in a different file or different files (one per
649660
# possible generator)
650-
651661
workflow['stages'].append(SGN_CONFIG_task)
652662

663+
# determine final conf key for signal simulation
664+
CONFKEY = constructConfigKeyArg(create_geant_config(args, args.confKey))
665+
653666
# -----------------
654667
# transport signals
655668
# -----------------
656669
signalneeds=[ SGN_CONFIG_task['name'], GRP_TASK['name'] ]
657670
if (args.pregenCollContext == True):
658671
signalneeds.append(PreCollContextTask['name'])
659672

660-
# determine final configKey args for signal transport
661-
CONFKEY = constructConfigKeyArg(create_geant_config(args, args.confKey))
662673

663674
# add embedIntoFile only if embeddPattern does contain a '@'
664675
embeddinto= "--embedIntoFile ../bkg_MCHeader.root" if (doembedding & ("@" in args.embeddPattern)) else ""

0 commit comments

Comments
 (0)