Skip to content

Commit f765c5e

Browse files
gconesabchiarazampolli
authored andcommitted
Add option to get mean vertex from external file
1 parent 4bb65ca commit f765c5e

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

MC/bin/o2dpg_sim_workflow.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import itertools
2828
import time
2929
import requests, re
30+
import pandas as pd
3031

3132
sys.path.append(join(dirname(__file__), '.', 'o2dpg_workflow_utils'))
3233

@@ -54,6 +55,7 @@
5455

5556
parser.add_argument('-interactionRate',help='Interaction rate, used in digitization', default=-1)
5657
parser.add_argument('-bcPatternFile',help='Bunch crossing pattern file, used in digitization (a file name or "ccdb")', default='')
58+
parser.add_argument('-meanVertexPerRunTxtFile',help='Txt file with mean vertex settings per run', default='')
5759
parser.add_argument('-eCM',help='CMS energy', default=-1)
5860
parser.add_argument('-eA',help='Beam A energy', default=-1) #6369 PbPb, 2.510 pp 5 TeV, 4 pPb
5961
parser.add_argument('-eB',help='Beam B energy', default=-1)
@@ -205,6 +207,30 @@ def retrieve_sor(run_number):
205207

206208
return int(SOR)
207209

210+
CONFKEY=''
211+
if args.confKey!= '':
212+
CONFKEY=' --configKeyValues "' + args.confKey + '"'
213+
214+
# Recover mean vertex settings from external txt file
215+
216+
if len(args.meanVertexPerRunTxtFile) > 0:
217+
if "Diamond" in CONFKEY:
218+
print("confKey already sets diamond, stop!")
219+
sys.exit()
220+
#df = pd.read_csv(args.vertexPerRunFile, sep=" ", header=None) # for single space
221+
df = pd.read_csv(args.meanVertexPerRunTxtFile, delimiter="\t", header=None) # for tabular
222+
df.columns = ["runNumber", "vx", "vy", "vz", "sx", "sy", "sz"]
223+
#print(df) # print full table
224+
MV_SX = float(df.loc[df['runNumber'].eq(args.run), 'sx'])
225+
MV_SY = float(df.loc[df['runNumber'].eq(args.run), 'sy'])
226+
MV_SZ = float(df.loc[df['runNumber'].eq(args.run), 'sz'])
227+
MV_VX = float(df.loc[df['runNumber'].eq(args.run), 'vx'])
228+
MV_VY = float(df.loc[df['runNumber'].eq(args.run), 'vy'])
229+
MV_VZ = float(df.loc[df['runNumber'].eq(args.run), 'vz'])
230+
print("** Using mean vertex parameters from file",args.meanVertexPerRunTxtFile,"for run =",args.run,
231+
": \n \t vx =",MV_VX,", vy =",MV_VY,", vz =",MV_VZ,",\n \t sx =",MV_SX,", sy =",MV_SY,", sz =",MV_SZ)
232+
CONFKEY = CONFKEY + ' "Diamond.width[2]='+str(MV_SZ)+';Diamond.width[1]='+str(MV_SY)+';Diamond.width[0]='+str(MV_SX)+';Diamond.position[2]='+str(MV_VZ)+';Diamond.position[1]='+str(MV_VY)+';Diamond.position[0]='+str(MV_VX)+'"'
233+
print("** New confKey:",CONFKEY)
208234

209235
# ----------- START WORKFLOW CONSTRUCTION -----------------------------
210236

@@ -422,9 +448,6 @@ def getDPL_global_options(bigshm=False):
422448
INIFILE=''
423449
if args.ini!= '':
424450
INIFILE=' --configFile ' + args.ini
425-
CONFKEY=''
426-
if args.confKey!= '':
427-
CONFKEY=' --configKeyValues "' + args.confKey + '"'
428451
PROCESS=args.proc
429452
TRIGGER=''
430453
if args.trigger != '':

0 commit comments

Comments
 (0)