Skip to content

Refactor ConformalTrackingV2 Configuration#165

Merged
tmadlener merged 2 commits intoiLCSoft:masterfrom
Victor-Schwan:pr_fix_fmt
Aug 11, 2025
Merged

Refactor ConformalTrackingV2 Configuration#165
tmadlener merged 2 commits intoiLCSoft:masterfrom
Victor-Schwan:pr_fix_fmt

Conversation

@Victor-Schwan
Copy link
Copy Markdown
Contributor

@Victor-Schwan Victor-Schwan commented Jul 16, 2025

BEGINRELEASENOTES

  • fixes: wrong position of fmt off/on statements render them ineffective
  • refactors the ConformalTrackingV2 processor configuration in TrackingReco_FCCeeMDI.py

The previous manual string-list definition for the Steps parameter was unwieldy, especially with autoformatting that spread each item across a new line. This change introduces a new utility function, encode_CT_steps_dict_to_legacy_list in py_utils.py, allowing the conformal tracking steps to be defined using a structured Python dictionary.

This significantly improves readability and maintainability by:

  • Presenting the configuration in a more intuitive, nested dictionary format.
  • Reducing the number of lines occupied by the configuration, particularly after autoformatting.

This is a refactoring effort only; the physics behavior of ConformalTrackingV2 should remain unchanged.

ENDRELEASENOTES

@Victor-Schwan Victor-Schwan changed the title minor bug fix fix ineffective fmt off/on statements Jul 16, 2025
@tmadlener
Copy link
Copy Markdown
Contributor

Some more structured form for configuring conformal tracking has been introduced in the Gaudi port: https://github.com/key4hep/k4Reco/blob/9a8b181c092e1eb04640869820328a04392a52d6/k4Reco/ConformalTracking/options/runConformalTracking.py#L98-L183

See also key4hep/k4Reco#23 for some more details / discussion. Maybe it's possible to write a similar utility function that converts the dict into the parameters for the wrapped version?

@jmcarcell
Copy link
Copy Markdown

Have a look at this PR: key4hep/CLDConfig#70 where the parameters for tracking for the CLD reconstruction are changed to a more structured format while there are some conversions (look for conformal_tracking_args_marlin) to make sure it still works for Marlin.

@Victor-Schwan
Copy link
Copy Markdown
Contributor Author

Some more structured form for configuring conformal tracking has been introduced in the Gaudi port: https://github.com/key4hep/k4Reco/blob/9a8b181c092e1eb04640869820328a04392a52d6/k4Reco/ConformalTracking/options/runConformalTracking.py#L98-L183

See also key4hep/k4Reco#23 for some more details / discussion. Maybe it's possible to write a similar utility function that converts the dict into the parameters for the wrapped version?

Exactly what I was thinking. I didn’t want to spend too much time on it initially, so I just went with the minimal bug fix. But I have now implemented the function or at least I do provide a suggestion :)

@Victor-Schwan
Copy link
Copy Markdown
Contributor Author

Have a look at this PR: key4hep/CLDConfig#70 where the parameters for tracking for the CLD reconstruction are changed to a more structured format while there are some conversions (look for conformal_tracking_args_marlin) to make sure it still works for Marlin.

Thank you for bringing this to my attention. It wasn't even on my radar :)
I just skimmed through the CLD PR and noticed a few things:

  • There’s no SSOT — for example, the argparse option names are redefined in CLDReconstruction_iosvc, which is part of the user interface. Given that we already have inconsistencies in the utils (as discussed here: Configurability for material plots key4hep/k4geo#392), I think this is quite risky.

In CLDConfig/Tracking/ConformalTracking.py:

  • In general, the translation from the dict to the legacy string is implemented twice (in CLDConfig and now in this PR for ILDConfig) — not ideal.

  • I think it’s cleaner to move that logic into a separate function, like I did. The details around inserting special characters are a bit distracting where they are for CLD in my humble opinion.

  • Also, the following part looks a bit awkwardly implemented, in my opinion:

    for i in range(len(param_dict["collections"])):
        marlin_collections.append(f"{param_dict['collections'][i]}")
        if i < len(param_dict["collections"]) - 1:
            marlin_collections[-1] += ","
    marlin_parameters = []
    for i, (k, v) in enumerate(param_dict["params"].items()):
        marlin_parameters.extend([k, ":", f"{v};"])

    marlin_flags = []
    for i in range(len(param_dict["flags"])):
        marlin_flags.append(f"{param_dict['flags'][i]}")
        if i < len(param_dict["flags"]) - 1:
            marlin_flags[-1] += ","
    marlin_functions = []
    for i in range(len(param_dict["functions"])):
        marlin_functions.append(f"{param_dict['functions'][i]}")
        if i < len(param_dict["functions"]) - 1:
            marlin_functions[-1] += ","

I would guess that pylint would have some suggestions for improvement there.

Let me know what you think :)

@tmadlener
Copy link
Copy Markdown
Contributor

Thanks. This looks good to me. Could you change the PR title and the release notes to better reflect the changes that are now done with this PR?

@Victor-Schwan Victor-Schwan changed the title fix ineffective fmt off/on statements Refactor ConformalTrackingV2 Configuration Aug 11, 2025
@Victor-Schwan
Copy link
Copy Markdown
Contributor Author

I suggest to not squash the two commits as they are orthogonal. First, the wrong position of the fmt on/off statements is fixed and later, the CT config is refactored.

@tmadlener tmadlener merged commit 65d5c55 into iLCSoft:master Aug 11, 2025
11 checks passed
@Victor-Schwan Victor-Schwan deleted the pr_fix_fmt branch August 11, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants