Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 8988)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 8989)
@@ -18,4 +18,62 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2008/07/01 Thomas Bretz
+
+   * ganymed.cc:
+     - removed the checks for the accessability of the files. They
+       are checked in the corresponding classes instead
+
+   * sponde.cc:
+     - display only the base name of the ganymed file, not the full path
+
+   * mbase/MMath.[h,cc]:
+     - added a new member function ErrorExc
+     - Let SignificanceExc (former SignificanceLiMaExc) use ErrorExc
+
+   * mhflux/MAlphaFitter.[h,cc]:
+     - replaced fSignificanceExc by fErrorExcess
+     - calculate the error instead of the significance (otherwise we
+       get infinity at 0)
+     - also store a negative number of excess events
+     - replaced all -1 in ProjectionZ calls by the histogram limits
+       (including under- and overflows) This is necessary to get
+       root 5.20/00 working
+     - increased class version number according to the changes
+
+   * mjobs/MDataSet.[h,cc], mjobs/MSequence.[h,cc]:
+     - removed wrong usage of fName and fTitle, introduced new data
+       members instead
+     - initialize fName and fTitle in the constructors correctly
+     - always store the full qualified path name
+     - introduced new member functions GetBaseName and GetFilePath
+     - give the ostream as an argument to Print
+     - added new member function WriteFile to directly Print to
+       an fostream
+     - do not print empty values in Print
+     - increased class version number accordingly
+     - removed GetName and GetRcName accordingly
+
+   * mjobs/MDataSet.cc:
+     - set the dataset number to an invalid status if the file could
+       not be accessed
+
+   * mjobs/MJCut.cc:
+     - replaced GetName for the dataset by GetBaseName
+     - make sure the summary file is not created if not requested
+     - do not use pointers to MWriteRootFile to make sure the instances
+       always get deleted
+
+   * mjobs/MJSpectrum.cc:
+     - fixed a bug in the check for the existence of the excess time
+     - replaced GetName for the dataset by GetBaseName
+     - Write the full path name to the ganymed.root into the file
+     - fixed typos in determine
+
+   * mpointing/MPointingDevCalc.cc:
+     - initialize fNsb* members also in PreProcess as correctly 
+       suggested by valgrind
+
+
 
  2008/06/30 Thomas Bretz
Index: /trunk/MagicSoft/Mars/ganymed.cc
===================================================================
--- /trunk/MagicSoft/Mars/ganymed.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/ganymed.cc	(revision 8989)
@@ -207,18 +207,4 @@
     }
 
-    gSystem->ExpandPathName(kSequences);
-
-    if (gSystem->AccessPathName(kSequences, kFileExists))
-    {
-        gLog << err << "Sorry, dataset file '" << kSequences << "' doesn't exist." << endl;
-        return 2;
-    }
-
-    if (gSystem->AccessPathName(kConfig, kFileExists))
-    {
-        gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
-        return 2;
-    }
-
     if (kDebugMem)
         TObject::SetObjectStat(kTRUE);
@@ -228,4 +214,9 @@
     //
     MDataSet seq(kSequences, (UInt_t)kNumDataset, kPathSequences, kPathDataFiles);
+    if (!seq.IsValid())
+    {
+        gLog << err << "ERROR - Reading dataset file " << kSequences << "." << endl;
+        return 0xfc;
+    }
     if (!seq.IsMonteCarlo())
         seq.SetMonteCarlo(kIsMc);
Index: /trunk/MagicSoft/Mars/mbase/MMath.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 8989)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.40 2008-06-30 09:36:35 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.41 2008-07-01 14:03:58 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -172,18 +172,26 @@
 //
 // Return Li/Ma (5) for the error of the excess, under the assumption that
-// the existance of a signal is already known.
-//
-Double_t MMath::SignificanceLiMaExc(Double_t s, Double_t b, Double_t alpha)
-{
-    Double_t Ns = s - alpha*b;
-    Double_t sN = s + alpha*alpha*b;
-
-    if (Ns<0 || sN<0)
+// the existance of a signal is already known. (basically signal/error
+// calculated by error propagation)
+//
+Double_t MMath::SignificanceExc(Double_t s, Double_t b, Double_t alpha)
+{
+    const Double_t error = ErrorExc(s, b, alpha);
+    if (error==0)
         return 0;
 
-    if (Ns==0 && sN==0)
-        return 0;
-
-    return Ns/TMath::Sqrt(sN);
+    const Double_t Ns = s - alpha*b;
+
+    return Ns/error;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the error of s-alpha*b by error propagation
+//
+Double_t MMath::ErrorExc(Double_t s, Double_t b, Double_t alpha)
+{
+    const Double_t sN = s + alpha*alpha*b;
+    return sN<0 ? 0 : TMath::Sqrt(sN);
 }
 
Index: /trunk/MagicSoft/Mars/mbase/MMath.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MMath.h	(revision 8988)
+++ /trunk/MagicSoft/Mars/mbase/MMath.h	(revision 8989)
@@ -37,5 +37,6 @@
     Double_t SignificanceLiMa(Double_t s, Double_t b, Double_t alpha=1);
     Double_t SignificanceLiMaSigned(Double_t s, Double_t b, Double_t alpha=1);
-    Double_t SignificanceLiMaExc(Double_t s, Double_t b, Double_t alpha=1);
+    Double_t SignificanceExc(Double_t s, Double_t b, Double_t alpha=1);
+    Double_t ErrorExc(Double_t s, Double_t b, Double_t alpha=1);
 
     void ReducePrecision(Float_t &val);
Index: /trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 8989)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -42,4 +42,9 @@
 //  + TArrayD fErrors;  // errors of coefficients
 //
+// Version 4:
+// ----------
+//  + Double_t fErrorExcess;
+//  - Double_t fSignificanceExc;
+//
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -68,5 +73,5 @@
 {
     fSignificance=0;
-    fSignificanceExc=0;
+    fErrorExcess=0;
     fEventsExcess=0;
     fEventsSignal=0;
@@ -168,12 +173,9 @@
     fEventsExcess     = fEventsSignal-fEventsBackground;
     fSignificance     = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground);
-    fSignificanceExc  = MMath::SignificanceLiMaExc(fEventsSignal, fEventsBackground);
+    fErrorExcess      = MMath::ErrorExc(fEventsSignal, fEventsBackground);
 
     // !Finitite includes IsNaN
     if (!TMath::Finite(fSignificance))
         fSignificance=0;
-
-    if (fEventsExcess<0)
-        fEventsExcess=0;
 }
 
