Index: trunk/MagicSoft/Mars/macros/optim/optimdisp.C
===================================================================
--- trunk/MagicSoft/Mars/macros/optim/optimdisp.C	(revision 8558)
+++ trunk/MagicSoft/Mars/macros/optim/optimdisp.C	(revision 8656)
@@ -8,12 +8,27 @@
 
     // -------------------- Setup ----------------------------
-    opt.AddParameter("1-(MHillas.fWidth/MHillas.fLength)"); // M[0]
-    opt.AddParameter("log10(MNewImagePar.fLeakage1+1)");    // M[1]
 
-    opt.SetParameter(0,  1.30871);                          // Setup [0]
-    opt.SetParameter(1,  5.81119);                          // Setup [1]
-    opt.SetParameter(2,  0.763486);                         // Setup [2]
+    opt.AddParameter("1-MHillas.fWidth/MHillas.fLength");   // M[0]
+    opt.AddParameter("MHillasExt.fSlopeLong*sign(MHillasSrc.fCosDeltaAlpha)/MGeomCam.fConvMm2Deg"); // M[1]
+    opt.AddParameter("MNewImagePar.fLeakage1");             // M[2]
+    opt.AddParameter("log10(MHillas.fSize)");               // M[3]
 
-    char *r = "([0]+([1]*pow(M[1], [2])))*M[0]";            // Rule to calc Disp
+    // -------------- Parametrization --------------------
+
+    char *r = "M[0]*([0] + [1]*M[1] + [2]*M[2] + (M[3]>[3])*[4]*(M[3]-[3])^2)";
+
+    opt.FixParameter(0, 1.266195);
+    opt.FixParameter(1, 0.100577);
+    opt.FixParameter(2, 1.80309);
+    opt.FixParameter(3, 2.87177);
+    opt.FixParameter(4, 0.616823); 
+
+    opt.AddPreCut("MNewImagePar.fLeakage1>0");
+    opt.AddPreCut("log10(MHillas.fSize)<3.2");
+
+    //opt.AddPreCut("abs(MHillasSrc.fDCA*MGeomCam.fConvMm2Deg)<0.2");
+    //opt.AddPreCut("(MHillasSrc.fDist*MGeomCam.fConvMm2Deg-0.5)*7.2>MHillasExt.fSlopeLong*sign(MHillasSrc.fCosDeltaAlpha)/MGeomCam.fConvMm2Deg");
+    opt.AddPreCut("MHillasExt.fM3Long*sign(MHillasSrc.fCosDeltaAlpha)*MGeomCam.fConvMm2Deg>-0.07");
+    opt.AddPreCut("DataType.fVal>0.5");
 
     // -------------------- Run ----------------------------
@@ -26,15 +41,17 @@
      MFMagicCuts cuts;
      cuts.SetHadronnessCut(MFMagicCuts::kArea);
-     cuts.SetThetaCut(MFMagicCuts::kOn);
+     cuts.SetThetaCut(MFMagicCuts::kNone);
 
      TArrayD arr(10);
      arr[0]=  1.3245;
      arr[1]=  0.208700;
-     arr[2]=  0.229200;
-     arr[3]=  5.305200;
-     arr[4]=  0.098930;
-     arr[5]= -0.082950;
-     arr[6]=  8.2957;
-     arr[7]=  0.8677;
+     arr[2]=  0.0836169;
+     arr[3]=  5.63973;
+     arr[4]=  0.0844195;
+     arr[5]= -0.07;
+     arr[6]=  13.2;
+     arr[7]=  1.0;
+     arr[8]=  7.2;
+     arr[9]=  0.5;
 
      cuts.SetVariables(arr);
@@ -47,26 +64,17 @@
 
      -------------------- Other cuts ----------------------
-     opt.AddPreCut("MNewImagePar.fLeakage1<0.0001");
-    */
+     */
 
-    opt.RunDisp("ganymedmcpart.root", r);
+    opt.RunDisp("ganymed00000001-summary.root", r);
 }
 
 /* ------------------ Good strategy -------------------
- 1) first fix parameters:
-      opt.FixParameter(1,  0);
-      opt.FixParameter(2,  1);
-    and process only showers without leakage
-      opt.AddPreCut("MNewImagePar.fLeakage1<0.0001");
- 2) release parameters 1 and 2 and fix 0 to the result of 1)
-      opt.FixParameter(0,  0.8362);
-      opt.SetParameter(1,  2.0);
-      opt.SetParameter(2,  0.8);
-    and process only showers with leakage
-      opt.AddPreCut("MNewImagePar.fLeakage1>0.0001");
- 3) release all parameters and start with the result of 1) and 2)
-      opt.SetParameter(0,  0.8362);
-      opt.SetParameter(1,  5.84);
-      opt.SetParameter(2,  0.76);
-    and process all showers. (Comment out opt.PreCuts())
- */
+
+   Par  |   0    1     2      3     4     |  Cut
+ -------+---------------------------------+-----------------------
+  Fit 1 |  1.3  0.8  fix=0  fix=0  fix=0  | Leak1==0 lgSize<2.5
+  Fit 2 |  fix  fix  fix=0   2.4    0.3   | Leak1==0
+  Fit 2 |  fix  fix   1.8    fix    fix   | Leak1>0
+  Fit 3 |  free free  fix    fix    fix   | -/-
+ -------+---------------------------------+-----------------------
+*/
