diff --git a/MC/bin/o2dpg_sim_config.py b/MC/bin/o2dpg_sim_config.py index 6e5e6bdb6..76f306c37 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}" +# 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"] + +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..3372adb90 100644 --- a/MC/bin/tests/test_sim_config_alignment.py +++ b/MC/bin/tests/test_sim_config_alignment.py @@ -67,5 +67,25 @@ 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"} + + 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): + 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") + + if __name__ == "__main__": unittest.main()