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

Add fibonaccifit script

parent 4efe70e2
No related branches found
No related tags found
No related merge requests found
Pipeline #55111 failed
FROM julia:1.10
LABEL maintainer="Tamas Gal <tgal@km3net.de>"
WORKDIR /reco
RUN apt-get -y update && apt-get -y install build-essential && apt-get clean
COPY Project.toml .
RUN julia -e 'using Pkg; Pkg.Registry.add(); Pkg.Registry.add(RegistrySpec(url="https://git.km3net.de/common/julia-registry")); Pkg.activate("."); Pkg.instantiate(); Pkg.build("NeRCA"); Pkg.test("NeRCA")'
# COPY fibonaccifit.jl ./src/fibonaccifit.jl
ENTRYPOINT ["julia", "--project=.", "src/fibonaccifit.jl"]
This diff is collapsed.
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
FHist = "68837c9b-b678-4cd5-9925-8a54edc8f695"
Healpix = "9f4e344d-96bc-545a-84a3-ae6b9e1b672b"
KM3io = "2cab5852-6f21-4982-99b0-6a4792870cfb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NeRCA = "89b7c20c-a96a-11e9-35df-35fba0891eb2"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
#!/usr/bin/env julia
if length(ARGS) != 2
println("Usage: ./fibonaccifit.jl LIGIER_HOST LIGIER_PORT")
exit(1)
end
println("Initialising libraries, this may take a minute...")
using Sockets
using KM3io
using NeRCA
using CairoMakie
const LIGIER_HOST = getalladdrinfo(ARGS[1])[1]
const LIGIER_PORT = parse(Int, ARGS[2])
function main()
println("Starting live FibonacciFit")
detector = Detector("/data/ffit.datx")
@show detector
fig_indices = Dict{Int, Tuple{Int, Int}}()
row = 1
col = 1
for s in detector.strings
if col > 6
row += 1
col = 1
end
fig_indices[s] = (row, col)
col += 1
end
msfparams = MuonScanfitParameters(;tmaxlocal=18.0, roadwidth=200.0, nfits=12)
msfit = MuonScanfit(msfparams, detector)
@show msfparams
idx = 0
for event in CHClient{KM3io.DAQEvent}(LIGIER_HOST, LIGIER_PORT)
idx += 1
muons = msfit(event.snapshot_hits)
best_fit = first(muons)
flag = "."
if best_fit.Q > 0
flag = "+"
chits = calibrate(detector, event.snapshot_hits)
if best_fit.dir.z > 0
flag = "U"
fig = Figure(size=(600,400))
for s in detector.strings
col, row = fig_indices[s]
_chits = filter(h->h.string == s, chits)
ts = [h.t for h in _chits]
zs = [h.pos.z for h in _chits]
ax = Axis(fig[col, row])
scatter!(ax, ts, zs)
end
save("/plots/ztplot_ffit.png", fig)
end
if best_fit.dir.z < -0.99
flag = "T"
write_timeresiduals("/data/reco_timeres.csv", event.header.run, best_fit, chits)
end
end
print(flag)
if idx % 80 == 0
println()
flush(stdout)
end
end
end
function write_timeresiduals(fname::AbstractString, run_id, fit, calibrated_hits)
if !isfile(fname)
fobj = open(fname, "w")
write(fobj, "run,timestamp,du,floor,dom_id,t_res,Q\n")
else
fobj = open(fname, "a")
end
t = Int(round(time()))
for hit in calibrated_hits
cphoton = cherenkov(fit, hit)
cphoton.d_closest > 100 && continue # skip DOMs which are too far away
write(fobj, "$(run_id),$(t),$(hit.string),$(hit.floor),$(hit.dom_id),$(cphoton.Δt),$(fit.Q)\n")
end
flush(fobj)
end
main()
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