Skip to content

SimCalorimeter Hit Contribution Time After SimCalorimeterHitProcessor Should Include Travel Time #1907 #1923

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mhkim-anl
Copy link
Contributor

@mhkim-anl mhkim-anl commented Jun 20, 2025

Briefly, what does this PR introduce?

Currently we are (optionally) attenuation calorimeter hit contributions in SimCalorimeterHitProcessor to be evaluated at a certain position in the detector. However, we are not updating the time to correspond to this attenuated signal leaving the contributions in an inconsistent state. Moreover, this step has to be done at some point during pulse generation. This can easily be fixed by adding this to SimCalorimeterHitProcessor.

This PR is currently a draft.

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?

Does this PR change default behavior?

@mhkim-anl mhkim-anl self-assigned this Jun 20, 2025
@github-actions github-actions bot added topic: calorimetry relates to calorimetry topic: barrel labels Jun 20, 2025
@mhkim-anl mhkim-anl marked this pull request as draft June 20, 2025 20:25
Copy link
Contributor

github-actions bot commented Jun 20, 2025

…ter-simcalorimeterhitprocessor-should-include-travel-time
@mhkim-anl mhkim-anl marked this pull request as ready for review June 27, 2025 19:57
…ter-simcalorimeterhitprocessor-should-include-travel-time
Copy link
Contributor

@wdconinc wdconinc left a comment

Choose a reason for hiding this comment

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

Division-by-zero safety should be added; suggestions below. Ideally without adding branching.

Comment on lines +195 to +201
const double propaTime =
m_attenuationReferencePosition
? std::abs(m_attenuationReferencePosition.value() - ih.getPosition().z) /
m_cfg.propagationSpeed
: 0.;
hit_accum.add(contrib.getEnergy() * attFactor, contrib.getTime() + propaTime,
ih.getPosition());
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid abbreviations.

Suggested change
const double propaTime =
m_attenuationReferencePosition
? std::abs(m_attenuationReferencePosition.value() - ih.getPosition().z) /
m_cfg.propagationSpeed
: 0.;
hit_accum.add(contrib.getEnergy() * attFactor, contrib.getTime() + propaTime,
ih.getPosition());
const double propagationTime =
m_attenuationReferencePosition
? std::abs(m_attenuationReferencePosition.value() - ih.getPosition().z) /
m_cfg.propagationSpeed
: 0.;
hit_accum.add(contrib.getEnergy() * attFactor, contrib.getTime() + propagationTime,
ih.getPosition());

@@ -21,6 +21,9 @@ struct SimCalorimeterHitProcessorConfig {
std::vector<std::string> hitMergeFields{};
// fields for merging contributions
std::vector<std::string> contributionMergeFields{};

// propagation speed of hits in the detector material
double propagationSpeed{};
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, you set this configuration parameter to zero by default, and then you divide by it without conditions. Please make sure the default value is not dangerous like that. I'd suggest that the default behavior should be 'infinite' propagation speed (but, of course, not std::infinite).

Another options is to specify the inverse propagation speed, and default that to zero. Since you would multiply instead of divide, that's inherently safer.

And once you're specifying inverse propagation speed, you can maybe just specify (effective) index of refraction, where a default of zero is infinite speed, a value of 1 is physical speed of light, and a value > 1 would be more realistic.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would second the idea of the refraction index! I think that's a nice way of making things safe! (With some explanatory comments above the declaration, of course 😉)

Another (clunkier) approach could be to check the value of the parameter:

if (m_cfg.propagationSpeed > 0.0) {
  /* add propagation time */
}

Copy link
Contributor

@ruse-traveler ruse-traveler left a comment

Choose a reason for hiding this comment

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

Thanks for the development! I second Wouter's suggestions, and once those are addressed I think this is good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SimCalorimeter Hit Contribution Time After SimCalorimeterHitProcessor Should Include Travel Time
3 participants