Skip to content

Commit bf67c09

Browse files
maciaccoalcaliva
authored andcommitted
set parallel world in test script + toggle ideal ITS in anchored simulation (#1908)
* set pw in test script + toggle ideal ITS in anchored simulation * remove duplicated flag for pw activation * fix string check * fix variable declaration * fix check
1 parent 00622d2 commit bf67c09

File tree

1 file changed

+94
-17
lines changed

1 file changed

+94
-17
lines changed

MC/run/ANCHOR/anchorMC.sh

Lines changed: 94 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bashMore actions
1+
#!/bin/bash
22

33
# add distortion maps
44
# https://alice.its.cern.ch/jira/browse/O2-3346?focusedCommentId=300982&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-300982
@@ -60,7 +60,6 @@ print_help()
6060
echo "ALIEN_JDL_MC_ORBITS_PER_TF=N, enforce some orbits per timeframe, instead of determining from CCDB"
6161
echo "ALIEN_JDL_RUN_TIME_SPAN_FILE=FILE, use a run-time-span file to exclude bad data-taking periods"
6262
echo "ALIEN_JDL_INVERT_IRFRAME_SELECTION, invertes the choice of ALIEN_JDL_RUN_TIME_SPAN_FILE"
63-
echo "ALIEN_JDL_CCDB_CONDITION_NOT_AFTER, sets the condition_not_after timestamp for CCDB queries"
6463
echo "DISABLE_QC, set this to disable QC, e.g. to 1"
6564
}
6665

@@ -125,6 +124,10 @@ ALIEN_JDL_LPMPRODUCTIONTAG_KEEP=$ALIEN_JDL_LPMPRODUCTIONTAG
125124
echo_info "Substituting ALIEN_JDL_LPMPRODUCTIONTAG=$ALIEN_JDL_LPMPRODUCTIONTAG with ALIEN_JDL_LPMANCHORPRODUCTION=$ALIEN_JDL_LPMANCHORPRODUCTION for simulating reco pass..."
126125
ALIEN_JDL_LPMPRODUCTIONTAG=$ALIEN_JDL_LPMANCHORPRODUCTION
127126

127+
if [[ $ALIEN_JDL_ANCHOR_SIM_OPTIONS == *"--tpc-distortion-type 2"* ]]; then
128+
export O2DPG_ENABLE_TPC_DISTORTIONS=ON
129+
fi
130+
128131
# check variables that need to be set
129132
[ -z "${ALIEN_JDL_LPMANCHORPASSNAME}" ] && { echo_error "Set ALIEN_JDL_LPMANCHORPASSNAME or ANCHORPASSNAME" ; exit 1 ; }
130133
[ -z "${ALIEN_JDL_LPMRUNNUMBER}" ] && { echo_error "Set ALIEN_JDL_LPMRUNNUMBER or RUNNUMBER" ; exit 1 ; }
@@ -146,6 +149,48 @@ NWORKERS=${NWORKERS:-8}
146149
# set a default seed if not given
147150
SEED=${ALIEN_PROC_ID:-${SEED:-1}}
148151

