Commit Graph
234 Commits
Author SHA1 Message Date
suter_aandClaude Opus 4.8 4af5606efb PMsrHandler: escape '?' to avoid trigraph warning in date placeholder
The fallback date placeholder string contained the sequence '??-', which
the compiler interprets as a trigraph for '~' (-Wtrigraphs warning).
Escape the question marks (\?) so the literal string is unchanged while
the warning is silenced.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 09:32:50 +02:00
suter_aandClaude Opus 4.8 e3096036b5 PStringUtils::ToDouble: signal conversion errors like ToInt
ToDouble() had the same shortcoming as ToInt(): wrapping strtod() with a
nullptr endptr made a failed conversion indistinguishable from a
legitimate 0.0. Add an optional `bool *ok` out-parameter that reports
success. strtod() (with endptr + errno) is kept instead of
std::from_chars so the accepted input set stays identical to
TString::Atof() (leading whitespace skipped, leading '+' honoured,
trailing characters ignored); ok is set false on a non-numeric string or
an ERANGE overflow. The parameter defaults to nullptr, so existing call
sites keep compiling unchanged.

Convert the IsFloat-guarded ToDouble call sites in PMsrHandler to the
single-parse ToDouble(token, &ok) form (replacing the IsFloat() guard +
separate ToDouble() that parsed every token twice). All downstream
>=0 / <=0 / range checks are preserved, and push_back sites only append
on success so no spurious 0.0 is stored on error. Number-vs-keyword
discriminators (pos.error/boundary "none", rrf_phase/fourier-phase parX)
are restructured so the keyword branch is taken when ok is false.

As a side effect this fixes a latent gap in the GLOBAL rrf_freq handler,
where a non-numeric frequency previously slipped through with a stale
value instead of raising an error.

The IsFloat-guarded ToInt fit-range offsets (fgb/lgb) are intentionally
left untouched, as there the guard type differs from the conversion.

All 85 integration tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 09:31:09 +02:00
suter_aandClaude Opus 4.8 3f5765fe46 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-07-23 09:30:23 +02:00
suter_aandClaude Opus 4.8 a6c887e059 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-07-23 08:13:25 +02:00
suter_aandClaude Opus 4.8 57fa059fed PStringUtils::ToDouble: signal conversion errors like ToInt
ToDouble() had the same shortcoming as ToInt(): wrapping strtod() with a
nullptr endptr made a failed conversion indistinguishable from a
legitimate 0.0. Add an optional `bool *ok` out-parameter that reports
success. strtod() (with endptr + errno) is kept instead of
std::from_chars so the accepted input set stays identical to
TString::Atof() (leading whitespace skipped, leading '+' honoured,
trailing characters ignored); ok is set false on a non-numeric string or
an ERANGE overflow. The parameter defaults to nullptr, so existing call
sites keep compiling unchanged.

Convert the IsFloat-guarded ToDouble call sites in PMsrHandler to the
single-parse ToDouble(token, &ok) form (replacing the IsFloat() guard +
separate ToDouble() that parsed every token twice). All downstream
>=0 / <=0 / range checks are preserved, and push_back sites only append
on success so no spurious 0.0 is stored on error. Number-vs-keyword
discriminators (pos.error/boundary "none", rrf_phase/fourier-phase parX)
are restructured so the keyword branch is taken when ok is false.

As a side effect this fixes a latent gap in the GLOBAL rrf_freq handler,
where a non-numeric frequency previously slipped through with a stale
value instead of raising an error.

The IsFloat-guarded ToInt fit-range offsets (fgb/lgb) are intentionally
left untouched, as there the guard type differs from the conversion.

