Commit Graph

28 Commits

Author SHA1 Message Date
Khalil Ferjaoui a6afa45b3b Feature/minuit2 wrapper (#279)
Build on RHEL8 / build (push) Successful in 3m6s
Build on RHEL9 / build (push) Successful in 3m20s
Run tests using data on local RHEL8 / build (push) Successful in 3m36s
Build on local RHEL8 / build (push) Successful in 2m21s
## Unified Minuit2 fitting framework with FitModel API

### Models (`Models.hpp`)
Consolidate all model structs (Gaussian, RisingScurve, FallingScurve)
into a
single header. Each model provides: `eval`, `eval_and_grad`, `is_valid`,
`estimate_par`, `compute_steps`, and `param_info` metadata. No Minuit2
dependency.

### Chi2 functors (`Chi2.hpp`)
Generic `Chi2Model1DGrad` (analytic gradient) templated on the model
struct.
Replaces the separate Chi2Gaussian, Chi2GaussianGradient,
Chi2Scurves, and Chi2ScurvesGradient headers.

### FitModel (`FitModel.hpp`)
Configuration object wrapping `MnUserParameters`, strategy, tolerance,
and
user-override tracking. User constraints (fixed parameters, start
values, limits)
always take precedence over automatic data-driven estimates.

### Fit functions (`Fit.hpp`)
- `fit_pixel<Model, FCN>(model, x, y, y_err)` -> single-pixel,
self-contained
- `fit_pixel<Model, FCN>(model, upar_local, x, y, y_err)` -> pre-cloned
upar for hot loops
- `fit_3d<Model, FCN>(model, x, y, y_err, ..., n_threads)` ->
row-parallel over pixel grid

### Python bindings
- `Pol1`, `Pol2`, `Gaussian`, `RisingScurve`, `FallingScurve` model
classes with
  `FixParameter`, `SetParLimits`, `SetParameter`, and properties for
  `max_calls`, `tolerance`, `compute_errors`
- Single `fit(model, x, y, y_err, n_threads)` dispatch replacing the old
`fit_gaus_minuit`, `fit_gaus_minuit_grad`, `fit_scurve_minuit_grad`,
etc.

### Benchmarks
- Updated `fit_benchmark.cpp` (Google Benchmark) to use the new FitModel
API
- Jupyter notebooks for 1D and 3D S-curve fitting (lmfit vs Minuit2
analytic)
- ~1.8x speedup over lmfit, near-linear thread scaling up to physical
core count

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2026-03-30 09:12:23 +02:00
Erik Fröjdh 53aed8d8c6 added license 2025-11-20 09:01:28 +01:00
Erik Fröjdh abae2674a9 Apply calibration to Jungfrau raw data (#216)
- Added function to read calibration file
- Multi threaded pedestal subtraction and application of the calibration
2025-07-18 10:19:14 +02:00
Erik Fröjdh 94ac58b09e For 2025.5.22 release (#181)
Build on RHEL9 / build (push) Successful in 2m22s
Build on RHEL8 / build (push) Successful in 2m29s
Co-authored-by: Patrick <patrick.sieberer@psi.ch>
Co-authored-by: JulianHeymes <julian.heymes@psi.ch>
Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
Co-authored-by: Xiangyu Xie <45243914+xiangyuxie@users.noreply.github.com>
Co-authored-by: xiangyu.xie <xiangyu.xie@psi.ch>
Co-authored-by: AliceMazzoleni99 <alice.mazzoleni@psi.ch>
Co-authored-by: Mazzoleni Alice Francesca <mazzol_a@pc17378.psi.ch>
Co-authored-by: siebsi <sieb.patr@gmail.com>
2025-05-22 11:40:39 +02:00
Erik Fröjdh 5d8ad27b21 Developer (#138)
Build the package using cmake then documentation / build (ubuntu-latest, 3.12) (push) Successful in 1m45s
- Fully functioning variable size cluster finder
- Added interpolation
- Bit reordering for ADC SAR 05

---------

Co-authored-by: Patrick <patrick.sieberer@psi.ch>
Co-authored-by: JulianHeymes <julian.heymes@psi.ch>
Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
Co-authored-by: xiangyu.xie <xiangyu.xie@psi.ch>
2025-03-20 12:52:04 +01:00
Erik Fröjdh b7a47576a1 Multi threaded fitting and returning chi2 (#132)
Co-authored-by: Patrick <patrick.sieberer@psi.ch>
Co-authored-by: JulianHeymes <julian.heymes@psi.ch>
Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
2025-02-19 07:19:59 +01:00
Erik Fröjdh dadf5f4869 Added fitting, fixed roi etc (#129)
Co-authored-by: Patrick <patrick.sieberer@psi.ch>
Co-authored-by: JulianHeymes <julian.heymes@psi.ch>
2025-02-12 16:50:31 +01:00
froejdh_e 7f2a23d5b1 accumulating clusters in one array 2024-12-10 22:00:12 +01:00
froejdh_e 6a150e8d98 WIP 2024-12-10 17:21:05 +01:00
Erik Fröjdh 17f8d28019 frame reading for cluster file 2024-11-15 16:13:46 +01:00
Erik Fröjdh e77b615293 Added expression templates (#98)
- Works with NDArray
- Works with NDView
2024-11-15 15:17:52 +01:00
Erik Fröjdh 7ffd732d98 ported reading clusters (#95) 2024-11-14 16:22:38 +01:00
Erik Fröjdh 17917ac7ea Merge branch 'main' into developer 2024-11-12 16:44:15 +01:00
froejdh_e 2ee1a5583e WIP 2024-11-12 09:27:01 +01:00
Erik Fröjdh 349e3af8e1 Brining in changes (#93) 2024-11-11 19:59:55 +01:00
Erik Fröjdh a0b6c4cc03 Merge branch 'main' into developer 2024-11-11 18:52:23 +01:00
froejdh_e ecf1b2a90b WIP 2024-11-11 17:13:48 +01:00
froejdh_e b172c7aa0a starting work on ROI 2024-11-07 16:24:48 +01:00
Erik Fröjdh d8d1f0c517 Taking v1 as the first release (#92)
- file reading
- decoding master file
2024-11-07 10:14:20 +01:00
Erik Fröjdh 9c220bff51 added simple decoding of scan parameters 2024-11-07 08:14:33 +01:00
Erik Fröjdh b2e5c71f9c MH02 1-4 counters 2024-11-06 21:32:03 +01:00
Erik Fröjdh cbfd1f0b6c ClusterFinder 2024-11-06 12:41:41 +01:00
Erik Fröjdh 5b2809d6b0 working Moench03 detector type 2024-11-06 10:13:56 +01:00
Erik Fröjdh 25812cb291 RawFile is now using RawMasterFile 2024-11-06 09:10:09 +01:00
Erik Fröjdh 80a39415de added CtbRawFile 2024-11-05 14:36:18 +01:00
Erik Fröjdh 49da039ff9 working on 05 2024-10-31 15:35:43 +01:00
Erik Fröjdh 563c39c0dd decoding of old Moench03 2024-10-31 11:53:24 +01:00
Erik Fröjdh abb1d20ca3 WIP 2024-10-28 12:25:47 +01:00