Commit Graph
517 Commits
Author SHA1 Message Date
Erik Frojdh 7752c262fa first attempt at simplifying 2026-09-30 15:47:50 +02:00
Khalil FerjaouiandClaude Opus 5.5 28c8defc5a Fix convergence and precision bugs in the LM and VarPro minimizers (#388)
Build on RHEL9 / build (push) Failing after 5s
Run tests using data on local RHEL8 / build (push) Failing after 2m23s
Build on RHEL8 / build (push) Successful in 3m36s
## Fix convergence and precision bugs in the LM and VarPro minimizers

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 13:37:06 +02:00
Erik Frojdh 781fcaf49b errors if paramter sits on limit
Build on RHEL9 / build (push) Successful in 2m55s
Build on RHEL8 / build (push) Successful in 3m35s
Run tests using data on local RHEL8 / build (push) Failing after 4m42s
2026-09-29 13:19:24 +02:00
Erik Frojdh 18396e4f5e updated comments
Build on RHEL9 / build (push) Successful in 2m58s
Build on RHEL8 / build (push) Successful in 3m37s
Run tests using data on local RHEL8 / build (push) Failing after 4m35s
2026-09-29 09:58:33 +02:00
Erik Frojdh 9f2dbe5143 updated docs 2026-09-29 09:53:09 +02:00
Erik Frojdh e0bfbd313e note on using minimizers 2026-09-29 09:43:12 +02:00
Erik Frojdh 60feb01972 moved private implementation to fit folder
Build on RHEL9 / build (push) Successful in 2m56s
Build on RHEL8 / build (push) Successful in 3m35s
Run tests using data on local RHEL8 / build (push) Failing after 4m35s
2026-09-29 09:20:42 +02:00
Erik Frojdh 05a9696c89 removed c arrays
Build on RHEL9 / build (push) Successful in 3m6s
Build on RHEL8 / build (push) Successful in 3m47s
Run tests using data on local RHEL8 / build (push) Failing after 4m31s
2026-09-28 19:28:28 +02:00
Erik Frojdh db2f645580 silence warnings on gcc
Build on RHEL9 / build (push) Successful in 2m52s
Build on RHEL8 / build (push) Successful in 3m30s
Run tests using data on local RHEL8 / build (push) Failing after 4m35s
2026-09-28 10:30:07 +02:00
Erik Frojdh c236f2ff02 optimized more
Build on RHEL9 / build (push) Successful in 2m53s
Build on RHEL8 / build (push) Successful in 3m32s
Run tests using data on local RHEL8 / build (push) Failing after 4m36s
2026-09-28 09:18:28 +02:00
Erik FröjdhandClaude Fable 5.1 a211a3e8e2 Add Minimizer::VarPro, a variable projection minimizer
Every bundled model now declares the parameters it is linear in
(linear_par, basis_and_grad) and, except the polynomials, a vectorisable
bulk basis pass (basis_columns) built on the new model::fast_exp. The
Levenberg-Marquardt iteration is factored into a shared DampedGaussNewton
driver with unchanged results; VarPro solves the linear parameters exactly
at every trial point and iterates over the nonlinear ones, rejecting
degenerate trial points and polishing the converged point with one
undamped step. Limits on linear parameters, pixels that do not converge
and models without the separable structure fall back to
LevenbergMarquardt. Parameter errors are the same Gauss-Newton estimates.
The [fit] tests run VarPro through every configuration and check the
separable structure of each model against its derivatives.

Measured on an M1 Max, single thread: FallingScurve population 5.5 us per
fit against 11.7 us with LevenbergMarquardt, and 2 wrong minima in 4096
pixels against 30; Gaussian 3.3 vs 4.3 us; GaussianChargeSharingKb 33 vs
49 us; Pol2 0.34 vs 1.52 us. Migrad stays the default.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-25 21:36:53 +02:00
Erik Fröjdh d1bfc85c8f Merge remote-tracking branch 'origin/main' into dev/multifit
Build on RHEL9 / build (push) Successful in 2m52s
Build on RHEL8 / build (push) Successful in 3m30s
Run tests using data on local RHEL8 / build (push) Failing after 4m34s
# Conflicts:
#	RELEASE.md
#	docs/src/pyFit.rst
2026-09-25 19:12:45 +02:00
Erik Frojdh 5beabf1888 optimizations
Build on RHEL9 / build (push) Successful in 2m52s
Build on RHEL8 / build (push) Successful in 3m31s
Run tests using data on local RHEL8 / build (push) Successful in 4m28s
2026-09-25 18:05:43 +02:00
Erik Fröjdh 941325ea15 More uniform binding of Numpy arrays (#381)
Build on RHEL9 / build (push) Successful in 2m54s
Build on RHEL8 / build (push) Successful in 3m31s
Run tests using data on local RHEL8 / build (push) Failing after 4m28s
Build on local RHEL8 / build (push) Successful in 3m6s
- Introduce a standard way to bind numpy arrays: py::array_t<T> and
.noconvert() on the argument
- Take py::array_t by value since it's just a small wrapper
- Update bindings
2026-09-25 14:40:33 +02:00
Erik Fröjdh 1693497609 Merge remote-tracking branch 'origin/main' into dev/multifit
# Conflicts:
#	RELEASE.md
2026-09-25 11:01:54 +02:00
Erik FröjdhandClaude Fable 5.1 86a773f6db Add a built-in Levenberg-Marquardt minimizer selectable like Migrad and Fumili
Bring the dependency-free Levenberg-Marquardt solver from dev/custom-fit in
as Minimizer::LevenbergMarquardt next to Minuit2's Migrad (default) and
Fumili, selected through the FitModel constructor, SetMinimizer() or the
Python `minimizer` argument and property.

- FitModel becomes plain data (limits, fixed flags, start values, minimizer
  settings) with index and limit validation. Minuit2 user parameters are
  built per pixel in src/FitMinuit2.cpp, the only translation unit that
  includes Minuit2 headers.
- fit_3d fits through a per-thread PixelFitter so the LM path allocates
  nothing per pixel, and no minimizer allocates a per-pixel result array.
- Fixed parameters and parameters ending on a limit report an error of 0
  with every minimizer; user start values are applied before the validity
  check and clamped into the limits.
- Minuit2's Fumili cannot converge once a two-sided limit is active, so
  such pixels are refitted with Migrad. The Minuit2 minimizers keep a wide
  two-sided range for one-sided limits because Minuit2's one-sided
  transform converges markedly slower.
- The [fit] tests run every scenario through all three minimizers and
  check that they agree; the benchmark gains LM and data-cube cases.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-25 10:58:16 +02:00
Erik Fröjdh 8579a140f7 Improved ArrayExpr (#378)
Build on RHEL9 / build (push) Successful in 3m9s
Build on RHEL8 / build (push) Successful in 3m34s
Run tests using data on local RHEL8 / build (push) Successful in 4m25s
Build on local RHEL8 / build (push) Successful in 3m5s
- removes code repetition
- avoid temporaries for scalar operations
2026-09-25 10:43:58 +02:00
Erik Fröjdh b74c0afb97 initial implementation 2026-09-24 17:20:44 +02:00
Khalil Ferjaoui 4677e1003e Updated licensing info (#384)
Build on RHEL9 / build (push) Successful in 2m54s
Build on RHEL8 / build (push) Successful in 3m31s
Run tests using data on local RHEL8 / build (push) Successful in 4m24s
Build on local RHEL8 / build (push) Successful in 3m8s
- MIT correctly stated for NumpyHelpers
- added missing SPDX identifiers
- pinned sources for licensing
2026-09-24 15:52:37 +02:00
Erik Frojdh 24f1a6138a now correct
Build on RHEL9 / build (push) Successful in 2m58s
Build on RHEL8 / build (push) Successful in 3m36s
Run tests using data on local RHEL8 / build (push) Successful in 4m28s
2026-09-24 15:24:30 +02:00
Erik Frojdh 691735d89b added missing alias for Minuit standalone 2026-09-24 15:23:07 +02:00
Erik Frojdh 516b922b38 updated licensing info 2026-09-24 09:09:37 +02:00
Khalil Ferjaoui fb4a78b380 Removed move for SPSC queue and fixed license (#383)
Build on RHEL9 / build (push) Successful in 2m52s
Build on RHEL8 / build (push) Successful in 3m29s
Run tests using data on local RHEL8 / build (push) Successful in 4m34s
Build on local RHEL8 / build (push) Successful in 3m6s
- Removed faulty move (pointed out by: #227)
- Fixed license for the queue
- Runtime check for capacity=>2

Thank you @kferjaoui for finding the issue. In the end I found it better
to remove the operators rather than modifying the queue
2026-09-23 17:53:34 +02:00
Erik Frojdh abacfd5fda removed move for SPSC queue and fixed license 2026-09-23 16:58:48 +02:00
Erik Fröjdh 1398a74877 updated AGENTS.md and added CLAUDE.md (#380)
Build on RHEL9 / build (push) Successful in 2m48s
Build on RHEL8 / build (push) Successful in 3m25s
Run tests using data on local RHEL8 / build (push) Successful in 4m25s
Build on local RHEL8 / build (push) Successful in 3m7s
- Updated AGENTS.md 
- Added CLAUDE.md which tells claude to read AGENTS.md
2026-09-22 16:48:36 +02:00
Erik Fröjdh 752ec38596 added template for making views (#377)
Build on RHEL9 / build (push) Successful in 3m4s
Build on RHEL8 / build (push) Successful in 3m32s
Run tests using data on local RHEL8 / build (push) Successful in 4m25s
Build on local RHEL8 / build (push) Successful in 3m8s
Cleaned up the helper functions by: 
- Added template for make_view (and new make_const_view) instead of the
copy paste implementation
- checks c_style and dimensions inside make_view
- test binding to be able to probe the checks in make_view

Call sites can be reviewed in a second PR since usage of const or
strictness of conversion depends...
2026-09-22 09:25:42 +02:00
Erik Frojdh cbc4864e93 changed to size_t
Build on RHEL9 / build (push) Successful in 2m53s
Build on RHEL8 / build (push) Successful in 3m28s
Run tests using data on local RHEL8 / build (push) Successful in 4m29s
Build on local RHEL8 / build (push) Successful in 3m5s
2026-09-21 10:51:43 +02:00
Erik Fröjdhandmazzol_a 0dc72634a9 Reject raw files without padding if discard partial is not set (#374)
Build on RHEL9 / build (push) Successful in 3m3s
Build on RHEL8 / build (push) Successful in 3m25s
Run tests using data on local RHEL8 / build (push) Successful in 4m21s
Build on local RHEL8 / build (push) Successful in 3m5s
We have no code in aare to deal with RawFiles that have missing packets
if they are not padded to full size or frames with packet loss dropped.

Added: 
- check that we don't try to read files that are not supported
- python bindings for frame discard policy

at least we get the check in: 
closes #171

---------

Co-authored-by: AliceMazzoleni99 <alice.mazzoleni@psi.ch>
2026-09-18 17:06:11 +02:00
mazzol_aandErik Fröjdh 97ddf6e7c1 error when compiling with warnings (#376)
Build on RHEL9 / build (push) Successful in 2m43s
Build on RHEL8 / build (push) Successful in 3m23s
Run tests using data on local RHEL8 / build (push) Successful in 4m31s
Build on local RHEL8 / build (push) Successful in 3m5s
- error upon warning when building documentation (warnings often
indicate malrendered documentation)
- fixed some warnings

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2026-09-17 09:27:05 +02:00
Erik Fröjdhandmazzol_a b558f1146b Fixed seek bug in CtbRawFile (#373)
Build on RHEL9 / build (push) Successful in 2m49s
Build on RHEL8 / build (push) Successful in 3m25s
Run tests using data on local RHEL8 / build (push) Successful in 4m27s
Build on local RHEL8 / build (push) Successful in 3m6s
- seek to the edge of a file + read_into would select the wrong file
- Visible for example in f.read_frame(index) in python

Added fix, release notes and a small test. 

closes #371

Co-authored-by: AliceMazzoleni99 <alice.mazzoleni@psi.ch>
2026-09-17 08:09:12 +02:00
Erik Fröjdh 8551281eb7 Cleaned up Pedestal (#370)
Build on RHEL9 / build (push) Successful in 2m52s
Build on RHEL8 / build (push) Successful in 3m33s
Run tests using data on local RHEL8 / build (push) Successful in 4m31s
Build on local RHEL8 / build (push) Successful in 3m4s
- renamed pedestal.hpp to bind_Pedestal.hpp for python bindings
- variance is now always calculated in double and made private
- cost correctness in a few places
- removed push_fast and explicit updates of mean from Pedestal. If
performance is needed use FastPedestal
- Pedestal no longer caches std
2026-09-14 16:27:53 +02:00
Erik Fröjdh b0875106e3 Improved ClusterFile API (#358)
Build on RHEL9 / build (push) Successful in 2m49s
Build on RHEL8 / build (push) Successful in 3m23s
Run tests using data on local RHEL8 / build (push) Successful in 4m23s
Build on local RHEL8 / build (push) Successful in 3m5s
Improved API for ClusterFile

- read_frame now returns a std::optional<ClusterVector> to differentiate
between an empty frame and end of file
- f.frames() produces an iterator over frames
- f.chunks() produces an iterator reading chunks of clusters
2026-09-14 16:01:25 +02:00
mazzol_aandErik Fröjdh 86db375948 python repr for Eta, Cluster (#367)
Build on RHEL9 / build (push) Successful in 2m40s
Build on RHEL8 / build (push) Successful in 3m15s
Run tests using data on local RHEL8 / build (push) Successful in 4m15s
Build on local RHEL8 / build (push) Successful in 2m56s
- python string repr for Cluster and Eta
- Context manager for RawMasterFile 
- slice operator for ROI

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2026-09-10 12:18:27 +02:00
Erik Fröjdh 3431bbe117 better error and update frames (#365)
Build on RHEL9 / build (push) Successful in 2m34s
Build on RHEL8 / build (push) Successful in 3m13s
Run tests using data on local RHEL8 / build (push) Failing after 4m14s
Build on local RHEL8 / build (push) Successful in 2m54s
- Updated error message to mention out of range and which file it
applies to
- If there are different number of frames in the subfiles, take the
minimum and print a warning

Closes: #363 
Closes: #362
2026-09-09 17:07:08 +02:00
mazzol_a afce91b358 Fix/clusterfinder test (#359)
Build on RHEL9 / build (push) Successful in 2m41s
Build on RHEL8 / build (push) Successful in 3m19s
Run tests using data on local RHEL8 / build (push) Successful in 4m21s
Build on local RHEL8 / build (push) Successful in 2m53s
- fixed test in ClusterFinderMT (use minimum one pedestal to accumulate
dummy pedestal)
- added minimum_pedestal_samples as additional constructor argument in
ClusterFinder and ClusterFinderMT
- bugfix: race conditions for empty queues in collect() - check directly
when needed
2026-09-09 16:38:54 +02:00
Erik Fröjdh dd409cfe41 Fixed ClusterVector move, filtering, and improved documentation (#357)
Run tests using data on local RHEL8 / build (push) Failing after 4m6s
Build on local RHEL8 / build (push) Successful in 2m52s
Build on RHEL9 / build (push) Successful in 2m44s
Build on RHEL8 / build (push) Successful in 3m16s
- Default `ClusterVector` move operations simplifying the code and
fixing a bug.
- Fixed inconsistent frame number type (uint64/int32)
- Validate Python masks as one-dimensional, C-contiguous Boolean arrays,
handle empty masks safely, and reserve filtered storage based on the
selected cluster count.
- Align the C++ and Python API documentation with the implementation,
including concise `hitmap` and reduction documentation and a correctly
rendered constructor example.
2026-09-07 08:19:26 +02:00
mazzol_a 4eb2bfcfcc enum TiminMode same as in slsDetectorPackage (#360)
Build on RHEL9 / build (push) Successful in 2m36s
Build on RHEL8 / build (push) Successful in 3m19s
Run tests using data on local RHEL8 / build (push) Failing after 4m13s
Build on local RHEL8 / build (push) Successful in 2m53s
**BugFix: **
- enum TimingMode same as in slsDetectorPackage 
- supports reading all timing modes from RawMasterFile
2026-09-04 12:19:00 +02:00
mazzol_aandErik Fröjdh 641ef047b5 Dev/filereading for disabled udp (#342)
Build on RHEL9 / build (push) Successful in 2m41s
Build on RHEL8 / build (push) Successful in 3m15s
Run tests using data on local RHEL8 / build (push) Failing after 4m13s
Build on local RHEL8 / build (push) Successful in 2m53s
- handles file reading of disabled udp ports 
- adds members disabled_udp_ports in master file as an optional 
- adds member diasbled_udp_port_types in master file as an optional
- Treats enabled udp ports as ROIs 
- merges/combines consecutive ROis into one 

### To discuss: 

- right now can only handle either ROI or disabled udp ports (disabled
udp ports has higher precedence)
- Should Frames in File be removed from Master File as value is nonsense
for disabled udp ports

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2026-09-03 14:14:57 +02:00
Erik Fröjdh eddb919328 FastPedestal + optimizations in the cluster finder (#341)
Build on RHEL9 / build (push) Successful in 2m42s
Build on RHEL8 / build (push) Successful in 3m21s
Run tests using data on local RHEL8 / build (push) Failing after 3m56s
Build on local RHEL8 / build (push) Successful in 2m54s
Optimized pedestal tracking with FastPedestal and performance improvements to the cluster finder. 
- ~2x faster hitting 14k FPS on benchmark dataset on 16 core threadripper pro


**Changes**
- No bounds check on interior of frame. (only within half of a cluster)
(~15% improvement)
- Cache threshold (std*n_rms) Biggest improvement comes from not
computing std for each access
- Cache pedestal subtracted frame
- Switched to FastPedestal which assumes we reached steady state

**Things tried but rejected:**
- Always store cluster values, commit on val==max (~15% drop in frame
rate)

**Options**
- using 16 bit clusters and 16 bit pedestal. (slows down the single
threaded case but allow us to reach 12k with multi threading)

**Other notes on performance**
- Passing in memory frames from python and doing nothing: 0.8us/frame
- Passing + pedestal subtraction: 28us/frame
- Passing + pedestal + cluster finding (no store): 652us/frame
- Passing + pedestal + cluster finding: 886 us/frame
2026-09-01 18:41:12 +02:00
Erik Fröjdh 568f94926b baseline AGENTS.md (#356)
Build on RHEL9 / build (push) Successful in 2m32s
Build on RHEL8 / build (push) Successful in 3m15s
Run tests using data on local RHEL8 / build (push) Successful in 3m57s
Build on local RHEL8 / build (push) Successful in 2m44s
- AI generated baseline for AGENTS.md
- Meant to be edited in the future
2026-08-28 09:22:29 +02:00
Erik Fröjdh 85f9d0176a Dev/guess clusters (#355)
Build on RHEL9 / build (push) Successful in 2m40s
Build on RHEL8 / build (push) Successful in 3m17s
Run tests using data on local RHEL8 / build (push) Successful in 3m53s
Build on local RHEL8 / build (push) Successful in 2m47s
- exposing ClusterVector::empty in python
- added member guess_n_clusters
2026-08-25 09:15:38 +02:00
Erik Fröjdh 26d11f74a8 Fix/expand const buffer (#354)
Build on RHEL9 / build (push) Successful in 2m34s
Build on RHEL8 / build (push) Successful in 3m15s
Run tests using data on local RHEL8 / build (push) Successful in 3m53s
Build on local RHEL8 / build (push) Successful in 2m46s
Minor API change:

- NDView<T> implicitly converts to NDView<const T> (as std::span in
C++20)
- expand4to8bit and expand24to32bit now takes a view over const uint8_t
to show that the input is not changes

closes #291
2026-08-25 08:51:41 +02:00
mazzol_a 4970a92d50 updated clang-format commands (#352)
Build on RHEL9 / build (push) Successful in 2m28s
Build on RHEL8 / build (push) Successful in 3m21s
Run tests using data on local RHEL8 / build (push) Successful in 3m59s
Build on local RHEL8 / build (push) Successful in 2m43s
- updated custom targets clang-format, check-format, clang-tidy 
- find: paths must precede expression: `\' (double \\ not properly
escaped in bash)
2026-08-20 16:14:32 +02:00
Erik Fröjdh fef57c13c9 added const overload for NDArray::view() (#351)
Build on RHEL9 / build (push) Successful in 2m29s
Build on RHEL8 / build (push) Successful in 3m3s
Run tests using data on local RHEL8 / build (push) Successful in 3m59s
Build on local RHEL8 / build (push) Successful in 2m45s
- Added missing const T overload for NDArray::view()
- Tests
2026-08-19 16:21:37 +02:00
Erik Fröjdh af25aea684 Fixed bug in reading analog samples for <v8.0 (#349)
Build on RHEL9 / build (push) Successful in 2m34s
Build on RHEL8 / build (push) Successful in 3m2s
Run tests using data on local RHEL8 / build (push) Successful in 3m59s
Build on local RHEL8 / build (push) Successful in 2m43s
Before v8.0 we should always try to read analog samples. This bug
resulted in old Mönch03 data not being reordered.

1. Added test for master file parsing
2. Fixed code 

closing #348
2026-08-19 12:34:37 +02:00
Erik Fröjdh aa39470686 Removed unused DynamicCluster (#346)
Build on RHEL9 / build (push) Successful in 2m31s
Build on RHEL8 / build (push) Successful in 3m4s
Run tests using data on local RHEL8 / build (push) Successful in 3m52s
Build on local RHEL8 / build (push) Successful in 2m45s
- Removed unused DynamicCluster
- Removed commented out references to ClusterFileV2
2026-08-14 11:11:43 +02:00
Erik Fröjdh 4f6b69fba6 Removing deprecated use of lmfit (#344)
Build on RHEL9 / build (push) Successful in 2m44s
Build on RHEL8 / build (push) Successful in 3m9s
Run tests using data on local RHEL8 / build (push) Successful in 3m58s
Build on local RHEL8 / build (push) Successful in 2m44s
Removed the lmfit based fitting and the old API for calling functions

closes #296
2026-08-14 10:31:07 +02:00
Erik Fröjdh e26db97b5c Prototype multi threaded file reader (#343)
Build on RHEL9 / build (push) Successful in 2m40s
Build on RHEL8 / build (push) Successful in 3m4s
Run tests using data on local RHEL8 / build (push) Successful in 3m51s
Build on local RHEL8 / build (push) Successful in 2m46s
- Reading files from nfs shares tops out at ~1GB/s for single threaded
reads.
- MultiThreadedFileReader uses our File wrapper to read a generic file
in parallel
- Placed in aare::experimental to show that it's not production ready
2026-08-11 15:28:54 +02:00
mazzol_a 533ecb8a4a removed patch for minuit2 CMakeLists.txt (#336)
Build on RHEL9 / build (push) Successful in 2m57s
Build on RHEL8 / build (push) Successful in 3m35s
Run tests using data on local RHEL8 / build (push) Successful in 3m57s
Build on local RHEL8 / build (push) Successful in 2m46s
- patch no longer needed for minuit2 as CMakeLists.txt has been updated:
https://github.com/GooFit/Minuit2/commit/46716e516e34a95e1f4effa95705a9e0c3425839
2026-07-16 10:39:06 +02:00
Erik Fröjdh db67e870d9 readme
Build on RHEL9 / build (push) Successful in 2m42s
Build on RHEL8 / build (push) Successful in 3m15s
Run tests using data on local RHEL8 / build (push) Successful in 3m58s
Build on local RHEL8 / build (push) Successful in 2m46s
2026.7.2
2026-07-02 17:00:45 +02:00