PRunSingleHistoRRF: replace TObjArray/TObjString with PStringUtils
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -39,13 +39,14 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <TString.h>
|
||||
#include <TObjArray.h>
|
||||
#include <TObjString.h>
|
||||
#include <TH1F.h>
|
||||
|
||||
#include "PMusr.h"
|
||||
#include "PStringUtils.h"
|
||||
#include "PFourier.h"
|
||||
#include "PRunSingleHistoRRF.h"
|
||||
|
||||
@@ -528,18 +529,15 @@ UInt_t PRunSingleHistoRRF::GetNoOfFitBins()
|
||||
*/
|
||||
void PRunSingleHistoRRF::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
|
||||
@@ -550,8 +548,7 @@ void PRunSingleHistoRRF::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
|
||||
@@ -560,16 +557,15 @@ void PRunSingleHistoRRF::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 << ">> PRunSingleHistoRRF::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
|
||||
@@ -580,8 +576,7 @@ void PRunSingleHistoRRF::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
|
||||
@@ -595,11 +590,6 @@ void PRunSingleHistoRRF::SetFitRangeBin(const TString fitRange)
|
||||
std::cerr << std::endl << ">> PRunSingleHistoRRF::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
|
||||
std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl;
|
||||
}
|
||||
|
||||
// clean up
|
||||
if (tok) {
|
||||
delete tok;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user