Skip to content

Conversation

@tillrue
Copy link
Contributor

@tillrue tillrue commented Sep 17, 2025

Hi!

In my bachelor degree project, I have developed the matching logic for Tracks and HCal clusters in the ParticleFlow algorithm. Inspired by the existing code from the Track and ECal matching, I have added matching criteria such as a distance threshold between the extrapolated track and cluster, as well as a minimum and maximum energy ratio between track and cluster. For the Track-HCal matching, I have made these configurable such that they can be decided on in the future.

I have also taken care of special cases such as a Track that is matched to an ECal cluster but not to an HCal cluster and the two clusters were matched to each other. In these cases I combined them all and the output is that they appear together as Track+ECal+HCal entry. In the previous version this case would have been registred as Track+ECal and ECal+HCal cluster entries such that there would suddenly be an additional ECal cluster. However, I think the code still needs more testing and can maybe just be seen as a first draft. The "new" variable names are inspired by the existing ones, but these were sometimes a bit confusing, as Calo and HadCalo are for instance describing ECal and HCal. But i guess that can easily be fixed when the code is refined at a later stage.

The report of the project can be found here:
https://lup.lub.lu.se/student-papers/search/publication/9195974

There I also wrote about the performance of the current matching and found that the clustering can be improved. Both in a sense of optimizing the distance threshold parameter and by e.g. adding a "satellite clustering" algorithm to link multiple clusters.

What are the issues that this addresses?

  • added matching logic between Track + HCal cluster with configurable matching criteria
  • added arbitration for all possible cases and removed "double" counting of tracks and clusters in special cases

Check List

  • [x ] I successfully compiled ldmx-sw with my developments.
  • [x ] I read, understood and follow the coding rules. (I just used the existing variable names and extended them as I didn't want to mess it up completely but think that they can maybe be adjusted at a later stage.)
  • [x ] I ran my developments and the following shows that they are successful. (see project report)

tillrue added 6 commits June 8, 2025 11:23
Added wide angle event generator.

Shots single (mono-energetic) electrons downstream at a configurable angle with respect to the z axis.
Added linking between Track and HCal cluster

Added and refined arbitration for Track and HCal cluster matching

I've implemented these algorithms as part of my bachelor degree project and I have written them very similar to the ones for the track + ecal cluster matching. I tried to stick to the existing variable "convention" but think that they might need some refinement at a later stage as "Calo" and "HadCalo" sound confusingly similar to describe the ECal and HCal respectively.
Added linking between Track and HCal cluster

Added and refined arbitration for Track and HCal cluster matching

I've implemented these algorithms as part of my bachelor degree project and I have written them very similar to the ones for the track + ecal cluster matching. I tried to stick to the existing variable "convention" but think that they might need some refinement at a later stage as "Calo" and "HadCalo" sound confusingly similar to describe the ECal and HCal respectively.
Added updates according to current version of trunk
@tillrue tillrue requested a review from bryngemark September 17, 2025 11:57
@tillrue
Copy link
Contributor Author

tillrue commented Sep 17, 2025

The changes in pfReco.py and generators.py seem to have passed the basic tests. However, the ones in ParticleFlow.h and ParticleFlow.cxx have not passed the tests and I do not quite understand why. Especially in the case of ParticleFlow.h as there are only 3 lines that initialize additional parameters... when I used these codes in my own development environment, they didn't yield any errors...

@tomeichlersmith
Copy link
Member

The conflicts shown here make me think that your branch is based off an older version of ldmx-sw. I can check locally to see what version of ldmx-sw your branch is based on:

eichl008@spa-cms016 ~/ldmx/ldmx-sw> git fetch --tags
eichl008@spa-cms016 ~/ldmx/ldmx-sw> git switch wide-angle-scattering-events-degree-project 
eichl008@spa-cms016 ~/ldmx/ldmx-sw> git describe --tags
v4.3.1-12-g25b0f75b

so your branch is 12 commits "on top" of v4.3.1 currently pointing at commit 25b0f75b.

We need to update your branch to the current version of ldmx-sw (the trunk branch) so that your updates are applied correctly. The reason you are seeing errors is because we recently applied clang-tidy to all the C++ sources of ldmx-sw in order to align the code with our naming scheme.

How to Update

You need to make sure your local copy of trunk is up to date.

git switch trunk
git pull

And then you can merge trunk into your branch.

git switch wide-angle-scattering-events-degree-project
git merge trunk

When I do this, I see CONFLICTs because you have changed things that other commits (currently on trunk) also change.

eichl008@spa-cms016 ~/ldmx/ldmx-sw> git merge trunk                                                                                                                                                                                           
Auto-merging Recon/include/Recon/ParticleFlow.h                                                                                                                                                                                               
CONFLICT (content): Merge conflict in Recon/include/Recon/ParticleFlow.h                                                                                                                                                                      
Auto-merging Recon/python/pfReco.py                                                                                                                                                                                                           
CONFLICT (content): Merge conflict in Recon/python/pfReco.py                                                                                                                                                                                  
Auto-merging Recon/src/Recon/ParticleFlow.cxx                                                                                                                                                                                                 
CONFLICT (content): Merge conflict in Recon/src/Recon/ParticleFlow.cxx                                                                                                                                                                        
Auto-merging SimCore/python/generators.py                                                                                                                                                                                                     
Automatic merge failed; fix conflicts and then commit the result.    

It is up to you as the human developer to tell git how to resolve this conflicts. I believe resolving merge conflicts to be a good skill in the world of software development, so I am going to leave you to do it, but please reach out if you get stuck or lost. GitHub has a short tutorial giving the basic syntax of conflicts: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line

@tomeichlersmith tomeichlersmith force-pushed the wide-angle-scattering-events-degree-project branch from 25b0f75 to ee2cd72 Compare October 1, 2025 16:26
@bryngemark
Copy link
Contributor

bryngemark commented Oct 2, 2025

hey @tillrue, i just started a PR with some work i did over summer. since you are anyway going to have to resolve conflicts, it's better to rebase to trunk after my changes have been added.

also, a heads-up that you need to check out your branch again since we removed some bulky git history yesterday and don't want it reintroduced from old copies. so

  1. save any work you want to keep that was not committed and pushed to your branch
  2. delete your old copy of ldmx-sw
  3. make a fresh clone. NOTE you should cd ldmx-sw to run just init downstream of ldmx-sw from now on.
  4. apply your changes (rebase, or copy/paste stuff from a local copy of your changed files into the versions from trunk)
  5. push to your branch when happy.

swing by/reach out if you need any help with all of this (beyond @tomeichlersmith's helpful pointers)

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.

4 participants