Index: trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.cc	(revision 2313)
+++ trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.cc	(revision 2318)
@@ -38,4 +38,5 @@
 
 #include <TFile.h>
+#include <TArrayD.h>
 #include <TMinuit.h>
 #include <TCanvas.h>
@@ -117,6 +118,22 @@
     // transfer current parameter values to MCT1Supercuts
     //
-    super->SetParameters(TArrayD(npar, par));
-
+    // Attention : npar is the number of variable parameters
+    //                  not the total number of parameters
+    //
+    Double_t fMin, fEdm, fErrdef;
+    Int_t     fNpari, fNparx, fIstat;
+    gMinuit->mnstat(fMin, fEdm, fErrdef, fNpari, fNparx, fIstat);
+
+    super->SetParameters(TArrayD(fNparx, par));
+
+    //$$$$$$$$$$$$$$$$$$$$$
+    // for testing
+    //TArrayD checkparameters = super->GetParameters();
+    //gLog << "fcnsupercuts : i, par, checkparameters =" << endl;
+    //for (Int_t i=0; i<fNparx; i++)
+    //{
+    //  gLog << i << ",  " << par[i] << ",  " << checkparameters[i] << endl;
+    //}
+    //$$$$$$$$$$$$$$$$$$$$$
 
     //
@@ -629,5 +646,5 @@
 //
 // - for the minimization, the starting values of the parameters are taken as 
-//   MCT1Supercuts::GetParams(fVinit)
+//   MCT1Supercuts::GetParameters(fVinit)
 //
 //----------------------------------------------------------------------
@@ -651,4 +668,11 @@
     {
       *fLog << "MCT1FindSupercuts::FindParams; training matrix is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+    if (fMatrixTrain->GetM().GetNrows() <= 0)
+    {
+      *fLog << "MCT1FindSupercuts::FindParams; training matrix has no entries"
             << endl;
       return kFALSE;
@@ -737,17 +761,30 @@
     //
 
-    // get initial values of parameters from MCT1SupercutsCalc
+    // get initial values of parameters from MCT1Supercuts
     fVinit = super.GetParameters();
 
     TString name[fVinit.GetSize()];
-
-    for (Int_t i=0; i<fVinit.GetSize(); i++)
+    fStep.Set(fVinit.GetSize());
+    fLimlo.Set(fVinit.GetSize());
+    fLimup.Set(fVinit.GetSize());
+    fFix.Set(fVinit.GetSize());
+
+    fNpar = fVinit.GetSize();
+
+    for (UInt_t i=0; i<fNpar; i++)
     {
         name[i]   = "p";
         name[i]  += i+1;
         fStep[i]  = TMath::Abs(fVinit[i]/10.0);
-        fLimlo[i] = -10.0;
-        fLimup[i] =  10.0;
+        fLimlo[i] = -100.0;
+        fLimup[i] =  100.0;
         fFix[i]   =     0;
+
+        // vary only first 48 parameters
+        if (i >= 48)
+	{
+          fStep[i] = 0.0;
+          fFix[i]  =   1;
+	}
     }
 
@@ -757,4 +794,6 @@
     TStopwatch clock;
     clock.Start();
+
+    *fLog << "before calling CallMinuit" << endl;
 
     MMinuitInterface inter;               
@@ -763,4 +802,6 @@
                                  &evtloopfcn, "SIMPLEX", kFALSE);
  
+    *fLog << "after calling CallMinuit" << endl;
+
     *fLog << "Time spent for the minimization in MINUIT :   " << endl;;
     clock.Stop();
@@ -812,5 +853,6 @@
     if (fMatrixTest->GetM().GetNrows() <= 0)
     {
-        *fLog << "MCT1FindSupercuts::TestParams; test matrix is empty... aborting" << endl;
+        *fLog << "MCT1FindSupercuts::TestParams; test matrix has no entries" 
+              << endl;
         return kFALSE;
     }
Index: trunk/MagicSoft/Mars/manalysis/MCT1Supercuts.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1Supercuts.cc	(revision 2313)
+++ trunk/MagicSoft/Mars/manalysis/MCT1Supercuts.cc	(revision 2318)
@@ -162,8 +162,24 @@
 {
     if (d.GetSize() != fParameters.GetSize())
-        // *fLog << err << ...
+    {
+        *fLog << err << "Sizes of d and of fParameters are different : "
+              << d.GetSize() << ",  " << fParameters.GetSize() << endl;
         return kFALSE;
+    }
 
     fParameters = d;
+
     return kTRUE;
 }
+
+
+
+
+
+
+
+
+
+
+
+
Index: trunk/MagicSoft/Mars/manalysis/MMinuitInterface.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMinuitInterface.cc	(revision 2313)
+++ trunk/MagicSoft/Mars/manalysis/MMinuitInterface.cc	(revision 2318)
@@ -89,5 +89,5 @@
     //..............................................
     // Set the maximum number of parameters
-    TMinuit *const save = gMinuit;
+    //TMinuit *const save = gMinuit;
 
     TMinuit &minuit = *new TMinuit(vinit.GetSize());
@@ -284,6 +284,9 @@
     minuit.mnexcm("CALL", &iflag, 1, errfcn3);
 
-    delete &minuit;
-    gMinuit = save;
+    // WW : the following statements were commented out because the
+    // Minuit object will still be used;
+    // this may be changed in the future 
+    //delete &minuit;
+    //gMinuit = save;
 
     return kTRUE;
