switched PMsrHandler where possible to smart pointers.

This commit is contained in:
suter_a 2023-10-21 11:21:27 +02:00
parent 17bc497b30
commit 9ef5c5cac6
2 changed files with 7 additions and 20 deletions

View File

@ -66,8 +66,6 @@ PMsrHandler::PMsrHandler(const Char_t *fileName, PStartupOptions *startupOptions
fStatistic.fMinExpectedPerHisto.clear();
fStatistic.fNdfPerHisto.clear();
fFuncHandler = nullptr;
// check if the file name given is a path-file-name, and if yes, split it into path and file name.
if (fFileName.Contains("/")) {
Int_t idx = -1;
@ -99,11 +97,6 @@ PMsrHandler::~PMsrHandler()
fStatistic.fMinExpectedPerHisto.clear();
fStatistic.fNdfPerHisto.clear();
fParamInUse.clear();
if (fFuncHandler) {
delete fFuncHandler;
fFuncHandler = nullptr;
}
}
//--------------------------------------------------------------------------
@ -2941,11 +2934,7 @@ Bool_t PMsrHandler::HandleFunctionsEntry(PMsrLines &lines)
fFunctions = lines;
// create function handler
fFuncHandler = new PFunctionHandler(fFunctions);
if (fFuncHandler == nullptr) {
std::cerr << std::endl << ">> PMsrHandler::HandleFunctionsEntry: **ERROR** Couldn't invoke PFunctionHandler." << std::endl;
return false;
}
fFuncHandler = std::make_unique<PFunctionHandler>(fFunctions);
// do the parsing
if (!fFuncHandler->DoParse()) {
@ -3545,7 +3534,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
} else {
PUIntVector group;
str = iter->fLine;
PStringNumberList *rl = new PStringNumberList(str.Data());
std::unique_ptr<PStringNumberList> rl = std::make_unique<PStringNumberList>(str.Data());
std::string errorMsg("");
if (rl->Parse(errorMsg, true)) {
group = rl->GetList();
@ -3555,7 +3544,6 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
} else {
error = true;
}
delete rl;
group.clear();
}
}
@ -3570,7 +3558,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
} else {
PUIntVector group;
str = iter->fLine;
PStringNumberList *rl = new PStringNumberList(str.Data());
std::unique_ptr<PStringNumberList> rl = std::make_unique<PStringNumberList>(str.Data());
std::string errorMsg("");
if (rl->Parse(errorMsg, true)) {
group = rl->GetList();
@ -3580,7 +3568,6 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
} else {
error = true;
}
delete rl;
group.clear();
}
}
@ -4634,7 +4621,7 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
param.fLifeTimeCorrection = true;
} else if (line.Contains("runs", TString::kIgnoreCase)) { // handle plot runs
TComplex run;
PStringNumberList *rl;
std::unique_ptr<PStringNumberList> rl;
std::string errorMsg;
PUIntVector runList;
switch (param.fPlotType) {
@ -4648,7 +4635,7 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
case MSR_PLOT_ASYM_RRF:
case MSR_PLOT_NON_MUSR:
case MSR_PLOT_MU_MINUS:
rl = new PStringNumberList(line.Data());
rl = std::make_unique<PStringNumberList>(line.Data());
if (!rl->Parse(errorMsg, true)) {
std::cerr << std::endl << ">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo;
std::cerr << std::endl << ">> Error Message: " << errorMsg;
@ -4662,7 +4649,6 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
}
// clean up
runList.clear();
delete rl;
break;
default:
error = true;

View File

@ -31,6 +31,7 @@
#define _PMSRHANDLER_H_
#include <string>
#include <memory>
#include <TString.h>
#include <TComplex.h>
@ -134,7 +135,7 @@ class PMsrHandler
Int_t fMsrBlockCounter; ///< used to select the proper msr-block
PFunctionHandler *fFuncHandler; ///< needed to parse functions
std::unique_ptr<PFunctionHandler> fFuncHandler; ///< needed to parse functions
PIntVector fParamInUse; ///< array holding the information if a particular parameter is used at all, i.e. if the theory is using it (perhaps via maps or functions)