more work to get rid of raw pointers.

This commit is contained in:
2023-10-17 16:35:54 +02:00
parent 75bb526ca3
commit f9d0d7f18f
8 changed files with 58 additions and 142 deletions

View File

@@ -290,14 +290,14 @@ void musrfit_write_root(TFile &f, TString fln, PRunData *data, int runCounter)
snprintf(name, sizeof(name),"c%d", runCounter);
std::unique_ptr<TCanvas> c = std::unique_ptr<TCanvas>(new TCanvas(name, title.Data(), 10, 10, 800, 600));
std::unique_ptr<TCanvas> c = std::make_unique<TCanvas>(name, title.Data(), 10, 10, 800, 600);
// create histos
Double_t diff = data->GetDataTimeStep();
Double_t start = -diff/2.0;
Double_t end = data->GetDataTimeStep()*data->GetValue()->size();
std::unique_ptr<TH1F> hdata = std::unique_ptr<TH1F>(new TH1F("hdata", "run data", data->GetValue()->size(), start, end));
std::unique_ptr<TH1F> htheo = std::unique_ptr<TH1F>(new TH1F("htheo", "run theory", data->GetValue()->size(), start, end));
std::unique_ptr<TH1F> hdata = std::make_unique<TH1F>("hdata", "run data", data->GetValue()->size(), start, end);
std::unique_ptr<TH1F> htheo = std::make_unique<TH1F>("htheo", "run theory", data->GetValue()->size(), start, end);
// fill data
for (unsigned int i=0; i<data->GetValue()->size(); i++) {
@@ -618,8 +618,8 @@ int main(int argc, char *argv[])
// read startup file
char startup_path_name[128];
std::unique_ptr<TSAXParser> saxParser(new TSAXParser());
std::unique_ptr<PStartupHandler> startupHandler(new PStartupHandler());
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<PStartupHandler> startupHandler = std::make_unique<PStartupHandler>();
if (!startupHandler->StartupFileFound()) {
std::cerr << std::endl << ">> musrfit **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
std::cerr << std::endl;
@@ -645,9 +645,9 @@ int main(int argc, char *argv[])
// read msr-file
std::unique_ptr<PMsrHandler> msrHandler;
if (startupHandler)
msrHandler = std::unique_ptr<PMsrHandler>(new PMsrHandler(filename, &startup_options));
msrHandler = std::make_unique<PMsrHandler>(filename, &startup_options);
else
msrHandler = std::unique_ptr<PMsrHandler>(new PMsrHandler(filename));
msrHandler = std::make_unique<PMsrHandler>(filename);
status = msrHandler->ReadMsrFile();
if (status != PMUSR_SUCCESS) {
switch (status) {
@@ -667,9 +667,9 @@ int main(int argc, char *argv[])
// read all the necessary runs (raw data)
std::unique_ptr<PRunDataHandler> dataHandler;
if (startupHandler)
dataHandler = std::unique_ptr<PRunDataHandler>(new PRunDataHandler(msrHandler.get(), startupHandler->GetDataPathList()));
dataHandler = std::make_unique<PRunDataHandler>(msrHandler.get(), startupHandler->GetDataPathList());
else
dataHandler = std::unique_ptr<PRunDataHandler>(new PRunDataHandler(msrHandler.get()));
dataHandler = std::make_unique<PRunDataHandler>(msrHandler.get());
dataHandler->ReadData();
@@ -690,7 +690,7 @@ int main(int argc, char *argv[])
std::unique_ptr<PRunListCollection> runListCollection;
if (success) {
// feed all the necessary histogramms for the fit
runListCollection = std::unique_ptr<PRunListCollection>(new PRunListCollection(msrHandler.get(), dataHandler.get()));
runListCollection = std::make_unique<PRunListCollection>(msrHandler.get(), dataHandler.get());
for (unsigned int i=0; i < msrHandler->GetMsrRunList()->size(); i++) {
success = runListCollection->Add(i, kFit);
if (!success) {
@@ -705,7 +705,7 @@ int main(int argc, char *argv[])
std::unique_ptr<TThread> th;
if (timeout_enabled) {
pid_t musrfit_pid = getpid();
th = std::unique_ptr<TThread>(new TThread(musrfit_timeout, (void*)&musrfit_pid));
th = std::make_unique<TThread>(musrfit_timeout, (void*)&musrfit_pid);
if (th) {
th->Run();
}
@@ -714,7 +714,7 @@ int main(int argc, char *argv[])
// do fitting
std::unique_ptr<PFitter> fitter;
if (success) {
fitter = std::unique_ptr<PFitter>(new PFitter(msrHandler.get(), runListCollection.get(), chisq_only));
fitter = std::make_unique<PFitter>(msrHandler.get(), runListCollection.get(), chisq_only);
if (fitter->IsValid()) {
fitter->DoFit();
if (!fitter->IsScanOnly())