Skip to content

Conversation

ShujieL
Copy link
Contributor

@ShujieL ShujieL commented Sep 3, 2025

Briefly, what does this PR introduce?

In Si digi, the weight between raw and sim hit was set to 1 manually regardless of how many sim hits on the same cell. This update should provide a rough but more correct weight.

What kind of change does this PR introduce?

  • [ x] Bug fix (issue #__)
  • New feature (issue #__)
  • Documentation update
  • Other: __

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?

Does this PR change default behavior?

The weight was set to 1 manually regardless of how many sim hits on the same cell. This update should provide a rough but more correct weight.
@ShujieL
Copy link
Contributor Author

ShujieL commented Sep 3, 2025

To add a bit more context to this PR, I looked at the background merged events, and noticed that the photons from Synchrotron radiation almost always left a pair of sim hits on one pixel, see attached an example from the vertex barrel hits.

In our current digi code, the energy deposit on a given cell is the sum of all sim hits so they almost always pass the edep threshold. But any idea on how DD4hep created two hits here? The non-zero quality code in this case seems to indicate overlay (bit=31).
image

@ShujieL ShujieL requested a review from wdconinc September 3, 2025 21:41
hitassoc.setWeight(1.0);
double weight = 0.0;
if (raw_hit.getCharge() > 0) {
weight = std::round((sim_hit.getEDep() * 1e6 / raw_hit.getCharge()) * 10.0) / 10.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove these magic numbers.

Copy link
Contributor

Choose a reason for hiding this comment

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

And why the rounding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

by "magic number" I guess you mean the times 10 for rounding?

In line 72 will fill the charge with (std::int32_t)std::llround(sim_hit.getEDep() * 1e6). one could use exactly this formula. I wanted to use rounding to make sure it will return 1 instead of 0.99999 for example, and I assume we don't care about too much about precision. Would times 100 (two decimal digits) be better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't round.

Other magical number is the 1e6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1e6 is the unit conversion. Can you suggest some alternative?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I changed to use eV for rawhit.charge so it's always integer. It was keV with the magic number of 1e6, which is not the best choice because our detector threshold is often <1keV.
We can have a separate discussion later on whether it makes sense to declare RawTrackerHit.charge as int32_t.

@github-actions github-actions bot added the topic: tracking Relates to tracking reconstruction label Sep 4, 2025
@wdconinc
Copy link
Contributor

wdconinc commented Sep 4, 2025

I don't know how we've come this far without proper energy deposition digitization in the silicon tracker. What bit depth and dynamic range do we expect there? This digitization algorithm can learn a lot from the calorimeter digitization... It almost doesn't make sense to tack on more hacky hard coded bit depth and dynamic range assumptions with this PR until the underlying logic is fixed.

@simonge
Copy link
Contributor

simonge commented Sep 4, 2025

I don't know how we've come this far without proper energy deposition digitization in the silicon tracker.

I thought we'd decided to leave this in place, rather than spend time patching it, while pursuing proper technology dependant approaches.

To add a bit more context to this PR, I looked at the background merged events, and noticed that the photons from Synchrotron radiation almost always left a pair of sim hits on one pixel, see attached an example from the vertex barrel hits.
In our current digi code, the energy deposit on a given cell is the sum of all sim hits so they almost always pass the edep threshold. But any idea on how DD4hep created two hits here? The non-zero quality code in this case seems to indicate overlay (bit=31).

Is that not the quality flag for secondary rather than overlay. Does the associated MCParticle point to the same particle? Is this just the synchrotron backgrounds or are other sources showing the same thing?

@ShujieL
Copy link
Contributor Author

ShujieL commented Sep 4, 2025

Is that not the quality flag for secondary rather than overlay. Does the associated MCParticle point to the same particle? Is this just the synchrotron backgrounds or are other sources showing the same thing?

Edited: the quality value I saw is 1073741824, which is indeed the secondary bit (30th) given how the set_bit function works. Thanks for pointing it out.
See https://github.com/key4hep/EDM4hep/blob/a200fd1567fb189f19b3db0330261c37b062ccca/edm4hep.yaml#L323

Both hits are associated with the same particle, mainly from SR.

@ShujieL
Copy link
Contributor Author

ShujieL commented Sep 4, 2025

I don't know how we've come this far without proper energy deposition digitization in the silicon tracker. What bit depth and dynamic range do we expect there? This digitization algorithm can learn a lot from the calorimeter digitization... It almost doesn't make sense to tack on more hacky hard coded bit depth and dynamic range assumptions with this PR until the underlying logic is fixed.

I will follow up with you and Simon to arrange a dedicated discussion on edep digitization scheme. Any more suggestions on the current change?

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