PRunAsymmetry: replace TObjArray/TObjString with PStringUtils
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -38,12 +38,13 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <TString.h>
|
||||
#include <TObjArray.h>
|
||||
#include <TObjString.h>
|
||||
|
||||
#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<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
|
||||
@@ -426,8 +424,7 @@ void PRunAsymmetry::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
|
||||
@@ -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<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
|
||||
@@ -456,8 +452,7 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange)
|
||||
fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
|
||||
|
||||
// handle lgb-n1 entry
|
||||
ostr = static_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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user