Skip to content
Snippets Groups Projects
Verified Commit b56c643d authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Add besttrack stuff

parent 79dabe8f
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,9 @@ most_frequent
### Reconstruction
```@docs
besttrack
bestjppmuon
bestjppshower
bestaashower
RecStageRange
hashistory
```
......@@ -20,7 +20,8 @@ export Hit, TriggeredHit, Trk, MCHit, MCTrk, EvtHit
export calibrate, floordist, slew
export besttrack, RecStageRange, hashistory, hasjppmuonprefit, hasjppmuonsimplex, hasjppmuongandalf,
export besttrack, bestjppmuon, bestjppshower, bestaashower,
RecStageRange, hashistory, hasjppmuonprefit, hasjppmuonsimplex, hasjppmuongandalf,
hasjppmuonenergy, hasjppmuonstart, hasjppmuonfit, hasshowerprefit, hasshowerpositionfit,
hasshowercompletefit, hasshowerfit, hasaashowerfit, hasreconstructedjppmuon,
hasreconstructedjppshower, hasreconstructedaashower
......
......@@ -72,10 +72,23 @@ Return the best reconstructed track for a given reconstruction type and
reconstruction stage range. If no track could be found, `nothing` is returned.
"""
function besttrack(e::Evt, rec_type::Integer, rsr::RecStageRange)
candidates = filter(e.trks) do t
besttrack(e::Evt, rec_type::Integer, rsr::RecStageRange) = besttrack(e.trks, rec_type, rsr)
function besttrack(trks::Vector{Trk}, rec_type::Integer, rsr::RecStageRange)
candidates = filter(trks) do t
hashistory(t, rec_type, rsr)
end
length(candidates) == 0 && return nothing
sort(candidates; by=c -> (length(c.rec_stages), c.lik)) |> last
_besttrack(candidates)
end
function _besttrack(trks::Vector{Trk})
length(trks) == 0 && return nothing
sort(trks; by=c -> (length(c.rec_stages), c.lik)) |> last
end
bestjppmuon(e::Evt) = bestjppmuon(e.trks)
bestjppmuon(trks::Vector{Trk}) = filter(hasjppmuonfit, trks) |> _besttrack
bestjppshower(e::Evt) = bestjppshower(e.trks)
bestjppshower(trks::Vector{Trk}) = filter(hasshowerfit, trks) |> _besttrack
bestaashower(e::Evt) = bestaashower(e.trks)
bestaashower(trks::Vector{Trk}) = filter(hasaashowerfit, trks) |> _besttrack
......@@ -65,6 +65,12 @@ end
@test hasreconstructedjppmuon(e)
@test !hasreconstructedjppshower(e)
@test !hasreconstructedaashower(e)
@test 294.6407542676734 bestjppmuon(e).lik
@test isnothing(bestjppshower(e))
@test isnothing(bestaashower(e))
@test 294.6407542676734 bestjppmuon(e.trks).lik
@test isnothing(bestjppshower(e.trks))
@test isnothing(bestaashower(e.trks))
close(f)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment