Commit Graph

2265 Commits

Author SHA1 Message Date
suter_a 4319b4ad69 PStringUtils::ToInt: signal conversion errors via from_chars
ToInt() previously wrapped strtol() with a nullptr endptr, so a failed
conversion was indistinguishable from a legitimate 0 (matching the old
TString::Atoi() behaviour). Switch the implementation to std::from_chars
and add an optional `bool *ok` out-parameter that reports success: it is
set to false on a non-numeric string or an out-of-range value, true
otherwise. Leading whitespace is skipped and trailing characters are
ignored, preserving the Atoi-like prefix semantics. The parameter
defaults to nullptr, so existing call sites keep compiling unchanged.

Convert the parse-validation call sites in PMsrHandler to the single
-parse ToInt(token, &ok) form, replacing the IsInt() guard + separate
ToInt() (which parsed every token twice). All downstream >0 / >=0 /
range / enum checks are preserved.

Left untouched the call sites where IsInt() acts as a structural
discriminator rather than a numeric validator (write path, xy-data
index-vs-label, fParamInUse usage scans) and the IsFloat-guarded ToInt
offsets, where switching to ToInt(&ok) would change parsing semantics.

All 85 integration tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 11:54:33 +02:00
suter_a b072a481ba PMsrHandler: replace ROOT tokenizer machinery with C++17 PStringUtils
Reduce the ROOT footprint of the MSR parser by removing the pervasive
TString::Tokenize / TObjArray / TObjString / dynamic_cast pattern (28
tokenize sites, 14 TObjArray, 106 TObjString) used to split lines into
tokens, together with the manual `delete tokens` cleanup.

Add a new dependency-free C++17 utility class PStringUtils (Split, IsInt,
IsFloat, ToInt, ToDouble, IsEqualNoCase, ContainsNoCase, BeginsWithNoCase)
that replicates the relevant TString semantics exactly, so it can be reused
elsewhere in the suite. IsInt/IsFloat tolerate surrounding whitespace to
match TString::IsDigit/IsFloat (needed for tokens split on ',' / ';' only).

The public API and the PMusr.h data structures keep TString unchanged; only
the internal tokenizing logic is rewritten. Net -451 lines in
PMsrHandler.cpp. All 85 integration tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 11:15:02 +02:00
suter_a b05ed4de05 mupp: fix crash in PmuppGui::getValues plotting a variable.
getValues()/getErrors() return a std::vector by value, but the QVector was
built from begin() of one call and end() of a second call -> iterators into
two distinct temporaries -> UB and a segfault in getValues(). Bind the result
to a single local before taking begin()/end(). Same in getPosErr/getNegErr.

This surfaced reliably when plotting a <python>-generated variable added via
the GUI (the script path was unaffected as it reads getValues() only once).

Also fix check() to validate the actually selected collections
(GetCollection(idx[i]) instead of GetCollection(i)).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 15:52:02 +02:00
suter_a 3abdace782 mupp: expose all collections inside a <python> block (coll[]/collErr[]).
A <python> variable block previously saw only the parameters of the single
collection the variable is linked to via 'col', injected as bare names plus
par[]/parErr[]. To compute variables for several collections one therefore
needed a separate block per collection.

Now every loaded collection is additionally injected as coll[]/collErr[]
dictionaries, addressable both by integer index (matching 'col <idx>' /
'select <idx>') and by collection name; index and name keys reference the same
per-parameter dict. A single block placed after all 'var = python' declarations
can thus compute - and combine - variables for any collection, e.g.
coll[0]['Sigma'] or coll['NAME.db']['Sigma'].

The bound-collection bare names / par[] / parErr[] are unchanged, so existing
scripts and GUI variables keep working. The collection list is threaded through
PmuppScript::var_cmd and the GUI add()/check() paths into PVarHandler.

Verified: a one-block script using both an index key and a name key reproduces
the numeric output of the equivalent two-block script bit-for-bit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 13:55:38 +02:00
suter_a 9c09d0bd1a mupp: pair each python variable with its own <python> block.
getPythonBlock() always returned the first <python> ... </python>
entry of the script, so when several 'var X = python' declarations
each had their own block, every declaration after the first one
re-ran the first block and the read-back of the requested variable
failed. Thread the script index through var_cmd into getPythonBlock,
which now scans from that position onwards. Each declaration is
paired with the next block in script order.
2026-05-27 13:03:17 +02:00
suter_a 6a6de42308 mupp: add x-axis error bar support to all plot outputs.
Previously only y-errors were rendered. The IPC data file format now
includes x-errors per point (x, xPosErr, xNegErr, y, yPosErr, yNegErr,
...). Both the live canvas (PMuppCanvas) and the ROOT macro exports
(GUI and script path) propagate x-errors to TGraphAsymmErrors;
x-errors default to 0.0 when the parameter carries none.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-26 20:43:05 +02:00
suter_a 9d859950d2 mupp: optional Python3 interface for variables via ROOT TPython.
Variables can now be computed by an embedded Python3 interpreter in addition
to the Boost.Spirit X3 expression engine. A <python> ... </python> block
receives all collection parameters as per-run lists (bare names, plus
par[]/parErr[] dictionaries as a fallback for names that are not valid Python
identifiers such as 'lambda') and must assign <name> and <name>Err; errors are
user supplied. Works both in the GUI variable dialog and in scripts.

The feature is optional and only enabled when ROOT is built with TPython
(CMake target ROOT::ROOTTPython); otherwise it compiles out. See MUPP_PY.README
for ROOT configure requirements and usage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 19:06:07 +02:00
suter_a 64f4e1d2dd mupp: RUN is now treated as a variable.
Build and Deploy Documentation / build-and-deploy (push) Successful in 31s
2026-05-20 12:45:13 +02:00
suter_a bedbe2584b proper handling in dump_header of TDirectory in combination with the summary option.
Build and Deploy Documentation / build-and-deploy (push) Successful in 31s
2026-04-30 11:07:20 +02:00
suter_a 92143b1c2e fix wrong install path for macOS Qt-based applications.
Build and Deploy Documentation / build-and-deploy (push) Successful in 29s
2026-04-17 14:20:43 +02:00
suter_a a735f92195 more improvements on the cmake build system. 2026-04-17 09:15:07 +02:00
suter_a 53ec95db6e work on cleaner cmake. 2026-04-15 20:29:55 +02:00
suter_a dbbaf554b2 MusrRoot: XML-schema evaluation files are moved to https://doi.org/10.5281/zenodo.19593555. to have a DOI and not be depend on a shaky URL
Build and Deploy Documentation / build-and-deploy (push) Successful in 29s
2026-04-15 14:34:32 +02:00
krieger_j 5304f276d8 adds installation of musredit as a unix app 2026-03-13 15:20:31 +01:00
suter_a 9083561e20 added PyScripts/nexus_muon_validator.py to nexus.
Build and Deploy Documentation / build-and-deploy (push) Successful in 21s
2026-03-07 14:50:57 +01:00
suter_a 14d2648fc4 remove obsolate test/nexus
Build and Deploy Documentation / build-and-deploy (push) Successful in 29s
2026-03-07 13:38:53 +01:00
suter_a f91bc12709 suppress warning missing deadtime correction if not relevant.
Build and Deploy Documentation / build-and-deploy (push) Successful in 29s
2026-03-03 08:52:19 +01:00
suter_a 3174b320b2 fix linker errors: add HDF5 C++ lib and FFTW3 include paths
Build and Deploy Documentation / build-and-deploy (push) Successful in 22s
- Add ${HDF5_LIBRARIES} to PMusr link dependencies so HDF5 C++ symbols
  (H5::DataType, H5::PredType, etc.) used in PRunDataHandler.cpp resolve.
- Add ${FFTW3_INCLUDE} to musrRootValidation and write_musrRoot_runHeader
  include paths; both pull in PMusr.h which transitively includes fftw3.h.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 11:21:01 +01:00