@@ -282,5 +284,4 @@
     const Int_t bin = hon.GetXaxis()->FindFixBin(fSigInt*0.999);
 
-
     MAlphaFitter fit(*this);
     fit.EnableBackgroundFit();
@@ -290,4 +291,5 @@
     // off-source in the off-source region and the on-data in the source-region
     TH1D h(hof);
+    h.SetDirectory(0);
     h.Add(&hon);
     h.Scale(0.5);
@@ -342,4 +344,5 @@
 {
     TH1D h(hon);
+    h.SetDirectory(0);
     h.Add(&hof, -1); // substracts also number of entries!
     h.SetEntries(hon.GetEntries());
@@ -354,5 +357,4 @@
     fCoefficients = fit.GetCoefficients();
     fErrors       = fit.GetErrors();
-
 
     // ----------------------------------------------------------------------------
@@ -372,11 +374,9 @@
     fScaleFactor      = alpha;
     fSignificance     = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground/alpha, alpha);
-    fSignificanceExc  = MMath::SignificanceLiMaExc(fEventsSignal, fEventsBackground/alpha, alpha);
+    fErrorExcess      = MMath::ErrorExc(fEventsSignal, fEventsBackground/alpha, alpha);
 
     // !Finitite includes IsNaN
     if (!TMath::Finite(fSignificance))
         fSignificance=0;
-    if (fEventsExcess<0)
-        fEventsExcess=0;
 
     return kTRUE;
@@ -461,5 +461,5 @@
     // Result
     f.fSignificance     = fSignificance;
-    f.fSignificanceExc  = fSignificanceExc;
+    f.fErrorExcess      = fErrorExcess;
     f.fEventsExcess     = fEventsExcess;
     f.fEventsSignal     = fEventsSignal;
@@ -526,5 +526,5 @@
 {
     const TString name(Form("TempAlphaEnergy%06d", gRandom->Integer(1000000)));
-    TH1D *h = hon.ProjectionZ(name, -1, -1, bin, bin, "E");
+    TH1D *h = hon.ProjectionZ(name, 0, hon.GetNbinsX()+1, bin, bin, "E");
     h->SetDirectory(0);
 
@@ -537,5 +537,5 @@
 {
     const TString name(Form("TempAlphaTheta%06d", gRandom->Integer(1000000)));
-    TH1D *h = hon.ProjectionZ(name, bin, bin, -1, -1, "E");
+    TH1D *h = hon.ProjectionZ(name, bin, bin, 0, hon.GetNbinsY()+1, "E");
     h->SetDirectory(0);
 
@@ -563,5 +563,5 @@
 {
     const TString name(Form("TempAlpha%06d", gRandom->Integer(1000000)));
-    TH1D *h = hon.ProjectionZ(name, -1, -1, -1, -1, "E");
+    TH1D *h = hon.ProjectionZ(name, 0, hon.GetNbinsX()+1, 0, hon.GetNbinsY()+1, "E");
     h->SetDirectory(0);
 
@@ -576,6 +576,6 @@
     const TString name0(Form("TempAlpha%06d_off", gRandom->Integer(1000000)));
 
-    TH1D *h1 = hon.ProjectionZ(name1, -1, -1, bin, bin, "E");
-    TH1D *h0 = hof.ProjectionZ(name0, -1, -1, bin, bin, "E");
+    TH1D *h1 = hon.ProjectionZ(name1, 0, hon.GetNbinsX()+1, bin, bin, "E");
+    TH1D *h0 = hof.ProjectionZ(name0, 0, hof.GetNbinsX()+1, bin, bin, "E");
     h1->SetDirectory(0);
     h0->SetDirectory(0);
@@ -594,6 +594,6 @@
     const TString name0(Form("TempAlpha%06d_off", gRandom->Integer(1000000)));
 
-    TH1D *h1 = hon.ProjectionZ(name1, bin, bin, -1, -1, "E");
-    TH1D *h0 = hof.ProjectionZ(name0, bin, bin, -1, -1, "E");
+    TH1D *h1 = hon.ProjectionZ(name1, bin, bin, 0, hon.GetNbinsY()+1, "E");
+    TH1D *h0 = hof.ProjectionZ(name0, bin, bin, 0, hof.GetNbinsY()+1, "E");
     h1->SetDirectory(0);
     h0->SetDirectory(0);
@@ -636,6 +636,6 @@
     const TString name0(Form("TempAlpha%06d_off", gRandom->Integer(1000000)));
 
-    TH1D *h1 = hon.ProjectionZ(name1, -1, -1, -1, -1, "E");
-    TH1D *h0 = hof.ProjectionZ(name0, -1, -1, -1, -1, "E");
+    TH1D *h1 = hon.ProjectionZ(name1, 0, hon.GetNbinsX()+1, 0, hon.GetNbinsY()+1, "E");
+    TH1D *h0 = hof.ProjectionZ(name0, 0, hof.GetNbinsX()+1, 0, hof.GetNbinsY()+1, "E");
     h1->SetDirectory(0);
     h0->SetDirectory(0);
@@ -654,6 +654,6 @@
     const TString name0(Form("TempAlpha%06d_off", gRandom->Integer(1000000)));
 
-    TH1D *h1 = hon.ProjectionZ(name1, -1, -1, bin, bin, "E");
-    TH1D *h0 = hof.ProjectionZ(name0, -1, -1, bin, bin, "E");
+    TH1D *h1 = hon.ProjectionZ(name1, 0, hon.GetNbinsX()+1, bin, bin, "E");
+    TH1D *h0 = hof.ProjectionZ(name0, 0, hof.GetNbinsX()+1, bin, bin, "E");
     h1->SetDirectory(0);
     h0->SetDirectory(0);
Index: /trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 8988)
+++ /trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 8989)
@@ -56,5 +56,5 @@
     // Result
     Double_t fSignificance;     // significance of an unknown signal (Li/Ma 17)
-    Double_t fSignificanceExc;  // significance of a known excess    (Li/Ma 5)
+    Double_t fErrorExcess;      // Simple error propagation
     Double_t fEventsExcess;     // calculated number of excess events (signal-bg)
     Double_t fEventsSignal;     // calculated number of signal events
@@ -179,5 +179,5 @@
 
     Double_t GetSignificance() const       { return fSignificance; }
-    Double_t GetSignificanceExc() const    { return fSignificanceExc; }
+    Double_t GetErrorExcess() const        { return fErrorExcess; }
     Double_t GetChiSqSignal() const        { return fChiSqSignal; }
     Double_t GetChiSqBg() const            { return fChiSqBg; }
@@ -253,5 +253,5 @@
     Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
 
-    ClassDef(MAlphaFitter, 3)
+    ClassDef(MAlphaFitter, 4)
 };
 
