From 850fb6bbc6810c272df2c012be80a83e39c82d6b Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 6 Jun 2026 16:26:00 +0200 Subject: [PATCH] PRunAsymmetry: replace TObjArray/TObjString with PStringUtils Co-Authored-By: Claude Opus 4.8 --- src/classes/PRunAsymmetry.cpp | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index cdafa3d62..6c3b2038d 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -38,12 +38,13 @@ #include #include +#include +#include #include -#include -#include #include "PMusr.h" +#include "PStringUtils.h" #include "PRunAsymmetry.h" //-------------------------------------------------------------------------- @@ -404,18 +405,15 @@ UInt_t PRunAsymmetry::GetNoOfFitBins() */ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) { - TObjArray *tok = nullptr; - TObjString *ostr = nullptr; TString str; Ssiz_t idx = -1; Int_t offset = 0; - tok = fitRange.Tokenize(" \t"); + std::vector tok = PStringUtils::Split(fitRange.Data(), " \t"); - if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 + if (tok.size() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 // handle fgb+n0 entry - ostr = dynamic_cast(tok->At(1)); - str = ostr->GetString(); + str = tok[1]; // check if there is an offset present idx = str.First("+"); if (idx != -1) { // offset present @@ -426,8 +424,7 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = dynamic_cast(tok->At(2)); - str = ostr->GetString(); + str = tok[2]; // check if there is an offset present idx = str.First("-"); if (idx != -1) { // offset present @@ -436,16 +433,15 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) offset = str.Atoi(); } fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; - } else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) { // structure FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]] - Int_t pos = 2*(fRunNo+1)-1; + } else if ((tok.size() > 3) && (tok.size() % 2 == 1)) { // structure FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]] + UInt_t pos = 2*(fRunNo+1)-1; - if (pos + 1 >= tok->GetEntries()) { + if (pos + 1 >= tok.size()) { std::cerr << std::endl << ">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } else { // handle fgb+n0 entry - ostr = static_cast(tok->At(pos)); - str = ostr->GetString(); + str = tok[pos]; // check if there is an offset present idx = str.First("+"); if (idx != -1) { // offset present @@ -456,8 +452,7 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = static_cast(tok->At(pos+1)); - str = ostr->GetString(); + str = tok[pos+1]; // check if there is an offset present idx = str.First("-"); if (idx != -1) { // offset present @@ -471,11 +466,6 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) std::cerr << std::endl << ">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } - - // clean up - if (tok) { - delete tok; - } } //--------------------------------------------------------------------------