Index: trunk/Mars/hawc/callisto.C
===================================================================
--- trunk/Mars/hawc/callisto.C	(revision 19718)
+++ trunk/Mars/hawc/callisto.C	(revision 19719)
@@ -66,10 +66,10 @@
     // Range in which the pulse extraction searches for the
     // pulse (in samples).
-    const int first_slice = 100;
-    const int last_slice  = 500;
+    const int first_slice = 290;
+    const int last_slice  = 350;
 
     // Calibration constant (for the moment a single constant to
     // convert the extracted charge to photo-electrons)
-    double scale = 0.2;
+    double scale = 1./22.553;//0.2;
 
     // ------------------------------------------------------
@@ -179,9 +179,12 @@
     // ------------------ Setup the tasks ---------------
 
+    MDirIter files(datafile);
+
     // Instantiate the reading task
     // You can use
     //    read5.AddFiles("*.fits.fz")
     // for example to read more than one file at once
-    MRawFitsRead read5(datafile);
+    MRawFitsRead read5;
+    read5.AddFiles(files);
     if (mmap)
         read5.LoadMap(mmap);
@@ -278,4 +281,5 @@
     //MWriteRootFile write5(2, fname, "RECREATE", "Calibrated Data");
 
+    /*
     // Convert the name of the input file to the name of the output file
     TString fname = gSystem->ConcatFileName(outpath, gSystem->BaseName(datafile));
@@ -286,7 +290,11 @@
 
     gSystem->ExpandPathName(fname);
+    */
+
+    const TString rule(Form("s/(([0-9]+_)?[0-9.]+)_[PCD]_(.*)([.]fits)$/%s\\/$1_Y_$3.root/",
+                            MJob:: Esc(outpath).Data()));
 
     // Instantitate the writing task and setup the writing
-    MWriteRootFile write5(fname, "RECREATE", "Calibrated Data", 2);
+    MWriteRootFile write5(2, rule, "RECREATE", "Calibrated Data");
     write5.AddContainer("MSignalCam",      "Events");
     write5.AddContainer("MRawEvtHeader",   "Events");
@@ -340,12 +348,6 @@
     // ============================================================
 
-    // Check if the output file is still accessible from root
-    TFile *ofile = (TFile*)gROOT->GetListOfFiles()->FindObject(fname);
-    cout << ofile << endl;
-    if (!ofile || !ofile->IsOpen() || ofile->IsZombie())
-    {
-        gLog << err << "File " << fname << " not found" << endl;
-        return 20;
-    }
+    TString fname = write5.GetFileName();
+    fname.ReplaceAll(".root", "-display.root");
 
     // Write the status display to the file
@@ -355,6 +357,5 @@
     d->SetTitle(title, kFALSE);
 
-    ofile->cd();
-    d->Write();
+    d->SaveAsRoot(fname);
 
     return 0;
Index: trunk/Mars/hawc/star.C
===================================================================
--- trunk/Mars/hawc/star.C	(revision 19718)
+++ trunk/Mars/hawc/star.C	(revision 19719)
@@ -94,4 +94,6 @@
     loop.SetParList(&plist2);
 
+    MDirIter files(datafile);
+
     // Instantiate the reading task
     // You can use
@@ -100,5 +102,5 @@
     MReadMarsFile read("Events");
     read.DisableAutoScheme();
-    read.AddFile(datafile);
+    read.AddFiles(files);
 
     // Instantiate the task which takes care of the size of all containers
@@ -116,5 +118,5 @@
     MImgCleanTime clean;
     clean.SetMinCount(0);
-    clean.SetMinSize(50);
+    clean.SetMinSize(55);
     clean.SetDeltaT(17.5);
 
@@ -173,6 +175,9 @@
     //MWriteRootFile write5(2, fname, "RECREATE", "Image parameters");
 
+    const TString rule(Form("s/(([0-9]+_)?[0-9.]+)_Y_(.*)([.]root)$/%s\\/$1_Y_$3.root/",
+                            MJob:: Esc(outpath).Data()));
+
     // Instantiate writing the file
-    MWriteRootFile write(fname, "RECREATE", "Image parameters", 2);
+    MWriteRootFile write(2, rule, "RECREATE", "Image parameters");
     write.AddContainer("MTime",           "Events");
     write.AddContainer("MHillas",         "Events");
@@ -224,11 +229,6 @@
     // ============================================================
 
-    // Check if the output file is still accessible from root
-    TFile *ofile = (TFile*)gROOT->GetListOfFiles()->FindObject(fname);
-    if (!ofile || !ofile->IsOpen() || ofile->IsZombie())
-    {
-        gLog << err << "File " << fname << " not found" << endl;
-        return 20;
-    }
+    TString fname = write.GetFileName();
+    fname.ReplaceAll(".root", "-display.root");
 
     // Write the status display to the file
@@ -238,6 +238,5 @@
     d->SetTitle(title, kFALSE);
 
-    ofile->cd();
-    d->Write();
+    d->SaveAsRoot(fname);
 
     return 0;
