From ef653c11b234b245faeedbdd628552897dece9c9 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Sat, 18 Aug 2018 14:17:41 +0200 Subject: [PATCH] Resolve conflict from Jonas' commits --- src/external/libBNMR/TBNMR.cpp | 74 +++++++--------------------------- src/external/libBNMR/TBNMR.h | 45 +++++---------------- 2 files changed, 26 insertions(+), 93 deletions(-) diff --git a/src/external/libBNMR/TBNMR.cpp b/src/external/libBNMR/TBNMR.cpp index fb7223bb..b1f7b042 100644 --- a/src/external/libBNMR/TBNMR.cpp +++ b/src/external/libBNMR/TBNMR.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2010 by Zaher Salman * - * zaher.salman@psi.ch * + * Copyright (C) 2010 by Zaher Salman * + * zaher.salman@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -20,7 +20,7 @@ * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * @@ -30,29 +30,15 @@ ***************************************************************************/ #include "TBNMR.h" -#include "TF1.h" -#include "Math/WrappedTF1.h" -#include "Math/GaussIntegrator.h" #define tau_Li 1210 #define gamma_Li 6.3018 // In units kHz/mT #define PI 3.14159265358979323846 #define TWOPI 6.28318530717958647692 -ClassImp(TBNMR) // for the ROOT-dictionary -ClassImp(ExpRlx) +ClassImp(ExpRlx) // for the ROOT-dictionary ClassImp(SExpRlx) -ClassImp(MLRes) -double TBNMR::operator()(double x, const vector &par) const { - assert(par.size()==1); // make sure the number of parameters handed to the function is correct - - double arg(par[0]*x); - - if(!arg) - return 1.0; - return sin(arg)/arg; -} double ExpRlx::operator()(double x, const vector &par) const { assert(par.size()==2); // make sure the number of parameters handed to the function is correct @@ -75,55 +61,25 @@ double ExpRlx::operator()(double x, const vector &par) const { return y; } + +//initialize Integrators +TF1 SExpRlx::sexp1=TF1("sexp", "exp(-([0]-x)/[3])*exp(-pow(([1]*([0]-x)),[2]))", 0.0, 20000.0); +TF1 SExpRlx::sexp2=TF1("sexp", "exp(-([3]-x)/[4])*exp(-pow(([1]*([0]-x)),[2]))", 0.0, 20000.0); + double SExpRlx::operator()(double x, const vector &par) const { assert(par.size()==3); // make sure the number of parameters handed to the function is correct // par[0] time of beam off // par[1] is the relaxation rate // par[2] is the exponent - double tau_p; - double y; - tau_p = (tau_Li/(1.+par[1]*tau_Li)); - - - if ( x >= 0 && x <= par[0] ) { - TF1 sexp("sexp", "exp(-([0]-x)/[3])*exp(-pow(([1]*([0]-x)),[2]))", 0.0, 20000.0); - sexp.SetParameters(x, par[1], par[2],tau_Li); - sexp.SetNpx(1000); - y=sexp.Integral(0.0,x)/(1-exp(-x/tau_Li))/tau_Li; + if ( x >= 0 && x <= par[0] ) { + sexp1.SetParameters(x, par[1], par[2],tau_Li); + return sexp1.Integral(0.0,x)/(1-exp(-x/tau_Li))/tau_Li; } else if ( x > par[0] ) { - TF1 sexp("sexp", "exp(-([3]-x)/[4])*exp(-pow(([1]*([0]-x)),[2]))", 0.0, 20000.0); - sexp.SetParameters(x, par[1], par[2], par[0],tau_Li); - sexp.SetNpx(1000); - y=sexp.Integral(0.0,par[0])/(1-exp(-par[0]/tau_Li))/tau_Li; - } else { - y = 0; + sexp2.SetParameters(x, par[1], par[2], par[0],tau_Li); + return sexp2.Integral(0.0,par[0])/(1-exp(-par[0]/tau_Li))/tau_Li; } - return y; -} - -double MLRes::operator()(double x, const vector &par) const { - assert(par.size()==3); // make sure the number of parameters handed to the function is correct - - // par[0] time of beam off - // par[1] is the relaxation rate - // par[2] is the exponent - double y; - - if ( x >= 0 && x <= par[0] ) { - TF1 sexp("sexp", "exp(-([0]-x)/[3])*exp(-pow(([1]*([0]-x)),[2]))", 0.0, 10000.0); - sexp.SetParameters(x, par[1], par[2],tau_Li); - sexp.SetNpx(1000); - y=sexp.Integral(0.0,x)/(1-exp(-x/tau_Li))/tau_Li; - } else if ( x > par[0] ) { - TF1 sexp("sexp", "exp(-([3]-x)/[4])*exp(-pow(([1]*([0]-x)),[2]))", 0.0, 10000.0); - sexp.SetParameters(x, par[1], par[2], par[0],tau_Li); - sexp.SetNpx(1000); - y=sexp.Integral(0.0,par[0])/(1-exp(-par[0]/tau_Li))/tau_Li; - } else { - y = 0; - } - return y; + return 0; } diff --git a/src/external/libBNMR/TBNMR.h b/src/external/libBNMR/TBNMR.h index 2304ff99..24d95172 100644 --- a/src/external/libBNMR/TBNMR.h +++ b/src/external/libBNMR/TBNMR.h @@ -31,29 +31,18 @@ #include "PUserFcnBase.h" +#include "TF1.h" +#include "Math/WrappedTF1.h" +#include "Math/GaussIntegrator.h" #include #include #include +#ifndef LIBBNMRH +#define LIBBNMRH + using namespace std; -class TBNMR : public PUserFcnBase { - -public: - // default constructor and destructor - TBNMR(){} - ~TBNMR(){} - - Bool_t NeedGlobalPart() const { return false; } - void SetGlobalPart(vector &globalPart, UInt_t idx) { } - Bool_t GlobalPartIsValid() const { return true; } - - // function operator - double operator()(double, const vector&) const; - - // definition of the class for the ROOT-dictionary - ClassDef(TBNMR,1) -}; class ExpRlx : public PUserFcnBase { @@ -77,7 +66,7 @@ class SExpRlx : public PUserFcnBase { public: // default constructor and destructor - SExpRlx(){} + SExpRlx(){sexp1.SetNpx(1000); sexp2.SetNpx(1000);} ~SExpRlx(){} Bool_t NeedGlobalPart() const { return false; } @@ -86,25 +75,13 @@ public: // function operator double operator()(double, const vector&) const; +private: + static TF1 sexp1; + static TF1 sexp2; // definition of the class for the ROOT-dictionary ClassDef(SExpRlx,1) }; -class MLRes : public PUserFcnBase { -public: - // default constructor and destructor - MLRes(){} - ~MLRes(){} - - Bool_t NeedGlobalPart() const { return false; } - void SetGlobalPart(vector &globalPart, UInt_t idx) { } - Bool_t GlobalPartIsValid() const { return true; } - - // function operator - double operator()(double, const vector&) const; - - // definition of the class for the ROOT-dictionary - ClassDef(MLRes,1) -}; +#endif //LIBBNMRH