Commit Graph

42 Commits

Author SHA1 Message Date
mazzol_a 792b26089e passing eta vector to interpolator and transform_eta_values 2026-04-16 18:57:43 +02:00
mazzol_a 0814bd5678 allow passing mask to clustervector 2026-04-15 17:40:12 +02:00
lunin_l 8f8173feb6 CI/CD: Integrate pre-commit hooks and GitHub Actions workflow (#303)
Build on RHEL8 / build (push) Successful in 2m48s
Build on RHEL9 / build (push) Successful in 3m8s
Run tests using data on local RHEL8 / build (push) Successful in 3m34s
Build on local RHEL8 / build (push) Successful in 2m24s
To improve codebase quality and reduce human error, this PR introduces
the pre-commit framework. This ensures that all code adheres to project
standards before it is even committed, maintaining a consistent style
and catching common mistakes early.

Key Changes:

- Code Formatting: Automated C++ formatting using clang-format (based on
the project's .clang-format file).
- Syntax Validation: Basic checks for file integrity and syntax.
- Spell Check: Automated scanning for typos in source code and comments.
- CMake Formatting: Standardization of CMakeLists.txt and .cmake
configuration files.
- GitHub Workflow: Added a CI action that validates every Pull Request
against the pre-commit configuration to ensure compliance.

The configuration includes a [ci] block to handle automated fixes within
the PR. Currently, this is disabled. If we want the CI to automatically
commit formatting fixes back to the PR branch, this can be toggled to
true in .pre-commit-config.yaml.

```yaml
ci:
  autofix_commit_msg: [pre-commit] auto fixes from pre-commit hooks
  autofix_prs: false
  autoupdate_schedule: monthly
```

The last large commit with the fit functions, for example, was not
formatted according to the clang-format rules. This PR would allow to
avoid similar mistakes in the future.

Python fomat with `ruff` for tests and sanitiser for `.ipynb` notebooks
can be added as well.
2026-04-14 11:52:23 +02:00
Erik Fröjdh a25f5d2344 Access to parameter names and fast erf approx (#298)
Build on RHEL8 / build (push) Successful in 2m44s
Build on RHEL9 / build (push) Successful in 3m3s
Run tests using data on local RHEL8 / build (push) Successful in 3m39s
Build on local RHEL8 / build (push) Successful in 2m23s
- Set parameter starting values, limits or fix through name as well as
index
- Updated parameter names for the scurve
- Fast approximation to erf function (~10% speedup of fitting)

---------

Co-authored-by: Khalil Ferjaoui <khalilferjaoui@yahoo.fr>
2026-04-02 13:33:37 +02:00
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
mazzol_a d9ff73e8b2 added matterhorn transformation tests (#284)
- added matterhorn transformation tests

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2026-03-17 16:54:06 +01:00
mazzol_a 2a3c121574 Fix/test (#278)
Build on RHEL8 / build (push) Successful in 2m29s
Build on RHEL9 / build (push) Successful in 2m40s
Build on local RHEL9 / build (push) Successful in 1m9s
Run tests using data on local RHEL8 / build (push) Has been cancelled
Build on local RHEL8 / build (push) Has been cancelled
2026-02-26 14:23:45 +01:00
mazzol_a 2139e5843c Dev/stuff from pyctbgui (#273)
Build on RHEL8 / build (push) Successful in 2m23s
Build on RHEL9 / build (push) Successful in 2m35s
Run tests using data on local RHEL8 / build (push) Failing after 3m19s
Matterhorn10 Transform 
some other Transformations from pyctbGUI 
added method get_reading_mode for easier error handling in decoders 


## TODO: 

- proper error handling for all other decoders 
- proper documentation for all other decoders 
- refactoring all other decoders to store hard coded values in a Struct
ChipSpecification
2026-02-19 16:12:44 +01:00
mazzol_a 218f31ce60 Dev/multiple rois in aare (#263)
Build on RHEL8 / build (push) Successful in 2m23s
Build on RHEL9 / build (push) Successful in 2m32s
Run tests using data on local RHEL8 / build (push) Failing after 3m14s
Reading multiple ROI's for aare 

- read_frame, read_n etc throws for multiple ROIs
- new functions read_ROIs, read_n_ROIs 
-  read_roi_into (used for python bindings - to not copy) 

all these functions use get_frame or get_frame_into where one passes the
roi_index
## Refactoring:
- each roi keeps track of its subfiles that one has to open e.g.
subfiles can be opened several times
- refactored class DetectorGeometry - keep track of the updated module
geometries in new class ROIGeometry.
- ModuleGeometry updates based on ROI

## ROIGeometry: 
- stores number of modules overlapping with ROI and its indices
- size of ROI 

Note: only tested size of the resulting frames not the actual values

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
2026-02-18 10:57:56 +01:00
mazzol_a b77a576f72 Dev/automate tests using data (#267)
Build on RHEL8 / build (push) Successful in 2m13s
Build on RHEL9 / build (push) Successful in 2m37s
Run tests using data on local RHEL8 / build (push) Successful in 3m12s
- automatically run python tests 
- automatically run test using data files on local runner from gitea
- fixed some of the workflows

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2026-01-20 17:20:48 +01:00
mazzol_a fb95e518b4 Dev/interpolation documentation (#255)
Build on RHEL8 / build (push) Successful in 3m5s
Build on RHEL9 / build (push) Successful in 3m21s
- added transform_eta_values for easier debugging more control for the
user
- updated Documentation
2025-12-16 13:06:28 +01:00
mazzol_a e795310b16 fixed tests (#252)
Build on RHEL8 / build (push) Successful in 3m11s
Build on RHEL9 / build (push) Successful in 3m46s
- fixed failed tests 
- removed import of pickle, scipy 
- still requires boost_histogram, pytest_check

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2025-11-28 11:28:13 +01:00
mazzol_a 6f7cb4ae30 Merge branch 'main' into dev/license 2025-11-21 14:52:54 +01:00
mazzol_a 267ca87ab0 Dev/rosenblatttransform (#241)
- added rosenblatttransform 
- added 3x3 eta methods 
- interpolation can be used with various eta functions
- added documentation for interpolation, eta calculation 
- exposed full eta struct in python 
- disable ClusterFinder for 2x2 clusters 
- factory function for ClusterVector

---------

Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2025-11-21 14:48:46 +01:00
Erik Fröjdh 53aed8d8c6 added license 2025-11-20 09:01:28 +01:00
mazzol_a df7b9be5a5 added docstrings wrap struct into tuple
Build on RHEL8 / build (push) Failing after 3m42s
Build on RHEL9 / build (push) Failing after 3m41s
2025-10-23 19:16:33 +02:00
mazzol_a 01fa61cf47 index now returns enum type 2025-10-23 17:34:54 +02:00
mazzol_a 790dd63ba3 make max_sum_2x2 properly accessible from python 2025-10-23 15:00:52 +02:00
mazzol_a 516ef88d10 adresses SonarQube comments 2025-10-08 18:19:17 +02:00
mazzol_a 5329be816e removed times 2 in calculated photon center distance 2025-10-08 17:01:38 +02:00
mazzol_a 72a2604ca5 test for interpolation with simulated normal energy distribution 2025-10-08 16:35:52 +02:00
mazzol_a 474c35cc6b Merge branch 'main' into dev/reduce
Build on RHEL8 / build (push) Successful in 3m16s
Build on RHEL9 / build (push) Successful in 3m35s
2025-09-08 15:39:27 +02:00
mazzol_a 7926993bb2 reduction tests for python 2025-09-01 14:15:08 +02:00
Erik Fröjdh cb439efb48 added tests
Build on RHEL8 / build (push) Successful in 3m0s
Build on RHEL9 / build (push) Successful in 3m8s
2025-07-23 11:34:47 +02: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 6ec8fbee72 migrated tags for tests and added missing raw files (#206)
Build on RHEL8 / build (push) Successful in 2m57s
Build on RHEL9 / build (push) Successful in 2m59s
- No changes or evaluation of existing tests
- Tags for including tests that require data is changed to
**[.with-data]** and **--with-data** for C++ and python respectively
- Minor update to docs
- Added missing files to the test data repo
2025-06-26 17:11:20 +02:00
mazzol_a ff7312f45d replaced fmt with LOG 2025-06-24 16:24:25 +02:00
mazzol_a c92be4bca2 added eiger quad test
Build on RHEL8 / build (push) Successful in 2m53s
Build on RHEL9 / build (push) Successful in 3m0s
2025-06-24 11:29:25 +02:00
mazzol_a 9f8eee5d08 fixed python bindings - only read headers of modules that are in the roi
Build on RHEL8 / build (push) Successful in 2m51s
Build on RHEL9 / build (push) Successful in 2m53s
2025-06-16 11:07:00 +02:00
froejdh_e 9ecf4f4b44 merge
Build on RHEL9 / build (push) Successful in 2m22s
Build on RHEL8 / build (push) Successful in 2m30s
2025-05-22 11:23:57 +02:00
Erik Fröjdh 9e1b8731b0 RawSubFile support multi file access (#173)
This PR is a fix/improvement to a problem that Jonathan had. (#156) The
original implementation opened all subfiles at once witch works for
normal sized datasets but fails at a certain point (thousands of files).

- This solution uses RawSubFile to manage the different file indicies
and only opens the file we need
- Added logger.h from slsDetectorPackage for debug printing (in
production no messages should be visible)
2025-05-22 11:00:03 +02:00
froejdh_e 86d343f5f5 merged with developer
Build on RHEL9 / build (push) Successful in 2m9s
Build on RHEL8 / build (push) Failing after 2m32s
2025-04-23 11:45:04 +02:00
Erik Fröjdh fd0196f2fd Developer (#164)
Build on RHEL9 / build (push) Successful in 1m58s
Build on RHEL8 / build (push) Successful in 2m22s
- State before merging the new cluster vector API

---------

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: siebsi <sieb.patr@gmail.com>
2025-04-22 16:41:48 +02:00
froejdh_e 7c93632605 tests and fix 2025-04-14 16:38:25 +02:00
Erik Fröjdh a59e9656be Making RawSubFile usable from Python (#158)
Build on RHEL8 / build (push) Successful in 1m55s
Build on RHEL9 / build (push) Successful in 1m44s
- Removed a printout left from debugging
- return also header when reading
- added read_n 
- check for error in ifstream
2025-04-11 16:54:21 +02:00
froejdh_e 92f5421481 np test 2025-04-10 16:58:47 +02:00
Mazzoleni Alice Francesca 53a90e197e added additional tests
Build on RHEL9 / buildh (push) Successful in 1m52s
2025-04-10 10:41:58 +02:00
Mazzoleni Alice Francesca 76f050f69f solved merge conflict
Build on RHEL9 / buildh (push) Failing after 1m22s
2025-04-10 09:21:50 +02:00
Mazzoleni Alice Francesca a13affa4d3 changed template arguments added tests 2025-04-10 09:13:58 +02:00
Erik Fröjdh f16273a566 Adding support for Jungfrau .dat files (#152)
Build on RHEL9 / buildh (push) Successful in 1m48s
closes #150 

**Not addressed in this PR:** 

- pixels_per_frame, bytes_per_frame and tell should be made cost in
FileInterface
2025-04-08 15:31:04 +02:00
Mazzoleni Alice Francesca 017960d963 added push_back property
Build the package using cmake then documentation / build (ubuntu-latest, 3.12) (push) Failing after 37s
2025-04-07 13:41:14 +02:00
Mazzoleni Alice Francesca 9de84a7f87 added some python tests
Build the package using cmake then documentation / build (ubuntu-latest, 3.12) (push) Failing after 41s
2025-04-04 17:19:15 +02:00