diff --git a/src/external/libFitPofB/classes/TLondon1D.cpp b/src/external/libFitPofB/classes/TLondon1D.cpp index cc0e4a34..24ba1dad 100644 --- a/src/external/libFitPofB/classes/TLondon1D.cpp +++ b/src/external/libFitPofB/classes/TLondon1D.cpp @@ -30,6 +30,7 @@ #include "TLondon1D.h" #include +#include #include #include @@ -55,12 +56,6 @@ TLondon1DHS::~TLondon1DHS() { fParForBofZ.clear(); fParForPofB.clear(); fParForPofT.clear(); - delete fImpProfile; - fImpProfile = 0; - delete fPofB; - fPofB = 0; - delete fPofT; - fPofT = 0; } TLondon1D1L::~TLondon1D1L() { @@ -68,12 +63,6 @@ TLondon1D1L::~TLondon1D1L() { fParForBofZ.clear(); fParForPofB.clear(); fParForPofT.clear(); - delete fImpProfile; - fImpProfile = 0; - delete fPofB; - fPofB = 0; - delete fPofT; - fPofT = 0; } TLondon1D2L::~TLondon1D2L() { @@ -81,12 +70,6 @@ TLondon1D2L::~TLondon1D2L() { fParForBofZ.clear(); fParForPofB.clear(); fParForPofT.clear(); - delete fImpProfile; - fImpProfile = 0; - delete fPofB; - fPofB = 0; - delete fPofT; - fPofT = 0; } TProximity1D1LHS::~TProximity1D1LHS() { @@ -94,12 +77,6 @@ TProximity1D1LHS::~TProximity1D1LHS() { fParForBofZ.clear(); fParForPofB.clear(); fParForPofT.clear(); - delete fImpProfile; - fImpProfile = 0; - delete fPofB; - fPofB = 0; - delete fPofT; - fPofT = 0; } TLondon1D3L::~TLondon1D3L() { @@ -107,12 +84,6 @@ TLondon1D3L::~TLondon1D3L() { fParForBofZ.clear(); fParForPofB.clear(); fParForPofT.clear(); - delete fImpProfile; - fImpProfile = 0; - delete fPofB; - fPofB = 0; - delete fPofT; - fPofT = 0; } TLondon1D3LS::~TLondon1D3LS() { @@ -120,12 +91,6 @@ TLondon1D3LS::~TLondon1D3LS() { fParForBofZ.clear(); fParForPofB.clear(); fParForPofT.clear(); - delete fImpProfile; - fImpProfile = 0; - delete fPofB; - fPofB = 0; - delete fPofT; - fPofT = 0; } // TLondon1D4L::~TLondon1D4L() { @@ -133,10 +98,6 @@ TLondon1D3LS::~TLondon1D3LS() { // fParForBofZ.clear(); // fParForPofB.clear(); // fParForPofT.clear(); -// delete fImpProfile; -// fImpProfile = 0; -// delete fPofT; -// fPofT = 0; // } //------------------ @@ -149,13 +110,13 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) { // read startup file std::string startup_path_name("BMW_startup.xml"); - TSAXParser *saxParser = new TSAXParser(); - BMWStartupHandler *startupHandler = new BMWStartupHandler(); - saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); + std::unique_ptr saxParser = std::make_unique(); + std::unique_ptr startupHandler = std::make_unique(); + saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get()); //int status (saxParser->ParseFile(startup_path_name.c_str())); // parsing the file as above seems to lead to problems in certain environments; // use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition) - int status = parseXmlFile(saxParser, startup_path_name.c_str()); + int status = parseXmlFile(saxParser.get(), startup_path_name.c_str()); // check for parse errors if (status) { // error std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -180,21 +141,11 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) { fParForPofB.push_back(0.005); // Bkg-width fParForPofB.push_back(0.0); // Bkg-weight - fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug()); + fImpProfile = std::make_unique(rge_path, energy_vec, startupHandler->GetDebug()); - fPofB = new TPofBCalc(fParForPofB); + fPofB = std::make_unique(fParForPofB); - fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT); - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + fPofT = std::make_unique(fPofB.get(), fWisdom, fParForPofT); } //------------------ @@ -273,7 +224,7 @@ double TLondon1DHS::operator()(double t, const std::vector &par) const { TLondon1D_HS BofZ(fParForBofZ); fPofB->UnsetPBExists(); - fPofB->Calculate(&BofZ, fImpProfile, fParForPofB); + fPofB->Calculate(&BofZ, fImpProfile.get(), fParForPofB); fPofT->DoFFT(); }/* else { @@ -299,13 +250,13 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) { // read startup file std::string startup_path_name("BMW_startup.xml"); - TSAXParser *saxParser = new TSAXParser(); - BMWStartupHandler *startupHandler = new BMWStartupHandler(); - saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); + std::unique_ptr saxParser = std::make_unique(); + std::unique_ptr startupHandler = std::make_unique(); + saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get()); //int status (saxParser->ParseFile(startup_path_name.c_str())); // parsing the file as above seems to lead to problems in certain environments; // use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition) - int status = parseXmlFile(saxParser, startup_path_name.c_str()); + int status = parseXmlFile(saxParser.get(), startup_path_name.c_str()); // check for parse errors if (status) { // error std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -330,21 +281,11 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) { fParForPofB.push_back(0.005); // Bkg-width fParForPofB.push_back(0.0); // Bkg-weight - fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug()); + fImpProfile = std::make_unique(rge_path, energy_vec, startupHandler->GetDebug()); - fPofB = new TPofBCalc(fParForPofB); + fPofB = std::make_unique(fParForPofB); - fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT); - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + fPofT = std::make_unique(fPofB.get(), fWisdom, fParForPofT); } //------------------ @@ -450,7 +391,7 @@ double TLondon1D1L::operator()(double t, const std::vector &par) const { TLondon1D_1L BofZ1(fParForBofZ); fPofB->UnsetPBExists(); - fPofB->Calculate(&BofZ1, fImpProfile, fParForPofB); + fPofB->Calculate(&BofZ1, fImpProfile.get(), fParForPofB); fPofT->DoFFT(); }/* else { @@ -485,13 +426,13 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true) { // read startup file std::string startup_path_name("BMW_startup.xml"); - TSAXParser *saxParser = new TSAXParser(); - BMWStartupHandler *startupHandler = new BMWStartupHandler(); - saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); + std::unique_ptr saxParser = std::make_unique(); + std::unique_ptr startupHandler = std::make_unique(); + saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get()); //int status (saxParser->ParseFile(startup_path_name.c_str())); // parsing the file as above seems to lead to problems in certain environments; // use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition) - int status = parseXmlFile(saxParser, startup_path_name.c_str()); + int status = parseXmlFile(saxParser.get(), startup_path_name.c_str()); // check for parse errors if (status) { // error std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -516,21 +457,11 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true) { fParForPofB.push_back(0.005); // Bkg-width fParForPofB.push_back(0.0); // Bkg-weight - fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug()); + fImpProfile = std::make_unique(rge_path, energy_vec, startupHandler->GetDebug()); - fPofB = new TPofBCalc(fParForPofB); + fPofB = std::make_unique(fParForPofB); - fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT); - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + fPofT = std::make_unique(fPofB.get(), fWisdom, fParForPofT); } //------------------ @@ -631,7 +562,7 @@ double TLondon1D2L::operator()(double t, const std::vector &par) const { TLondon1D_2L BofZ2(fParForBofZ); fPofB->UnsetPBExists(); - fPofB->Calculate(&BofZ2, fImpProfile, fParForPofB); + fPofB->Calculate(&BofZ2, fImpProfile.get(), fParForPofB); fPofT->DoFFT(); @@ -657,13 +588,13 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) { // read startup file std::string startup_path_name("BMW_startup.xml"); - TSAXParser *saxParser = new TSAXParser(); - BMWStartupHandler *startupHandler = new BMWStartupHandler(); - saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); + std::unique_ptr saxParser = std::make_unique(); + std::unique_ptr startupHandler = std::make_unique(); + saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get()); //int status (saxParser->ParseFile(startup_path_name.c_str())); // parsing the file as above seems to lead to problems in certain environments; // use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition) - int status = parseXmlFile(saxParser, startup_path_name.c_str()); + int status = parseXmlFile(saxParser.get(), startup_path_name.c_str()); // check for parse errors if (status) { // error std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -688,21 +619,11 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) { fParForPofB.push_back(0.01); // Bkg-width fParForPofB.push_back(0.0); // Bkg-weight - fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug()); + fImpProfile = std::make_unique(rge_path, energy_vec, startupHandler->GetDebug()); - fPofB = new TPofBCalc(fParForPofB); + fPofB = std::make_unique(fParForPofB); - fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT); - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + fPofT = std::make_unique(fPofB.get(), fWisdom, fParForPofT); } //------------------ @@ -781,7 +702,7 @@ double TProximity1D1LHS::operator()(double t, const std::vector &par) co TProximity1D_1LHS BofZ(fParForBofZ); fPofB->UnsetPBExists(); - fPofB->Calculate(&BofZ, fImpProfile, fParForPofB); + fPofB->Calculate(&BofZ, fImpProfile.get(), fParForPofB); fPofT->DoFFT(); @@ -806,13 +727,13 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true) { // read startup file std::string startup_path_name("BMW_startup.xml"); - TSAXParser *saxParser = new TSAXParser(); - BMWStartupHandler *startupHandler = new BMWStartupHandler(); - saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); + std::unique_ptr saxParser = std::make_unique(); + std::unique_ptr startupHandler = std::make_unique(); + saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get()); //int status (saxParser->ParseFile(startup_path_name.c_str())); // parsing the file as above seems to lead to problems in certain environments; // use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition) - int status = parseXmlFile(saxParser, startup_path_name.c_str()); + int status = parseXmlFile(saxParser.get(), startup_path_name.c_str()); // check for parse errors if (status) { // error std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -837,21 +758,11 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true) { fParForPofB.push_back(0.005); // Bkg-width fParForPofB.push_back(0.0); // Bkg-weight - fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug()); + fImpProfile = std::make_unique(rge_path, energy_vec, startupHandler->GetDebug()); - fPofB = new TPofBCalc(fParForPofB); + fPofB = std::make_unique(fParForPofB); - fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT); - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + fPofT = std::make_unique(fPofB.get(), fWisdom, fParForPofT); } //------------------ @@ -953,7 +864,7 @@ double TLondon1D3L::operator()(double t, const std::vector &par) const { TLondon1D_3L BofZ3(fParForBofZ); fPofB->UnsetPBExists(); - fPofB->Calculate(&BofZ3, fImpProfile, fParForPofB); + fPofB->Calculate(&BofZ3, fImpProfile.get(), fParForPofB); fPofT->DoFFT(); }/* else { @@ -977,13 +888,13 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true) { // read startup file std::string startup_path_name("BMW_startup.xml"); - TSAXParser *saxParser = new TSAXParser(); - BMWStartupHandler *startupHandler = new BMWStartupHandler(); - saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); + std::unique_ptr saxParser = std::make_unique(); + std::unique_ptr startupHandler = std::make_unique(); + saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get()); //int status (saxParser->ParseFile(startup_path_name.c_str())); // parsing the file as above seems to lead to problems in certain environments; // use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition) - int status = parseXmlFile(saxParser, startup_path_name.c_str()); + int status = parseXmlFile(saxParser.get(), startup_path_name.c_str()); // check for parse errors if (status) { // error std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -1008,21 +919,11 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true) { fParForPofB.push_back(0.005); // Bkg-width fParForPofB.push_back(0.0); // Bkg-weight - fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug()); + fImpProfile = std::make_unique(rge_path, energy_vec, startupHandler->GetDebug()); - fPofB = new TPofBCalc(fParForPofB); + fPofB = std::make_unique(fParForPofB); - fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT); - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + fPofT = std::make_unique(fPofB.get(), fWisdom, fParForPofT); } //------------------ @@ -1124,7 +1025,7 @@ double TLondon1D3LS::operator()(double t, const std::vector &par) const TLondon1D_3LS BofZ3(fParForBofZ); fPofB->UnsetPBExists(); - fPofB->Calculate(&BofZ3, fImpProfile, fParForPofB); + fPofB->Calculate(&BofZ3, fImpProfile.get(), fParForPofB); fPofT->DoFFT(); }/* else { diff --git a/src/external/libFitPofB/include/TLondon1D.h b/src/external/libFitPofB/include/TLondon1D.h index 88157930..db50d78e 100644 --- a/src/external/libFitPofB/include/TLondon1D.h +++ b/src/external/libFitPofB/include/TLondon1D.h @@ -29,6 +29,8 @@ #ifndef _TLondon1D_H_ #define _TLondon1D_H_ +#include + #include "PUserFcnBase.h" #include "TPofTCalc.h" @@ -47,9 +49,9 @@ public: private: mutable std::vector fPar; ///< parameters of the model - TTrimSPData *fImpProfile; ///< low energy muon implantation profiles - TPofBCalc *fPofB; ///< static field distribution P(B) - TPofTCalc *fPofT; ///< muon spin polarization p(t) + std::unique_ptr fImpProfile; ///< low energy muon implantation profiles + std::unique_ptr fPofB; ///< static field distribution P(B) + std::unique_ptr fPofT; ///< muon spin polarization p(t) mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time mutable std::vector fParForPofT; ///< parameters for the calculation of p(t) @@ -76,9 +78,9 @@ public: private: mutable std::vector fPar; ///< parameters of the model - TTrimSPData *fImpProfile; ///< low energy muon implantation profiles - TPofBCalc *fPofB; ///< static field distribution P(B) - TPofTCalc *fPofT; ///< muon spin polarization p(t) + std::unique_ptr fImpProfile; ///< low energy muon implantation profiles + std::unique_ptr fPofB; ///< static field distribution P(B) + std::unique_ptr fPofT; ///< muon spin polarization p(t) mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time mutable std::vector fParForPofT; ///< parameters for the calculation of p(t) @@ -107,9 +109,9 @@ public: private: mutable std::vector fPar; ///< parameters of the model - TTrimSPData *fImpProfile; ///< low energy muon implantation profiles - TPofBCalc *fPofB; ///< static field distribution P(B) - TPofTCalc *fPofT; ///< muon spin polarization p(t) + std::unique_ptr fImpProfile; ///< low energy muon implantation profiles + std::unique_ptr fPofB; ///< static field distribution P(B) + std::unique_ptr fPofT; ///< muon spin polarization p(t) mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time mutable std::vector fParForPofT; ///< parameters for the calculation of p(t) @@ -137,9 +139,9 @@ public: private: mutable std::vector fPar; ///< parameters of the model - TTrimSPData *fImpProfile; ///< low energy muon implantation profiles - TPofBCalc *fPofB; ///< static field distribution P(B) - TPofTCalc *fPofT; ///< muon spin polarization p(t) + std::unique_ptr fImpProfile; ///< low energy muon implantation profiles + std::unique_ptr fPofB; ///< static field distribution P(B) + std::unique_ptr fPofT; ///< muon spin polarization p(t) mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time mutable std::vector fParForPofT; ///< parameters for the calculation of p(t) @@ -167,9 +169,9 @@ public: private: mutable std::vector fPar; ///< parameters of the model - TTrimSPData *fImpProfile; ///< low energy muon implantation profiles - TPofBCalc *fPofB; ///< static field distribution P(B) - TPofTCalc *fPofT; ///< muon spin polarization p(t) + std::unique_ptr fImpProfile; ///< low energy muon implantation profiles + std::unique_ptr fPofB; ///< static field distribution P(B) + std::unique_ptr fPofT; ///< muon spin polarization p(t) mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time mutable std::vector fParForPofT; ///< parameters for the calculation of p(t) @@ -197,9 +199,9 @@ public: private: mutable std::vector fPar; ///< parameters of the model - TTrimSPData *fImpProfile; ///< low energy muon implantation profiles - TPofBCalc *fPofB; ///< static field distribution P(B - TPofTCalc *fPofT; ///< muon spin polarization p(t) + std::unique_ptr fImpProfile; ///< low energy muon implantation profiles + std::unique_ptr fPofB; ///< static field distribution P(B + std::unique_ptr fPofT; ///< muon spin polarization p(t) mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time mutable std::vector fParForPofT; ///< parameters for the calculation of p(t)