From f2da1183eef952ea8d6fc711c050f8b8758779e0 Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Fri, 4 Dec 2026 18:08:36 +0100 Subject: [PATCH 1/2] Read alignment only for detectors in the geometry in geomprefetch This makes geomprefetch read the alignment only of the detectors that the job's geometry builds, and adds a unit test. - o2-create-aligned-geometry-workflow ran with its default --onlyDet all. - With ENABLE_UPGRADES this read 12 Calib/Align objects per job that cannot be used: the upgrade detectors, TST and CTP. - geomprefetch now passes --onlyDet with the built modules known to DetID, minus --skipModules. - The aligned geometry of an anchored pp job is unchanged node by node. --- MC/bin/o2dpg_sim_config.py | 11 +++++++++ MC/bin/o2dpg_sim_workflow.py | 6 +++-- MC/bin/tests/test_sim_config_alignment.py | 30 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/MC/bin/o2dpg_sim_config.py b/MC/bin/o2dpg_sim_config.py index 6e5e6bdb6..221770286 100755 --- a/MC/bin/o2dpg_sim_config.py +++ b/MC/bin/o2dpg_sim_config.py @@ -252,6 +252,17 @@ def geom_align_configkey(alignDetectors): """ return "" if alignDetectors == "all" else f";align-geom.mDetectors={alignDetectors}" +# DetID detectors with a geometry, in DetID order (no TST and CTP) +GEOMETRY_DETECTORS = ["ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", + "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD3"] + +def geometry_detectors(builtModules, skipModules): + """ + The --onlyDet value for o2-create-aligned-geometry-workflow: the detectors in this job's geometry; "none" if there is none. + """ + dets = [det for det in GEOMETRY_DETECTORS if det in builtModules and det not in skipModules] + return ",".join(dets) if dets else "none" + def its_ideal_in_transport(withParallelWorld, alignDetectors): """ Whether ITS is ideal in transport: without the parallel world the ideal ITS object is used, else when ITS is not aligned. diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index 281815904..f53dd299e 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -43,7 +43,7 @@ from o2dpg_workflow_utils import createTask, createGlobalInitTask, dump_workflow, adjust_RECO_environment, isActive, activate_detector, deactivate_detector, compute_n_workers, merge_dicts, restrict_to_detector_list from o2dpg_qc_finalization_workflow import include_all_QC_finalization -from o2dpg_sim_config import create_sim_config, create_geant_config, constructConfigKeyArg, option_if_available, overwrite_config, qed_included, sim_align_detectors, geom_align_configkey, its_ideal_in_transport +from o2dpg_sim_config import create_sim_config, create_geant_config, constructConfigKeyArg, option_if_available, overwrite_config, qed_included, sim_align_detectors, geom_align_configkey, its_ideal_in_transport, geometry_detectors from o2dpg_dpl_config_tools import dpl_option_from_config, TaskFinalizer, quote_if_needed # for some JAliEn interaction @@ -630,6 +630,8 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True, runcommand=True): sim_align_dets = sim_align_detectors(args.confKey) geom_align_confkey = geom_align_configkey(sim_align_dets) its_ideal = 1 if its_ideal_in_transport(with_parallel_world, sim_align_dets) else 0 +# only the detectors in this job's geometry, so that no alignment of an absent detector is read +geom_onlydet = geometry_detectors(builtModules, args.skipModules) geom_cmd = f''' # -- Create aligned geometry using ITS ideal alignment to avoid overlaps in geant ENABLEPW={with_parallel_world} @@ -656,7 +658,7 @@ 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}{geom_align_confkey}" -b --run ${{REMAP_OPT}} + --onlyDet {geom_onlydet} --configKeyValues "HBFUtils.startTime={args.timestamp}{geom_align_confkey}" -b --run ${{REMAP_OPT}} GEOM_RC="$?" if [ ! "${{GEOM_RC}}" == "0" ]; then echo "Problem during creation of the aligned geometry. Exiting." diff --git a/MC/bin/tests/test_sim_config_alignment.py b/MC/bin/tests/test_sim_config_alignment.py index f3e81d17e..946bb960f 100644 --- a/MC/bin/tests/test_sim_config_alignment.py +++ b/MC/bin/tests/test_sim_config_alignment.py @@ -67,5 +67,35 @@ def test_truth_table(self): self.assertFalse(simconfig.its_ideal_in_transport(1, "MCH,ITS")) + +class TestGeometryDetectors(unittest.TestCase): + ALICE2 = {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "CTP", + "HALL", "MAG", "DIPO", "COMP", "PIPE", "ABSO", "SHIL"} + ALICE2_1 = (ALICE2 - {"ITS", "TRD"}) | {"IT3", "FOC"} + UPGRADES = {"IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD3", "FOC"} + + def test_default_list(self): + dets = simconfig.geometry_detectors(self.ALICE2, []).split(",") + self.assertEqual(dets, ["ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD"]) + self.assertFalse(set(dets) & (self.UPGRADES | {"TST", "CTP"})) + + def test_it3_list(self): + dets = simconfig.geometry_detectors(self.ALICE2_1, []).split(",") + self.assertIn("IT3", dets) + self.assertIn("FOC", dets) + self.assertNotIn("ITS", dets) + self.assertNotIn("TRD", dets) + self.assertFalse(set(dets) & {"TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD3", "TST", "CTP"}) + + def test_skip_modules(self): + dets = simconfig.geometry_detectors(self.ALICE2, ["ZDC", "TRD", "PIPE"]).split(",") + self.assertNotIn("ZDC", dets) + self.assertNotIn("TRD", dets) + self.assertIn("TPC", dets) + + def test_passive_only(self): + self.assertEqual(simconfig.geometry_detectors({"HALL", "PIPE", "CTP"}, []), "none") + + if __name__ == "__main__": unittest.main() From b4beda7431556333e7135d2240ebd0a3298d90f8 Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Fri, 4 Dec 2026 20:34:23 +0100 Subject: [PATCH 2/2] Simplify the geometry_detectors tests This shortens the unit tests of geometry_detectors and explains the detector list. - The tests compare exact --onlyDet strings and now cover the ALICE 3 list. - The comment on GEOMETRY_DETECTORS says why the list is needed. --- MC/bin/o2dpg_sim_config.py | 2 +- MC/bin/tests/test_sim_config_alignment.py | 30 ++++++++--------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/MC/bin/o2dpg_sim_config.py b/MC/bin/o2dpg_sim_config.py index 221770286..76f306c37 100755 --- a/MC/bin/o2dpg_sim_config.py +++ b/MC/bin/o2dpg_sim_config.py @@ -252,7 +252,7 @@ def geom_align_configkey(alignDetectors): """ return "" if alignDetectors == "all" else f";align-geom.mDetectors={alignDetectors}" -# DetID detectors with a geometry, in DetID order (no TST and CTP) +# O2 DetID names with a geometry (no TST, CTP); --onlyDet throws on any other name GEOMETRY_DETECTORS = ["ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD3"] diff --git a/MC/bin/tests/test_sim_config_alignment.py b/MC/bin/tests/test_sim_config_alignment.py index 946bb960f..3372adb90 100644 --- a/MC/bin/tests/test_sim_config_alignment.py +++ b/MC/bin/tests/test_sim_config_alignment.py @@ -67,31 +67,21 @@ def test_truth_table(self): self.assertFalse(simconfig.its_ideal_in_transport(1, "MCH,ITS")) - class TestGeometryDetectors(unittest.TestCase): ALICE2 = {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "CTP", "HALL", "MAG", "DIPO", "COMP", "PIPE", "ABSO", "SHIL"} - ALICE2_1 = (ALICE2 - {"ITS", "TRD"}) | {"IT3", "FOC"} - UPGRADES = {"IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD3", "FOC"} - - def test_default_list(self): - dets = simconfig.geometry_detectors(self.ALICE2, []).split(",") - self.assertEqual(dets, ["ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD"]) - self.assertFalse(set(dets) & (self.UPGRADES | {"TST", "CTP"})) - - def test_it3_list(self): - dets = simconfig.geometry_detectors(self.ALICE2_1, []).split(",") - self.assertIn("IT3", dets) - self.assertIn("FOC", dets) - self.assertNotIn("ITS", dets) - self.assertNotIn("TRD", dets) - self.assertFalse(set(dets) & {"TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD3", "TST", "CTP"}) + + def test_lists(self): + self.assertEqual(simconfig.geometry_detectors(self.ALICE2, []), + "ITS,TPC,TRD,TOF,PHS,CPV,EMC,HMP,MFT,MCH,MID,ZDC,FT0,FV0,FDD") + alice21 = (self.ALICE2 - {"ITS", "TRD"}) | {"IT3", "FOC"} + self.assertEqual(simconfig.geometry_detectors(alice21, []), + "TPC,TOF,PHS,CPV,EMC,HMP,MFT,MCH,MID,ZDC,FT0,FV0,FDD,FOC,IT3") + alice3 = {"TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD3", "HALL", "MAG", "A3IP", "A3ABSO", "A3MAG"} + self.assertEqual(simconfig.geometry_detectors(alice3, []), "TRK,FT3,FCT,TF3,RCH,MI3,ECL,FD3") def test_skip_modules(self): - dets = simconfig.geometry_detectors(self.ALICE2, ["ZDC", "TRD", "PIPE"]).split(",") - self.assertNotIn("ZDC", dets) - self.assertNotIn("TRD", dets) - self.assertIn("TPC", dets) + self.assertEqual(simconfig.geometry_detectors({"TPC", "ZDC", "PIPE"}, ["ZDC", "PIPE"]), "TPC") def test_passive_only(self): self.assertEqual(simconfig.geometry_detectors({"HALL", "PIPE", "CTP"}, []), "none")