152+
ONCVMFS=0
153+
154+
if [ "${ALIEN_JDL_O2DPG_OVERWRITE}" ]; then
155+
echo "Setting O2DPG_ROOT to overwritten path"
156+
export O2DPG_ROOT=${ALIEN_JDL_O2DPG_OVERWRITE}
157+
fi
158+
159+
export > env_base.env
160+
161+
if ! declare -F module > /dev/null; then
162+
module() {
163+
eval "$(/usr/bin/modulecmd bash "$@")";
164+
}
165+
export -f module
166+
fi
167+
168+
[[ "${BASEDIR}" == /cvmfs/* ]] && ONCVMFS=1
169+
if [ ! "${MODULEPATH}" ]; then
170+
export MODULEPATH=${BASEDIR}/../Modules/modulefiles
171+
if [ "${ONCVMFS}" == "1" ]; then
172+
PLATFORM=$(echo "${BASEDIR}" | sed -E 's|.*/([^/]+)/Packages|\1|')
173+
export MODULEPATH=${MODULEPATH}:${BASEDIR}/../../etc/toolchain/modulefiles/${PLATFORM}
174+
fi
175+
echo "Determined Modulepath to be ${MODULEPATH}"
176+
fi
177+
178+
#<----- START OF part that should run under a clean alternative software environment if this was given ------
179+
if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then
180+
if [ "${LOADEDMODULES}" ]; then
181+
echo "Stashing initial modules"
182+
module save initial_modules.list # we stash the current modules environment
183+
module list --no-pager
184+
module purge --no-pager
185+
export > env_after_stashing.env
186+
echo "Modules after purge"
187+
module list --no-pager
188+
fi
189+
echo_info "Using tag ${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG} to setup anchored MC"
190+
/cvmfs/alice.cern.ch/bin/alienv printenv "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" &> async_environment.env
191+
source async_environment.env
192+
export > env_async.env
193+
fi
149194

150195
# default async_pass.sh script
151196
DPGRECO=$O2DPG_ROOT/DATA/production/configurations/asyncReco/async_pass.sh
@@ -173,10 +218,6 @@ chmod u+x setenv_extra.sh
173218

174219
echo_info "Setting up DPGRECO to ${DPGRECO}"
175220

176-
# settings that are MC-specific, modify setenv_extra.sh in-place
177-
sed -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
178-
### ???
179-
180221
# take out line running the workflow (if we don't have data input)
181222
[ ${CTF_TEST_FILE} ] || sed -i '/WORKFLOWMODE=run/d' async_pass.sh
182223

@@ -194,6 +235,7 @@ if [[ "${RECO_RC}" != "0" ]] ; then
194235
exit ${RECO_RC}
195236
fi
196237

238+
197239
ALIEN_JDL_LPMPRODUCTIONTAG=$ALIEN_JDL_LPMPRODUCTIONTAG_KEEP
198240
echo_info "Setting back ALIEN_JDL_LPMPRODUCTIONTAG to $ALIEN_JDL_LPMPRODUCTIONTAG"
199241

@@ -207,16 +249,32 @@ if [[ "${ASYNC_WF_RC}" != "0" || `grep "o2-ctf-reader-workflow-options" config-j
207249
exit 1
208250
fi
209251

252+
# get rid of the temporary software environment
253+
if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then
254+
module purge --no-pager
255+
# restore the initial software environment
256+
echo "Restoring initial environment"
257+
module --no-pager restore initial_modules.list
258+
module saverm initial_modules.list
259+
if [ "${ALIEN_JDL_O2DPG_OVERWRITE}" ]; then
260+
echo "Setting back O2DPG_ROOT to overwritten path ${ALIEN_JDL_O2DPG_OVERWRITE}"
261+
export O2DPG_ROOT=${ALIEN_JDL_O2DPG_OVERWRITE}
262+
fi
263+
fi
264+
#<----- END OF part that should run under a clean alternative software environment if this was given ------
265+
210266
# -- CREATE THE MC JOB DESCRIPTION ANCHORED TO RUN --
211267

212268
MODULES="--skipModules ZDC"
213269
# Since this is used, set it explicitly
214270
ALICEO2_CCDB_LOCALCACHE=${ALICEO2_CCDB_LOCALCACHE:-$(pwd)/ccdb}
215271

216272
# these arguments will be digested by o2dpg_sim_workflow_anchored.py
217-
baseargs="-tf ${NTIMEFRAMES} --split-id ${SPLITID} --prod-split ${PRODSPLIT} --cycle ${CYCLE} --run-number ${ALIEN_JDL_LPMRUNNUMBER}"
273+
baseargs="-tf ${NTIMEFRAMES} --split-id ${SPLITID} --prod-split ${PRODSPLIT} --cycle ${CYCLE} --run-number ${ALIEN_JDL_LPMRUNNUMBER} \
274+
${ALIEN_JDL_RUN_TIME_SPAN_FILE:+--run-time-span-file ${ALIEN_JDL_RUN_TIME_SPAN_FILE} ${ALIEN_JDL_INVERT_IRFRAME_SELECTION:+--invert-irframe-selection}} \
275+
${ALIEN_JDL_MC_ORBITS_PER_TF:+--orbitsPerTF ${ALIEN_JDL_MC_ORBITS_PER_TF}}"
218276

219-
# these arguments will be passed as well but only evetually be digested by o2dpg_sim_workflow.py which is called from o2dpg_sim_workflow_anchored.py
277+
# these arguments will be passed as well but only eventually be digested by o2dpg_sim_workflow.py which is called from o2dpg_sim_workflow_anchored.py
220278
remainingargs="-seed ${SEED} -ns ${NSIGEVENTS} --include-local-qc --pregenCollContext"
221279
remainingargs="${remainingargs} -e ${ALIEN_JDL_SIMENGINE} -j ${NWORKERS}"
222280
remainingargs="${remainingargs} -productionTag ${ALIEN_JDL_LPMPRODUCTIONTAG:-alibi_anchorTest_tmp}"
@@ -226,24 +284,39 @@ remainingargs="${ALIEN_JDL_ANCHOR_SIM_OPTIONS} ${remainingargs} --anchor-config
226284
# apply software tagging choice
227285
# remainingargs="${remainingargs} ${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG:+--alternative-reco-software ${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}}"
228286
remainingargs="${remainingargs} ${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG:+--alternative-reco-software ${PWD}/env_async.env}"
229-
# potentially add CCDB timemachine timestamp
230-
remainingargs="${remainingargs} ${ALIEN_JDL_CCDB_CONDITION_NOT_AFTER:+--condition-not-after ${ALIEN_JDL_CCDB_CONDITION_NOT_AFTER}}"
287+
231288

232289
echo_info "baseargs passed to o2dpg_sim_workflow_anchored.py: ${baseargs}"
233290
echo_info "remainingargs forwarded to o2dpg_sim_workflow.py: ${remainingargs}"
234291

292+
anchoringLogFile=timestampsampling_${ALIEN_JDL_LPMRUNNUMBER}.log
235293
# query CCDB has changed, w/o "_"
236-
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow_anchored.py ${baseargs} -- ${remainingargs} &> timestampsampling_${ALIEN_JDL_LPMRUNNUMBER}.log
294+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow_anchored.py ${baseargs} -- ${remainingargs} &> ${anchoringLogFile}
237295
WF_RC="${?}"
238296
if [ "${WF_RC}" != "0" ] ; then
239297
echo_error "Problem during anchor timestamp sampling and workflow creation. Exiting."
240298
exit ${WF_RC}
241299
fi
242300

243-
TIMESTAMP=`grep "Determined timestamp to be" timestampsampling_${ALIEN_JDL_LPMRUNNUMBER}.log | awk '//{print $6}'`
301+
TIMESTAMP=`grep "Determined timestamp to be" ${anchoringLogFile} | awk '//{print $6}'`
244302
echo_info "TIMESTAMP IS ${TIMESTAMP}"
245303

304+
305+
# check if this job is exluded because it falls inside a bad data-taking period
306+
ISEXCLUDED=$(grep "TIMESTAMP IS EXCLUDED IN RUN" ${anchoringLogFile})
307+
if [ "${ISEXCLUDED}" ]; then
308+
# we can quit here; there is nothing to do
309+
# (apart from maybe creating a fake empty AO2D.root file or the like)
310+
echo "Timestamp is excluded from run. Nothing to do here"
311+
exit 0
312+
fi
313+
246314
# -- Create aligned geometry using ITS ideal alignment to avoid overlaps in geant
315+
ENABLEPW=0
316+
if [[ ${remainingargs} == *"GeometryManagerParam.useParallelWorld=1"* ]]; then
317+
ENABLEPW=1
318+
fi
319+
247320
if [ "${ENABLEPW}" == "0" ]; then
248321
CCDBOBJECTS_IDEAL_MC="ITS/Calib/Align"
249322
TIMESTAMP_IDEAL_MC=1
@@ -257,13 +330,15 @@ fi
257330

258331
# 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
259332
if [ "${ENABLEPW}" == "0" ]; then
260-
echo "run with echo in pipe" | ${O2_ROOT}/bin/o2-create-aligned-geometry-workflow ${ALIEN_JDL_CCDB_CONDITION_NOT_AFTER:+--condition-not-after ${ALIEN_JDL_CCDB_CONDITION_NOT_AFTER}} --configKeyValues "HBFUtils.startTime=${TIMESTAMP}" --condition-remap=file://${ALICEO2_CCDB_LOCALCACHE}=ITS/Calib/Align -b --run
333+
echo "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 --run
261334
else
262-
echo "run with echo in pipe" | ${O2_ROOT}/bin/o2-create-aligned-geometry-workflow ${ALIEN_JDL_CCDB_CONDITION_NOT_AFTER:+--condition-not-after ${ALIEN_JDL_CCDB_CONDITION_NOT_AFTER}} --configKeyValues "HBFUtils.startTime=${TIMESTAMP}" -b --run
335+
echo "run with echo in pipe" | ${O2_ROOT}/bin/o2-create-aligned-geometry-workflow --configKeyValues "HBFUtils.startTime=${TIMESTAMP}" -b --run
263336
fi
264337
mkdir -p $ALICEO2_CCDB_LOCALCACHE/GLO/Config/GeometryAligned
265338
ln -s -f $PWD/o2sim_geometry-aligned.root $ALICEO2_CCDB_LOCALCACHE/GLO/Config/GeometryAligned/snapshot.root
266-
[[ -f $PWD/its_GeometryTGeo.root ]] && mkdir -p $ALICEO2_CCDB_LOCALCACHE/ITS/Config/Geometry && ln -s -f $PWD/its_GeometryTGeo.root $ALICEO2_CCDB_LOCALCACHE/ITS/Config/Geometry/snapshot.root
339+
if [ "${ENABLEPW}" == "0" ]; then
340+
[[ -f $PWD/its_GeometryTGeo.root ]] && mkdir -p $ALICEO2_CCDB_LOCALCACHE/ITS/Config/Geometry && ln -s -f $PWD/its_GeometryTGeo.root $ALICEO2_CCDB_LOCALCACHE/ITS/Config/Geometry/snapshot.root
341+
fi
267342
[[ -f $PWD/mft_GeometryTGeo.root ]] && mkdir -p $ALICEO2_CCDB_LOCALCACHE/MFT/Config/Geometry && ln -s -f $PWD/mft_GeometryTGeo.root $ALICEO2_CCDB_LOCALCACHE/MFT/Config/Geometry/snapshot.root
268343

269344
# -- RUN THE MC WORKLOAD TO PRODUCE AOD --
@@ -272,7 +347,7 @@ export FAIRMQ_IPC_PREFIX=./
272347

273348
echo_info "Ready to start main workflow"
274349

275-
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt ${ALIEN_JDL_O2DPGWORKFLOWTARGET:-aod} --cpu-limit ${ALIEN_JDL_CPULIMIT:-8}
350+
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt ${ALIEN_JDL_O2DPGWORKFLOWTARGET:-aod} --cpu-limit ${ALIEN_JDL_CPULIMIT:-8} --dynamic-resources
276351
MCRC=$? # <--- we'll report back this code
277352
if [[ "${ALIEN_JDL_ADDTIMESERIESINMC}" != "0" ]]; then
278353
# Default value is 1 so this is run by default.
@@ -296,7 +371,9 @@ fi
296371
#
297372
if [[ -n "$ALIEN_PROC_ID" ]]; then
298373
find ./ \( -name "*.log*" -o -name "*mergerlog*" -o -name "*serverlog*" -o -name "*workerlog*" -o -name "pythia8.cfg" \) | tar -czvf debug_log_archive.tgz -T -
299-
find ./ \( -name "*.log*" -o -name "*mergerlog*" -o -name "*serverlog*" -o -name "*workerlog*" -o -name "*.root" \) | tar -czvf debug_full_archive.tgz -T -
374+
if [[ "$ALIEN_JDL_CREATE_TAR_IN_MC" == "1" ]]; then
375+
find ./ \( -name "*.log*" -o -name "*mergerlog*" -o -name "*serverlog*" -o -name "*workerlog*" -o -name "*.root" \) | tar -czvf debug_full_archive.tgz -T -
376+
fi
300377
fi
301378

302379
unset FAIRMQ_IPC_PREFIX

0 commit comments

Comments
 (0)