suter_a c062e0f4e9 add musrfitConfig.cmake, etc. for musrfit.
Build and Deploy Documentation / build-and-deploy (push) Successful in 30s
2026-03-01 09:35:34 +01:00
suter_a a005e5750f fixed an index by one offset issue.
Build and Deploy Documentation / build-and-deploy (push) Successful in 21s
2026-02-23 13:02:46 +01:00
suter_a b29c7247e7 make sure that the requested pointer is not a nullptr.
Build and Deploy Documentation / build-and-deploy (push) Successful in 21s
2026-02-23 12:52:26 +01:00
suter_a 92008a4e49 fix Boost_INCLUDE_DIR -> Boost_INCLUDE_DIRS
Build and Deploy Documentation / build-and-deploy (push) Successful in 21s
2026-02-21 17:38:11 +01:00
suter_a 901fda9298 adopted ChangeLog. Fixed a minor issue in PTextEdit. Adopted ctests for the new NeXus handling.
Build and Deploy Documentation / build-and-deploy (push) Successful in 29s
2026-02-21 15:32:03 +01:00
suter_a 7d5aaf6429 increased the version number of musrfit and libPMusr. 2026-02-21 07:45:25 +01:00
suter_a 79b05cced7 adopted the PNeXus lib such that the class naming scheme is self-consistent. 2026-02-21 07:44:20 +01:00
suter_a 08350a2fde warning that deadtime correction estimate is not yet implemented. I am not even sure this would be a good feature. 2026-02-21 07:19:42 +01:00
suter_a 22b1ad7f2f full implementation of the deadtime correction from file for PRunAsymmetryRRF. 2026-02-21 07:15:44 +01:00
suter_a bb8bdafddd full implementation of the deadtime correction from file. 2026-02-21 07:10:48 +01:00
suter_a d5e305411f added a warning if deadtime correction cannot be carried out (missing parameters, etc.) 2026-02-21 07:09:36 +01:00
suter_a 50187b0c65 add DeadTimeCorrection to PRunAsymmetry - no ADDRUN handling yet. 2026-02-20 19:47:21 +01:00
suter_a d7908573b8 PRunSingleHistoRRF: add DeadTimeCorrection, and improve ADDRUN readability 2026-02-20 19:01:33 +01:00
suter_a 9aae350c13 move DeadTimeCorrection to PRunBase. Make ADDRUN part in PrepareData more readable. 2026-02-20 18:17:05 +01:00
suter_a f00f188f0b filter out '\r' and '\n' from command string (macOS issue). 2026-02-13 12:56:50 +01:00
suter_a 4136806847 better hdf4/5 include handling. 2026-02-11 16:05:02 +01:00
suter_a 6a41458310 start working on the deadtime correction. 2026-02-08 15:34:22 +01:00
suter_a d70fd34345 improved NeXus docu. 2026-02-08 09:11:36 +01:00
suter_a 3858cc723a improved docu for HDF4/5. 2026-02-07 21:43:34 +01:00
suter_a a6f5b956bf adopt HDF4 support for proper hierarchical writing of the data. 2026-02-07 21:26:35 +01:00
suter_a 86ecfc84af fixed a copy/paste error. 2026-02-07 21:24:14 +01:00
suter_a 8cb4fc7221 clean up HDF4 in PNeXus. First implementation for HDF4 IDF1/2 write. Compiles, but still some issues. 2026-02-07 20:54:09 +01:00
suter_a 95d087164d first full mandatory HDF5 IDF V2 writer. 2026-02-07 20:17:23 +01:00
suter_a 8f3ad0c61d PNeXus now handles std::vector<> attributes new correctly. HDF4/5 now is using int. 2026-02-07 20:00:27 +01:00
suter_a 49d42c93ba more work on HDF5 IDF V2. 2026-02-07 19:34:26 +01:00
suter_a df379b834e first full version for HDF5 IDF V1 write. 2026-02-07 17:25:52 +01:00
suter_a 3bb004ea2d more work on the NeXus write routines. 2026-02-07 11:31:11 +01:00
suter_a fc478d27c7 make sure that the config.h is accessible for the PMusr lib. 2026-02-07 11:29:48 +01:00
suter_a c690965025 add a function in the NeXus lib which gives the time in ISO8601. 2026-02-07 11:28:38 +01:00
suter_a 300c9200df start implementing the NeXus write routines, needed by any2many. 2026-02-07 08:05:42 +01:00
suter_a 4dcef1a835 add HDF4/HDF5 library version information, needed for writing. 2026-02-07 08:05:09 +01:00
suter_a 4519a0b76e add more complete dump info for NeXus. 2026-02-06 18:08:37 +01:00