Skip to content

Commit 20bfdeb

Browse files
committed
add pythia8 automatic configuration on bkg part and other bkg dedicated settings
1 parent 02fc68b commit 20bfdeb

File tree

6 files changed

+116
-40
lines changed

6 files changed

+116
-40
lines changed

MC/bin/o2dpg_sim_workflow.py

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232

3333
parser.add_argument('-ns',help='number of signal events / timeframe', default=20)
3434
parser.add_argument('-gen',help='generator: pythia8, extgen', default='')
35-
parser.add_argument('-proc',help='process type: dirgamma, jets, ccbar', default='')
35+
parser.add_argument('-proc',help='process type: inel, dirgamma, jets, ccbar, ...', default='')
3636
parser.add_argument('-trigger',help='event selection: particle, external', default='')
3737
parser.add_argument('-ini',help='generator init parameters file, for example: ${O2DPG_ROOT}/MC/config/PWGHF/ini/GeneratorHF.ini', default='')
3838
parser.add_argument('-confKey',help='generator or trigger configuration key values, for example: GeneratorPythia8.config=pythia8.cfg', default='')
3939

4040
parser.add_argument('-interactionRate',help='Interaction rate, used in digitization', default=-1)
4141
parser.add_argument('-eCM',help='CMS energy', default=-1)
42-
parser.add_argument('-eA',help='Beam A energy', default=6499.) #6369 PbPb, 2.510 pp 5 TeV, 4 pPb
42+
parser.add_argument('-eA',help='Beam A energy', default=-1) #6369 PbPb, 2.510 pp 5 TeV, 4 pPb
4343
parser.add_argument('-eB',help='Beam B energy', default=-1)
4444
parser.add_argument('-col',help='collision system: pp, PbPb, pPb, Pbp, ..., in case of embedding collision system of signal', default='pp')
4545
parser.add_argument('-field',help='L3 field rounded to kGauss, allowed: values +-2,+-5 and 0; +-5U for uniform field', default='-5')
@@ -51,9 +51,10 @@
5151

5252
parser.add_argument('--embedding',action='store_true', help='With embedding into background')
5353
parser.add_argument('-nb',help='number of background events / timeframe', default=20)
54-
parser.add_argument('-genBkg',help='embedding background generator', default='pythia8hi')
54+
parser.add_argument('-genBkg',help='embedding background generator', default='') #pythia8, not recomended: pythia8hi, pythia8pp
55+
parser.add_argument('-procBkg',help='process type: inel, ..., do not set it for Pythia8 PbPb', default='none')
5556
parser.add_argument('-iniBkg',help='embedding background generator init parameters file', default='${O2DPG_ROOT}/MC/config/common/ini/basic.ini')
56-
parser.add_argument('-confKeyBkg',help='embedding background configuration key values, for example: GeneratorPythia8.config=pythia8.cfg', default='')
57+
parser.add_argument('-confKeyBkg',help='embedding background configuration key values, for example: GeneratorPythia8.config=pythia8bkg.cfg', default='')
5758
parser.add_argument('-colBkg',help='embedding background collision system', default='PbPb')
5859

5960
parser.add_argument('-e',help='simengine', default='TGeant4')
@@ -101,6 +102,7 @@
101102
MODULES=args.mod #"--skipModules ZDC"
102103
SIMENGINE=args.e
103104
BFIELD=args.field
105+
RNDSEED=args.seed # 0 means random seed ! Should we set different seed for Bkg and signal?
104106

105107
# add here other possible types
106108

@@ -130,14 +132,77 @@ def getDPL_global_options(bigshm=False,nosmallrate=False):
130132
print('o2dpg_sim_workflow: Error! embedding background generator name not provided')
131133
exit(1)
132134