All 85 integration tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 07:46:59 +02:00
suter_aandClaude Opus 4.8 a22b9cb5c2 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-07-23 07:46:39 +02:00
suter_aandClaude Opus 4.8 cc652aed00 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-07-23 07:46:11 +02:00
suter_a 8cb7da2e2a adopted to new hdf4/5 approach of NeXus. 2026-03-02 13:46:47 +01:00
suter_a 9a48487220 updated the copyright info. 2026-02-13 13:59:49 +01:00
suter_a b3ee2000ed perform Fourier phase checks only if a Fourier block is present and not set to power spectra. 2025-12-22 16:10:56 +01:00
suter_a 7762f69c24 improve doxygen documentation of PMsrHandler.* 2025-11-26 17:43:48 +01:00
suter_a b692b78cac added a feature which brings up a error message box, if there was any issue with the msr-file when starting musrview from musredit. 2025-06-29 14:37:09 +02:00
suter_a 4da145d674 (i) make most internal checking functions in the msr handler private. (ii) improved checking of real Fourier for consistency. 2025-06-23 16:06:32 +02:00
suter_a 44821cb8cd updated the copyright info. 2025-01-30 12:00:49 +01:00
suter_a 86b5080dee proper handling of comments and descriptions in the RUN block. 2025-01-29 08:17:51 +01:00
suter_a 8dc871e082 path-run-name in RUN block of the msr-file can now handle spaces. 2025-01-20 16:10:25 +01:00
suter_a 17339e191d updated copyright info. 2024-02-07 15:29:08 +01:00
suter_a 9ef5c5cac6 switched PMsrHandler where possible to smart pointers. 2023-10-25 10:03:18 +02:00
suter_a 17bc497b30 remove one check for Fourier only. 2023-10-25 10:01:41 +02:00
suter_a f42306e42b fix of an old copy/paste error! 2023-01-10 16:18:44 +01:00
suter_a a356534e6a updated the copyright info. 2023-01-05 11:04:42 +01:00
suter_a e32aa61643 replaced sprintf -> snprintf throughout. 2022-11-25 10:16:20 +01:00
suter_a d0923d75b9 fixed bug in msr2data global+ according to issue #33 reported on bitbucket. 2022-08-09 08:21:53 +02:00
suter_a 0e68888948 improved formated string handling to make compilers happy. 2022-04-12 15:13:19 +02:00
suter_a 083e715fc4 remove obsolete test. 2021-06-17 08:24:39 +02:00
suter_a b3cd31199e Fix out-of-bound bug pointed out by Ryan McFadden. 2021-04-13 07:58:28 +02:00
suter_a 865efb506a make sure that group has indeed any elements. 2021-04-13 07:58:03 +02:00
suter_a a7b540cfdb update of the copyright info. 2021-03-29 08:30:43 +02:00
suter_a f9407ef975 fixed double newline with alpha and beta, accidentally introduced. 2020-05-26 19:55:15 +02:00
suter_a d2caf435fb allow alpha, beta in the RUN block being expressed via a function. 2020-05-26 07:17:02 +02:00
suter_a b6dba8965b update of the copyright info. 2020-04-30 17:46:10 +02:00
suter_a d5d6140e42 fixed a bug in the global+ option of msr2data if a global section is present. 2019-11-08 12:29:00 +01:00
suter_a 8b416b45e0 merged root6 2019-09-11 12:12:13 +02:00
salman 75958d0bce Fix a bug to allow passing lifetimecorrection flag into global fit files generated by msr2data. 2019-08-30 11:27:41 +02:00
suter_a cc1c914d93 Merge branch 'beta-NMR' into root6 2019-05-15 09:00:47 +02:00
suter_a 5953786611 properly check the number of t0 parameters in the msr-file. 2019-05-11 13:19:19 +02:00
suter_a 50314c56e3 properly check the number of t0 parameters in the msr-file. 2019-05-11 13:15:43 +02:00
salman be8c809c6a Follow Andreas' code modernization for BNMR code and cleanup 2019-04-26 10:58:17 +02:00
salman 3ae49b6c23 Resolve merge conflicts manually 2019-04-26 09:25:48 +02:00
salman 22141ae98d Deal with missing alpha line for beta-NMR. 2019-04-26 09:18:24 +02:00
Zaher Salmanandsalman bcd1c98ad2 More work towards implementation of beta-NMR asymmetry calculation 2019-04-26 09:11:00 +02:00
Zaher Salmanandsalman 4ad524216f Start branch to develop full featured beta-NMR support 2019-04-26 09:06:28 +02:00
suter_a c64c74dbf8 modernized code to C++11 and newer.
This allows to analyze the code by external code analyzers. Since a lot is adopted,
the version is changed to 1.4.3

Conflicts:
	src/classes/PFitter.cpp
	src/classes/PFourier.cpp
	src/classes/PMsrHandler.cpp
	src/classes/PMusrCanvas.cpp
	src/classes/PRunAsymmetry.cpp
	src/classes/PRunAsymmetryRRF.cpp
	src/classes/PRunListCollection.cpp
	src/classes/PRunSingleHisto.cpp
	src/classes/PRunSingleHistoRRF.cpp
	src/classes/PStartupHandler.cpp
	src/include/PFourier.h
	src/include/PRunListCollection.h
	src/musrFT.cpp
2019-04-24 17:44:58 +02:00
suter_a 795cd75b1e modernized code to C++11 and newer.
This allows to analyze the code by external code analyzers. Since a lot is adopted,
the version is changed to 1.4.3
2019-04-16 15:34:49 +02:00
suter_a 94950cb755 ifgk and ifll CUDA/OpenCL-GPU accessible. 2019-01-22 14:05:09 +01:00
Zaher Salman d1cf374354 Merged master into beta-NMR 2018-12-18 10:01:28 +01:00
suter_a a5748f0359 Fourier relative phase: bug fix
The reference phase for real Fourier was accidentely counted twice.
2018-11-29 11:00:24 +01:00
suter_a 7361dc6f70 Fourier relative phase: bug fix
The reference phase for real Fourier was accidentely counted twice.
2018-11-29 10:56:37 +01:00
suter_a 1e8b79ec1d set reference phase index in the case of a phase vector 2018-11-13 09:20:14 +01:00
suter_a 0d917564c5 allow to define the phase parameter lists in the Fourier block with a reference phase parameter. This means all the other phase parameters are then relative to this reference phase parameter. This is often used when analysing LEM data. 2018-11-13 09:19:48 +01:00