Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable calorimeter hit merging by functions #1668

Merged
merged 38 commits into from
Jan 9, 2025

Conversation

ruse-traveler
Copy link
Contributor

@ruse-traveler ruse-traveler commented Nov 6, 2024

Briefly, what does this PR introduce?

This PR extends the functionality of the CalorimeterHitsMerger algorithm. Previously, reconstructed hits could only be merged across a given field of the readout of a calorimeter. This presents a challenge for calorimeters such as the Barrel HCal where

  1. our readout has no segmentation beyond just eta & phi, and
  2. it could be useful to study the response of the detector as a function of how many readout channels we gang together after reconstruction.

This PR addresses this point by utilizing the EvaluatorSvc in a manner similar to the adjacencyMatrix, peakNeighbourhoodMatrix of the CalorimeterIslandClustering and the sampFrac of CalorimeterHitReco. Now the user has the ability to specify an (almost) arbitrarily complex transformation for a specific field of the readout via the fieldTransformations parameter, which defines both the field to transform and the function to map the indices of that field onto the desired reference indices.

For example:

app->Add(new JOmniFactoryGeneratorT<CalorimeterHitsMerger_factory>(
  "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"},
  {
    .readout = "HcalBarrelHits",
    .fieldTransformations = {"phi:phi-(5*((phi/5)-floor(phi/5)))"}
  },
  app   // TODO: Remove me once fixed
));

Here, the HcalBarrelMergedHits collection will merge 5 hits (i.e. scintillator tiles for the BHCal) adjacent in phi into a one with the position and cellID of the 1st of the 5, and no hits will be merged along eta.

The previous behavior of the algorithm can be recovered by simply specifying the index to be mapped onto. For example:

app->Add(new JOmniFactoryGeneratorT<CalorimeterHitsMerger_factory>(
  "HcalEndcapNMergedHits", {"HcalEndcapNRecHits"}, {"HcalEndcapNMergedHits"},
  {
    .readout = "HcalEndcapNHits",
    .fieldTransformations = {"layer:4", "slice:0"}
  },
  app   // TODO: Remove me once fixed
));

An example script of to change a transformation (and how to update the adjacency matrix accordingly) from the command-line is provided in the snippets repo here.

What kind of change does this PR introduce?

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No.

@github-actions github-actions bot added topic: calorimetry relates to calorimetry topic: barrel labels Nov 6, 2024
@ruse-traveler ruse-traveler marked this pull request as ready for review November 14, 2024 17:15
@ruse-traveler
Copy link
Contributor Author

I think this is ready to go. I'll post some plots here showing the test case in the BHCal at work shortly...

@ruse-traveler
Copy link
Contributor Author

Here are some (eta, phi) maps of the tiles before and after merging. I tried out two cases for merging (using the example map from the PR description): once with the no. of tiles to merge set to 1 (so in other words, don't merge the tiles, and once with the no. set to 5 (merge into an sPHENIX-style tower).

Broadly, things look like I would expect them to. Except for the giant hole in the hit map...
mergedHitPhiVsEta_nMerge5 e10pim d14m11y2024
recoHitPhiVsEta e10pim d14m11y2024
mergedHitPhiVsEta_nMerge1 e10pim d14m11y2024

@ruse-traveler
Copy link
Contributor Author

Then another odd feature I noticed is that even when the no. to merge is 1, there are still slight changes in the eta, phi distributions of the tiles even though it should just be copying one collection onto another...
recoVsMergedHitPhi_nMerge1 e10pim d14m11y2024
recoVsMergedHitEta_nMerge1 e10pim d14m11y2024

@veprbl
Copy link
Member

veprbl commented Jan 7, 2025

@ruse-traveler
Copy link
Contributor Author

Did this break HcalEndcapPInsertMergedHits?

https://eicrecon.epic-eic.org/pr/1668/capybara/rec_dis_5x41_minQ2=0_craterlake_5x41/index.html#HcalEndcapPInsertMergedHits

Uh oh, looks like it 😩
Let me take a closer look...

@ruse-traveler
Copy link
Contributor Author

Did this break HcalEndcapPInsertMergedHits?

https://eicrecon.epic-eic.org/pr/1668/capybara/rec_dis_5x41_minQ2=0_craterlake_5x41/index.html#HcalEndcapPInsertMergedHits

Looks like it was a typo (second field should've been "slices" not "layers") 😵

src/detectors/BHCAL/BHCAL.cc Outdated Show resolved Hide resolved
Co-authored-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
veprbl
veprbl previously approved these changes Jan 8, 2025
Copy link
Member

@veprbl veprbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff LGTM

veprbl
veprbl previously approved these changes Jan 8, 2025
src/detectors/BHCAL/BHCAL.cc Outdated Show resolved Hide resolved
@veprbl veprbl added this pull request to the merge queue Jan 9, 2025
Merged via the queue into main with commit d96cbff Jan 9, 2025
85 of 86 checks passed
@veprbl veprbl deleted the add-merge-matrix-to-hit-merger branch January 9, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants