diff --git a/ChangeLog b/ChangeLog
index 4bbe7137..0f218e29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
changes since 0.17.0
===================================
+NEW 2016-03-08 added a theory translator for DKS
NEW 2016-02-23 It is now possible to export the averaged data/Fourier
changes since 0.16.0
diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp
index d6d4e049..b475e517 100644
--- a/src/classes/PMsrHandler.cpp
+++ b/src/classes/PMsrHandler.cpp
@@ -6032,6 +6032,125 @@ Double_t PMsrHandler::GetAlphaEstimateN0()
return fStartupOptions->alphaEstimateN0;
}
+//--------------------------------------------------------------------------
+// GetDKSTheoryString (public)
+//--------------------------------------------------------------------------
+/**
+ *
returns the theory string in a c++ compatible string. This is needed
+ * for DKS/GPU.
+ *
+ * \return the theory in a c++ like string.
+ */
+std::string PMsrHandler::GetDKSTheoryString()
+{
+ std::string result("");
+ PStringVector args;
+
+ TString tp = TString::Format("%.15lf", TMath::TwoPi());
+ TString ph = TString::Format("%.15lf", TMath::Pi() / 180.0);
+
+ for (UInt_t i=1; i 1) {
+ if (!fTheory[i-1].fLine.BeginsWith("+")) {
+ result += " * ";
+ }
+ }
+
+ HandleTheoryArguments(fTheory[i].fLine, args);
+
+ if (fTheory[i].fLine.BeginsWith("asymmetry ", TString::kIgnoreCase) ||
+ fTheory[i].fLine.BeginsWith("a ", TString::kIgnoreCase)) {
+ result += args[0].Data();
+ } else if (fTheory[i].fLine.BeginsWith("simplExpo ", TString::kIgnoreCase) ||
+ fTheory[i].fLine.BeginsWith("se ")) { // se -> se(t,lambda)
+ result += "se(t, ";
+ result += args[0].Data();
+ result += ")";
+ } else if (fTheory[i].fLine.BeginsWith("simpleGss ", TString::kIgnoreCase) ||
+ fTheory[i].fLine.BeginsWith("sg ")) { // sg -> sg(t,sigma)
+ result += "sg(t, ";
+ result += args[0].Data();
+ result += ")";
+ } else if (fTheory[i].fLine.BeginsWith("TFieldCos ", TString::kIgnoreCase) ||
+ fTheory[i].fLine.BeginsWith("tf ")) { // tf -> tf(t, phi (°), nu (MHz))
+ result += "tf(t, ";
+ result += args[0].Data();
+ result += ", ";
+ result += args[1].Data();
+ result += ")";
+ } else if (fTheory[i].fLine.BeginsWith("+")) {
+ result.erase(result.end()-3, result.end()); // remove the '*' at the end
+ result += " + ";
+ } else {
+ result = string("??"); // not yet available in DKS
+ break;
+ }
+ }
+
+ return result;
+}
+
+//--------------------------------------------------------------------------
+// HandleTheoryArguments (private)
+//--------------------------------------------------------------------------
+/**
+ * tokenizes the theory function arguments and transforms them for DKS
+ *
+ * \param theo
+ * \param args vector of the transformed arguments
+ */
+void PMsrHandler::HandleTheoryArguments(const TString theo, PStringVector &args)
+{
+ TObjArray *tok=theo.Tokenize(" \t");
+ TObjString *ostr=0;
+ TString str, argStr;
+ Int_t ival;
+
+ args.clear(); // make sure vector is empty
+
+ if (tok == 0) {
+ cerr << ">> PMsrHandler::HandleTheoryArguments(): **ERROR** couldn't tokensize '" << theo << "'" << endl;
+ return;
+ }
+
+ for (Int_t i=0; iGetEntries(); i++) {
+ ostr = dynamic_cast(tok->At(i));
+ str = ostr->GetString();
+ if (str.BeginsWith("#") || str.BeginsWith("(")) { // comment or description
+ continue;
+ } else if (str.IsDigit()) { // parameter
+ ival = str.Atoi();
+ ival -= 1;
+ str = TString::Format("%d",ival);
+ argStr = "p["+ str +"]";
+ args.push_back(argStr);
+ } else if (str.BeginsWith("map", TString::kIgnoreCase)) { // map
+ str.Remove(0,3);
+ if (!str.IsDigit()) {
+ return;
+ }
+ ival = str.Atoi();
+ ival -= 1;
+ str = TString::Format("%d",ival);
+ argStr = "p[m[" + str + "]]";
+ args.push_back(argStr);
+ } else if (str.BeginsWith("fun", TString::kIgnoreCase)) { // function
+ str.Remove(0,3);
+ if (!str.IsDigit()) {
+ return;
+ }
+ ival = str.Atoi();
+ ival -= 1;
+ str = TString::Format("%d",ival);
+ argStr = "f[" + str + "]";
+ args.push_back(argStr);
+ }
+ }
+
+ // clean up
+ delete tok;
+}
+
//--------------------------------------------------------------------------
// NeededPrecision (private)
//--------------------------------------------------------------------------
diff --git a/src/include/PMsrHandler.h b/src/include/PMsrHandler.h
index 1dab817b..5d272f35 100644
--- a/src/include/PMsrHandler.h
+++ b/src/include/PMsrHandler.h
@@ -30,6 +30,8 @@
#ifndef _PMSRHANDLER_H_
#define _PMSRHANDLER_H_
+#include
+
#include
#include
@@ -109,6 +111,8 @@ class PMsrHandler
virtual Bool_t EstimateN0();
virtual Double_t GetAlphaEstimateN0();
+ virtual std::string GetDKSTheoryString();
+
private:
Bool_t fFourierOnly; ///< flag indicating if Fourier transform only is wished. If yes, some part of the msr-file blocks are not needed.
PStartupOptions *fStartupOptions; ///< contains information about startup options from the musrfit_startup.xml
@@ -156,6 +160,8 @@ class PMsrHandler
virtual void MakeDetectorGroupingString(TString str, PIntVector &group, TString &result, Bool_t includeDetector = true);
virtual void CheckLegacyLifetimecorrection();
+
+ virtual void HandleTheoryArguments(const TString theo, PStringVector &args);
};
#endif // _PMSRHANDLER_H_
diff --git a/src/musrfit.cpp b/src/musrfit.cpp
index f5f5ac44..00060851 100644
--- a/src/musrfit.cpp
+++ b/src/musrfit.cpp
@@ -712,6 +712,10 @@ int main(int argc, char *argv[])
}
}
+ cout << "debug> ++++++++++++" << endl;
+ cout << "debug> msrHandler->GetDKSTheoryString()='" << msrHandler->GetDKSTheoryString() << "'" << endl;
+ cout << "debug> ++++++++++++" << endl;
+
// check if dump is wanted
if (success && !dump.IsNull()) {
cout << endl << "will write dump file ..." << endl;