Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/OptimizeDisp.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/OptimizeDisp.C	(revision 5906)
+++ trunk/MagicSoft/Mars/mtemp/mifae/macros/OptimizeDisp.C	(revision 5907)
@@ -19,17 +19,19 @@
 //
 // - and determines the free parameters p[0],p[1],p[2]... from MC gamma data 
-//   by minimizing a chi2 which measures the deviation of the estimated
+//   by minimizing a parameter which measures the deviation of the estimated
 //   source position (using DISP) and the true source position
 //
 // The following classes are used :
 //
-// MDisp          container holding the parameters p[0],p[1],p[2],...
-//
-//   ::Calc       member function calculating DISP for a given event;
-//                it is called by MDispCalc::Process()      
-//
-// MDispCalc      task calculating DISP with the parameters stored in MDisp
-//
-// MFindDisp      class with several functions :
+// MDispParameters  container holding the parameters p[0],p[1],p[2],...
+//
+// MDispCalc        task calculating DISP with the parameters stored in 
+//                  MDispParameters
+//
+//   ::Calc         member function where the DISP parameterization is 
+//                  defined. It calculates DISP for a given event;
+//                  it is called by MDispCalc::Process()      
+//
+// MFindDisp        class with several functions :
 //
 //  ::DefineTrainMatrix     \  member functions which generate the training
@@ -37,21 +39,21 @@
 //  ::DefineTrainTestMatrix /  from the MC gamma data
 //
-//  ::FindParams  member function steering the minimization
-//                (definition of the fcn function for Minuit, setting up the 
-//                event loop to be executed in each minimization step,
-//                call to Minuit);
-//                for the minimization the training matrix is used
-//
-//  ::TestParams  member function testing the quality of the DISP estimate;
-//                for the test the test matrix is used
-//
-// MHDisp         container for histograms which are useful for judging
-//                the quality of the DISP estimate
-//                Also task calculating the chi2 contribution of an event 
-//                (in Fill()) 
-//                and computing the final chi2 of the whole event sample 
-//                (in Finalize())
-//
-// MFDisp         filter to select sample for the optimization     
+//  ::FindParams    member function steering the minimization
+//                  (definition of the fcn function for Minuit, setting up the 
+//                  event loop to be executed in each minimization step,
+//                  call to Minuit);
+//                  for the minimization the training matrices are used
+//
+//  ::TestParams    member function testing the quality of the DISP estimate;
+//                  for the test the test matrices are used
+//
+// MHDisp           container for histograms which are useful for judging
+//                  the quality of the DISP estimate
+//                  Also task calculating the Minimization parameter
+//                  contribution of an event (in Fill()) 
+//                  and computing the final Minimization parameter of the 
+//                  whole event sample (in Finalize())
+//
+// MFDisp           filter to select sample for the optimization     
 //
 // 
@@ -73,7 +75,7 @@
                         //TString typeOpt = "Data";
                         TString typeOpt = "MC";
-    Bool_t RTest       = kFALSE;  // Test the quality of the Disp estimate
+    Bool_t RTest       = kTRUE;  // Test the quality of the Disp estimate
                                   // using the test matrix
-    Bool_t WDisp       = kTRUE;  // Make Disp plots for the data of type :
+    Bool_t WDisp       = kFALSE;  // Make Disp plots for the data of type :
                         //TString typeInput = "ON";
                         //TString typeInput = "OFF";
@@ -100,8 +102,9 @@
       "/home/pcmagic14/wittek/CalibData/CrabLow42/2004_10_17/";
     TString inPathMC  = 
-      "~domingo/MC/";
+    //"/discpepe/root_0.73mirror/wuerzburg/";
+    "~domingo/Munich/Munich/MC/";
     
     // path for output from Mars
-    TString outPath = "/mnt/home/pcmagic04/domingo/DispOptimization/";
+    TString outPath = "~domingo/Munich/Bcn05/DispOptimization/";
     
     //-----------------------------------------------
@@ -110,4 +113,5 @@
     const char *onfile   = "*CrabLowEn42*";
     const char *mcfile   = "starmc_Gammas_30-20_Period21.27ReducedMC.Zbins0-12";
+    //const char *mcfile   = "All_gammas0.73wuerzburg_zbin0to12_cleaned_3020_PeakSearch6_RunHeaders";
     //-----------------------------------------------
     
@@ -309,5 +313,5 @@
     //     - from the file parDispInit (if != "")
     //     - or from the arrays params and steps (if their sizes are != 0)
-    //     - or from the MDisp constructor
+    //     - or from the MDispParameters constructor
     //======================================================================
     
@@ -316,7 +320,7 @@
       gLog << "-----------------------------------------------------" << endl; 
       gLog << "Optimize the Disp parameters over a " 
-	   << typeOpt << " sample, using the training matrix" << endl;
-      
-      // Read training matrix from file
+	   << typeOpt << " sample, using the training matrices" << endl;
+      
+      // Read training matrices from file
       finddisp.ReadMatrix(fileMatrixTrain, fileMatrixTest);
 
@@ -326,5 +330,5 @@
       //    - the initial values are taken from the arrays params and steps
       //      if their sizes are different from 0
-      //    - otherwise they are taken from the MDisp constructor
+      //    - otherwise they are taken from the MDispParameters constructor
       
       TString parDispInit = outPath;
@@ -377,13 +381,13 @@
     if (RTest)
     {
-      // Read test matrix from file
+      // Read test matrices from file
       finddisp.ReadMatrix(fileMatrixTrain, fileMatrixTest);
       
       gLog << "-----------------------------------------------------" << endl; 
-      gLog << "Test the Disp parameters using on the test matrix" << endl;
+      gLog << "Test the Disp parameters using the test matrices" << endl;
       Bool_t rt = finddisp.TestParams();
       if (!rt) 
       {
-	gLog << "Test of the Disp parameters on the test matrix failed" 
+	gLog << "Test of the Disp parameters on the test matrices failed" 
 	     << endl;
       }
@@ -424,6 +428,6 @@
       
       TFile inparam(parDispFile);
-      MDisp dispin;
-      dispin.Read("MDisp");
+      MDispParameters dispin;
+      dispin.Read("MDispParameters");
       inparam.Close();
       
@@ -463,9 +467,4 @@
       //               3               the position according to M3Long
       //               4               the position according to Asym
-      MHDisp hdisp;
-      hdisp.SetSelectedPos(1);
-      MFillH filldisp("MHDisp", "");
-      filldisp.SetName("FillDispPlots");
-      
       MHDisp hdisp1;
       hdisp1.SetName("MHDispCorr");
@@ -494,5 +493,4 @@
       pliston.AddToList(&tliston);
       pliston.AddToList(&dispin);
-      pliston.AddToList(&hdisp);
       pliston.AddToList(&hdisp1);
       pliston.AddToList(&hdisp2);
@@ -507,5 +505,4 @@
 	tliston.AddToList(&contdisp);
       tliston.AddToList(&dispcalc);
-      tliston.AddToList(&filldisp);
       tliston.AddToList(&filldisp1);
       tliston.AddToList(&filldisp2);
@@ -532,5 +529,4 @@
       // Display the histograms
       //
-      //    hdisp.Draw();
       hdisp1.Draw();
       hdisp2.Draw();