133-
INIBKG=''
134-
if args.iniBkg!= '':
135-
INIBKG=' --configFile ' + args.iniBkg
135+
PROCESSBKG=args.procBkg
136+
COLTYPEBKG=args.colBkg
137+
ECMSBKG=float(args.eCM)
138+
EBEAMABKG=float(args.eA)
139+
EBEAMBBKG=float(args.eB)
140+
141+
if COLTYPEBKG == 'pp':
142+
PDGABKG=2212 # proton
143+
PDGBBKG=2212 # proton
144+
145+
if COLTYPEBKG == 'PbPb':
146+
PDGABKG=1000822080 # Pb
147+
PDGBBKG=1000822080 # Pb
148+
if ECMSBKG < 0: # assign 5.02 TeV to Pb-Pb
149+
print('o2dpg_sim_workflow: Set BKG CM Energy to PbPb case 5.02 TeV')
150+
ECMSBKG=5020.0
151+
if GENBKG == 'pythia8':
152+
PROCESSBKG = 'none'
153+
print('o2dpg_sim_workflow: Process type not considered for Pythia8 PbPb')
154+
155+
if COLTYPEBKG == 'pPb':
156+
PDGABKG=2212 # proton
157+
PDGBBKG=1000822080 # Pb
158+
159+
if COLTYPEBKG == 'Pbp':
160+
PDGABKG=1000822080 # Pb
161+
PDGBBKG=2212 # proton
162+
163+
# If not set previously, set beam energy B equal to A
164+
if EBEAMBBKG < 0 and ECMSBKG < 0:
165+
EBEAMBBKG=EBEAMABKG
166+
print('o2dpg_sim_workflow: Set beam energy same in A and B beams')
167+
if COLTYPEBKG=="pPb" or COLTYPEBKG=="Pbp":
168+
print('o2dpg_sim_workflow: Careful! both beam energies in bkg are the same')
169+
170+
if ECMSBKG > 0:
171+
if COLTYPEBKG=="pPb" or COLTYPEBKG=="Pbp":
172+
print('o2dpg_sim_workflow: Careful! bkg ECM set for pPb/Pbp collisions!')
173+
174+
if ECMSBKG < 0 and EBEAMABKG < 0 and EBEAMBBKG < 0:
175+
print('o2dpg_sim_workflow: Error! bkg ECM or Beam Energy not set!!!')
176+
exit(1)
136177

137178
CONFKEYBKG=''
138179
if args.confKeyBkg!= '':
139180
CONFKEYBKG=' --configKeyValues ' + args.CONFKEYBKG
140181

182+
# Background PYTHIA configuration
183+
BKG_CONFIG_task=createTask(name='genbkgconf')
184+
BKG_CONFIG_task['cmd'] = 'echo "placeholder / dummy task"'
185+
if GENBKG == 'pythia8':
186+
BKG_CONFIG_task['cmd'] = '${O2DPG_ROOT}/MC/config/common/pythia8/utils/mkpy8cfg.py \
187+
--output=pythia8bkg.cfg \
188+
--seed='+str(RNDSEED)+' \
189+
--idA='+str(PDGABKG)+' \
190+
--idB='+str(PDGBBKG)+' \
191+
--eCM='+str(ECMSBKG)+' \
192+
--eA='+str(EBEAMABKG)+' \
193+
--eB='+str(EBEAMBBKG)+' \
194+
--process='+str(PROCESSBKG)
195+
# if we configure pythia8 here --> we also need to adjust the configuration
196+
# TODO: we need a proper config container/manager so as to combine these local configs with external configs etc.
197+
CONFKEYBKG='--configKeyValues "GeneratorPythia8.config=pythia8bkg.cfg"'
198+
199+
workflow['stages'].append(BKG_CONFIG_task)
200+
201+
# background task configuration
202+
INIBKG=''
203+
if args.iniBkg!= '':
204+
INIBKG=' --configFile ' + args.iniBkg
205+
141206
BKGtask=createTask(name='bkgsim', lab=["GEANT"], cpu=NWORKERS)
142207
BKGtask['cmd']='o2-sim -e ' + SIMENGINE + ' -j ' + str(NWORKERS) + ' -n ' + str(NBKGEVENTS) \
143208
+ ' -g ' + str(GENBKG) + ' ' + str(MODULES) + ' -o bkg ' + str(INIBKG) \
@@ -193,7 +258,6 @@ def getDPL_global_options(bigshm=False,nosmallrate=False):
193258
# ---- transport task -------
194259
# function encapsulating the signal sim part
195260
# first argument is timeframe id
196-
RNDSEED=args.seed # 0 means random seed !
197261
ECMS=float(args.eCM)
198262
EBEAMA=float(args.eA)
199263
EBEAMB=float(args.eB)
@@ -303,13 +367,15 @@ def getDPL_global_options(bigshm=False,nosmallrate=False):
303367
if GENERATOR == 'pythia8' and PROCESS!='':
304368
SGN_CONFIG_task['cmd'] = '${O2DPG_ROOT}/MC/config/common/pythia8/utils/mkpy8cfg.py \
305369
--output=pythia8.cfg \
306-
--seed='+str(RNDSEED)+' \
307-
--idA='+str(PDGA)+' \
308-
--idB='+str(PDGB)+' \
309-
--eCM='+str(ECMS)+' \
310-
--process='+str(PROCESS)+' \
311-
--ptHatMin=' + str(PTHATMIN) + ' \
312-
--ptHatMax=' + str(PTHATMAX)
370+
--seed='+str(RNDSEED)+' \
371+
--idA='+str(PDGA)+' \
372+
--idB='+str(PDGB)+' \
373+
--eCM='+str(ECMS)+' \
374+
--eA='+str(EBEAMA)+' \
375+
--eB='+str(EBEAMB)+' \
376+
--process='+str(PROCESS)+' \
377+
--ptHatMin='+str(PTHATMIN)+' \
378+
--ptHatMax='+str(PTHATMAX)
313379
if WEIGHTPOW > 0:
314380
SGN_CONFIG_task['cmd'] = SGN_CONFIG_task['cmd'] + ' --weightPow=' + str(WEIGHTPOW)
315381
# if we configure pythia8 here --> we also need to adjust the configuration

