-
Notifications
You must be signed in to change notification settings - Fork 31
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
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
…ter-simcalorimeterhitprocessor-should-include-travel-time
…ter-simcalorimeterhitprocessor-should-include-travel-time
There was a problem hiding this 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.
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid abbreviations.
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{}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 */
}
There was a problem hiding this 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!
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:
Does this PR introduce breaking changes? What changes might users need to make to their code?
Does this PR change default behavior?