1515# helper functionality #
1616# #######################
1717
18+ echo_info ()
19+ {
20+ echo " INFO [anchorMC]: ${* } "
21+ }
22+
23+ echo_error ()
24+ {
25+ echo " ERROR [anchorMC]: ${* } "
26+ }
27+
1828print_help ()
1929{
2030 echo " Usage: ./anchorMC.sh"
@@ -53,7 +63,7 @@ print_help()
5363# Prevent the script from being soured to omit unexpected surprises when exit is used
5464SCRIPT_NAME=" $( basename " $( test -L " $0 " && readlink " $0 " || echo " $0 " ) " ) "
5565if [ " ${SCRIPT_NAME} " != " $( basename ${BASH_SOURCE[0]} ) " ] ; then
56- echo " ERROR: This script cannot not be sourced" >&2
66+ echo_error " This script cannot not be sourced" >&2
5767 return 1
5868fi
5969
@@ -70,8 +80,15 @@ while [ "$1" != "" ] ; do
7080done
7181
7282# make sure O2DPG + O2 is loaded
73- [ ! " ${O2DPG_ROOT} " ] && echo " Error: This needs O2DPG loaded" && exit 1
74- [ ! " ${O2_ROOT} " ] && echo " Error: This needs O2 loaded" && exit 1
83+ [ ! " ${O2DPG_ROOT} " ] && echo_error " This needs O2DPG loaded" && exit 1
84+ [ ! " ${O2_ROOT} " ] && echo_error " This needs O2 loaded" && exit 1
85+
86+ # check if jq is there
87+ which jq > /dev/null 2>&1
88+ [ " ${?} " != " 0" ] && { echo_error " jq is not found. Install or load via alienv." ; exit 1 ; }
89+
90+ alien-token-info > /dev/null 2>&1
91+ [ " ${?} " != " 0" ] && { echo_error " No GRID token found, required to run." ; exit 1 ; }
7592
7693# ################################################################
7794# Set all required variables to identify an anchored production #
@@ -87,8 +104,8 @@ export ALIEN_JDL_WORKFLOWDETECTORS=${ALIEN_JDL_WORKFLOWDETECTORS:-ITS,TPC,TOF,FV
87104export ALIEN_JDL_ANCHOR_SIM_OPTIONS=${ALIEN_JDL_ANCHOR_SIM_OPTIONS:- -gen pythia8}
88105# all others MUST be set by the user/on the outside
89106export ALIEN_JDL_LPMANCHORPASSNAME=${ALIEN_JDL_LPMANCHORPASSNAME:- ${ANCHORPASSNAME} }
90- export ALIEN_JDL_MCANCHOR= ${ALIEN_JDL_MCANCHOR :- ${MCANCHOR} }
91- export ALIEN_JDL_LPMPASSNAME=${ALIEN_JDL_LPMPASSNAME :- ${PASSNAME} }
107+ # LPMPASSNAME is used in O2 and O2DPG scripts, however on the other hand, ALIEN_JDL_LPMANCHORPASSNAME is the one that is set in JDL templates; so use ALIEN_JDL_LPMANCHORPASSNAME and set ALIEN_JDL_LPMPASSNAME
108+ export ALIEN_JDL_LPMPASSNAME=${ALIEN_JDL_LPMANCHORPASSNAME }
92109export ALIEN_JDL_LPMRUNNUMBER=${ALIEN_JDL_LPMRUNNUMBER:- ${RUNNUMBER} }
93110export ALIEN_JDL_LPMPRODUCTIONTYPE=${ALIEN_JDL_LPMPRODUCTIONTYPE:- ${PRODUCTIONTYPE} }
94111export ALIEN_JDL_LPMINTERACTIONTYPE=${ALIEN_JDL_LPMINTERACTIONTYPE:- ${INTERACTIONTYPE} }
@@ -101,29 +118,29 @@ export ALIEN_JDL_ADDTIMESERIESINMC=${ALIEN_JDL_ADDTIMESERIESINMC:-1}
101118
102119# cache the production tag, will be set to a special anchor tag; reset later in fact
103120ALIEN_JDL_LPMPRODUCTIONTAG_KEEP=$ALIEN_JDL_LPMPRODUCTIONTAG
104- echo " Substituting ALIEN_JDL_LPMPRODUCTIONTAG=$ALIEN_JDL_LPMPRODUCTIONTAG with ALIEN_JDL_LPMANCHORPRODUCTION=$ALIEN_JDL_LPMANCHORPRODUCTION for simulating reco pass..."
121+ echo_info " Substituting ALIEN_JDL_LPMPRODUCTIONTAG=$ALIEN_JDL_LPMPRODUCTIONTAG with ALIEN_JDL_LPMANCHORPRODUCTION=$ALIEN_JDL_LPMANCHORPRODUCTION for simulating reco pass..."
105122ALIEN_JDL_LPMPRODUCTIONTAG=$ALIEN_JDL_LPMANCHORPRODUCTION
106123
107124# check variables that need to be set
108- [ -z " ${ALIEN_JDL_LPMANCHORPASSNAME} " ] && { echo " ERROR: Set ALIEN_JDL_LPMANCHORPASSNAME or ANCHORPASSNAME" ; exit 1 ; }
109- [ -z " ${ALIEN_JDL_MCANCHOR} " ] && { echo " ERROR: Set ALIEN_JDL_MCANCHOR or MCANCHOR" ; exit 1 ; }
110- [ -z " ${ALIEN_JDL_LPMPASSNAME} " ] && { echo " ERROR: Set ALIEN_JDL_LPMPASSNAME or PASSNAME" ; exit 1 ; }
111- [ -z " ${ALIEN_JDL_LPMRUNNUMBER} " ] && { echo " ERROR: Set ALIEN_JDL_LPMRUNNUMBER or RUNNUMBER" ; exit 1 ; }
112- [ -z " ${ALIEN_JDL_LPMPRODUCTIONTYPE} " ] && { echo " ERROR: Set ALIEN_JDL_LPMPRODUCTIONTYPE or PRODUCTIONTYPE" ; exit 1 ; }
113- [ -z " ${ALIEN_JDL_LPMINTERACTIONTYPE} " ] && { echo " ERROR: Set ALIEN_JDL_LPMINTERACTIONTYPE or INTERACTIONTYPE" ; exit 1 ; }
114- [ -z " ${ALIEN_JDL_LPMPRODUCTIONTAG} " ] && { echo " ERROR: Set ALIEN_JDL_LPMPRODUCTIONTAG or PRODUCTIONTAG" ; exit 1 ; }
115- [ -z " ${ALIEN_JDL_LPMANCHORRUN} " ] && { echo " ERROR: Set ALIEN_JDL_LPMANCHORRUN or ANCHORRUN" ; exit 1 ; }
116- [ -z " ${ALIEN_JDL_LPMANCHORPRODUCTION} " ] && { echo " ERROR: Set ALIEN_JDL_LPMANCHORPRODUCTION or ANCHORPRODUCTION" ; exit 1 ; }
117- [ -z " ${ALIEN_JDL_LPMANCHORYEAR} " ] && { echo " ERROR: Set ALIEN_JDL_LPMANCHORYEAR or ANCHORYEAR" ; exit 1 ; }
118-
119- [ -z " ${NTIMEFRAMES} " ] && { echo " ERROR: Set NTIMEFRAMES" ; exit 1 ; }
120- [ -z " ${NSIGEVENTS} " ] && { echo " ERROR: Set NSIGEVENTS" ; exit 1 ; }
121- [ -z " ${SPLITID} " ] && { echo " ERROR: Set SPLITID" ; exit 1 ; }
122- [ -z " ${CYCLE} " ] && { echo " ERROR: Set CYCLE" ; exit 1 ; }
123- [ -z " ${PRODSPLIT} " ] && { echo " ERROR: Set PRODSPLIT" ; exit 1 ; }
125+ [ -z " ${ALIEN_JDL_LPMANCHORPASSNAME} " ] && { echo_error " Set ALIEN_JDL_LPMANCHORPASSNAME or ANCHORPASSNAME" ; exit 1 ; }
126+ [ -z " ${ALIEN_JDL_LPMRUNNUMBER} " ] && { echo_error " Set ALIEN_JDL_LPMRUNNUMBER or RUNNUMBER" ; exit 1 ; }
127+ [ -z " ${ALIEN_JDL_LPMPRODUCTIONTYPE} " ] && { echo_error " Set ALIEN_JDL_LPMPRODUCTIONTYPE or PRODUCTIONTYPE" ; exit 1 ; }
128+ [ -z " ${ALIEN_JDL_LPMINTERACTIONTYPE} " ] && { echo_error " Set ALIEN_JDL_LPMINTERACTIONTYPE or INTERACTIONTYPE" ; exit 1 ; }
129+ [ -z " ${ALIEN_JDL_LPMPRODUCTIONTAG} " ] && { echo_error " Set ALIEN_JDL_LPMPRODUCTIONTAG or PRODUCTIONTAG" ; exit 1 ; }
130+ [ -z " ${ALIEN_JDL_LPMANCHORRUN} " ] && { echo_error " Set ALIEN_JDL_LPMANCHORRUN or ANCHORRUN" ; exit 1 ; }
131+ [ -z " ${ALIEN_JDL_LPMANCHORPRODUCTION} " ] && { echo_error " Set ALIEN_JDL_LPMANCHORPRODUCTION or ANCHORPRODUCTION" ; exit 1 ; }
132+ [ -z " ${ALIEN_JDL_LPMANCHORYEAR} " ] && { echo_error " Set ALIEN_JDL_LPMANCHORYEAR or ANCHORYEAR" ; exit 1 ; }
133+
134+ [ -z " ${NTIMEFRAMES} " ] && { echo_error " Set NTIMEFRAMES" ; exit 1 ; }
135+ [ -z " ${NSIGEVENTS} " ] && { echo_error " Set NSIGEVENTS" ; exit 1 ; }
136+ [ -z " ${SPLITID} " ] && { echo_error " Set SPLITID" ; exit 1 ; }
137+ [ -z " ${CYCLE} " ] && { echo_error " Set CYCLE" ; exit 1 ; }
138+ [ -z " ${PRODSPLIT} " ] && { echo_error " Set PRODSPLIT" ; exit 1 ; }
124139
125140# also for this keep a real default
126141NWORKERS=${NWORKERS:- 8}
142+ # set a default seed if not given
143+ SEED=${ALIEN_PROC_ID:- ${SEED:- 1} }
127144
128145
129146# default async_pass.sh script
143160# if there is no setenv_extra.sh in this directory (so no special version is "shipped" with this rpodcution), copy the default one
144161if [[ ! -f setenv_extra.sh ]] ; then
145162 cp ${DPGSETENV} .
146- echo " [INFO alien_setenv_extra.sh] Use default setenv_extra.sh from ${DPGSETENV} ."
163+ echo_info " Use default setenv_extra.sh from ${DPGSETENV} ."
147164else
148- echo " [INFO alien_setenv_extra.sh] setenv_extra.sh was found in the current working directory, use it."
165+ echo_info " setenv_extra.sh was found in the current working directory, use it."
149166fi
150167
151168chmod u+x setenv_extra.sh
152169
153- echo " [INFO alien_async_pass.sh] Setting up DPGRECO to ${DPGRECO} "
170+ echo_info " Setting up DPGRECO to ${DPGRECO} "
154171
155172# settings that are MC-specific, modify setenv_extra.sh in-place
156173sed -i ' s/GPU_global.dEdxUseFullGainMap=1;GPU_global.dEdxDisableResidualGainMap=1/GPU_global.dEdxSplineTopologyCorrFile=splines_for_dedx_V1_MC_iter0_PP.root;GPU_global.dEdxDisableTopologyPol=1;GPU_global.dEdxDisableGainMap=1;GPU_global.dEdxDisableResidualGainMap=1;GPU_global.dEdxDisableResidualGain=1/' setenv_extra.sh
@@ -167,30 +184,28 @@ touch list.list
167184./async_pass.sh ${CTF_TEST_FILE:- " " } 2& > async_pass_log.log
168185RECO_RC=$?
169186
170- echo " RECO finished with ${RECO_RC} "
187+ echo_info " async_pass.sh finished with ${RECO_RC} "
171188
172189if [[ " ${RECO_RC} " != " 0" ]] ; then
173190 exit ${RECO_RC}
174191fi
175192
176193ALIEN_JDL_LPMPRODUCTIONTAG=$ALIEN_JDL_LPMPRODUCTIONTAG_KEEP
177- echo " Setting back ALIEN_JDL_LPMPRODUCTIONTAG to $ALIEN_JDL_LPMPRODUCTIONTAG "
194+ echo_info " Setting back ALIEN_JDL_LPMPRODUCTIONTAG to $ALIEN_JDL_LPMPRODUCTIONTAG "
178195
179196# now create the local MC config file --> config-config.json
180197${O2DPG_ROOT} /UTILS/parse-async-WorkflowConfig.py
181198ASYNC_WF_RC=${?}
182199
183200# check if config reasonably created
184201if [[ " ${ASYNC_WF_RC} " != " 0" || ` grep " o2-ctf-reader-workflow-options" config-json.json 2> /dev/null | wc -l` == " 0" ]]; then
185- echo " Problem in anchor config creation. Exiting."
202+ echo_error " Problem in anchor config creation. Exiting."
186203 exit 1
187204fi
188205
189206# -- CREATE THE MC JOB DESCRIPTION ANCHORED TO RUN --
190207
191208MODULES=" --skipModules ZDC"
192- # introduce variable to make usage clear
193- SEED=${ALIEN_PROC_ID}
194209# Since this is used, set it explicitly
195210ALICEO2_CCDB_LOCALCACHE=${ALICEO2_CCDB_LOCALCACHE:- $(pwd)/ ccdb}
196211
@@ -205,28 +220,31 @@ remainingargs="${remainingargs} -productionTag ${ALIEN_JDL_LPMPRODUCTIONTAG:-ali
205220# since the last passed argument wins, e.g. -productionTag cannot be overwritten by the user
206221remainingargs=" ${ALIEN_JDL_ANCHOR_SIM_OPTIONS} ${remainingargs} --anchor-config config-json.json"
207222
208- echo " baseargs: ${baseargs} "
209- echo " remainingargs: ${remainingargs} "
223+ echo_info " baseargs passed to o2dpg_sim_workflow_anchored.py : ${baseargs} "
224+ echo_info " remainingargs forwarded to o2dpg_sim_workflow.py : ${remainingargs} "
210225
211226# query CCDB has changed, w/o "_"
212227${O2DPG_ROOT} /MC/bin/o2dpg_sim_workflow_anchored.py ${baseargs} -- ${remainingargs} & > timestampsampling_${ALIEN_JDL_LPMRUNNUMBER} .log
213- if [ " $? " != " 0" ] ; then
214- echo " Problem during anchor timestamp sampling and workflow creation. Exiting."
215- exit 1
228+ WF_RC=" ${?} "
229+ if [ " ${WF_RC} " != " 0" ] ; then
230+ echo_error " Problem during anchor timestamp sampling and workflow creation. Exiting."
231+ exit ${WF_RC}
216232fi
217233
218234TIMESTAMP=` grep " Determined timestamp to be" timestampsampling_${ALIEN_JDL_LPMRUNNUMBER} .log | awk ' //{print $6}' `
219- echo " TIMESTAMP IS ${TIMESTAMP} "
235+ echo_info " TIMESTAMP IS ${TIMESTAMP} "
220236
221237# -- Create aligned geometry using ITS ideal alignment to avoid overlaps in geant
222238CCDBOBJECTS_IDEAL_MC=" ITS/Calib/Align"
223239TIMESTAMP_IDEAL_MC=1
224240${O2_ROOT} /bin/o2-ccdb-downloadccdbfile --host http://alice-ccdb.cern.ch/ -p ${CCDBOBJECTS_IDEAL_MC} -d ${ALICEO2_CCDB_LOCALCACHE} --timestamp ${TIMESTAMP_IDEAL_MC}
225- if [ ! " $? " == " 0" ]; then
226- echo " Problem during CCDB prefetching of ${CCDBOBJECTS_IDEAL_MC} . Exiting."
227- exit 1
241+ CCDB_RC=" ${?} "
242+ if [ ! " ${CCDB_RC} " == " 0" ]; then
243+ echo_error " Problem during CCDB prefetching of ${CCDBOBJECTS_IDEAL_MC} . Exiting."
244+ exit ${CCDB_RC}
228245fi
229246
247+ # TODO This can potentially be removed or if needed, should be taken over by o2dpg_sim_workflow_anchored.py and O2_dpg_workflow_runner.py
230248echo " run with echo in pipe" | ${O2_ROOT} /bin/o2-create-aligned-geometry-workflow --configKeyValues " HBFUtils.startTime=${TIMESTAMP} " --condition-remap=file://${ALICEO2_CCDB_LOCALCACHE} =ITS/Calib/Align -b
231249mkdir -p $ALICEO2_CCDB_LOCALCACHE /GLO/Config/GeometryAligned
232250ln -s -f $PWD /o2sim_geometry-aligned.root $ALICEO2_CCDB_LOCALCACHE /GLO/Config/GeometryAligned/snapshot.root
@@ -235,22 +253,22 @@ ln -s -f $PWD/o2sim_geometry-aligned.root $ALICEO2_CCDB_LOCALCACHE/GLO/Config/Ge
235253
236254export FAIRMQ_IPC_PREFIX=./
237255
238- echo " Ready to start main workflow"
256+ echo_info " Ready to start main workflow"
239257
240258${O2DPG_ROOT} /MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt ${ALIEN_JDL_O2DPGWORKFLOWTARGET:- aod} --cpu-limit ${ALIEN_JDL_CPULIMIT:- 8}
241259MCRC=$? # <--- we'll report back this code
242260exit 0
243261if [[ " ${ALIEN_JDL_ADDTIMESERIESINMC} " != " 0" ]]; then
244262 # Default value is 1 so this is run by default.
245- echo " Running TPC time series"
263+ echo_info " Running TPC time series"
246264 ${O2DPG_ROOT} /MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt tpctimes
247265fi
248266
249- [[ ! -z " ${DISABLE_QC} " ]] && echo " INFO: QC is disabled, skip it."
267+ [[ ! -z " ${DISABLE_QC} " ]] && echo_info " QC is disabled, skip it."
250268
251269if [[ -z " ${DISABLE_QC} " && " ${MCRC} " = " 0" && " ${remainingargs} " == * " --include-local-qc" * ]] ; then
252270 # do QC tasks
253- echo " Doing QC"
271+ echo_info " Doing QC"
254272 ${O2DPG_ROOT} /MC/bin/o2_dpg_workflow_runner.py -f workflow.json --target-labels QC --cpu-limit ${ALIEN_JDL_CPULIMIT:- 8} -k
255273 # NOTE that with the -k|--keep-going option, the runner will try to keep on executing even if some tasks fail.
256274 # That means, even if there is a failing QC task, the return code will be 0
0 commit comments