void optimenergy()
{
    MJOptimizeEnergy opt;
    opt.SetDebug(2);
    opt.SetOptimizer(MJOptimize::kMigrad);
    opt.EnableTestTrain();

    // -------------------- Setup ----------------------------
    opt.AddParameter("MHillas.fSize");

    opt.FixParameter(0, 0.9, 0, 2);  //0.562676

    char *r = "[0]*M[0]";

    // -------------------- Run ----------------------------

    MStatusDisplay *d = new MStatusDisplay;
    opt.SetDisplay(d);

    //opt.AddPreCut("MNewImagePar.fLeakage1<0.0001");
    opt.RunEnergy("ganymedmcpart.root", r);
}
