Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 6590)
+++ trunk/MagicSoft/Mars/Changelog	(revision 6591)
@@ -22,4 +22,18 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2005/02/18 Thomas Bretz
+
+   * mbase/MStatusDisplay.cc:
+     - switch off TH1::AddDirectory during DrawClonePad
+
+   * mjobs/MSequence.[h,cc]:
+     - added some code (still commented) for later use, 
+       allowing to setup a different filename for each runfile
+     - added SetNight member function
+     - added Add*Runs member function
+     - with this changes MSequence can replace MRunIter now
+
+
+
  2005/02/17 Markus Gaug
 
@@ -36,4 +50,6 @@
    * msignal/MExtractTimeAndChargeDigitalFilter.cc
      - calculate high-gain signal even if saturation occurs
+
+
 
  2005/02/17 Thomas Bretz
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 6590)
+++ trunk/MagicSoft/Mars/NEWS	(revision 6591)
@@ -83,4 +83,7 @@
     - enhanced possibility to debug reading of resource file
 
+    - MDataChain should handle priorities of operator more 
+      accurate now
+
 
 
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 6590)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 6591)
@@ -63,4 +63,5 @@
 #include <fstream>                // fstream
 
+#include <TH1.h>                  // TH1::AddDirectory
 #include <TLine.h>                // TLine
 #include <TText.h>                // TText
@@ -1614,4 +1615,7 @@
     oldc.cd();
 
+    const Bool_t store = TH1::AddDirectoryStatus();
+    TH1::AddDirectory(kFALSE);
+
     //copy primitives
     TObject *obj;
@@ -1644,4 +1648,6 @@
     newc.Modified();
     newc.Update();
+
+    TH1::AddDirectory(store);
 
     padsav->cd();
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 6590)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 6591)
@@ -93,4 +93,28 @@
 // ===========================================================================
 //
+//  For special cases you can also setup a sequence directly from a macro,
+//  for example:
+//
+//    MDirIter pediter, datiter, caliter;
+//
+//    MSequence seq;
+//    seq.SetNight("2004-07-06");
+//    seq.AddPedRuns(31751);
+//    seq.AddCalRuns(31752);
+//    seq.AddDatRuns(31753, 31764);
+//    seq.SetupPedRuns(pediter);
+//    seq.SetupCalRuns(caliter);
+//    seq.SetupDatRuns(datiter);
+//
+//  or
+//
+//    MDirIter iter;
+//
+//    MSequence seq;
+//    seq.SetNight("2004-07-06");
+//    seq.AddRuns(31753, 31764);
+//    seq.SetupRuns(iter);
+//    seq.SetupPedRuns(iter, "/mypath", "[DPC]");
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MSequence.h"
@@ -105,4 +129,5 @@
 #include "MLogManip.h"
 
+#include "MAstro.h"
 #include "MDirIter.h"
 
@@ -110,4 +135,17 @@
 
 using namespace std;
+
+MSequence::~MSequence()
+{
+    /*
+    TExMapIter iter(&fFileNames);
+
+    Long_t key, val;
+
+    while (iter.Next(key, val))
+        delete (TString*)val;
+        */
+}
+
 
 // --------------------------------------------------------------------------
@@ -134,5 +172,5 @@
 }
 
-Int_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw) const
+UInt_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw) const
 {
     TString d(path);
@@ -167,4 +205,38 @@
 
     return iter.GetNumEntries();
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the file fname as setup file for the sequence.
+//
+void MSequence::GetFileNames(TEnv &env, const TArrayI &arr)
+{
+    /*
+    for (int i=0; i<arr.GetSize(); i++)
+    {
+        // Get run number
+        const Int_t num = arr[i];
+
+        // Check if name already set
+        if (fFileNames.GetValue(num))
+            continue;
+
+        TString *str = new TString(env.GetValue(Form("%d", num), ""));
+        fFileNames.Add(num, (Long_t)str);
+        }
+        */
+}
+
+// --------------------------------------------------------------------------
+//
+// Get a file name corresponding to the run-number num, returns 0 if n/a
+//
+const char *MSequence::GetFileName(UInt_t num)
+{
+    return 0;
+    /*
+    TString *str = (TString*)fFileNames.GetValue(num);
+    return str ? str->Data() : 0;*/
 }
 
@@ -210,4 +282,9 @@
     str = env.GetValue("DatRuns", "");
     Split(str, fDatRuns);
+
+    GetFileNames(env, fRuns);
+    GetFileNames(env, fCalRuns);
+    GetFileNames(env, fPedRuns);
+    GetFileNames(env, fDatRuns);
 }
 
@@ -260,5 +337,5 @@
 // Return the number of files added.
 //
