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

Bugfix for the charge drift for detectors simulated on a cartesian grid #57

Merged
merged 1 commit into from
Oct 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/ChargeDrift/ChargeDrift.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ function modulate_driftvector(sv::CartesianVector{T}, cp::CartesianPoint{T}, vdv
end
return sv
end

@inline function _is_next_point_in_det(pt_car::CartesianPoint{T}, pt_cyl::CylindricalPoint{T}, det::SolidStateDetector{T, :cylindrical}, point_types::PointTypes{T, 3, :cylindrical})::Bool where {T <: SSDFloat}
pt_cyl in point_types || pt_cyl in det
end
@inline function _is_next_point_in_det(pt_car::CartesianPoint{T}, pt_cyl::CylindricalPoint{T}, det::SolidStateDetector{T, :cartesian}, point_types::PointTypes{T, 3, :cartesian})::Bool where {T <: SSDFloat}
pt_car in point_types || pt_car in det
end

"""
_drift_charge(...)

Expand Down Expand Up @@ -112,8 +120,8 @@ function _drift_charge!(
done = true
end
next_pos::CartesianPoint{T} = current_pos + stepvector
next_pos_cyl::CylindricalPoint{T} = _convert_vector(next_pos, Val(S))
if next_pos_cyl in point_types || next_pos_cyl in det
next_pos_cyl::CylindricalPoint{T} = CylindricalPoint(next_pos)
if _is_next_point_in_det(next_pos, next_pos_cyl, det, point_types)
drift_path[istep] = next_pos
drifttime += Δt
timestamps[istep] = drifttime
Expand Down