PRunMuMinus: replace TObjArray/TObjString with PStringUtils

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-06 16:32:08 +02:00
parent 5939db2722
commit 6a93932f90
+12 -22
View File
@@ -36,11 +36,12 @@
#endif
#include <iostream>
#include <string>
#include <vector>
#include <TString.h>
#include <TObjArray.h>
#include <TObjString.h>
#include "PStringUtils.h"
#include "PRunMuMinus.h"
//--------------------------------------------------------------------------
@@ -448,18 +449,15 @@ UInt_t PRunMuMinus::GetNoOfFitBins()
*/
void PRunMuMinus::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<std::string> 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<TObjString*>(tok->At(1));
str = ostr->GetString();
str = tok[1];
// check if there is an offset present
idx = str.First("+");
if (idx != -1) { // offset present
@@ -470,8 +468,7 @@ void PRunMuMinus::SetFitRangeBin(const TString fitRange)
fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
// handle lgb-n1 entry
ostr = dynamic_cast<TObjString*>(tok->At(2));
str = ostr->GetString();
str = tok[2];
// check if there is an offset present
idx = str.First("-");
if (idx != -1) { // offset present
@@ -480,16 +477,15 @@ void PRunMuMinus::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 << ">> PRunMuMinus::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl;
} else {
// handle fgb+n0 entry
ostr = dynamic_cast<TObjString*>(tok->At(pos));
str = ostr->GetString();
str = tok[pos];
// check if there is an offset present
idx = str.First("+");
if (idx != -1) { // offset present
@@ -500,8 +496,7 @@ void PRunMuMinus::SetFitRangeBin(const TString fitRange)
fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
// handle lgb-n1 entry
ostr = dynamic_cast<TObjString*>(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
@@ -515,11 +510,6 @@ void PRunMuMinus::SetFitRangeBin(const TString fitRange)
std::cerr << std::endl << ">> PRunMuMinus::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl;
}
// clean up
if (tok) {
delete tok;
}
}
//--------------------------------------------------------------------------