MC/config/common/pythia8/utils/mkpy8cfg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@
9494

9595
### processes
9696
fout.write('### processes \n')
97-
fout.write('SoftQCD:inelastic = off \n') ### we switch this off because it might be on by default
97+
if args.idA == 2212 or args.idB == 2212:
98+
fout.write('SoftQCD:inelastic = off \n') ### we switch this off because it might be on by default, but only for pp or pPb,
99+
#in PbPb let's not force it in case it is needed in Angantyr
98100
if args.process == 'inel':
99101
fout.write('SoftQCD:inelastic = on \n')
100102
if args.process == 'ccbar' or args.process == 'heavy':

MC/run/PWGGAJE/run_dirgamma_embedding.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ echo 'Detector acceptance option ' $PARTICLE_ACCEPTANCE
5555
export CONFIG_OUTPARTON_PDG=${CONFIG_OUTPARTON_PDG:-0}
5656

5757
# create workflow
58-
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM ${CONFIG_ENERGY} -col pp -gen pythia8 -proc "dirgamma" \
59-
-ptHatMin ${PTHATMIN} -ptHatMax ${PTHATMAX} \
60-
-tf ${NTIMEFRAMES} -ns ${NSIGEVENTS} -e ${SIMENGINE} \
61-
-nb ${NBKGEVENTS} --embedding \
62-
-j ${NWORKERS} -mod "--skipModules ZDC" \
63-
-weightPow ${WEIGHTPOW} \
64-
-trigger "external" -ini "\$O2DPG_ROOT/MC/config/PWGGAJE/ini/trigger_prompt_gamma.ini"
58+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM ${CONFIG_ENERGY} \
59+
-nb ${NBKGEVENTS} --embedding \
60+
-colBkg PbPb -genBkg pythia8 -procBkg "none" \
61+
-col pp -gen pythia8 -proc "dirgamma" \
62+
-ptHatMin ${PTHATMIN} -ptHatMax ${PTHATMAX} \
63+
-tf ${NTIMEFRAMES} -ns ${NSIGEVENTS} -e ${SIMENGINE} \
64+
-j ${NWORKERS} -mod "--skipModules ZDC" \
65+
-weightPow ${WEIGHTPOW} \
66+
-trigger "external" -ini "\$O2DPG_ROOT/MC/config/PWGGAJE/ini/trigger_prompt_gamma.ini"
6567

6668
# run workflow
6769
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json

MC/run/PWGGAJE/run_dirgamma_hook_embedding.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ export CONFIG_OUTPARTON_PDG=${CONFIG_OUTPARTON_PDG:-0}
6161
echo 'Parton PDG option ' $CONFIG_OUTPARTON_PDG
6262