Index: /trunk/MagicSoft/Mars/mjobs/MDataSet.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 8989)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 1/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2004-2007
+!   Copyright: MAGIC Software Development, 2004-2008
 !
 !
@@ -177,9 +177,19 @@
 //
 //
+// ===========================================================================
+//
 // ToDO:
 //   * Default paths could be moved into the global .rootrc
 //
+// ===========================================================================
+//
+//
+// Class Version 3:
+// ----------------
+//  + fFileName
+//  + fDataSet
 //
 // Class Version 2:
+// ----------------
 //  + fMonteCarlo
 //  + fWobbleMode
@@ -297,5 +307,5 @@
 
         // FIXME: The sequence number from the sequence file is assigned!!!
-        MSequence *seq = new MSequence(useds?fName:name, dir, num[i]);
+        MSequence *seq = new MSequence(useds?fFileName:name, dir, num[i]);
         seq->ExcludeRuns(excl);
 
@@ -354,6 +364,9 @@
 void MDataSet::Init(const char *fname, const UInt_t num, TString sequences, TString &data)
 {
+    fName  = "MDataSet";
+    fTitle = "DataSet file";
+
     // Store given file name as name
-    fName = fname;
+    fFileName = fname;
 
     // Delete the stored Sequences automatically at destruction
@@ -361,22 +374,25 @@
     fSequencesOff.SetOwner();
 
+    // Expand the file name (eg $MARS or ~ are expanded)
+    gSystem->ExpandPathName(fFileName);
+
+    // Check its accessibility
+    const Bool_t access = !gSystem->AccessPathName(fFileName, kFileExists);
+    if (!access)
+    {
+        gLog << err << "ERROR - Dataset file " << fname << " not accessible!" << endl;
+        fNumAnalysis = (UInt_t)-1;
+        return;
+    }
+
     // Determin the prefix to access this resource
     const TString prefix = num==(UInt_t)-1 ? "" : Form("%d", num);
 
-    // Expand the file name (eg $MARS or ~ are expanded)
-    TString expname(fname);
-    gSystem->ExpandPathName(expname);
-
-    // Check its accessibility
-    const Bool_t access = !gSystem->AccessPathName(expname, kFileExists);
-    if (!access)
-        gLog << err << "ERROR - Dataset file " << expname << " not accessible!" << endl;
-
     // Open and read the file
-    MEnv env(expname);
+    MEnv env(fFileName);
 
     // Get analysis number and name
     fNumAnalysis = GetEnvValue2(env, prefix, "AnalysisNumber", (Int_t)num);
-    fTitle       = GetEnvValue2(env, prefix, "Name", expname);
+    fDataSet     = GetEnvValue2(env, prefix, "Name", GetBaseName());
 
     // Get sequences from file
@@ -443,10 +459,18 @@
 //---------------------------------------------------------------------------
 //
-// Make sure that the name used for writing doesn't contain a full path
-//
-const char *MDataSet::GetName() const
-{
-    const char *pos = strrchr(GetRcName(), '/');
-    return pos>0 ? pos+1 : GetRcName();
+// Return the name of the file
+//
+const char *MDataSet::GetBaseName() const
+{
+    return gSystem->BaseName(fFileName);
+}
+
+//---------------------------------------------------------------------------
+//
+// Return the directory of the file
+//
+const char *MDataSet::GetFilePath() const
+{
+    return gSystem->DirName(fFileName);
 }
 
@@ -456,5 +480,5 @@
 // Return '+' if both can be accessed, '-' otherwise.
 //
-void MDataSet::PrintFile(const MSequence &seq)
+void MDataSet::PrintFile(ostream &out, const MSequence &seq)
 {
     const Char_t access =
@@ -462,5 +486,5 @@
         !gSystem->AccessPathName(seq.GetDataPath(), kFileExists) ? '+' : '-';
 
-    gLog << "#  " << access << " " << seq.GetFileName() << " <" << seq.GetDataPath() << ">" << endl;
+    out << "#  " << access << " " << seq.GetFileName() << " <" << seq.GetDataPath() << ">" << endl;
 }
 
@@ -469,61 +493,65 @@
 // Helper to print a seqeunce in Print()
 //
-void MDataSet::PrintSeq(const MSequence &seq) const
-{
-    const Bool_t useds = seq.GetFileName()==fName;
-
-    gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".File:   " << (useds?"-":seq.GetFileName()) << endl;
-    gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".Dir:    " << seq.GetDataPath() << endl;
+void MDataSet::PrintSeq(ostream &out, const MSequence &seq) const
+{
+    const Bool_t useds = seq.GetFileName()==fFileName;
+
+    out << "Sequence" << Form("%08d", seq.GetSequence()) << ".File:   " << (useds?"-":seq.GetFileName()) << endl;
+    out << "Sequence" << Form("%08d", seq.GetSequence()) << ".Dir:    " << seq.GetDataPath() << endl;
     if (!useds && seq.GetNumExclRuns()>0)
-        gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl;
+        out << "Sequence" << Form("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl;
 
     if (useds)
     {
-        gLog << endl;
-        seq.Print("prefixed");
-        gLog << endl << "# ---" << endl;
-    }
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Print the contents of the sequence
-//
-void MDataSet::Print(Option_t *o) const
-{
-    gLog << all;
+        out << endl;
+        seq.Print(out, "prefixed");
+        out << endl << "# ---" << endl;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the contents of the dataset to the ostream out
+//
+void MDataSet::Print(ostream &out, Option_t *o) const
+{
     if (!IsValid())
     {
-        gLog << "Dataset: " << fName << " <invalid - no analysis number available>" << endl;
+        out << "Dataset: " << fFileName << " <invalid - no analysis number available>" << endl;
         return;
     }
-    gLog << "# Path: " << GetRcName() << endl;
-    gLog << "# Name: " << GetName() << endl;
-    gLog << endl;
-    gLog << "AnalysisNumber: " << fNumAnalysis << endl << endl;
-
-    if (!fTitle.IsNull())
-        gLog << "Name: " << fTitle << endl << endl;
-
-    gLog << "SequencesOn:   ";
+    out << "# Path: " << GetFilePath() << endl;
+    out << "# Name: " << GetBaseName() << endl;
+    out << endl;
+    out << "AnalysisNumber: " << fNumAnalysis << endl << endl;
+
+    if (!fDataSet.IsNull())
+        out << "Name: " << fDataSet << endl << endl;
+
+    out << "SequencesOn:   ";
     for (int i=0; i<fNumSequencesOn.GetSize(); i++)
-        gLog << " " << fNumSequencesOn[i];
-    gLog << endl;
-    gLog << "SequencesOff:  ";
-    for (int i=0; i<fNumSequencesOff.GetSize(); i++)
-        gLog << " " << fNumSequencesOff[i];
-    gLog << endl << endl;
-
-    gLog << "SourceName: " << fNameSource << endl;
-    gLog << "Catalog: " << fCatalog << endl;
-
-    gLog << "WobbleMode: " << (fWobbleMode?"Yes":"No") << endl << endl;
-    gLog << "MonteCarlo: " << (fMonteCarlo?"Yes":"No") << endl << endl;
-
-    gLog << "Comment: " << fComment << endl;
+        out << " " << fNumSequencesOn[i];
+    out << endl;
+    if (fNumSequencesOff.GetSize()>0)
+    {
+        out << "SequencesOff:  ";
+        for (int i=0; i<fNumSequencesOff.GetSize(); i++)
+            out << " " << fNumSequencesOff[i];
+        out << endl;
+    }
+
+    out << endl;
+    if (!fNameSource.IsNull())
+        out << "SourceName: " << fNameSource << endl;
+    out << "Catalog: " << fCatalog << endl;
+
+    out << "WobbleMode: " << (fWobbleMode?"Yes":"No") << endl << endl;
+    out << "MonteCarlo: " << (fMonteCarlo?"Yes":"No") << endl << endl;
+
+    if (!fComment.IsNull())
+        out << "Comment: " << fComment << endl;
 
     if (fSequencesOn.GetEntries()>0)
-        gLog << endl;
+        out << endl;
 
     // FIXME: If file==fName --> print Sequence0000.content
@@ -533,26 +561,53 @@
     MSequence *seq=0;
     while ((seq=(MSequence*)NextOn()))
-        PrintSeq(*seq);
+        PrintSeq(out, *seq);
     if (fSequencesOff.GetEntries()>0)
-        gLog << endl;
+        out << endl;
     while ((seq=(MSequence*)NextOff()))
-        PrintSeq(*seq);
+        PrintSeq(out, *seq);
 
     if (TString(o).Contains("files", TString::kIgnoreCase))
     {
-        gLog << endl;
-        gLog << "# On-Data Files:" << endl;
+        out << endl;
+        out << "# On-Data Files:" << endl;
         NextOn.Reset();
         while ((seq=(MSequence*)NextOn()))
-            PrintFile(*seq);
-
-        gLog << endl;
-        gLog << "# Off-Data Files:" << endl;
+            PrintFile(out, *seq);
+
+        out << endl;
+        out << "# Off-Data Files:" << endl;
         NextOff.Reset();
         while ((seq=(MSequence*)NextOff()))
-            PrintFile(*seq);
+            PrintFile(out, *seq);
 
         return;
     }
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the contents of the dataset to the gLog stream
+//
+void MDataSet::Print(Option_t *o) const
+{
+    gLog << all;
+    Print(gLog, o);
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the contents of the dataset to the file with name filename
+//
+void MDataSet::WriteFile(const char *name, const Option_t *o) const
+{
+    ofstream fout(name);
+    if (!fout)
+    {
+        gLog << err << "Cannot open file " << name << ": ";
+        gLog << strerror(errno) << endl;
+        return;
+    }
+
+    Print(fout, o);
 }
 
@@ -755,4 +810,5 @@
 }
 
+/*
 // --------------------------------------------------------------------------
 //
@@ -786,2 +842,3 @@
     }
 }
+*/
Index: /trunk/MagicSoft/Mars/mjobs/MDataSet.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MDataSet.h	(revision 8988)
+++ /trunk/MagicSoft/Mars/mjobs/MDataSet.h	(revision 8989)
@@ -21,4 +21,7 @@
 private:
     static const TString fgCatalog; //! Default Catalog path
+
+    TString fFileName;        // File name to original file (MParContainer::fName is not streamed)
+    TString fDataSet;         // Name of the dataset given by the user
 
     UInt_t  fNumAnalysis;     // Analysis number (artificial)
@@ -45,10 +48,10 @@
     void ResolveSequences(const TEnv &env, const TString &prefix, const TArrayI &num, TList &list/*, const TString &sequences, const TString &data*/) const;
     Bool_t GetWobbleMode(const TEnv &env, const TString &prefix) const;
-    static void PrintFile(const MSequence &obj);
-    void PrintSeq(const MSequence &seq) const;
+    static void PrintFile(ostream &out, const MSequence &obj);
+    void PrintSeq(ostream &out, const MSequence &seq) const;
 
     // Directory and file handling
-    void ReplaceDir(TList &list, const TString &old, const TString &news) const;
-    void ReplaceFile(TList &list, const TString &old, const TString &news) const;
+    //void ReplaceDir(TList &list, const TString &old, const TString &news) const;
+    //void ReplaceFile(TList &list, const TString &old, const TString &news) const;
 
     void SetupDefaultPath(TString &path, const TString &def) const
@@ -72,10 +75,16 @@
 
 public:
-    MDataSet() : fNumAnalysis((UInt_t)-1) { }
+    MDataSet() : fNumAnalysis((UInt_t)-1)
+    {
+        fName  = "MDataSet";
+        fTitle = "DataSet file";
+    }
     MDataSet(const char *fname, TString sequences="", TString data="");
     MDataSet(const char *fname, Int_t num, TString sequences="", TString data="");
 
-    const char *GetName() const;
-    const char *GetRcName() const { return fName; }
+    const char    *GetBaseName() const;
+    const char    *GetFilePath() const;
+    const TString &GetFileName() const { return fFileName; }
+    const TString &GetDataSet()  const { return fDataSet;  }
 
     void Copy(TObject &obj) const
@@ -154,4 +163,5 @@
     Bool_t AddFilesOff(MDirIter &iter) const;
 
+    /*
     void ReplaceDir(const TString &old, const TString &news)
     {
@@ -165,10 +175,16 @@
         ReplaceFile(fSequencesOff, old, news);
     }
+    */
+
+    // I/O
+    void WriteFile(const char *filename, const Option_t *o) const;
+    void WriteFile(const char *filename) const { WriteFile(filename,""); } //*MENU *ARGS={filename=>fBaseName}
 
     // TObject
+    void Print(ostream &out, Option_t *o) const;
     void Print(Option_t *o) const;
     void Print() const { Print(""); } //*MENU*
 
-    ClassDef(MDataSet, 2)
+    ClassDef(MDataSet, 3)
 };
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 8989)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 1/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2007
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -461,5 +461,5 @@
     *fLog << inf;
     fLog->Separator(GetDescriptor());
-    *fLog << "Filling MHSrcPosCam " << set.GetName() << endl;
+    *fLog << "Filling MHSrcPosCam " << set.GetBaseName() << endl;
     *fLog << endl;
 
@@ -591,5 +591,5 @@
     *fLog << inf;
     fLog->Separator(GetDescriptor());
-    *fLog << "Perform cuts for data set " << set.GetName() << endl;
+    *fLog << "Perform cuts for data set " << set.GetBaseName() << endl;
     *fLog << endl;
 
@@ -693,9 +693,12 @@
     TString fname0(path);
     TString fname1(path);
-    fname0 += fNameSummary.IsNull() ?  (TString) Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary;
-    fname1 += fNameResult.IsNull()  ?  (TString) Form("ganymed%08d.root",         set.GetNumAnalysis()) : fNameResult;
-
-    MWriteRootFile *write0 = CanStoreSummary() ? new MWriteRootFile(fPathOut.IsNull()?0:fname0.Data(), fOverwrite?"RECREATE":"NEW") : 0;
-    MWriteRootFile *write1 = CanStoreResult()  ? new MWriteRootFile(fPathOut.IsNull()?0:fname1.Data(), fOverwrite?"RECREATE":"NEW") : 0;
+    fname0 += fNameSummary.IsNull() ? (TString) Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary;
+    fname1 += fNameResult.IsNull()  ? (TString) Form("ganymed%08d.root",         set.GetNumAnalysis()) : fNameResult;
+
+    MWriteRootFile dummy0(fPathOut.IsNull()||!CanStoreSummary()?0:fname0.Data(), fOverwrite?"RECREATE":"NEW");
+    MWriteRootFile dummy1(fPathOut.IsNull()||!CanStoreResult() ?0:fname1.Data(), fOverwrite?"RECREATE":"NEW");
+
+    MWriteRootFile *write0 = CanStoreSummary() ? &dummy0 : 0;
+    MWriteRootFile *write1 = CanStoreResult()  ? &dummy1 : 0;
     SetupWriter(write0, "WriteAfterCut0");
     SetupWriter(write1, "WriteAfterCut3");
@@ -1046,9 +1049,4 @@
     }
 
-    if (write0)
-        delete write0;
-    if (write1)
-        delete write1;
-
     // FIXME: Perform fit and plot energy dependant alpha plots
     // and fit result to new tabs!
Index: /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 8989)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 4/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2007
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -311,5 +311,5 @@
 
     TH1D *time   = (TH1D*)arr.FindObjectInCanvas("ExcessTime", "TH1D", "Hist");
-    if (!size)
+    if (!time)
     {
         *fLog << err;
@@ -690,5 +690,5 @@
 Bool_t MJSpectrum::Refill(MParList &plist, TH1D &h2)/*const*/
 {
-    // Try to find the class used to determin the signal!
+    // Try to find the class used to determine the signal!
     TString cls("MHAlpha");
     if (fDisplay)
@@ -1498,5 +1498,5 @@
     *fLog << inf;
     fLog->Separator(GetDescriptor());
-    *fLog << "Compile Monte Carlo sample (dataset " << set.GetName() << ")" << endl;
+    *fLog << "Compile Monte Carlo sample (dataset " << set.GetBaseName() << ")" << endl;
     *fLog << endl;
 
@@ -1539,5 +1539,5 @@
     if (ontime<0)
     {
-        *fLog << err << GetDescriptor() << ": Could not determin effective on time..." << endl;
+        *fLog << err << GetDescriptor() << ": Could not determine effective on time..." << endl;
         return kFALSE;
     }
@@ -1605,5 +1605,5 @@
     // -------------- Fill excess events versus energy ---------------
 
-    // Refill excess histogram to determin the excess events
+    // Refill excess histogram to determine the excess events
     TH1D excess;
     if (!Refill(plist, excess))
@@ -1877,5 +1877,5 @@
         return kTRUE;
 
-    TNamed ganame("ganymed.root", gSystem->BaseName(fPathIn));
+    TNamed ganame("ganymed.root", fPathIn.Data());
 
     // Write the output
Index: /trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 8989)
@@ -141,16 +141,27 @@
 //    seq.SetupPedRuns(iter, "/mypath", "[DPC]");
 //
+//
 // ===========================================================================
 //
+// ToDO:
+//   * Default paths could be moved into the global .rootrc
+//
+// ===========================================================================
+//
+//
 //  Class Version 2:
+//  ----------------
 //   + fMonteCarlo
 //
 //  Class Version 3:
+//  ----------------
 //   + fComment
 //
 //  Class Version 4:
+//  ----------------
 //   + fExclRuns
 //
 //  Class Version 5:
+//  ----------------
 //   + fRunsSub
 //   + fDatRunsSub
@@ -163,4 +174,7 @@
 
 #include <stdlib.h>
+#include <errno.h>
+
+#include <fstream>
 
 #include <TEnv.h>
@@ -538,5 +552,5 @@
         *fLog << err;
         *fLog << "ERROR - No input files for sequence #" << GetSequence() << endl;
-        *fLog << "        read from " << GetName() << endl;
+        *fLog << "        read from " << GetBaseName() << endl;
         *fLog << "        found in" << (def?" default-path ":" ") << d << endl;
         return 0;
@@ -550,5 +564,5 @@
     *fLog << "        " << (def?" default-path ":" ") << d << endl;
     *fLog << "        but " << n2 << " files were defined in sequence file" << endl;
-    *fLog << "        " << GetName() << endl;
+    *fLog << "        " << GetBaseName() << endl;
     if (fLog->GetDebugLevel()<=4)
         return 0;
@@ -580,5 +594,5 @@
 
     gLog << warn;
-    gLog << "WARNING - in " << fFileName << ":" << endl;
+    gLog << "WARNING - in " << GetBaseName() << ":" << endl;
     gLog << "          LightCondition-tag is '" << str << "' but must be n/a, no_moon, twilight, moon or day." << endl;
     return kNA;
@@ -591,22 +605,22 @@
 MSequence::MSequence(const char *fname, const char *path, UInt_t seq)
 {
-    fName  = fname;
-    fTitle = path;
+    fName  = "MSequence";
+    fTitle = "Sequence file";
 
     fFileName = fname;
     fDataPath = path;
 
-    gSystem->ExpandPathName(fName);
-    gSystem->ExpandPathName(fTitle);
-
-    const Bool_t rc1 = gSystem->AccessPathName(fName, kFileExists);
-    const Bool_t rc2 = !fTitle.IsNull() && gSystem->AccessPathName(fTitle, kFileExists);
+    gSystem->ExpandPathName(fFileName);
+    gSystem->ExpandPathName(fDataPath);
+
+    const Bool_t rc1 = gSystem->AccessPathName(fFileName, kFileExists);
+    const Bool_t rc2 = !fDataPath.IsNull() && gSystem->AccessPathName(fDataPath, kFileExists);
 
     if (rc1)
-        gLog << err << "ERROR - Sequence file '" << fName << "' doesn't exist." << endl;
+        gLog << err << "ERROR - Sequence file '" << fname << "' doesn't exist." << endl;
     if (rc2)
-        gLog << err << "ERROR - Directory '" << fTitle << "' doesn't exist." << endl;
-
-    MEnv env(fName);
+        gLog << err << "ERROR - Directory '" << path << "' doesn't exist." << endl;
+
+    MEnv env(fFileName);
 
     fSequence = (UInt_t)env.GetValue("Sequence", (Int_t)seq);
@@ -659,8 +673,16 @@
 // Make sure that the name used for writing doesn't contain a full path
 //
-const char *MSequence::GetName() const
-{
-    const char *pos = strrchr(GetRcName(), '/');
-    return pos>0 ? pos+1 : GetRcName();
+const char *MSequence::GetBaseName() const
+{
+    return gSystem->BaseName(fFileName);
+}
+
+//---------------------------------------------------------------------------
+//
+// Make sure that the name used for writing doesn't contain a full path
+//
+const char *MSequence::GetFilePath() const
+{
+    return gSystem->DirName(fFileName);
 }
 
@@ -752,10 +774,10 @@
 // simplyfing the file setup
 //
-TString MSequence::PrintRuns(const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const
+TString MSequence::PrintRuns(ostream &out, const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const
 {
     if (r.GetSize()==0)
         return "";
 
-    gLog << pre << name;
+    out << pre << name;
     if (f.GetSize()==0)
         const_cast<TArrayI&>(f).Set(r.GetSize());
@@ -763,6 +785,6 @@
 #ifdef DEBUG
     for (int i=0; i<r.GetSize(); i++)
-        gLog << "  " << r[i] << "." << f[i];
-    gLog << endl;
+        out << "  " << r[i] << "." << f[i];
+    out << endl;
     return "";
 #endif
@@ -776,5 +798,5 @@
         if (!rc.IsNull())
         {
-            gLog << rc;
+            out << rc;
             continue;
         }
@@ -788,7 +810,7 @@
         if (n==1)
         {
-            gLog << " " << r[pos];
+            out << " " << r[pos];
             if (f[pos]>0)
-                gLog << "." << f[pos];
+                out << "." << f[pos];
         }
         else
@@ -802,12 +824,12 @@
             if (isseq)
             {
-                gLog << " " << r[pos] << ".";
+                out << " " << r[pos] << ".";
                 if (f[pos]!=0)
-                    gLog << f[pos];
-                gLog << ":" << f[pos+n-1];
+                    out << f[pos];
+                out << ":" << f[pos+n-1];
             }
             else
             {
-                gLog << " " << r[pos] << "+";
+                out << " " << r[pos] << "+";
 
                 str += '\n';
@@ -821,5 +843,5 @@
     }
 
-    gLog << endl;
+    out << endl;
 
     return str;
@@ -830,10 +852,10 @@
 // Print the numbers in the classical way (one run after the other)
 //
-void MSequence::PrintRunsClassic(const char *pre, const char *name, const TArrayI &r) const
-{
-    gLog << pre << name;
+void MSequence::PrintRunsClassic(ostream &out, const char *pre, const char *name, const TArrayI &r) const
+{
+    out << pre << name;
     for (int i=0; i<r.GetSize(); i++)
-        gLog << " " << r[i];
-    gLog << endl;
+        out << " " << r[i];
+    out << endl;
 }
 
@@ -842,5 +864,5 @@
 // Print the contents of the sequence
 //
-void MSequence::Print(Option_t *o) const
+void MSequence::Print(ostream &out, Option_t *o) const
 {
     const TString opt(o);
@@ -848,61 +870,102 @@
     const TString pre = opt.Contains("prefixed") ? Form("Sequence%08d.", fSequence) : "";
 
-    gLog << all;
     if (!IsValid())
     {
-        gLog << pre << "Sequence: " << fFileName << " <invalid>" << endl;
+        out << pre << "Sequence: " << fFileName << " <invalid>" << endl;
         return;
     }
-    gLog << "# Path: " << GetRcName() << endl;
-    gLog << "# Name: " << GetName() << endl;
-    gLog << endl;
+    out << "# Path: " << GetFileName() << endl;
+    out << "# Name: " << GetBaseName() << endl;
+    out << endl;
     if (pre.IsNull())
-        gLog << "Sequence:       " << fSequence << endl;
+        out << "Sequence:       " << fSequence << endl;
     if (fMonteCarlo)
-        gLog << pre << "MonteCarlo:     Yes" << endl;
-    gLog << pre <<"Period:         " << fPeriod << endl;
-    gLog << pre << "Night:          " << fNight << endl << endl;
-    gLog << pre << "LightCondition: ";
+        out << pre << "MonteCarlo:     Yes" << endl;
+    if (fPeriod>=0)
+        out << pre << "Period:         " << fPeriod << endl;
+    if (fNight!=MTime())
+        out << pre << "Night:          " << fNight << endl;
+    out << endl;
+    out << pre << "LightCondition: ";
     switch (fLightCondition)
     {
-    case kNA:       gLog << "n/a" << endl;      break;
-    case kNoMoon:   gLog << "NoMoon" << endl;   break;
-    case kTwilight: gLog << "Twilight" << endl; break;
-    case kMoon:     gLog << "Moon" << endl;     break;
-    case kDay:      gLog << "Day" << endl;     break;
-    }
-    gLog << pre << "Start:          " << fStart << endl;
-    gLog << pre << "LastRun:        " << fLastRun << endl;
-    gLog << pre << "NumEvents:      " << fNumEvents << endl;
-    gLog << pre << "Project:        " << fProject << endl;
-    gLog << pre << "Source:         " << fSource << endl;
-    gLog << pre << "TriggerTable:   " << fTriggerTable << endl;
-    gLog << pre << "HvSettings:     " << fHvSettings << endl << endl;
+    case kNA:       out << "n/a" << endl;      break;
+    case kNoMoon:   out << "NoMoon" << endl;   break;
+    case kTwilight: out << "Twilight" << endl; break;
+    case kMoon:     out << "Moon" << endl;     break;
+    case kDay:      out << "Day" << endl;     break;
+    }
+
+    if (fStart!=MTime())
+        out << pre << "Start:          " << fStart << endl;
+    if (fLastRun>=0)
+        out << pre << "LastRun:        " << fLastRun << endl;
+    if (fNumEvents>=0)
+        out << pre << "NumEvents:      " << fNumEvents << endl;
+    if (!fProject.IsNull())
+        out << pre << "Project:        " << fProject << endl;
+    if (!fSource.IsNull())
+        out << pre << "Source:         " << fSource << endl;
+    if (!fTriggerTable.IsNull())
+        out << pre << "TriggerTable:   " << fTriggerTable << endl;
+    if (!fHvSettings.IsNull())
+        out << pre << "HvSettings:     " << fHvSettings << endl;
+    out << endl;
 
     TString str;
     if (!HasSubRuns() && opt.Contains("classic"))
     {
-        PrintRunsClassic(pre, "Runs:     ", fRuns);
-        PrintRunsClassic(pre, "CalRuns:  ", fCalRuns);
-        PrintRunsClassic(pre, "PedRuns:  ", fPedRuns);
-        PrintRunsClassic(pre, "DataRuns: ", fDatRuns);
-        PrintRunsClassic(pre, "Exclude:  ", fExclRuns);
+        PrintRunsClassic(out, pre, "Runs:     ", fRuns);
+        PrintRunsClassic(out, pre, "CalRuns:  ", fCalRuns);
+        PrintRunsClassic(out, pre, "PedRuns:  ", fPedRuns);
+        PrintRunsClassic(out, pre, "DataRuns: ", fDatRuns);
+        PrintRunsClassic(out, pre, "Exclude:  ", fExclRuns);
     }
     else
     {
-        str += PrintRuns(pre, "Runs:     ", fRuns,     fRunsSub);
-        str += PrintRuns(pre, "CalRuns:  ", fCalRuns,  fCalRunsSub);
-        str += PrintRuns(pre, "PedRuns:  ", fPedRuns,  fPedRunsSub);
-        str += PrintRuns(pre, "DataRuns: ", fDatRuns,  fDatRunsSub);
-        str += PrintRuns(pre, "Exclude:  ", fExclRuns, fExclRunsSub);
+        str += PrintRuns(out, pre, "Runs:     ", fRuns,     fRunsSub);
+        str += PrintRuns(out, pre, "CalRuns:  ", fCalRuns,  fCalRunsSub);
+        str += PrintRuns(out, pre, "PedRuns:  ", fPedRuns,  fPedRunsSub);
+        str += PrintRuns(out, pre, "DataRuns: ", fDatRuns,  fDatRunsSub);
+        str += PrintRuns(out, pre, "Exclude:  ", fExclRuns, fExclRunsSub);
     }
 
     if (!fDataPath.IsNull())
-        gLog << endl << pre << "DataPath: " << fDataPath << endl;
+        out << endl << pre << "DataPath: " << fDataPath << endl;
 
     if (!str.IsNull())
-        gLog << str << endl;
-
-    gLog << endl << pre << "Comment: " << fComment << endl;
+        out << str << endl;
+
+    out << endl;
+
+    if (!fComment.IsNull())
+        out << pre << "Comment: " << fComment << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the contents of the sequence to gLog
+//
+void MSequence::Print(Option_t *o) const
+{
+    gLog << all;
+    Print(gLog, o);
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the contents of the sequence to the file with name filename
+//
+void MSequence::WriteFile(const char *name, const Option_t *o) const
+{
+    ofstream fout(name);
+    if (!fout)
+    {
+        gLog << err << "Cannot open file " << name << ": ";
+        gLog << strerror(errno) << endl;
+        return;
+    }
+
+    Print(fout, o);
 }
 
Index: /trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 8988)
+++ /trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 8989)
@@ -22,16 +22,16 @@
     };
 private:
-    TString fFileName;
-    TString fDataPath;
+    TString fFileName;         // Expanded file name
+    TString fDataPath;         // Path to data files
 
-    UInt_t fSequence;
+    UInt_t fSequence;          // Sequence number
 
-    MTime  fStart;
+    MTime  fStart;             // Start time of sequence
 
-    UInt_t fLastRun;
-    UInt_t fNumEvents;
+    UInt_t fLastRun;           // Last run in sequence (necessary?)
+    UInt_t fNumEvents;         // Number of events in sequence
 
-    UInt_t fPeriod;
-    MTime  fNight;
+    UInt_t fPeriod;            // Observation period of the sequence
+    MTime  fNight;             // Night (day of sunrise) of the sequence
 
     LightCondition_t fLightCondition;
@@ -43,20 +43,20 @@
     TString fComment;
 
-    TArrayI fRuns;
-    TArrayI fRunsSub;
+    TArrayI fRuns;            // Run numbers
+    TArrayI fRunsSub;         // Sub runs (files)
 
-    TArrayI fCalRuns;
-    TArrayI fCalRunsSub;
+    TArrayI fCalRuns;         // Numbers of calibration runs/files
+    TArrayI fCalRunsSub;      // Sub runs (files) of calibration runs
 
-    TArrayI fPedRuns;
-    TArrayI fPedRunsSub;
+    TArrayI fPedRuns;         // Numbers of pedestal runs/files
+    TArrayI fPedRunsSub;      // Sub runs (files) of pedestal runs
 
-    TArrayI fDatRuns;
-    TArrayI fDatRunsSub;
+    TArrayI fDatRuns;         // Numbers of data runs/files
+    TArrayI fDatRunsSub;      // Sub runs (files) of data runs
 
-    TArrayI fExclRuns;
-    TArrayI fExclRunsSub;
+    TArrayI fExclRuns;        // Numbers of excluded runs/files
+    TArrayI fExclRunsSub;     // Sub runs (files) of excluded runs
 
-    Bool_t fMonteCarlo;
+    Bool_t fMonteCarlo;       // Flag for Monte Carlo sequences
 
     // Helper for interpretation
@@ -78,6 +78,6 @@
     TString GetNumSequence(Int_t &pos, const TArrayI &n, const TArrayI &f) const;
 
-    void    PrintRunsClassic(const char *pre, const char *name, const TArrayI &r) const;
-    TString PrintRuns(const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const;
+    void    PrintRunsClassic(ostream &out, const char *pre, const char *name, const TArrayI &r) const;
+    TString PrintRuns(ostream &out, const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const;
 
     // General helper
@@ -92,7 +92,13 @@
 public:
     MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
-        fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fMonteCarlo(kFALSE) { }
+        fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fMonteCarlo(kFALSE)
+    {
+        fName  = "MSequence";
+        fTitle = "Sequence file";
+    }
     MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1);
-    MSequence(const MSequence &s) : fSequence(s.fSequence), fStart(s.fStart),
+    MSequence(const MSequence &s) : MParContainer(s),
+        fFileName(s.fFileName), fDataPath(s.fDataPath),
+        fSequence(s.fSequence), fStart(s.fStart),
         fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod),
         fNight(s.fNight), fProject(s.fProject), fSource(s.fSource),
@@ -101,10 +107,12 @@
         fDatRuns(s.fDatRuns), fMonteCarlo(s.fMonteCarlo) { }
 
+    // I/O
+    void WriteFile(const char *filename, const Option_t *o) const;
+    void WriteFile(const char *filename) const { WriteFile(filename,""); } //*MENU *ARGS={filename=>fBaseName}
+
     // TObject
+    void Print(ostream &out, Option_t *o) const;
     void Print(Option_t *o) const;
     void Print() const { Print(""); } //*MENU*
-
-    const char *GetName() const;
-    const char *GetRcName() const { return fName; }
 
     // Genaral interface
@@ -151,4 +159,6 @@
 
     // Filesystem getter
+    const char    *GetBaseName() const;
+    const char    *GetFilePath() const;
     const TString &GetFileName() const { return fFileName; }
     const TString &GetDataPath() const { return fDataPath; }
Index: /trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc	(revision 8989)
@@ -491,4 +491,10 @@
     fSkip.Reset();
 
+    // In cases in which ReInit isn't called right in time (e.g. if
+    // the first starguider event comes before the first data event)
+    fNsbSum   =  0;
+    fNsbSq    =  0;
+    fNsbCount =  0;
+
     return fDeviation ? kTRUE : kFALSE;
 }
Index: /trunk/MagicSoft/Mars/sponde.cc
===================================================================
--- /trunk/MagicSoft/Mars/sponde.cc	(revision 8988)
+++ /trunk/MagicSoft/Mars/sponde.cc	(revision 8989)
@@ -237,5 +237,5 @@
     //
     {
-        MJSpectrum job(Form("Spectrum - %s", kInfile.Data()));
+        MJSpectrum job(Form("Spectrum - %s", gSystem->BaseName(kInfile)));
         job.SetEnv(&env);
         job.SetEnvDebug(kDebugEnv);
