Index: trunk/Mars/fact/analysis/mc/callisto.C
===================================================================
--- trunk/Mars/fact/analysis/mc/callisto.C	(revision 17641)
+++ trunk/Mars/fact/analysis/mc/callisto.C	(revision 17699)
@@ -1,6 +1,7 @@
-using namespace std;
-
 #include <sstream>
 #include <iostream>
+
+#include "MLog.h"
+#include "MLogManip.h"
 
 #include "TH1F.h"
@@ -10,6 +11,6 @@
 #include "TLine.h"
 
+#include "../mcore/DrsCalib.h"
 #include "MDrsCalibration.h"
-//#include "MLogManip.h"
 #include "MExtralgoSpline.h"
 #include "MSequence.h"
@@ -45,4 +46,6 @@
 #include "MWriteAsciiFile.h"
 
+using namespace std;
+
 /* Maybe you wanna use this macro like this:
  * 
@@ -67,16 +70,39 @@
  */
 
-//using namespace std;
-
-int callisto(
-            const char *drs_calib_300_path="/fhgfs/groups/app/fact/mc_test/testingdrsfile/test300samples.drs.fits",
-            const char *pedestal_file_path="/fhgfs/groups/app/fact/mc_test/ceresfitstest/mcFilesForTests/mcNsbPedestal/00000001.001_P_MonteCarlo000_Events.fits",
-            const char *data_file_path="/fhgfs/groups/app/fact/mc_test/ceresfitstest/mcFilesForTests/mcProton/00000003.387_D_MonteCarlo010_Events.fits",
-            
-            const char *root_file_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto.root",
-            const char *status_display_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto_status_display.root", 
-            const char *status_display_title = "callisto_status_display")
+int callisto(const TString drsfile="test300samples.drs.fits",
+             const TString pedfile="00000001.001_P_MonteCarlo000_Events.fits",
+             const TString datfile="00000003.387_D_MonteCarlo010_Events.fits",
+             TString outfile = "",
+             TString displayfile = "", TString displaytitle = "")
 {
-    
+
+    // ======================================================
+
+    if (displaytitle.IsNull())
+        displaytitle = gSystem->BaseName(datfile);
+
+    FileStat_t fstat;
+    int rc = gSystem->GetPathInfo(outfile, fstat);
+    bool isdir = !rc || R_ISDIR(fstat.fMode);
+
+    const char *buf = gSystem->ConcatFileName(outfile, "callisto.root");
+    outfile = buf;
+    delete [] buf;
+
+    if (displayfile.IsNull())
+    {
+        displayfile = outfile;
+        displayfile.Insert(displayfile.Last('.'), "-display");
+    }
+    else
+    {
+        if (isdir && gSystem->DirName(displayfile)==TString("."))
+        {
+            buf = gSystem->ConcatFileName(outfile, displayfile);
+            displayfile = buf;
+            delete [] buf;
+        }
+    }
+
     // ======================================================
 
@@ -88,5 +114,5 @@
 
     // map file to use (get that from La Palma!)
-    const char *map = usemap ? "/fhgfs/groups/app/fact/resources/monte_carlo_FACTmap.txt" : NULL;
+    const char *map = usemap ? "TestForThomas/FACT/FACTmap111030.txt" : NULL;
 
     Bool_t maximum = kTRUE;
@@ -96,9 +122,5 @@
     //    "/cm/shared/apps/fact/Mars_svn_LP/template-lp-extractor-leading-edge.root";
 
-    const char *lp_template    = "/cm/shared/apps/fact/Mars_Trunk/template-lp.root";
-
-    //const char *pulse_template = "/cm/shared/apps/fact/Mars_svn_LP/template-pulse.root";
-
-    const char *pulse_template = "/cm/shared/apps/fact/Mars_Trunk/template-pulse.root";
+    const char *pulse_template = "TestForThomas/FACT/template-pulse.root";
 
     // ------------------------------------------------------
@@ -147,12 +169,8 @@
     }
 