-Int_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
+UInt_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
 {
     return SetupRuns(iter, fPedRuns, path, id, raw);
@@ -273,5 +350,5 @@
 // Return the number of files added.
 //
-Int_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
+UInt_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
 {
     return SetupRuns(iter, fDatRuns, path, id, raw);
@@ -286,5 +363,5 @@
 // Return the number of files added.
 //
-Int_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
+UInt_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
 {
     return SetupRuns(iter, fRuns, path, id, raw);
@@ -299,6 +376,56 @@
 // Return the number of files added.
 //
-Int_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
+UInt_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
 {
     return SetupRuns(iter, fCalRuns, path, id, raw);
 }
+
+// --------------------------------------------------------------------------
+//
+// If you want to add runs manually, use this function.
+//
+UInt_t MSequence::AddRuns(UInt_t first, UInt_t last, TArrayI *runs)
+{
+    if (last<first)
+    {
+        *fLog << warn << "MSequence::AddRuns - WARNING: Last runnumber " << last;
+        *fLog << " smaller than first " << first << "... ignored." << endl;
+        return 0;
+    }
+    if (!IsValid())
+    {
+        *fLog << inf << "Setting Sequence number to #" << first << endl;
+        fSequence = first;
+    }
+
+    const UInt_t nall = fRuns.GetSize();
+    const UInt_t nrun = runs ? runs->GetSize() : 0;
+    const UInt_t add  = last-first+1;
+
+    fRuns.Set(nall+add);
+    if (runs)
+        runs->Set(nrun+add);
+
+    for (UInt_t i=0; i<add; i++)
+    {
+        fRuns[nall+i] = first+i;
+        if (runs)
+            (*runs)[nrun+i]  = first+i;
+    }
+    return add;
+}
+
+// --------------------------------------------------------------------------
+//
+// If you want to change or set the night manually.
+// The Format is
+//     SetNight("yyyy-mm-dd");
+//
+void MSequence::SetNight(const char *txt)
+{
+    TString night(txt);
+    night += " 00:00:00";
+    fNight.SetSqlDateTime(night);
+
+    fPeriod = MAstro::GetMagicPeriod(fNight.GetMjd());
+}
Index: trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 6590)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 6591)
@@ -4,4 +4,8 @@
 #ifndef ROOT_TArrayI
 #include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TExMap
+#include <TExMap.h>
 #endif
 
@@ -35,6 +39,13 @@
     TArrayI fDatRuns;
 
+    //TExMap fFileNames;
+
     void Split(TString &runs, TArrayI &data) const;
-    Int_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw=kFALSE) const;
+    void GetFileNames(TEnv &env, const TArrayI &arr);
+
+    const char *GetFileName(UInt_t num);
+
+    UInt_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw=kFALSE) const;
+    UInt_t AddRuns(UInt_t first, UInt_t last, TArrayI *runs);
 
 public:
@@ -48,20 +59,23 @@
         fRuns(s.fRuns), fCalRuns(s.fCalRuns), fPedRuns(s.fPedRuns),
         fDatRuns(s.fDatRuns) { }
+    ~MSequence();
 
+    // TObject
     void Print(Option_t *o="") const;
 
+    // Genaral interface
     Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
 
-    Int_t SetupPedRuns(MDirIter &iter, const char *path=0, char *id="P", Bool_t raw=kFALSE) const;
-    Int_t SetupDatRuns(MDirIter &iter, const char *path=0, char *id="D", Bool_t raw=kFALSE) const;
-    Int_t SetupAllRuns(MDirIter &iter, const char *path=0, char *id="?", Bool_t raw=kFALSE) const;
-    Int_t SetupCalRuns(MDirIter &iter, const char *path=0, char *id="C", Bool_t raw=kFALSE) const;
-
-    Int_t GetNumAllRuns() const { return fRuns.GetSize(); }
-    Int_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
-    Int_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
-    Int_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
+    UInt_t SetupPedRuns(MDirIter &iter, const char *path=0, char *id="P", Bool_t raw=kFALSE) const;
+    UInt_t SetupDatRuns(MDirIter &iter, const char *path=0, char *id="D", Bool_t raw=kFALSE) const;
+    UInt_t SetupAllRuns(MDirIter &iter, const char *path=0, char *id="?", Bool_t raw=kFALSE) const;
+    UInt_t SetupCalRuns(MDirIter &iter, const char *path=0, char *id="C", Bool_t raw=kFALSE) const;
 
     // Getter
+    UInt_t GetNumAllRuns() const { return fRuns.GetSize(); }
+    UInt_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
+    UInt_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
+    UInt_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
+
     UInt_t GetSequence() const { return fSequence; }
     UInt_t GetLastRun() const  { return fLastRun; }
@@ -79,4 +93,17 @@
     const TString &GetSource() const { return fSource; } 
 
+    // Setter
+    void SetNight(const char*night);
+
+    UInt_t AddRuns(UInt_t first, UInt_t last)    { return MSequence::AddRuns(first, last, 0); }
+    UInt_t AddCalRuns(UInt_t first, UInt_t last) { return MSequence::AddRuns(first, last, &fCalRuns); }
+    UInt_t AddPedRuns(UInt_t first, UInt_t last) { return MSequence::AddRuns(first, last, &fPedRuns); }
+    UInt_t AddDatRuns(UInt_t first, UInt_t last) { return MSequence::AddRuns(first, last, &fDatRuns); }
+
+    UInt_t AddRuns(UInt_t num)    { return AddRuns(num, num); }
+    UInt_t AddCalRuns(UInt_t num) { return AddCalRuns(num, num); }
+    UInt_t AddPedRuns(UInt_t num) { return AddPedRuns(num, num); }
+    UInt_t AddDatRuns(UInt_t num) { return AddDatRuns(num, num); }
+
     ClassDef(MSequence, 0)
 };
