Index: trunk/MagicSoft/Mars/mdata/MDataPhrase.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataPhrase.cc	(revision 8077)
+++ trunk/MagicSoft/Mars/mdata/MDataPhrase.cc	(revision 8083)
@@ -54,4 +54,58 @@
 //   Gaus, Gausn, Landau, Landaun, Pol0-Pol10, Pow2-Pow5
 //
+// In the constructor you can give rule, like
+//   "HillasSource.fDist / MHillas.fLength"
+// Where MHillas/HillasSource is the name of the parameter container in
+// the parameter list and fDist/fLength is the name of the data members
+// in the containers. The result will be fDist divided by fLength.
+//
+// In case you want to access a data-member which is a data member object
+// you can acces it with (Remark: it must derive from MParContainer):
+//   "MCameraLV.fPowerSupplyA.fVoltagePos5V"
+// (THIS FEATURE IS CURRENTLY NOT SUPPORTED)
+//
+// You can also use parantheses:
+//   "HillasDource.fDist / (MHillas.fLength + MHillas.fWidth)"
+//
+// Additional implementations:
+//
+//   isnan(x)  return 1 if x is NaN (Not a Number) otherwise 0
+//   finite(x) return 1 if the number is a valid double (not NaN, inf)
+//
+// NaN (Not a Number) means normally a number which is to small to be
+// stored in a floating point variable (eg. 0<x<1e-56 or similar) or
+// a number which function is not defined (like asin(1.5))
+//
+// inf is the symbol for an infinite number.
+//
+//
+// Constants
+// ---------
+//
+// Most constants you might need can be found in TMath, eg:
+//  TMath::Pi(), TMath::TwoPi(), TMath::Ln10(), TMath::LogE()
+//  TMath::RadToDeg(), TMath::DegToRad();
+//
+//
+// Variable Parameters
+// ------------------------
+// If you want to use variables, eg for fits you can use [0], [1], ...
+// These values are initialized with 0 and set by calling
+// SetVariables(), eg
+//   [0]*MHillas.fArea
+//
+//
+// Multi-argument functions
+// ------------------------
+// You can use multi-argument functions, too. Example:
+//   "TMath::Hypot(MHillas.fMeanX, MHillas.MeanY)"
+//   "pow(MHillas.fMeanX*MHillas.MeanY, -1.2)"
+//
+//
+//
+// To Do:
+//  - The possibility to use other objects inheriting from MData
+//    is missing.
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MDataPhrase.h"
@@ -329,15 +383,18 @@
     // More in TFormulaPrimitive.cxx
     // More in TFormulaMathInterface
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("log2",   "log2",   (TFormulaPrimitive::GenFunc10)TMath::Log2));
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("fabs",   "fabs",   (TFormulaPrimitive::GenFunc10)TMath::Abs));
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("floor",  "floor",  (TFormulaPrimitive::GenFunc10)TMath::Floor));
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("ceil",   "ceil",   (TFormulaPrimitive::GenFunc10)TMath::Ceil));
-
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("nint",   "nint",   (TFormulaPrimitive::GenFunc10)MFastFun::Nint));
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("round",  "round",  (TFormulaPrimitive::GenFunc10)MFastFun::Nint));
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("sgn",    "sgn",    (TFormulaPrimitive::GenFunc10)MFastFun::Sign));
-
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("isnan",  "isnan",  (TFormulaPrimitive::GenFunc10)MFastFun::IsNaN));
-    TFormulaPrimitive::AddFormula(new TFormulaPrimitive("finite", "finite", (TFormulaPrimitive::GenFunc10)MFastFun::Finite));
+    if (!TFormulaPrimitive::FindFormula("isnan"))
+    {
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("log2",   "log2",   (TFormulaPrimitive::GenFunc10)TMath::Log2));
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("fabs",   "fabs",   (TFormulaPrimitive::GenFunc10)TMath::Abs));
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("floor",  "floor",  (TFormulaPrimitive::GenFunc10)TMath::Floor));
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("ceil",   "ceil",   (TFormulaPrimitive::GenFunc10)TMath::Ceil));
+
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("nint",   "nint",   (TFormulaPrimitive::GenFunc10)MFastFun::Nint));
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("round",  "round",  (TFormulaPrimitive::GenFunc10)MFastFun::Nint));
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("sgn",    "sgn",    (TFormulaPrimitive::GenFunc10)MFastFun::Sign));
+
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("isnan",  "isnan",  (TFormulaPrimitive::GenFunc10)MFastFun::IsNaN));
+        TFormulaPrimitive::AddFormula(new TFormulaPrimitive("finite", "finite", (TFormulaPrimitive::GenFunc10)MFastFun::Finite));
+    }
 
     //    TFormulaPrimitive is used to get direct acces to the function pointers