-    TString datfile = TString(data_file_path);
-    TString drsfile = TString(drs_calib_300_path);
-    TString pedfile = TString(pedestal_file_path);
-
     gLog.Separator("Callisto");
-    gLog << all;    
-    gLog << "Data File        : " << datfile << "\n";
-    gLog << "DRS calib     300: " << drsfile << '\n';
+    gLog << all;
+    gLog << "Data File:     " << datfile << '\n';
+    gLog << "DRS calib 300: " << drsfile << endl;;
 
     MDrsCalibration drscalib300;
@@ -162,27 +180,26 @@
     }
     gLog << all;
-    gLog << "Pedestal     file: " << pedfile << '\n';
-
-    gLog << "root_file_output_path: " << root_file_output_path << endl;
-    gLog << "status_display_output_path: " << status_display_output_path << endl;
-    gLog << "status_display_title: " << status_display_title << endl;
+    gLog << "Pedestal file: " << pedfile << '\n';
+    gLog << "Output file:   " << outfile << '\n';
+    gLog << "Display file:  " << displayfile << '\n';
+    gLog << "Display title: " << displaytitle << endl;
 
     // ------------------------------------------------------
     MStatusArray arrt, arrp;
 
-    TFile ft(lp_template);
-    if (arrt.Read()<=0)
-    {
-        gLog << err << "ERROR - Reading LP template from " << lp_template << endl;
-        return 100;
-    }
-
-    MHCamera *lpref = (MHCamera*)arrt.FindObjectInCanvas("ExtCalSig;avg", "MHCamera", "Cam");
-    if (!lpref)
-    {
-        gLog << err << "ERROR - LP Template not found in " << lp_template << endl;
-        return 101;
-    }
-    lpref->SetDirectory(0);
+    // TFile ft(lp_template);
+    // if (arrt.Read()<=0)
+    // {
+    //     gLog << err << "ERROR - Reading LP template from " << lp_template << endl;
+    //     return 100;
+    // }
+
+    // MHCamera *lpref = (MHCamera*)arrt.FindObjectInCanvas("ExtCalSig;avg", "MHCamera", "Cam");
+    // if (!lpref)
+    // {
+    //     gLog << err << "ERROR - LP Template not found in " << lp_template << endl;
+    //     return 101;
+    // }
+    // lpref->SetDirectory(0);
 
     // MHCamera *gain = (MHCamera*)arrt.FindObjectInCanvas("gain", "MHCamera", "Gain");
@@ -619,12 +636,20 @@
     // The second rule is for the case reading raw-files!
     
-    MWriteRootFile write5(root_file_output_path, "RECREATE", "Calibrated Data", 2);
-    write5.AddContainer("MRawRunHeader", "RunHeaders");
-    write5.AddContainer("MGeomCam",      "RunHeaders");
-    write5.AddContainer("MSignalCam",    "Events");
-    write5.AddContainer("MTime",         "Events");
-    write5.AddContainer("MRawEvtHeader", "Events");
+    MWriteRootFile write5(outfile, "RECREATE", "Calibrated Data", 2);
+    write5.AddContainer("MRawRunHeader",       "RunHeaders");
+    write5.AddContainer("MGeomCam",            "RunHeaders");
+    write5.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
+    write5.AddContainer("MCorsikaRunHeader",   "RunHeaders", kFALSE);
+    write5.AddContainer("MMcRunHeader",        "RunHeaders", kFALSE);
+
+    // Common events
+    write5.AddContainer("MCorsikaEvtHeader",   "Events", kFALSE);
+    write5.AddContainer("MMcEvt",              "Events", kFALSE);
+    write5.AddContainer("IncidentAngle",       "Events", kFALSE);
+    write5.AddContainer("MPointingPos",        "Events", kFALSE);
+    write5.AddContainer("MSignalCam",          "Events");
+    write5.AddContainer("MTime",               "Events");
+    write5.AddContainer("MRawEvtHeader",       "Events");
     //write.AddContainer("MTriggerPattern", "Events");
