forked from Geant4/geant4
-
Notifications
You must be signed in to change notification settings - Fork 1
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
biasing particle change is not initialized properly #13
Comments
3 tasks
tomeichlersmith
added a commit
that referenced
this issue
Feb 6, 2024
See #13 for full context. This is not affecting much except the weird situation where we want to biasing processes upstream of the target.
|
Well, I figured out how the geant4/cmake/Modules/Geant4LibraryBuildOptions.cmake Lines 180 to 191 in d61ba82
I was just |
|
Resolved by #14 and a part of the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Somehow, it has been lost to the sands of time that
G4ParticleChangeForOccurenceBiasingis neverinitialized properly. This means that its internal variables are just the default-constructed values.
Good News
This bug is not affecting the physics of these distributions at all.
The
G4SteppingManageris what callsPostStepDoItinInvokePSDIPand uses the returnedG4VParticleChangepointer.The function
UpdateStepForPostStepis then called to copy any particle change into the steps and thenpassed onto the track with
G4Step::UpdateTrack. The secondaries are also retrieved usingGetNumberOfSecondariesand
GetSecondary.UpdateStepFor*calls withinG4ParticleChangeForOccurenceBiasingareall passed down to the wrapped particle change while changing the weight value (if need be).
Secondary*calls are not passed down, but before they are used by the stepping manager, we useStealSecondariesto move the secondaries from the wrapped particle change into the biasing particle change.
Bad News
What this bug does do is break when
G4ParticleChangeForOccurenceBiasinguses its internal member variables insteadof the wrapped
G4VParticleChange. This occurs withinCheckSecondarywhere we make sure produced secondariesdo not have negative energy or go backwards in time. We use the internal member variable
theParentGlobalTimehereto make sure the secondary track passed as an argument has a later global time than the parent.
theParentGlobalTimeis
0when not initialized which is after any particles produced upstream of the target (since we time shift theprimaries to make global t=0 at the target).
We haven't noticed this before because
I noticed this now since I want to do dimuon production in a calibration target upstream of LDMX.
tomeichlersmith/ldmx-dimuon#5
Fix
Actually initialize the particle change if we are going to return it.
One funky thing is that I don't know how the
debugFlagwithin any of theG4VParticleChangeis set to true (which is the only wayCheckSecondaryis ever called withinAddSecondary). This is checked in more detail in tomeichlersmith/ldmx-dimuon#5 (comment) . I suspect some memory funkiness is happening inSetNumberOfSecondariesbecause I can watch the variable and see it get set fromfalseto2in gdb.The text was updated successfully, but these errors were encountered: