Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NeRCA.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tamas Gal
NeRCA.jl
Commits
bc4eafd9
Verified
Commit
bc4eafd9
authored
11 months ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Deprecate MuonScan -> FibonacciFit
parent
743b6733
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/NeRCA.jl
+4
-2
4 additions, 2 deletions
src/NeRCA.jl
src/ffit.jl
+25
-25
25 additions, 25 deletions
src/ffit.jl
with
29 additions
and
27 deletions
src/NeRCA.jl
+
4
−
2
View file @
bc4eafd9
...
...
@@ -25,7 +25,8 @@ export
L1Builder
,
L1BuilderParameters
,
Match3B
,
Match1D
,
Line1Z
,
Line1ZEstimator
,
dumandfit
,
MuonScanfit
,
MuonScanfitCandidate
,
MuonScanfitParameters
,
timetoz
,
FibonacciFit
,
FibonacciFitCandidate
,
FibonacciFitParameters
,
timetoz
,
duhits
,
nfoldhits
,
most_frequent
,
categorize
,
modulemap
,
initdb
,
streamds
,
detx
,
# db.jl
...
...
@@ -37,9 +38,10 @@ export
include
(
"math.jl"
)
include
(
"hits.jl"
)
include
(
"mc.jl"
)
include
(
"
scan
fit.jl"
)
include
(
"
f
fit.jl"
)
include
(
"dumandfit.jl"
)
include
(
"royfit.jl"
)
include
(
"db.jl"
)
include
(
"deprecated.jl"
)
end
This diff is collapsed.
Click to expand it.
src/
scan
fit.jl
→
src/
f
fit.jl
+
25
−
25
View file @
bc4eafd9
const
N_FITS_SPREAD
=
10
# number of prefits to calculate the spread of the fit
Base
.
@kwdef
struct
MuonScanf
itParameters
Base
.
@kwdef
struct
FibonacciF
itParameters
tmaxlocal
::
Float64
=
18.0
# [ns]
roadwidth
::
Float64
=
200.0
# [m]
nmaxhits
::
Int
=
50
# maximum number of hits to use
...
...
@@ -25,55 +25,55 @@ struct DirectionSet
angular_separation
::
Float64
end
struct
MuonScanf
it
params
::
MuonScanf
itParameters
struct
FibonacciF
it
params
::
FibonacciF
itParameters
detector
::
Detector
coarsedirections
::
DirectionSet
coincidencebuilder
::
L1Builder
function
MuonScanf
it
(
params
::
MuonScanf
itParameters
,
detector
::
Detector
)
function
FibonacciF
it
(
params
::
FibonacciF
itParameters
,
detector
::
Detector
)
coincidencebuilder
=
L1Builder
(
L1BuilderParameters
(
params
.
tmaxlocal
,
false
))
new
(
params
,
detector
,
DirectionSet
(
fibonaccisphere
(
params
.
α₁
),
params
.
α₁
),
coincidencebuilder
)
end
end
MuonScanf
it
(
det
::
Detector
)
=
MuonScanfit
(
MuonScanf
itParameters
(),
det
)
function
Base.show
(
io
::
IO
,
m
::
MuonScanf
it
)
FibonacciF
it
(
det
::
Detector
)
=
FibonacciFit
(
FibonacciF
itParameters
(),
det
)
function
Base.show
(
io
::
IO
,
m
::
FibonacciF
it
)
print
(
io
,
"
$
(typeof(m)) with a coarse scan of
$
(m.params.α₁)ᵒ and a fine scan of
$
(m.params.α₂)ᵒ."
)
end
"""
Performs a Muon track fit for a given event.
"""
(
ms
f
::
MuonScanf
it
)(
event
::
DAQEvent
)
=
ms
f
(
event
.
snapshot_hits
)
(
f
f
::
FibonacciF
it
)(
event
::
DAQEvent
)
=
f
f
(
event
.
snapshot_hits
)
"""
Performs a Muon track fit for a given set of hits (usually snapshot hits).
"""
function
(
ms
f
::
MuonScanf
it
)(
hits
::
Vector
{
T
})
where
T
<:
KM3io
.
AbstractHit
function
(
f
f
::
FibonacciF
it
)(
hits
::
Vector
{
T
})
where
T
<:
KM3io
.
AbstractHit
rhits
=
ms
f
.
coincidencebuilder
(
HitR1
,
ms
f
.
detector
,
hits
)
rhits
=
f
f
.
coincidencebuilder
(
HitR1
,
f
f
.
detector
,
hits
)
sort!
(
rhits
)
unique!
(
h
->
h
.
dom_id
,
rhits
)
clusterize!
(
rhits
,
Match3B
(
ms
f
.
params
.
roadwidth
,
ms
f
.
params
.
tmaxlocal
))
clusterize!
(
rhits
,
Match3B
(
f
f
.
params
.
roadwidth
,
f
f
.
params
.
tmaxlocal
))
# First stage on 4π
candidates
=
scanfit
(
ms
f
.
params
,
rhits
,
ms
f
.
coarsedirections
)
candidates
=
scanfit
(
f
f
.
params
,
rhits
,
f
f
.
coarsedirections
)
isempty
(
candidates
)
&&
return
candidates
sort!
(
candidates
,
by
=
m
->
m
.
Q
;
rev
=
true
)
S1
=
spread
(
candidates
[
1
:
min
(
N_FITS_SPREAD
,
length
(
candidates
))])
# Second stage on directed cones pointing towards the previous best directions
if
ms
f
.
params
.
nprefits
>
0
if
f
f
.
params
.
nprefits
>
0
directions
=
Vector
{
Vector
{
Direction
{
Float64
}}}()
for
idx
in
1
:
min
(
ms
f
.
params
.
nprefits
,
length
(
candidates
))
for
idx
in
1
:
min
(
f
f
.
params
.
nprefits
,
length
(
candidates
))
most_likely_dir
=
candidates
[
idx
]
.
dir
push!
(
directions
,
fibonaccicone
(
most_likely_dir
,
ms
f
.
params
.
α₂
,
ms
f
.
params
.
θ
))
push!
(
directions
,
fibonaccicone
(
most_likely_dir
,
f
f
.
params
.
α₂
,
f
f
.
params
.
θ
))
end
directionset
=
DirectionSet
(
vcat
(
directions
...
),
ms
f
.
params
.
α₂
)
directionset
=
DirectionSet
(
vcat
(
directions
...
),
f
f
.
params
.
α₂
)
# TODO: setting the stage field here is maybe a bit awkward
for
candidate
in
scanfit
(
ms
f
.
params
,
rhits
,
directionset
)
for
candidate
in
scanfit
(
f
f
.
params
,
rhits
,
directionset
)
push!
(
candidates
,
@set
candidate
.
stage
=
2
)
end
...
...
@@ -83,23 +83,23 @@ function (msf::MuonScanfit)(hits::Vector{T}) where T<:KM3io.AbstractHit
S2
=
spread
(
candidates
[
1
:
min
(
N_FITS_SPREAD
,
length
(
candidates
))])
[
setproperties
(
c
,
(
S1
=
S1
,
S2
=
S2
))
for
c
in
candidates
[
1
:
min
(
length
(
candidates
),
ms
f
.
params
.
nfits
)]]
[
setproperties
(
c
,
(
S1
=
S1
,
S2
=
S2
))
for
c
in
candidates
[
1
:
min
(
length
(
candidates
),
f
f
.
params
.
nfits
)]]
end
"""
Performs the scanfit for each given direction and returns a
`Vector{
MuonScanf
itCandidate}` with all successful fits. The resulting vector can
`Vector{
FibonacciF
itCandidate}` with all successful fits. The resulting vector can
be empty if none of the directions had enough hits to perform the algorithm.
"""
function
scanfit
(
params
::
MuonScanf
itParameters
,
rhits
::
Vector
{
T
},
directionset
::
DirectionSet
)
where
T
<:
AbstractReducedHit
function
scanfit
(
params
::
FibonacciF
itParameters
,
rhits
::
Vector
{
T
},
directionset
::
DirectionSet
)
where
T
<:
AbstractReducedHit
xytsolver
=
XYTSolver
(
params
.
nmaxhits
,
params
.
roadwidth
,
params
.
tmaxlocal
,
params
.
σ
)
[
xytsolver
(
rhits
,
dir
,
directionset
.
angular_separation
)
for
dir
in
directionset
.
directions
]
end
struct
MuonScanf
itCandidate
struct
FibonacciF
itCandidate
pos
::
Position
{
Float64
}
dir
::
Direction
{
Float64
}
t
::
Float64
...
...
@@ -109,8 +109,8 @@ struct MuonScanfitCandidate
stage
::
Int
# stage number (1 for the first stage, 2 for the second one...)
NDF
::
Int
end
MuonScanf
itCandidate
(
pos
::
Position
{
Float64
},
dir
::
Direction
{
Float64
},
t
::
Float64
,
Q
::
Float64
,
NDF
::
Int
)
=
MuonScanf
itCandidate
(
pos
,
dir
,
t
,
Q
,
π
,
π
,
1
,
NDF
)
Base
.
angle
(
m1
::
T
,
m2
::
T
)
where
T
<:
MuonScanf
itCandidate
=
angle
(
m1
.
dir
,
m2
.
dir
)
FibonacciF
itCandidate
(
pos
::
Position
{
Float64
},
dir
::
Direction
{
Float64
},
t
::
Float64
,
Q
::
Float64
,
NDF
::
Int
)
=
FibonacciF
itCandidate
(
pos
,
dir
,
t
,
Q
,
π
,
π
,
1
,
NDF
)
Base
.
angle
(
m1
::
T
,
m2
::
T
)
where
T
<:
FibonacciF
itCandidate
=
angle
(
m1
.
dir
,
m2
.
dir
)
"""
The quality of the fit, the larger the better, as used in e.g. Jpp.
...
...
@@ -391,7 +391,7 @@ function (s::XYTSolver)(hits::Vector{T}, dir::Direction{Float64}, α::Float64) w
hits
=
s
.
hits_buffer
# just for convenience
n_final_hits
=
length
(
hits
)
n_final_hits
<=
s
.
est
.
NUMBER_OF_PARAMETERS
&&
return
MuonScanf
itCandidate
(
Position
(
0
,
0
,
0
),
dir
,
0
,
-
Inf
,
π
,
π
,
1
,
0
)
n_final_hits
<=
s
.
est
.
NUMBER_OF_PARAMETERS
&&
return
FibonacciF
itCandidate
(
Position
(
0
,
0
,
0
),
dir
,
0
,
-
Inf
,
π
,
π
,
1
,
0
)
NDF
=
n_final_hits
-
s
.
est
.
NUMBER_OF_PARAMETERS
N
=
hitcount
(
hits
)
...
...
@@ -401,7 +401,7 @@ function (s::XYTSolver)(hits::Vector{T}, dir::Direction{Float64}, α::Float64) w
estimate!
(
s
.
est
,
hits
)
catch
ex
# isa(ex, SingularSVDException) && @warn "Singular SVD"
return
MuonScanf
itCandidate
(
Position
(
0
,
0
,
0
),
dir
,
0
,
-
Inf
,
π
,
π
,
0
)
return
FibonacciF
itCandidate
(
Position
(
0
,
0
,
0
),
dir
,
0
,
-
Inf
,
π
,
π
,
0
)
end
# TODO: consider creating a "pos()" getter for everything
...
...
@@ -417,5 +417,5 @@ function (s::XYTSolver)(hits::Vector{T}, dir::Direction{Float64}, α::Float64) w
χ²
=
dot
(
Y
,
V
\
Y
)
fit_pos
=
R
\
s
.
est
.
model
.
pos
MuonScanf
itCandidate
(
fit_pos
,
dir
,
s
.
est
.
model
.
t
,
quality
(
χ²
,
N
,
NDF
),
NDF
)
FibonacciF
itCandidate
(
fit_pos
,
dir
,
s
.
est
.
model
.
t
,
quality
(
χ²
,
N
,
NDF
),
NDF
)
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment