diff --git a/src/external/TFitPofB-lib/classes/Makefile.TFitPofB b/src/external/TFitPofB-lib/classes/Makefile.TFitPofB index 89592882..128e26f4 100644 --- a/src/external/TFitPofB-lib/classes/Makefile.TFitPofB +++ b/src/external/TFitPofB-lib/classes/Makefile.TFitPofB @@ -5,7 +5,7 @@ ROOTCFLAGS = $(shell $(ROOTSYS)/bin/root-config --cflags) #--------------------------------------------------- - +OS = LINUX CXX = g++ CXXFLAGS = -g -Wall -Wno-trigraphs -fPIC MUSRFITINCLUDE = ../../../include @@ -63,3 +63,9 @@ TFitPofBStartupHandlerDict.cpp: ../include/TFitPofBStartupHandler.h ../include/T @echo "Generating dictionary $@..." rootcint -f $@ -c -p $^ +install: all + @echo "Installing shared lib: libTFitPofB.so" +ifeq ($(OS),LINUX) + cp -pv $(SHLIB) $(ROOTSYS)/lib + cp -pv $(LOCALINCLUDE)/*.h $(ROOTSYS)/include +endif diff --git a/src/external/TFitPofB-lib/classes/TLondon1D.cpp b/src/external/TFitPofB-lib/classes/TLondon1D.cpp index 0946f6a2..f22028d1 100644 --- a/src/external/TFitPofB-lib/classes/TLondon1D.cpp +++ b/src/external/TFitPofB-lib/classes/TLondon1D.cpp @@ -16,16 +16,54 @@ using namespace std; #include #include "TFitPofBStartupHandler.h" -ClassImp(TLondon1D) ClassImp(TLondon1D1L) ClassImp(TLondon1D2L) +ClassImp(TLondon1D3L) ClassImp(TLondon1D3LS) + //------------------ -// Destructor of the TLondon1D class -- cleaning up +// Destructor of the TLondon1D1L/2L/3L/3LS classes -- cleaning up //------------------ -TLondon1D::~TLondon1D() { +TLondon1D1L::~TLondon1D1L() { + cout << "This is the TLondon1D1L-destructor. Jippieh!" << endl; + fPar.clear(); + fParForBofZ.clear(); + fParForPofB.clear(); + fParForPofT.clear(); + delete fImpProfile; + fImpProfile = 0; + delete fPofT; + fPofT = 0; +} + +TLondon1D2L::~TLondon1D2L() { + cout << "This is the TLondon1D2L-destructor. Jippieh!" << endl; + fPar.clear(); + fParForBofZ.clear(); + fParForPofB.clear(); + fParForPofT.clear(); + delete fImpProfile; + fImpProfile = 0; + delete fPofT; + fPofT = 0; +} + +TLondon1D3L::~TLondon1D3L() { + cout << "This is the TLondon1D3L-destructor. Jippieh!" << endl; + fPar.clear(); + fParForBofZ.clear(); + fParForPofB.clear(); + fParForPofT.clear(); + delete fImpProfile; + fImpProfile = 0; + delete fPofT; + fPofT = 0; +} + +TLondon1D3LS::~TLondon1D3LS() { + cout << "This is the TLondon1D3LS-destructor. Jippieh!" << endl; fPar.clear(); fParForBofZ.clear(); fParForPofB.clear(); @@ -41,63 +79,53 @@ TLondon1D::~TLondon1D() { // creates (a pointer to) the TPofTCalc object (with the FFT plan) //------------------ -TLondon1D1L::TLondon1D1L(const vector &par) { +TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) { + cout << "This is the TLondon1D1L-constructor. Juhu!" << endl; - // extract function parameters - // for(unsigned int i(0); iConnectToHandler("TFitPofBStartupHandler", startupHandler); + int status (saxParser->ParseFile(startup_path_name.c_str())); + // check for parse errors + if (status) { // error + cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl; + } - // read startup file - string startup_path_name("TFitPofB_startup.xml"); + fNSteps = startupHandler->GetNSteps(); + fWisdom = startupHandler->GetWisdomFile(); + string rge_path(startupHandler->GetDataPath()); + vector energy_vec(startupHandler->GetEnergyList()); - TSAXParser *saxParser = new TSAXParser(); - TFitPofBStartupHandler *startupHandler = new TFitPofBStartupHandler(); - saxParser->ConnectToHandler("TFitPofBStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); - // check for parse errors - if (status) { // error - cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl; - } + fParForPofT.push_back(0.0); + fParForPofT.push_back(startupHandler->GetDeltat()); + fParForPofT.push_back(startupHandler->GetDeltaB()); - fNSteps = startupHandler->GetNSteps(); - fWisdom = startupHandler->GetWisdomFile(); - string rge_path(startupHandler->GetDataPath()); - vector energy_vec(startupHandler->GetEnergyList()); + fParForPofB.push_back(startupHandler->GetDeltat()); + fParForPofB.push_back(startupHandler->GetDeltaB()); + fParForPofB.push_back(0.0); - fParForPofT.push_back(fPar[0]); - fParForPofT.push_back(startupHandler->GetDeltat()); - fParForPofT.push_back(startupHandler->GetDeltaB()); + TTrimSPData *x = new TTrimSPData(rge_path, energy_vec); + fImpProfile = x; + x = 0; + delete x; - for (unsigned int i(2); iGetDeltat()); - fParForPofB.push_back(startupHandler->GetDeltaB()); - fParForPofB.push_back(fPar[1]); - - TTrimSPData *x = new TTrimSPData(rge_path, energy_vec); - fImpProfile = x; - x = 0; - delete x; - - TPofTCalc *y = new TPofTCalc(fWisdom, fParForPofT); - fPofT = y; - y = 0; - delete y; - - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } } //------------------ @@ -107,6 +135,25 @@ TLondon1D1L::TLondon1D1L(const vector &par) { //------------------ double TLondon1D1L::operator()(double t, const vector &par) const { + if(t<0.0) + return 0.0; + + // check if the function is called the first time and if yes, read in parameters + + if(fFirstCall){ + fPar = par; + + for (unsigned int i(0); i &par) const { TPofBCalc PofB1(BofZ1, *fImpProfile, fParForPofB); fPofT->DoFFT(PofB1); - } else { + }/* else { cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << endl; - } + }*/ fPofT->CalcPol(fParForPofT); @@ -165,62 +212,51 @@ double TLondon1D1L::operator()(double t, const vector &par) const { // creates (a pointer to) the TPofTCalc object (with the FFT plan) //------------------ -TLondon1D2L::TLondon1D2L(const vector &par) : fLastTwoChanged(true) { - -// extract function parameters -// for(unsigned int i(0); iConnectToHandler("TFitPofBStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); - // check for parse errors - if (status) { // error - cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl; - } + TSAXParser *saxParser = new TSAXParser(); + TFitPofBStartupHandler *startupHandler = new TFitPofBStartupHandler(); + saxParser->ConnectToHandler("TFitPofBStartupHandler", startupHandler); + int status (saxParser->ParseFile(startup_path_name.c_str())); + // check for parse errors + if (status) { // error + cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl; + } - fNSteps = startupHandler->GetNSteps(); - fWisdom = startupHandler->GetWisdomFile(); - string rge_path(startupHandler->GetDataPath()); - vector energy_vec(startupHandler->GetEnergyList()); + fNSteps = startupHandler->GetNSteps(); + fWisdom = startupHandler->GetWisdomFile(); + string rge_path(startupHandler->GetDataPath()); + vector energy_vec(startupHandler->GetEnergyList()); - fParForPofT.push_back(fPar[0]); - fParForPofT.push_back(startupHandler->GetDeltat()); - fParForPofT.push_back(startupHandler->GetDeltaB()); + fParForPofT.push_back(0.0); + fParForPofT.push_back(startupHandler->GetDeltat()); + fParForPofT.push_back(startupHandler->GetDeltaB()); - for (unsigned int i(2); iGetDeltat()); + fParForPofB.push_back(startupHandler->GetDeltaB()); + fParForPofB.push_back(0.0); - fParForPofB.push_back(startupHandler->GetDeltat()); - fParForPofB.push_back(startupHandler->GetDeltaB()); - fParForPofB.push_back(fPar[1]); + TTrimSPData *x = new TTrimSPData(rge_path, energy_vec); + fImpProfile = x; + x = 0; + delete x; - TTrimSPData *x = new TTrimSPData(rge_path, energy_vec); - fImpProfile = x; - x = 0; - delete x; + TPofTCalc *y = new TPofTCalc(fWisdom, fParForPofT); + fPofT = y; + y = 0; + delete y; - TPofTCalc *y = new TPofTCalc(fWisdom, fParForPofT); - fPofT = y; - y = 0; - delete y; - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } } //------------------ @@ -230,6 +266,24 @@ TLondon1D2L::TLondon1D2L(const vector &par) : fLastTwoChanged(true) { //------------------ double TLondon1D2L::operator()(double t, const vector &par) const { + if(t<0.0) + return 0.0; + + // check if the function is called the first time and if yes, read in parameters + + if(fFirstCall){ + fPar = par; + + for (unsigned int i(0); i &par) const { TPofBCalc PofB2(BofZ2, *fImpProfile, fParForPofB); fPofT->DoFFT(PofB2); - } else { + }/* else { cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << endl; - } + }*/ fPofT->CalcPol(fParForPofT); @@ -303,63 +357,51 @@ double TLondon1D2L::operator()(double t, const vector &par) const { // creates (a pointer to) the TPofTCalc object (with the FFT plan) //------------------ -TLondon1D3L::TLondon1D3L(const vector &par) : fLastThreeChanged(true) { +TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true), fLastThreeChanged(true) { + // read startup file + string startup_path_name("TFitPofB_startup.xml"); - // extract function parameters - // for(unsigned int i(0); iConnectToHandler("TFitPofBStartupHandler", startupHandler); + int status (saxParser->ParseFile(startup_path_name.c_str())); + // check for parse errors + if (status) { // error + cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl; + } - fPar = par; + fNSteps = startupHandler->GetNSteps(); + fWisdom = startupHandler->GetWisdomFile(); + string rge_path(startupHandler->GetDataPath()); + vector energy_vec(startupHandler->GetEnergyList()); - // read startup file - string startup_path_name("TFitPofB_startup.xml"); + fParForPofT.push_back(0.0); + fParForPofT.push_back(startupHandler->GetDeltat()); + fParForPofT.push_back(startupHandler->GetDeltaB()); - TSAXParser *saxParser = new TSAXParser(); - TFitPofBStartupHandler *startupHandler = new TFitPofBStartupHandler(); - saxParser->ConnectToHandler("TFitPofBStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); - // check for parse errors - if (status) { // error - cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl; - } + fParForPofB.push_back(startupHandler->GetDeltat()); + fParForPofB.push_back(startupHandler->GetDeltaB()); + fParForPofB.push_back(0.0); - fNSteps = startupHandler->GetNSteps(); - fWisdom = startupHandler->GetWisdomFile(); - string rge_path(startupHandler->GetDataPath()); - vector energy_vec(startupHandler->GetEnergyList()); + TTrimSPData *x = new TTrimSPData(rge_path, energy_vec); + fImpProfile = x; + x = 0; + delete x; - fParForPofT.push_back(fPar[0]); - fParForPofT.push_back(startupHandler->GetDeltat()); - fParForPofT.push_back(startupHandler->GetDeltaB()); - - for (unsigned int i(2); iGetDeltat()); - fParForPofB.push_back(startupHandler->GetDeltaB()); - fParForPofB.push_back(fPar[1]); - - TTrimSPData *x = new TTrimSPData(rge_path, energy_vec); - fImpProfile = x; - x = 0; - delete x; - - TPofTCalc *y = new TPofTCalc(fWisdom, fParForPofT); - fPofT = y; - y = 0; - delete y; - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + TPofTCalc *y = new TPofTCalc(fWisdom, fParForPofT); + fPofT = y; + y = 0; + delete y; + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } } //------------------ @@ -369,6 +411,24 @@ TLondon1D3L::TLondon1D3L(const vector &par) : fLastThreeChanged(true) { //------------------ double TLondon1D3L::operator()(double t, const vector &par) const { + if(t<0.0) + return 0.0; + + // check if the function is called the first time and if yes, read in parameters + + if(fFirstCall){ + fPar = par; + + for (unsigned int i(0); i &par) const { TPofBCalc PofB3(BofZ3, *fImpProfile, fParForPofB); fPofT->DoFFT(PofB3); - } else { + }/* else { cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << endl; - } + }*/ fPofT->CalcPol(fParForPofT); @@ -457,63 +517,51 @@ double TLondon1D3L::operator()(double t, const vector &par) const { // creates (a pointer to) the TPofTCalc object (with the FFT plan) //------------------ -TLondon1D3LS::TLondon1D3LS(const vector &par) : fLastThreeChanged(true) { +TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true), fLastThreeChanged(true) { + // read startup file + string startup_path_name("TFitPofB_startup.xml"); - // extract function parameters - // for(unsigned int i(0); iConnectToHandler("TFitPofBStartupHandler", startupHandler); + int status (saxParser->ParseFile(startup_path_name.c_str())); + // check for parse errors + if (status) { // error + cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl; + } - fPar = par; + fNSteps = startupHandler->GetNSteps(); + fWisdom = startupHandler->GetWisdomFile(); + string rge_path(startupHandler->GetDataPath()); + vector energy_vec(startupHandler->GetEnergyList()); - // read startup file - string startup_path_name("TFitPofB_startup.xml"); + fParForPofT.push_back(0.0); + fParForPofT.push_back(startupHandler->GetDeltat()); + fParForPofT.push_back(startupHandler->GetDeltaB()); - TSAXParser *saxParser = new TSAXParser(); - TFitPofBStartupHandler *startupHandler = new TFitPofBStartupHandler(); - saxParser->ConnectToHandler("TFitPofBStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); - // check for parse errors - if (status) { // error - cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl; - } + fParForPofB.push_back(startupHandler->GetDeltat()); + fParForPofB.push_back(startupHandler->GetDeltaB()); + fParForPofB.push_back(0.0); - fNSteps = startupHandler->GetNSteps(); - fWisdom = startupHandler->GetWisdomFile(); - string rge_path(startupHandler->GetDataPath()); - vector energy_vec(startupHandler->GetEnergyList()); + TTrimSPData *x = new TTrimSPData(rge_path, energy_vec); + fImpProfile = x; + x = 0; + delete x; - fParForPofT.push_back(fPar[0]); - fParForPofT.push_back(startupHandler->GetDeltat()); - fParForPofT.push_back(startupHandler->GetDeltaB()); - - for (unsigned int i(2); iGetDeltat()); - fParForPofB.push_back(startupHandler->GetDeltaB()); - fParForPofB.push_back(fPar[1]); - - TTrimSPData *x = new TTrimSPData(rge_path, energy_vec); - fImpProfile = x; - x = 0; - delete x; - - TPofTCalc *y = new TPofTCalc(fWisdom, fParForPofT); - fPofT = y; - y = 0; - delete y; - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } + TPofTCalc *y = new TPofTCalc(fWisdom, fParForPofT); + fPofT = y; + y = 0; + delete y; + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } } //------------------ @@ -523,6 +571,24 @@ TLondon1D3LS::TLondon1D3LS(const vector &par) : fLastThreeChanged(true) //------------------ double TLondon1D3LS::operator()(double t, const vector &par) const { + if(t<0.0) + return 0.0; + + // check if the function is called the first time and if yes, read in parameters + + if(fFirstCall){ + fPar = par; + + for (unsigned int i(0); i &par) const { TPofBCalc PofB3S(BofZ3S, *fImpProfile, fParForPofB); fPofT->DoFFT(PofB3S); - } else { + }/* else { cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << endl; - } + }*/ fPofT->CalcPol(fParForPofT); diff --git a/src/external/TFitPofB-lib/classes/TPofTCalc.cpp b/src/external/TFitPofB-lib/classes/TPofTCalc.cpp index 9a6f4700..6aa0dfd7 100644 --- a/src/external/TFitPofB-lib/classes/TPofTCalc.cpp +++ b/src/external/TFitPofB-lib/classes/TPofTCalc.cpp @@ -53,7 +53,7 @@ TPofTCalc::TPofTCalc (const string &wisdom, const vector &par) : fWisdom } fFFTplan = fftw_plan_dft_r2c_1d(fNFFT, fFFTin, fFFTout, FFTW_EXHAUSTIVE); - + cout << &fFFTplan << endl; } //-------------- @@ -93,7 +93,7 @@ void TPofTCalc::DoFFT(const TPofBCalc &PofB) { fFFTout[i][1] = 0.0; } - cout << "perform the Fourier transform..." << endl; +// cout << "perform the Fourier transform..." << endl; fftw_execute(fFFTplan); @@ -154,7 +154,7 @@ TPofTCalc::~TPofTCalc() { fftw_destroy_plan(fFFTplan); free(fFFTin); fftw_free(fFFTout); - fftw_cleanup(); +// fftw_cleanup(); fT.clear(); fPT.clear(); diff --git a/src/external/TFitPofB-lib/include/TLondon1D.h b/src/external/TFitPofB-lib/include/TLondon1D.h index 5eb135b9..fe0505d9 100644 --- a/src/external/TFitPofB-lib/include/TLondon1D.h +++ b/src/external/TFitPofB-lib/include/TLondon1D.h @@ -15,86 +15,101 @@ #include "PUserFcnBase.h" #include "TPofTCalc.h" -class TLondon1D : public PUserFcnBase { +class TLondon1D1L : public PUserFcnBase { public: - // default conctructor only for the ROOT dictionary - DO NOT USE IT OTHERWISE! - TLondon1D() : fCalcNeeded(true) {} - virtual ~TLondon1D(); + // default conctructor + TLondon1D1L(); + ~TLondon1D1L(); - virtual double operator()(double, const vector&) const = 0; + double operator()(double, const vector&) const; -protected: +private: mutable vector fPar; TTrimSPData *fImpProfile; TPofTCalc *fPofT; mutable bool fCalcNeeded; + mutable bool fFirstCall; mutable vector fParForPofT; mutable vector fParForBofZ; mutable vector fParForPofB; string fWisdom; unsigned int fNSteps; - ClassDef(TLondon1D,1) -}; - -class TLondon1D1L : public TLondon1D { - -public: - // default conctructor only for the ROOT dictionary - DO NOT USE IT OTHERWISE! - TLondon1D1L() {} - TLondon1D1L(const vector&); - ~TLondon1D1L() {} - - double operator()(double, const vector&) const; - ClassDef(TLondon1D1L,1) }; -class TLondon1D2L : public TLondon1D { +class TLondon1D2L : public PUserFcnBase { public: - // default conctructor only for the ROOT dictionary - DO NOT USE IT OTHERWISE! - TLondon1D2L() : fLastTwoChanged(true) {} - TLondon1D2L(const vector&); - ~TLondon1D2L() {} + // default conctructor + TLondon1D2L(); + ~TLondon1D2L(); double operator()(double, const vector&) const; private: + mutable vector fPar; + TTrimSPData *fImpProfile; + TPofTCalc *fPofT; + mutable bool fCalcNeeded; + mutable bool fFirstCall; + mutable vector fParForPofT; + mutable vector fParForBofZ; + mutable vector fParForPofB; + string fWisdom; + unsigned int fNSteps; mutable bool fLastTwoChanged; ClassDef(TLondon1D2L,1) }; -class TLondon1D3L : public TLondon1D { +class TLondon1D3L : public PUserFcnBase { public: - // default conctructor only for the ROOT dictionary - DO NOT USE IT OTHERWISE! - TLondon1D3L() : fLastThreeChanged(true) {} - TLondon1D3L(const vector&); - ~TLondon1D3L() {} + // default conctructor + TLondon1D3L(); + ~TLondon1D3L(); double operator()(double, const vector&) const; private: + mutable vector fPar; + TTrimSPData *fImpProfile; + TPofTCalc *fPofT; + mutable bool fCalcNeeded; + mutable bool fFirstCall; + mutable vector fParForPofT; + mutable vector fParForBofZ; + mutable vector fParForPofB; + string fWisdom; + unsigned int fNSteps; mutable bool fLastThreeChanged; ClassDef(TLondon1D3L,1) }; -class TLondon1D3LS : public TLondon1D { +class TLondon1D3LS : public PUserFcnBase { public: - // default conctructor only for the ROOT dictionary - DO NOT USE IT OTHERWISE! - TLondon1D3LS() : fLastThreeChanged(true) {} - TLondon1D3LS(const vector&); - ~TLondon1D3LS() {} + // default conctructor + TLondon1D3LS(); + ~TLondon1D3LS(); double operator()(double, const vector&) const; private: + mutable vector fPar; + TTrimSPData *fImpProfile; + TPofTCalc *fPofT; + mutable bool fCalcNeeded; + mutable bool fFirstCall; + mutable vector fParForPofT; + mutable vector fParForBofZ; + mutable vector fParForPofB; + string fWisdom; + unsigned int fNSteps; mutable bool fLastThreeChanged; ClassDef(TLondon1D3LS,1) diff --git a/src/external/TFitPofB-lib/include/TLondon1DLinkDef.h b/src/external/TFitPofB-lib/include/TLondon1DLinkDef.h index 66da0b0c..57217f01 100644 --- a/src/external/TFitPofB-lib/include/TLondon1DLinkDef.h +++ b/src/external/TFitPofB-lib/include/TLondon1DLinkDef.h @@ -16,7 +16,6 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class TLondon1D+; #pragma link C++ class TLondon1D1L+; #pragma link C++ class TLondon1D2L+; #pragma link C++ class TLondon1D3L+;