6363
# create workflow
64-
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM ${CONFIG_ENERGY} -col pp -gen pythia8 -proc "dirgamma" \
65-
-ptHatMin ${PTHATMIN} -ptHatMax ${PTHATMAX} \
66-
-tf ${NTIMEFRAMES} -ns ${NSIGEVENTS} -e ${SIMENGINE} \
67-
-nb ${NBKGEVENTS} --embedding \
68-
-j ${NWORKERS} -mod "--skipModules ZDC" \
69-
-weightPow ${WEIGHTPOW} \
70-
-ini "\$O2DPG_ROOT/MC/config/PWGGAJE/ini/hook_prompt_gamma.ini"
64+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM ${CONFIG_ENERGY} \
65+
-nb ${NBKGEVENTS} --embedding \
66+
-colBkg PbPb -genBkg pythia8 -procBkg "none" \
67+
-col pp -gen pythia8 -proc "dirgamma" \
68+
-ptHatMin ${PTHATMIN} -ptHatMax ${PTHATMAX} \
69+
-tf ${NTIMEFRAMES} -ns ${NSIGEVENTS} -e ${SIMENGINE} \
70+
-j ${NWORKERS} -mod "--skipModules ZDC" \
71+
-weightPow ${WEIGHTPOW} \
72+
-ini "\$O2DPG_ROOT/MC/config/PWGGAJE/ini/hook_prompt_gamma.ini"
7173

7274
# run workflow
7375
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json

MC/run/PWGGAJE/run_jets_embedding.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
RNDSEED=${RNDSEED:-0} # [default = 0] time-based random seed
1616
NSIGEVENTS=${NSIGEVENTS:-2}
1717
NBKGEVENTS=${NBKGEVENTS:-1}
18-
NTIMEFRAMES=${NTIMEFRAMES:-5}
18+
NTIMEFRAMES=${NTIMEFRAMES:-1}
1919
NWORKERS=${NWORKERS:-8}
2020
MODULES="--skipModules ZDC" #"PIPE ITS TPC EMCAL"
2121
CONFIG_ENERGY=${CONFIG_ENERGY:-5020.0}
@@ -41,12 +41,14 @@ else
4141
fi
4242

4343
# create workflow
44-
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM ${CONFIG_ENERGY} -col pp -gen pythia8 -proc "jets" \
45-
-ptHatMin ${PTHATMIN} -ptHatMax ${PTHATMAX} \
46-
-tf ${NTIMEFRAMES} -ns ${NSIGEVENTS} -e ${SIMENGINE} \
47-
-nb ${NBKGEVENTS} --embedding \
48-
-j ${NWORKERS} -mod "--skipModules ZDC" \
49-
-weightPow ${WEIGHTPOW}
44+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM ${CONFIG_ENERGY} \
45+
-nb ${NBKGEVENTS} --embedding \
46+
-colBkg PbPb -genBkg pythia8 -procBkg "none" \
47+
-col pp -gen pythia8 -proc "jets" \
48+
-ptHatMin ${PTHATMIN} -ptHatMax ${PTHATMAX} \
49+
-tf ${NTIMEFRAMES} -ns ${NSIGEVENTS} -e ${SIMENGINE} \
50+
-j ${NWORKERS} -mod "--skipModules ZDC" \
51+
-weightPow ${WEIGHTPOW}
5052
# run workflow
5153
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json
5254

MC/run/PWGHF/embedding_benchmark.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ SIMENGINE=${SIMENGINE:-TGeant4}
2424
PYPROCESS=${PYPROCESS:-ccbar} #ccbar, bbar, ...
2525

2626
# create workflow
27-
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 5020 -col pp -gen pythia8 -proc ${PYPROCESS} -tf ${NTIMEFRAMES} -nb ${NBKGEVENTS} \
28-
-ns ${NSIGEVENTS} -e ${SIMENGINE} \
29-
-j ${NWORKERS} --embedding -interactionRate 50000
27+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 5020 -col pp -gen pythia8 -proc ${PYPROCESS} \
28+
-colBkg PbPb -genBkg pythia8 -procBkg "none" \
29+
-tf ${NTIMEFRAMES} -nb ${NBKGEVENTS} \
30+
-ns ${NSIGEVENTS} -e ${SIMENGINE} \
31+
-j ${NWORKERS} --embedding -interactionRate 50000
3032

3133
# run workflow
3234
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json --cpu-limit ${CPULIMIT:-8}

0 commit comments

Comments
 (0)