From aa1d5944f8d37e00fb549ebbd4a6c096964a2083 Mon Sep 17 00:00:00 2001 From: simonge Date: Wed, 4 Jun 2025 23:00:10 +0100 Subject: [PATCH 1/5] Automate beam energy configurations --- CMakeLists.txt | 3 +- bin/make_detector_configuration | 31 ++++++++++++++++++ configurations/craterlake_10x100.yml | 38 ---------------------- configurations/craterlake_10x100_Au197.yml | 38 ---------------------- configurations/craterlake_10x115_Cu63.yml | 38 ---------------------- configurations/craterlake_10x115_Ru96.yml | 38 ---------------------- configurations/craterlake_10x130.yml | 38 ---------------------- configurations/craterlake_10x130_H2.yml | 38 ---------------------- configurations/craterlake_10x166_He3.yml | 38 ---------------------- configurations/craterlake_10x250.yml | 38 ---------------------- configurations/craterlake_10x275.yml | 38 ---------------------- configurations/craterlake_18x110_Au.yml | 38 ---------------------- configurations/craterlake_18x110_He3.yml | 38 ---------------------- configurations/craterlake_18x275.yml | 38 ---------------------- configurations/craterlake_5x100.yml | 38 ---------------------- configurations/craterlake_5x41.yml | 36 -------------------- templates/epic.xml.jinja2 | 2 +- 17 files changed, 34 insertions(+), 532 deletions(-) delete mode 100644 configurations/craterlake_10x100.yml delete mode 100644 configurations/craterlake_10x100_Au197.yml delete mode 100644 configurations/craterlake_10x115_Cu63.yml delete mode 100644 configurations/craterlake_10x115_Ru96.yml delete mode 100644 configurations/craterlake_10x130.yml delete mode 100644 configurations/craterlake_10x130_H2.yml delete mode 100644 configurations/craterlake_10x166_He3.yml delete mode 100644 configurations/craterlake_10x250.yml delete mode 100644 configurations/craterlake_10x275.yml delete mode 100644 configurations/craterlake_18x110_Au.yml delete mode 100644 configurations/craterlake_18x110_He3.yml delete mode 100644 configurations/craterlake_18x275.yml delete mode 100644 configurations/craterlake_5x100.yml delete mode 100644 configurations/craterlake_5x41.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 49e5778d3f..121290ff32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,7 +81,8 @@ foreach(config_yml ${CONFIG_YMLS}) --output ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${config}.xml COMMENT "Creating configuration ${config} for ${PROJECT_NAME}" ) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${config}.xml + file(GLOB GENERATED_XMLS "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${config}*.xml") + install(FILES ${GENERATED_XMLS} DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/ ) endforeach() diff --git a/bin/make_detector_configuration b/bin/make_detector_configuration index 496e5db93c..b81df31ba7 100755 --- a/bin/make_detector_configuration +++ b/bin/make_detector_configuration @@ -29,3 +29,34 @@ if args.config is not None: # render the template with open(args.output, 'w') as output: output.write(template.render(**config)) + +# If the config contains far_forward or far_backward create new xml files with ebeam and pbeam set +if 'features' in config and ('far_forward' in config['features'] or 'far_backward' in config['features']): + + # Dictonary of potential ebeam and pbeam values + ebeam_pbeam_values = [ + {'ebeam': '5', 'pbeam': '41'}, + {'ebeam': '5', 'pbeam': '100'}, + {'ebeam': '10', 'pbeam': '100'}, + {'ebeam': '10', 'pbeam': '100_Au197'}, + {'ebeam': '10', 'pbeam': '115_Cu63'}, + {'ebeam': '10', 'pbeam': '115_Ru96'}, + {'ebeam': '10', 'pbeam': '130'}, + {'ebeam': '10', 'pbeam': '130_H2'}, + {'ebeam': '10', 'pbeam': '166_He3'}, + {'ebeam': '10', 'pbeam': '250'}, + {'ebeam': '10', 'pbeam': '275'}, + {'ebeam': '18', 'pbeam': '110_Au'}, + {'ebeam': '18', 'pbeam': '110_He3'}, + {'ebeam': '18', 'pbeam': '275'}, + ] + + for values in ebeam_pbeam_values: + # Create a new config dictionary with the current ebeam and pbeam values + new_config = config.copy() + new_config.update(values) + + # Render the template with the new config + new_output = args.output.replace('.xml', f"_{values['ebeam']}x{values['pbeam']}.xml") + with open(new_output, 'w') as output: + output.write(template.render(**new_config)) diff --git a/configurations/craterlake_10x100.yml b/configurations/craterlake_10x100.yml deleted file mode 100644 index 3e6f1ec6ec..0000000000 --- a/configurations/craterlake_10x100.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 100 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - forward_endcap_flux: - barrel_flux_return: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_10x100_Au197.yml b/configurations/craterlake_10x100_Au197.yml deleted file mode 100644 index 3364254f9e..0000000000 --- a/configurations/craterlake_10x100_Au197.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 100_Au197 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - forward_endcap_flux: - barrel_flux_return: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_10x115_Cu63.yml b/configurations/craterlake_10x115_Cu63.yml deleted file mode 100644 index 811c55b1bf..0000000000 --- a/configurations/craterlake_10x115_Cu63.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 115_Cu63 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - forward_endcap_flux: - barrel_flux_return: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_10x115_Ru96.yml b/configurations/craterlake_10x115_Ru96.yml deleted file mode 100644 index 8f1a2d47c0..0000000000 --- a/configurations/craterlake_10x115_Ru96.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 115_Ru96 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - forward_endcap_flux: - barrel_flux_return: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_10x130.yml b/configurations/craterlake_10x130.yml deleted file mode 100644 index 8f2a716f2c..0000000000 --- a/configurations/craterlake_10x130.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 130 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - forward_endcap_flux: - barrel_flux_return: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_10x130_H2.yml b/configurations/craterlake_10x130_H2.yml deleted file mode 100644 index 199a7332b9..0000000000 --- a/configurations/craterlake_10x130_H2.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 130_H2 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - forward_endcap_flux: - barrel_flux_return: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_10x166_He3.yml b/configurations/craterlake_10x166_He3.yml deleted file mode 100644 index 79bd1734e8..0000000000 --- a/configurations/craterlake_10x166_He3.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 166_He3 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - forward_endcap_flux: - barrel_flux_return: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_10x250.yml b/configurations/craterlake_10x250.yml deleted file mode 100644 index 36b141cc59..0000000000 --- a/configurations/craterlake_10x250.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 250 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - forward_endcap_flux: - barrel_flux_return: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_10x275.yml b/configurations/craterlake_10x275.yml deleted file mode 100644 index 021150e71f..0000000000 --- a/configurations/craterlake_10x275.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 10 -pbeam: 275 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - barrel_gdml: - barrel_flux_return: - forward_endcap_flux: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_18x110_Au.yml b/configurations/craterlake_18x110_Au.yml deleted file mode 100644 index 55963a6fec..0000000000 --- a/configurations/craterlake_18x110_Au.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 18 -pbeam: 110_Au -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - barrel_gdml: - barrel_flux_return: - forward_endcap_flux: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_18x110_He3.yml b/configurations/craterlake_18x110_He3.yml deleted file mode 100644 index 2254276603..0000000000 --- a/configurations/craterlake_18x110_He3.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 18 -pbeam: 110_He3 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - barrel_gdml: - barrel_flux_return: - forward_endcap_flux: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_18x275.yml b/configurations/craterlake_18x275.yml deleted file mode 100644 index b1fe4981e0..0000000000 --- a/configurations/craterlake_18x275.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 18 -pbeam: 275 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - barrel_gdml: - barrel_flux_return: - forward_endcap_flux: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_5x100.yml b/configurations/craterlake_5x100.yml deleted file mode 100644 index 25b7b6c1e9..0000000000 --- a/configurations/craterlake_5x100.yml +++ /dev/null @@ -1,38 +0,0 @@ -ebeam: 5 -pbeam: 100 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - barrel_gdml: - barrel_flux_return: - forward_endcap_flux: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/configurations/craterlake_5x41.yml b/configurations/craterlake_5x41.yml deleted file mode 100644 index ef920a70db..0000000000 --- a/configurations/craterlake_5x41.yml +++ /dev/null @@ -1,36 +0,0 @@ -ebeam: 5 -pbeam: 41 -features: - beampipe: - tracking: - definitions_craterlake: - vertex_barrel: - silicon_barrel: - mpgd_barrel: - support_service_craterlake: - mpgd_outerbarrel: - mpgd_forward_endcap: - mpgd_backward_endcap: - silicon_disks: - tof_barrel: - tof_endcap: - pid: - dirc: - pfrich: - drich: - ecal: - forward_homogeneous: - forward_insert_homogeneous: - bic_default: - backward_PbWO4: - solenoid: - hcal: - lfhcal_with_space_for_insert: - forward_insert: - barrel_gdml: - backward: - backward_endcap_flux: - far_forward: - default: - far_backward: - default: diff --git a/templates/epic.xml.jinja2 b/templates/epic.xml.jinja2 index 687347a0e4..790c0bad2a 100644 --- a/templates/epic.xml.jinja2 +++ b/templates/epic.xml.jinja2 @@ -44,7 +44,7 @@ The ip6 (or other ip) defines should be included first. These files have only a define tags. - + From 99066cea87efa957b699f4483b49a0e615446452 Mon Sep 17 00:00:00 2001 From: simonge Date: Thu, 5 Jun 2025 19:48:58 +0100 Subject: [PATCH 2/5] Find configurations in install dir rather than configurations --- .github/workflows/linux-eic-shell.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index a8634fa00a..6355a0a766 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -34,11 +34,11 @@ jobs: - id: list-detector-configs run: | CONFIGS_CSV=$( - ls -1 configurations | sed 's/^/epic_/g' | xargs | sed 's/\.yml//g;s/ /,/g' + ls -1 install/share/epic/ | sed 's/^/epic_/g' | xargs | sed 's/\.xml//g;s/ /,/g' ) CONFIGS_JSON=$(( echo '[' - ls -1 configurations | sed 's/^/epic_/g' | xargs | sed 's/\.yml//g;s/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/' + ls -1 install/share/epic/ | sed 's/^/epic_/g' | xargs | sed 's/\.xml//g;s/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/' echo ']' ) | jq -c .) echo "configs_csv=${CONFIGS_CSV}" | tee -a $GITHUB_OUTPUT From ef9f4a9ffb12a0496ff7e00bbcfc9fb819922052 Mon Sep 17 00:00:00 2001 From: simonge Date: Thu, 5 Jun 2025 22:06:49 +0100 Subject: [PATCH 3/5] Revert "Find configurations in install dir rather than configurations" This reverts commit 99066cea87efa957b699f4483b49a0e615446452. --- .github/workflows/linux-eic-shell.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index 6355a0a766..a8634fa00a 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -34,11 +34,11 @@ jobs: - id: list-detector-configs run: | CONFIGS_CSV=$( - ls -1 install/share/epic/ | sed 's/^/epic_/g' | xargs | sed 's/\.xml//g;s/ /,/g' + ls -1 configurations | sed 's/^/epic_/g' | xargs | sed 's/\.yml//g;s/ /,/g' ) CONFIGS_JSON=$(( echo '[' - ls -1 install/share/epic/ | sed 's/^/epic_/g' | xargs | sed 's/\.xml//g;s/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/' + ls -1 configurations | sed 's/^/epic_/g' | xargs | sed 's/\.yml//g;s/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/' echo ']' ) | jq -c .) echo "configs_csv=${CONFIGS_CSV}" | tee -a $GITHUB_OUTPUT From c592377bf4a79a0e37cc927d509bc83ea4cdb437 Mon Sep 17 00:00:00 2001 From: simonge Date: Thu, 5 Jun 2025 22:30:07 +0100 Subject: [PATCH 4/5] Try to collect configurations from the script which makes them --- .github/workflows/linux-eic-shell.yml | 20 ++++++++++++-------- bin/make_detector_configuration | 24 ++++++++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index a8634fa00a..3545c0acab 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -33,14 +33,18 @@ jobs: - uses: actions/checkout@v4 - id: list-detector-configs run: | - CONFIGS_CSV=$( - ls -1 configurations | sed 's/^/epic_/g' | xargs | sed 's/\.yml//g;s/ /,/g' - ) - CONFIGS_JSON=$(( - echo '[' - ls -1 configurations | sed 's/^/epic_/g' | xargs | sed 's/\.yml//g;s/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/' - echo ']' - ) | jq -c .) + # Collect all config names from all YAMLs, one per line + CONFIGS="$( + for config in configurations/*.yml; do + ./bin/make_detector_configuration -d templates -t epic.xml.jinja2 -c "$config" -o "epic_$(basename "$config" .yml).xml" -p + done | sort -u + )" + + # CSV + CONFIGS_CSV="$(echo "$CONFIGS" | paste -sd, -)" + # JSON + CONFIGS_JSON="$(echo "$CONFIGS" | jq -R -s -c 'split("\n")[:-1]')" + echo "configs_csv=${CONFIGS_CSV}" | tee -a $GITHUB_OUTPUT echo "configs_json=${CONFIGS_JSON}" | tee -a $GITHUB_OUTPUT diff --git a/bin/make_detector_configuration b/bin/make_detector_configuration index b81df31ba7..2d849f1403 100755 --- a/bin/make_detector_configuration +++ b/bin/make_detector_configuration @@ -12,8 +12,11 @@ parser.add_argument('-d', '--dir', type=str, default='templates', help='Template parser.add_argument('-t', '--template', type=str, help='Template to render.') parser.add_argument('-o', '--output', type=str, help='Output file to write.') parser.add_argument('-c', '--config', type=str, help='Config file to load.') +parser.add_argument('-p', '--print', action='store_true', help='Print the list of configurations to be created without creating them.') args = parser.parse_args() +outputs = [args.output] + # template env = jinja2.Environment( loader = jinja2.FileSystemLoader(args.dir), @@ -27,8 +30,9 @@ if args.config is not None: config = yaml.safe_load(f) # render the template -with open(args.output, 'w') as output: - output.write(template.render(**config)) +if not args.print: + with open(args.output, 'w') as output: + output.write(template.render(**config)) # If the config contains far_forward or far_backward create new xml files with ebeam and pbeam set if 'features' in config and ('far_forward' in config['features'] or 'far_backward' in config['features']): @@ -52,11 +56,19 @@ if 'features' in config and ('far_forward' in config['features'] or 'far_backwar ] for values in ebeam_pbeam_values: + # Create a new output filename based on the ebeam and pbeam values + new_output = args.output.replace('.xml', f"_{values['ebeam']}x{values['pbeam']}.xml") + outputs.append(new_output) + # Create a new config dictionary with the current ebeam and pbeam values new_config = config.copy() new_config.update(values) + + if not args.print: + with open(new_output, 'w') as output: + output.write(template.render(**new_config)) - # Render the template with the new config - new_output = args.output.replace('.xml', f"_{values['ebeam']}x{values['pbeam']}.xml") - with open(new_output, 'w') as output: - output.write(template.render(**new_config)) +if args.print: + for output in outputs: + # Print the output configuration name without the xml extension + print(os.path.basename(output).replace('.xml', '')) From 489e1411e31cddda2ac796b1b5ae0e7dab708b0a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 21:32:00 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/linux-eic-shell.yml | 4 ++-- bin/make_detector_configuration | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index 3545c0acab..0935f55d76 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -36,10 +36,10 @@ jobs: # Collect all config names from all YAMLs, one per line CONFIGS="$( for config in configurations/*.yml; do - ./bin/make_detector_configuration -d templates -t epic.xml.jinja2 -c "$config" -o "epic_$(basename "$config" .yml).xml" -p + ./bin/make_detector_configuration -d templates -t epic.xml.jinja2 -c "$config" -o "epic_$(basename "$config" .yml).xml" -p done | sort -u )" - + # CSV CONFIGS_CSV="$(echo "$CONFIGS" | paste -sd, -)" # JSON diff --git a/bin/make_detector_configuration b/bin/make_detector_configuration index 2d849f1403..df3186b003 100755 --- a/bin/make_detector_configuration +++ b/bin/make_detector_configuration @@ -63,7 +63,7 @@ if 'features' in config and ('far_forward' in config['features'] or 'far_backwar # Create a new config dictionary with the current ebeam and pbeam values new_config = config.copy() new_config.update(values) - + if not args.print: with open(new_output, 'w') as output: output.write(template.render(**new_config))