diff --git a/src/external/Nonlocal/Makefile b/src/external/Nonlocal/Makefile index 66f3adb1..ea2f0e24 100644 --- a/src/external/Nonlocal/Makefile +++ b/src/external/Nonlocal/Makefile @@ -63,6 +63,7 @@ GLIBS = $(ROOTGLIBS) -lXMLParser # some definitions: headers (used to generate *Dict* stuff), sources, objects,... OBJS = OBJS += PNL_StartupHandler.o PNL_StartupHandlerDict.o +OBJS += PNL_RgeHandler.o OBJS += PNL_PippardFitter.o PNL_PippardFitterDict.o SHLIB = libPNL_PippardFitter.so diff --git a/src/external/Nonlocal/PNL_PippardFitter.cpp b/src/external/Nonlocal/PNL_PippardFitter.cpp index 1d7e55e5..b7bae142 100644 --- a/src/external/Nonlocal/PNL_PippardFitter.cpp +++ b/src/external/Nonlocal/PNL_PippardFitter.cpp @@ -29,6 +29,13 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include + +#include +using namespace std; + +#include + #include "PNL_PippardFitter.h" ClassImp(PNL_PippardFitter) @@ -41,6 +48,39 @@ ClassImp(PNL_PippardFitter) */ PNL_PippardFitter::PNL_PippardFitter() { + // read XML startup file + char startup_path_name[128]; + TSAXParser *saxParser = new TSAXParser(); + PNL_StartupHandler *fStartupHandler = new PNL_StartupHandler(); + strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data()); + saxParser->ConnectToHandler("PNL_StartupHandler", fStartupHandler); + Int_t status = saxParser->ParseFile(startup_path_name); + // check for parse errors + if (status) { // error + cout << endl << "**WARNING** reading/parsing nonlocal_startup.xml."; + cout << endl; + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + if (fStartupHandler) { + delete fStartupHandler; + fStartupHandler = 0; + } + assert(false); + } + + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + + // load all the TRIM.SP rge-files + fRgeHandler = new PNL_RgeHandler(fStartupHandler->GetTrimSpDataPathList()); + if (!fRgeHandler->IsValid()) + assert(false); } //-------------------------------------------------------------------------- @@ -51,6 +91,10 @@ PNL_PippardFitter::PNL_PippardFitter() */ PNL_PippardFitter::~PNL_PippardFitter() { + if (fStartupHandler) { + delete fStartupHandler; + fStartupHandler = 0; + } } //-------------------------------------------------------------------------- @@ -61,7 +105,8 @@ PNL_PippardFitter::~PNL_PippardFitter() */ Double_t PNL_PippardFitter::operator()(Double_t t, const std::vector ¶m) const { -// assert(param.size() >= 4); + // expected parameters: energy, temp, thickness, meanFreePath, xi0, lambdaL + assert(param.size() != 6); return 0.0; } diff --git a/src/external/Nonlocal/PNL_PippardFitter.h b/src/external/Nonlocal/PNL_PippardFitter.h index 60bb247f..0352a38e 100644 --- a/src/external/Nonlocal/PNL_PippardFitter.h +++ b/src/external/Nonlocal/PNL_PippardFitter.h @@ -33,6 +33,8 @@ #define _PNL_PIPPARDFITTER_H_ #include "PUserFcnBase.h" +#include "PNL_StartupHandler.h" +#include "PNL_RgeHandler.h" class PNL_PippardFitter : public PUserFcnBase { @@ -42,6 +44,10 @@ class PNL_PippardFitter : public PUserFcnBase virtual Double_t operator()(Double_t t, const std::vector ¶m) const; + private: + PNL_StartupHandler *fStartupHandler; + PNL_RgeHandler *fRgeHandler; + ClassDef(PNL_PippardFitter, 1) }; diff --git a/src/external/Nonlocal/PNL_RgeHandler.cpp b/src/external/Nonlocal/PNL_RgeHandler.cpp new file mode 100644 index 00000000..d6792ab4 --- /dev/null +++ b/src/external/Nonlocal/PNL_RgeHandler.cpp @@ -0,0 +1,208 @@ +/*************************************************************************** + + PNL_RgeHandler.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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 * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +using namespace std; + +#include "PNL_RgeHandler.h" + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + * + */ +PNL_RgeHandler::PNL_RgeHandler(const PStringVector &rgeDataPathList) +{ + fIsValid = false; + + fIsValid = LoadRgeData(rgeDataPathList); +} + +//-------------------------------------------------------------------------- +// Destructor +//-------------------------------------------------------------------------- +/** + * + */ +PNL_RgeHandler::~PNL_RgeHandler() +{ + fRgeDataList.clear(); +} + +//-------------------------------------------------------------------------- +// GetRgeEnergyIndex +//-------------------------------------------------------------------------- +/** + * + */ +Int_t PNL_RgeHandler::GetRgeEnergyIndex(const Double_t energy) +{ + Int_t idx = -1; + + for (UInt_t i=0; i= fRgeDataList[index].stoppingDistance.size()) || (distIdx < 0)) { + rgeVal = 0.0; + } else { + rgeVal = fRgeDataList[index].stoppingAmplitude[distIdx] + + (fRgeDataList[index].stoppingAmplitude[distIdx] - fRgeDataList[index].stoppingAmplitude[distIdx+1]) * + (fRgeDataList[index].stoppingDistance[distIdx+1]-dist)/(fRgeDataList[index].stoppingDistance[distIdx+1]-fRgeDataList[index].stoppingDistance[distIdx]); + } + + return rgeVal; +} + +//-------------------------------------------------------------------------- +// GetRgeValue +//-------------------------------------------------------------------------- +/** + * + */ +Double_t PNL_RgeHandler::GetRgeValue(const Double_t energy, const Double_t dist) +{ + // check if energy is present in rge data list + Int_t idx = -1; + + for (UInt_t i=0; i PStringVector; +//------------------------------------------------------------- +/** + *

typedef to make to code more readable. + */ +typedef std::vector PDoubleVector; + +//------------------------------------------------------------- +/** + *

+ */ +typedef struct { + Double_t energy; + PDoubleVector stoppingDistance; + PDoubleVector stoppingAmplitude; +} PNL_RgeData; + +//------------------------------------------------------------- +/** + *

+ */ +typedef std::vector PNL_RgeDataList; #endif // _PNONLOCAL_H_