-    
     
     // ------------------ Setup histograms and fill tasks ----------------
@@ -669,6 +694,6 @@
         return 19;
 
-    d->SetTitle(status_display_title, kFALSE);
-    d->SaveAs(status_display_output_path);
+    d->SetTitle(displaytitle, kFALSE);
+    d->SaveAs(displayfile);
 
     return 0;
Index: trunk/Mars/fact/analysis/mc/star.C
===================================================================
--- trunk/Mars/fact/analysis/mc/star.C	(revision 17641)
+++ trunk/Mars/fact/analysis/mc/star.C	(revision 17699)
@@ -1,4 +1,7 @@
 #include <sstream>
 #include <iostream>
+
+#include "MLog.h"
+#include "MLogManip.h"
 
 #include "TH1F.h"
@@ -8,4 +11,5 @@
 #include "TLine.h"
 
+#include "../mcore/DrsCalib.h"
 #include "MDrsCalibration.h"
 //#include "MLogManip.h"
@@ -53,17 +57,24 @@
 #include "MImgCleanStd.h"
 
-
 using namespace std;
 
-int star(
-    const char *mars_data_file_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto.root",
-    const char *root_output_file_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/star.root",
-    const char *status_display_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/star_status_display.root", 
-    const char *status_display_title = "star_status_display_title",
-    const char *hillas_txt_file_path = "/fhgfs/groups/app/callisto_star_test/star_hillas.txt",
-    Double_t lvl1=4.0, 
-    Double_t lvl2=2.5,
-    Double_t deltat = 17.5)
+int star(const TString callistofile, TString outfile,
+         TString displayfile, TString displaytitle,
+         const TString txtfile,
+         Double_t lvl1=4.0, Double_t lvl2=2.5, Double_t deltat = 17.5);
+
+
+int star(const TString infile = "callisto.root", TString outfile = "",
+         Double_t lvl1=4.0,  Double_t lvl2=2.5, Double_t deltat = 17.5)
 {
+    return star(infile, outfile, "", "", "", lvl1, lvl2, deltat);
+}
+
+int star(const TString callistofile, TString outfile,
+         TString displayfile,  TString displaytitle,
+         const TString txtfile,
+         Double_t lvl1, Double_t lvl2, Double_t deltat)
+{
+
     //Double_t lvl1=7.8, 
     //Double_t lvl2=3.9,
@@ -72,14 +83,43 @@
     // ------------------------------------------------------
 
+    if (displaytitle.IsNull())
+        displaytitle = gSystem->BaseName(callistofile);
+
+    FileStat_t fstat;
+    int rc = gSystem->GetPathInfo(outfile, fstat);
+    bool isdir = !rc || R_ISDIR(fstat.fMode);
+
+    char *buf = gSystem->ConcatFileName(outfile, "star.root");
+    outfile = buf;
+    delete [] buf;
+
+    if (displayfile.IsNull())
+    {
+        displayfile = outfile;
+        displayfile.Insert(displayfile.Last('.'), "-display");
+    }
+    else
+    {
+        if (isdir && gSystem->DirName(displayfile)==TString("."))
+        {
+            buf = gSystem->ConcatFileName(outfile, displayfile);
+            displayfile = buf;
+            delete [] buf;
+        }
+    }
+
+    // ------------------------------------------------------
+
     gLog.Separator("Star");
     gLog << all << "Calculate image parameters of sequence ";
     gLog << endl;
-    gLog << "mars_data_file_path: " << mars_data_file_path << endl;
-    gLog << "root_output_file_path: " << root_output_file_path << endl;
-    gLog << "status_display_output_path: " << status_display_output_path << endl;
-    gLog << "status_display_title: " << status_display_title << endl;
+    gLog << "Callisto file: " << callistofile << endl;
+    gLog << "Output file:   " << outfile << endl;
+    gLog << "Display file:  " << displayfile << endl;
+    gLog << "Display title: " << displaytitle << endl;
     gLog << endl;
-    gLog << "lvl1: " << lvl1 <<endl;
-    gLog << "lvl2: " << lvl2 <<endl;
+    gLog << "lvl1: "   << lvl1 <<endl;
+    gLog << "lvl2: "   << lvl2 <<endl;
+    gLog << "deltat: " << deltat <<endl;
     
     
@@ -152,5 +192,5 @@
     MReadMarsFile read("Events");
     read.DisableAutoScheme();
-    read.AddFile(mars_data_file_path);
+    read.AddFile(callistofile);
 
     MContinue cont("MRawEvtHeader.GetTriggerID!=4", "SelectData");
@@ -276,21 +316,30 @@
     // ---------------------------------------------------------------
 
-    MWriteAsciiFile write_ascii_hillas(hillas_txt_file_path, "MHillas");
-    write_ascii_hillas.AddColumns("MHillasExt");
-    write_ascii_hillas.AddColumns("MHillasSrc");
-
-
-    MWriteRootFile write(root_output_file_path, "RECREATE", "Image parameters", 2);
-    write.AddContainer("MTime",           "Events");
-    write.AddContainer("MHillas",         "Events");
-    write.AddContainer("MHillasExt",      "Events");
-    write.AddContainer("MHillasSrc",      "Events");
-    write.AddContainer("MImagePar",       "Events");
-    write.AddContainer("MNewImagePar",    "Events");
-    write.AddContainer("MRawEvtHeader",   "Events");
-    write.AddContainer("ThetaSquared",   "Events");
-    write.AddContainer("Disp",           "Events");
-    write.AddContainer("MRawRunHeader",   "RunHeaders");
-    write.AddContainer("MGeomCam",        "RunHeaders");
+    MWriteAsciiFile writeascii(txtfile, "MHillas");
+    writeascii.AddColumns("MHillasExt");
+    writeascii.AddColumns("MHillasSrc");
+
+
+    MWriteRootFile write(outfile, "RECREATE", "Image parameters", 2);
+    write.AddContainer("MTime",               "Events");
+    write.AddContainer("MHillas",             "Events");
+    write.AddContainer("MHillasExt",          "Events");
+    write.AddContainer("MHillasSrc",          "Events");
+    write.AddContainer("MImagePar",           "Events");
+    write.AddContainer("MNewImagePar",        "Events");
+    write.AddContainer("MRawEvtHeader",       "Events");
+    write.AddContainer("ThetaSquared",        "Events");
+    write.AddContainer("Disp",                "Events");
+    write.AddContainer("MCorsikaEvtHeader",   "Events", kFALSE);
+    write.AddContainer("MMcEvt",              "Events", kFALSE);
+    write.AddContainer("IncidentAngle",       "Events", kFALSE);
+    write.AddContainer("MPointingPos",        "Events", kFALSE);
+
+    write.AddContainer("MRawRunHeader",       "RunHeaders");
+    write.AddContainer("MGeomCam",            "RunHeaders");
+    write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
+    write.AddContainer("MCorsikaRunHeader",   "RunHeaders", kFALSE);
+    write.AddContainer("MMcRunHeader",        "RunHeaders", kFALSE);
+
     MFDataPhrase fmuonhn("MMuonCalibPar.fRelTimeSigma>=0",
                          "MuonHistCut");
@@ -351,5 +400,6 @@
     //tlist.AddToList(&writem);
     tlist.AddToList(&write);
-    tlist.AddToList(&write_ascii_hillas);
+    if (!txtfile.IsNull())
+        tlist.AddToList(&writeascii);
 
     if (!loop.Eventloop())
@@ -359,7 +409,8 @@
         return 4;
 
-    d->SetTitle(status_display_title, kFALSE);
-    d->SaveAs(status_display_output_path);
+    d->SetTitle(displaytitle, kFALSE);
+    d->SaveAs(displayfile);
 
     return 0;
 }
+
