From 6f512ad2e1fbf1a2951ffbb5191aaaf2cddf7a6e Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Thu, 26 Nov 2026 16:01:27 +0100 Subject: [PATCH] Check the aligned geometry creation and report the sim alignment This makes geomprefetch fail when the aligned geometry cannot be created, and makes sim_alignment report which MCH/MID alignment the simulation uses. - A failed o2-create-aligned-geometry-workflow returned 0 and could leave a previous geometry in place. - sim_alignment downloads into a temporary file and moves it into place, so a failed download leaves the cache unchanged. https://its.cern.ch/jira/browse/O2-7374 Co-Authored-By: Claude Opus 5.5 --- MC/bin/o2dpg_sim_workflow.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index b1a4ca157..36e490a8b 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -627,6 +627,11 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True, runcommand=True): # fetch the global alignment geometry ${{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={args.timestamp}" -b --run ${{REMAP_OPT}} +GEOM_RC="$?" +if [ ! "${{GEOM_RC}}" == "0" ]; then + echo "Problem during creation of the aligned geometry. Exiting." + exit ${{GEOM_RC}} +fi # copy the object into the CCDB cache mkdir -p $ALICEO2_CCDB_LOCALCACHE/GLO/Config/GeometryAligned @@ -649,10 +654,23 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True, runcommand=True): # These object will take precedence over ordinary align objects **and** will only be applied in transport simulation # and digitization (Det/Calib/Align is only read in simulation since reconstruction tasks use GLO/Config/AlignedGeometry automatically). SIM_ALIGNMENT_PREFETCH_TASK = createTask(name='sim_alignment', needs=['geomprefetch'], cpu='0') -SIM_ALIGNMENT_PREFETCH_TASK['cmd'] = '${O2_ROOT}/bin/o2-ccdb-downloadccdbfile --host http://alice-ccdb.cern.ch -p MID/MisCalib/Align --timestamp ' + str(args.timestamp) + ' --created-not-after ' \ - + str(args.condition_not_after) + ' -d ${ALICEO2_CCDB_LOCALCACHE}/MID/Calib/Align --no-preserve-path ; ' -SIM_ALIGNMENT_PREFETCH_TASK['cmd'] += '${O2_ROOT}/bin/o2-ccdb-downloadccdbfile --host http://alice-ccdb.cern.ch -p MCH/MisCalib/Align --timestamp ' + str(args.timestamp) + ' --created-not-after ' \ - + str(args.condition_not_after) + ' -d ${ALICEO2_CCDB_LOCALCACHE}/MCH/Calib/Align --no-preserve-path ' +sim_align_cmd = f''' +for DET in MCH MID; do + TARGETDIR=${{ALICEO2_CCDB_LOCALCACHE}}/${{DET}}/Calib/Align + NEWFILE=snapshot.root.new.$$ + ${{O2_ROOT}}/bin/o2-ccdb-downloadccdbfile --host http://alice-ccdb.cern.ch -p ${{DET}}/MisCalib/Align --timestamp {args.timestamp} \ + --created-not-after {args.condition_not_after} -d ${{TARGETDIR}} --no-preserve-path -o ${{NEWFILE}} + if [ -f ${{TARGETDIR}}/${{NEWFILE}} ]; then + mv -f ${{TARGETDIR}}/${{NEWFILE}} ${{TARGETDIR}}/snapshot.root + echo "Simulation uses ${{DET}}/MisCalib/Align" + else + echo "No ${{DET}}/MisCalib/Align found for timestamp {args.timestamp}; simulation uses ${{DET}}/Calib/Align" + fi +done +''' +with open("sim_alignment_script.sh",'w') as f: + f.write(sim_align_cmd) +SIM_ALIGNMENT_PREFETCH_TASK['cmd'] = 'chmod +x ${PWD}/sim_alignment_script.sh; ${PWD}/sim_alignment_script.sh' workflow['stages'].append(SIM_ALIGNMENT_PREFETCH_TASK) # create/publish the GRPs and other GLO objects for consistent use further down the pipeline