modernized code to C++11 and newer.

This allows to analyze the code by external code analyzers. Since a lot is adopted,
the version is changed to 1.4.3
This commit is contained in:
2019-04-16 15:34:49 +02:00
parent e6d424e900
commit 795cd75b1e
136 changed files with 6870 additions and 7085 deletions

View File

@@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2011 by Andreas Suter *
* Copyright (C) 2011-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -31,7 +31,6 @@
#include <iostream>
#include <fstream>
using namespace std;
#include "PMPRgeHandler.h"
@@ -92,7 +91,7 @@ Double_t PMPRgeHandler::GetRgeValue(const Int_t index, const Double_t dist)
{
Double_t rgeVal = 0.0;
UInt_t distIdx = (UInt_t)(dist/(fRgeDataList[index].stoppingDistance[1]-fRgeDataList[index].stoppingDistance[0]));
UInt_t distIdx = static_cast<UInt_t>(dist/(fRgeDataList[index].stoppingDistance[1]-fRgeDataList[index].stoppingDistance[0]));
if (distIdx >= fRgeDataList[index].stoppingDistance.size()) {
rgeVal = 0.0;
@@ -140,7 +139,7 @@ Double_t PMPRgeHandler::GetRgeValue(const Double_t energy, const Double_t dist)
*/
Bool_t PMPRgeHandler::LoadRgeData(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList)
{
ifstream fin;
std::ifstream fin;
PMPRgeData data;
Int_t idx=0;
TString dataName, tstr;
@@ -150,11 +149,11 @@ Bool_t PMPRgeHandler::LoadRgeData(const PStringVector &rgeDataPathList, const PD
for (UInt_t i=0; i<rgeDataPathList.size(); i++) {
// open rge-file for reading
fin.open(rgeDataPathList[i].Data(), iostream::in);
fin.open(rgeDataPathList[i].Data(), std::iostream::in);
if (!fin.is_open()) {
cout << endl << "PMPRgeHandler::LoadRgeData **ERROR**";
cout << endl << " Could not open file " << rgeDataPathList[i].Data();
cout << endl;
std::cout << std::endl << "PMPRgeHandler::LoadRgeData **ERROR**";
std::cout << std::endl << " Could not open file " << rgeDataPathList[i].Data();
std::cout << std::endl;
return false;
}

View File

@@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2011 by Andreas Suter *
* Copyright (C) 2011-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2011 by Andreas Suter *
* Copyright (C) 2011-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -31,7 +31,6 @@
#include <iostream>
#include <fstream>
using namespace std;
#include "PMPStartupHandler.h"
@@ -61,7 +60,7 @@ PMPStartupHandler::PMPStartupHandler()
fStartupFileFound = true;
fStartupFilePath = TString(startup_path_name);
} else { // startup file is not found in the current directory
cout << endl << "PMPStartupHandler(): **WARNING** Couldn't find mag_proximity_startup.xml in the current directory, will try default one." << endl;
std::cout << std::endl << "PMPStartupHandler(): **WARNING** Couldn't find mag_proximity_startup.xml in the current directory, will try default one." << std::endl;
strncpy(startup_path_name, "/home/nemu/analysis/musrfit/src/external/MagProximity/mag_proximity_startup.xml", sizeof(startup_path_name));
if (StartupFileExists(startup_path_name)) {
fStartupFileFound = true;
@@ -160,9 +159,9 @@ void PMPStartupHandler::OnCharacters(const char *str)
tstr += ".rge";
fTrimSpDataPathList.push_back(tstr);
} else {
cout << endl << "PMPStartupHandler::OnCharacters: **ERROR** when finding energy:";
cout << endl << "\"" << str << "\" is not a floating point number, will ignore it and use the default value.";
cout << endl;
std::cout << std::endl << "PMPStartupHandler::OnCharacters: **ERROR** when finding energy:";
std::cout << std::endl << "\"" << str << "\" is not a floating point number, will ignore it and use the default value.";
std::cout << std::endl;
}
break;
default:
@@ -193,8 +192,8 @@ void PMPStartupHandler::OnComment(const char *str)
*/
void PMPStartupHandler::OnWarning(const char *str)
{
cout << endl << "PMPStartupHandler **WARNING** " << str;
cout << endl;
std::cout << std::endl << "PMPStartupHandler **WARNING** " << str;
std::cout << std::endl;
}
//--------------------------------------------------------------------------
@@ -207,8 +206,8 @@ void PMPStartupHandler::OnWarning(const char *str)
*/
void PMPStartupHandler::OnError(const char *str)
{
cout << endl << "PMPStartupHandler **ERROR** " << str;
cout << endl;
std::cout << std::endl << "PMPStartupHandler **ERROR** " << str;
std::cout << std::endl;
}
//--------------------------------------------------------------------------
@@ -221,8 +220,8 @@ void PMPStartupHandler::OnError(const char *str)
*/
void PMPStartupHandler::OnFatalError(const char *str)
{
cout << endl << "PMPStartupHandler **FATAL ERROR** " << str;
cout << endl;
std::cout << std::endl << "PMPStartupHandler **FATAL ERROR** " << str;
std::cout << std::endl;
}
//--------------------------------------------------------------------------
@@ -249,7 +248,7 @@ bool PMPStartupHandler::StartupFileExists(char *fln)
{
bool result = false;
ifstream ifile(fln);
std::ifstream ifile(fln);
if (ifile.fail()) {
result = false;

View File

@@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2011 by Andreas Suter *
* Copyright (C) 2011-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2011 by Andreas Suter *
* Copyright (C) 2011-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2011 by Andreas Suter *
* Copyright (C) 2011-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@@ -10,7 +10,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2011 by Andreas Suter *
* Copyright (C) 2011-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -33,7 +33,6 @@
#include <cmath>
#include <iostream>
using namespace std;
#include <TSAXParser.h>
#include <TMath.h>
@@ -70,8 +69,8 @@ PMagProximityFitterGlobal::PMagProximityFitterGlobal()
Int_t status = parseXmlFile(saxParser, startup_path_name);
// check for parse errors
if (status) { // error
cout << endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal: **WARNING** Reading/parsing mag_proximity_startup.xml failed.";
cout << endl;
std::cout << std::endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal: **WARNING** Reading/parsing mag_proximity_startup.xml failed.";
std::cout << std::endl;
fValid = false;
}
@@ -83,18 +82,18 @@ PMagProximityFitterGlobal::PMagProximityFitterGlobal()
// check if everything went fine with the startup handler
if (!fStartupHandler->IsValid()) {
cout << endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal **PANIC ERROR**";
cout << endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry.";
cout << endl;
std::cout << std::endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal **PANIC ERROR**";
std::cout << std::endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry.";
std::cout << std::endl;
fValid = false;
}
// load all the TRIM.SP rge-files
fRgeHandler = new PMPRgeHandler(fStartupHandler->GetTrimSpDataPathList(), fStartupHandler->GetTrimSpDataVectorList());
if (!fRgeHandler->IsValid()) {
cout << endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal **PANIC ERROR**";
cout << endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry.";
cout << endl;
std::cout << std::endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal **PANIC ERROR**";
std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry.";
std::cout << std::endl;
fValid = false;
}
}
@@ -113,11 +112,11 @@ PMagProximityFitterGlobal::~PMagProximityFitterGlobal()
if (fRgeHandler) {
delete fRgeHandler;
fRgeHandler = 0;
fRgeHandler = nullptr;
}
if (fStartupHandler) {
delete fStartupHandler;
fStartupHandler = 0;
fStartupHandler = nullptr;
}
}
@@ -198,19 +197,6 @@ Double_t PMagProximityFitterGlobal::GetMagneticField(const Double_t z) const
}
}
/*
static UInt_t count=0;
if (count < 10) {
count++;
if (idx == fField.size()-1)
cout << endl << "debug> z=" << z << ", idx=" << idx << ", fDz=" << fDz << ", fField[idx]=" << fField[idx] << ", result=" << result;
else
cout << endl << "debug> z=" << z << ", idx=" << idx << ", fDz=" << fDz << ", fField[idx]=" << fField[idx] << ", fField[idx+1]=" << fField[idx+1] << ", result=" << result;
cout << endl;
}
*/
// cout << endl << z << ", " << result;
return result;
}
@@ -228,7 +214,7 @@ PMagProximityFitter::PMagProximityFitter()
{
fValid = false;
fInvokedGlobal = false;
fMagProximityFitterGlobal = 0;
fMagProximityFitterGlobal = nullptr;
}
//--------------------------------------------------------------------------
@@ -241,7 +227,7 @@ PMagProximityFitter::~PMagProximityFitter()
{
if ((fMagProximityFitterGlobal != 0) && fInvokedGlobal) {
delete fMagProximityFitterGlobal;
fMagProximityFitterGlobal = 0;
fMagProximityFitterGlobal = nullptr;
}
}
@@ -256,7 +242,7 @@ PMagProximityFitter::~PMagProximityFitter()
* \param globalPart
* \param idx
*/
void PMagProximityFitter::SetGlobalPart(vector<void*> &globalPart, UInt_t idx)
void PMagProximityFitter::SetGlobalPart(std::vector<void*> &globalPart, UInt_t idx)
{
fIdxGlobal = static_cast<Int_t>(idx);
@@ -264,10 +250,10 @@ void PMagProximityFitter::SetGlobalPart(vector<void*> &globalPart, UInt_t idx)
fMagProximityFitterGlobal = new PMagProximityFitterGlobal();
if (fMagProximityFitterGlobal == 0) {
fValid = false;
cerr << endl << ">> PMagProximityFitter::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << endl;
std::cerr << std::endl << ">> PMagProximityFitter::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << std::endl;
} else if (!fMagProximityFitterGlobal->IsValid()) {
fValid = false;
cerr << endl << ">> PMagProximityFitter::SetGlobalPart(): **ERROR** initialization of global user function object failed, sorry ..." << endl;
std::cerr << std::endl << ">> PMagProximityFitter::SetGlobalPart(): **ERROR** initialization of global user function object failed, sorry ..." << std::endl;
} else {
fValid = true;
fInvokedGlobal = true;

View File

@@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2009 by Andreas Suter *
* Copyright (C) 2009-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -69,7 +69,7 @@ class PMagProximityFitter : public PUserFcnBase
virtual ~PMagProximityFitter();
virtual Bool_t NeedGlobalPart() const { return true; }
virtual void SetGlobalPart(vector<void*> &globalPart, UInt_t idx);
virtual void SetGlobalPart(std::vector<void*> &globalPart, UInt_t idx);
virtual Bool_t GlobalPartIsValid() const;
virtual Double_t operator()(Double_t t, const std::vector<Double_t> &param) const;

View File

@@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2011 by Andreas Suter *
* Copyright (C) 2011-2019 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *