Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 6458)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 6459)
@@ -59,7 +59,31 @@
        of phe in the outer pixels is equiv. to the inner pixels.
      - the same for the calibration factor - with the same argument
+     - adapted to change in MWriteRootFile
 
    * mhist/MHCamera.cc:
      - changed drawing such, that NaN is not displayed anymore
+
+   * Makefile:   
+     - added new program ganymed
+
+   * mfileio/MWriteRootFile.[h,cc]:  
+     - added possibility to use UPDATE mode with rules (dangerous!)
+       as discussed with Abelardo, Daniel M. and Thomas S.
+
+   * mjobs/MJStar.cc:
+     - adapted to change in MWriteRootFile
+     - added software trigger (still untuned) as suggested by
+       Thomas S.
+     - added calculation of source position before calculation
+       of image parameters
+     - added MPointingPos to Events-Tree
+     - removed MPointingPos from Drive-Tree
+     - renamed sub-tasklists to something more intuitive
+
+   * mjobs/Makefile, mjobs/JobsLinkDef.h:
+     - added MJCut.cc
+
+   * mraw/MRawFileRead.cc:
+     - return kERROR if ReInit fails
 
 
Index: /trunk/MagicSoft/Mars/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/Makefile	(revision 6458)
+++ /trunk/MagicSoft/Mars/Makefile	(revision 6459)
@@ -20,5 +20,5 @@
 #
 #PROGRAMS = readraw merpp mars test mona status
-PROGRAMS = readdaq readraw merpp mars mona showlog callisto showplot star
+PROGRAMS = readdaq merpp readraw callisto star ganymed showlog showplot mars mona
 SOLIB    = libmars.so
 CINT     = M
@@ -80,5 +80,5 @@
 .SUFFIXES: .c .cc .h .o 
 
-SRCFILES =
+SRCFILES = 
 
 ############################################################
Index: /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 6458)
+++ /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 6459)
@@ -127,5 +127,5 @@
 MWriteRootFile::MWriteRootFile(const Int_t comp,
                                const char *rule,
-                               const Bool_t overwrite,
+                               const Option_t *option,
                                const char *ftitle,
                                const char *name,
@@ -139,5 +139,6 @@
     // a valid file. (Stupid workaround - but does a good job)
     //
-    fOut = new TFile("/dev/null", overwrite?"RECREATE":"NEW", ftitle, comp);
+    fOut = new TFile("/dev/null", option, ftitle, comp);
+    fOut->SetOption(option); // IMPORTANT!
 }
 
@@ -713,9 +714,10 @@
     const Int_t   compr = fOut->GetCompressionLevel();
     const TString title = fOut->GetTitle();
-
-    *fLog << inf << "MWriteRootFile - Open new file " << fname << " (Title=" << title << ", Compression=" << compr << ")" << endl;
+    const TString opt   = fOut->GetOption();
+
+    *fLog << inf << "MWriteRootFile - Open new file " << fname << " (Title=" << title << ", Option=" << opt << ", Compression=" << compr << ")" << endl;
 
     // Open new file with old setup
-    TFile *newfile = TFile::Open(fname, "RECREATE", title, compr);
+    TFile *newfile = TFile::Open(fname, opt, title, compr);
     if (!newfile)
     {
Index: /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 6458)
+++ /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 6459)
@@ -112,5 +112,5 @@
     MWriteRootFile(const Int_t comp,
                    const char *rule,
-                   const Bool_t overwrite=kTRUE,
+                   const Option_t *opt="RECREATE",
                    const char *ftitle="Untitled",
                    const char *name=NULL,
Index: /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc	(revision 6458)
+++ /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc	(revision 6459)
@@ -19,5 +19,5 @@
 !   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2005
 !
 !
@@ -30,10 +30,38 @@
 //  This is a class to evaluate a software trigger
 //
-//  to be called after the calibration (when the number of photons is
-//               available for all pixels)
-//
-// require 2 neighboring pixels (which are not in the outermost ring),
-//                       each having at least 'fNumMinPhotons' photons
-//
+//  The number of required pixels is setup by:
+//   SetNumNeighbors(4)   // default
+//
+//  The Threshold is setup by:
+//    SetThreshold(5)     // default
+//
+//  Time window for coincidence:
+//    SetTimeWindow(3.3)
+// To switch off time-coincidence use
+//    SetTimeWindow(-1)
+//   or
+//    SetTimeWindow()
+//
+//  kSinglePixelsNeighbors <default>
+//  ----------------------
+//    Checks whether there is at least one pixel above threshold which
+//    has fNumNeighbors direct neighbors which are also above threshold.
+//    The outermost ring of pixels is ignord. Only 'used' pixels are
+//    taken into account.
+//
+//  kAnyPattern 
+//  -----------
+//    Checks whether it find a cluster of pixels above fThreshold which
+//    has a size bigger/equal than fNumNeighbors. The layout (pattern) of
+//    the cluster is ignored. Unmapped pixels are ignored.
+//
+//  WARNING: Using trigger type kAllPattern resets the BIT(21) bit
+//           of all pixels in MCerPhotEvt
+//
+//
+//  Input:
+//    MCerPhotEvt
+//    MArrivalTime
+//    MGeomCam
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -49,4 +77,5 @@
 
 #include "MCerPhotEvt.h"
+#include "MArrivalTime.h"
 
 ClassImp(MFSoftwareTrigger);
@@ -59,5 +88,6 @@
 //
 MFSoftwareTrigger::MFSoftwareTrigger(const char *name, const char *title)
-    : fNumMinPhotons(0), fNumNeighbors(2)
+    : fCam(NULL), fEvt(NULL), fTme(NULL), fThreshold(5),
+    fTimeWindow(0.5), fNumNeighbors(4), fType(kSinglePixelNeighbors)
 {
     fName  = name  ? name  : "MFSoftwareTrigger";
@@ -67,9 +97,227 @@
 // --------------------------------------------------------------------------
 //
-// Software trigger
-// 
-// require 2 neighboring pixels (which are not in the outermost ring), 
-//                       each having at least 'fNumMinPhotons' photons
-// 
+// This function recursively finds all pixels of one island and sets
+// BIT(14) for the pixel.
+//
+//  1) Check whether a pixel with the index idx exists, is unused
+//     and has not yet BIT(14) set
+//  2) Set BIT(14) to the pixel
+//  3) Loop over all its neighbors taken from the geometry geom. For all
+//     neighbors recursively call this function (CountPixels)
+//  4) Sum the number of valid neighbors newly found
+//
+// Returns the size of the cluster
+//
+Int_t MFSoftwareTrigger::CountPixels(Int_t idx, Float_t tm0) const
+{
+    // Try to get the pixel information of a pixel with this index
+    MCerPhotPix *pix = fEvt->GetPixById(idx);
+
+    // If a pixel with this index is not existing... do nothing.
+    if (!pix)
+        return 0;
+
+    // If pixel already assigned to a cluster
+    if (pix->TestBit(kWasChecked))
+        return 0;
+
+    if (pix->IsPixelUnmapped())
+        return 0;
+
+    // Assign the new island number num to this used pixel
+    pix->SetBit(kWasChecked);
+
+    // Get the size of this pixel and check threshold
+    const Double_t size = pix->GetNumPhotons()*fCam->GetPixRatio(idx);
+    if (size<fThreshold)
+        return 0;
+
+    const Float_t tm1 = (*fTme)[idx];
+    if (fTimeWindow>0 && TMath::Abs(tm1-tm0)>fTimeWindow)
+        return 0;
+
+    //pix->SetBit(kAboveThreshold);
+
+    Int_t num = 1;
+
+    // Get the geometry information (neighbors) of this pixel
+    const MGeomPix &gpix = (*fCam)[idx];
+
+    // Now do the same with all its neighbors and sum the
+    // sizes which they correspond to
+    const Int_t n = gpix.GetNumNeighbors();
+    for (int i=0; i<n; i++)
+        num += CountPixels(gpix.GetNeighbor(i), tm1);
+
+    // return size of this (sub)cluster
+    return num;
+}
+/*
+Int_t MFSoftwareTrigger::CountCoincidencePixels(Int_t idx) const
+{
+    // Try to get the pixel information of a pixel with this index
+    MCerPhotPix *pix = fEvt->GetPixById(idx);
+
+    // If a pixel with this index is not existing... do nothing.
+    if (!pix)
+        return 0;
+
+    // If pixel already assigned to a cluster
+    if (pix->TestBit(kWasChecked))
+        return 0;
+
+    if (pix->IsPixelUnmapped())
+        return 0;
+
+    // Assign the new island number num to this used pixel
+    pix->SetBit(kWasChecked);
+
+    // Get the size of this pixel and check threshold
+    const Double_t size = pix->GetNumPhotons();
+    if (size<fThreshold)
+        return 0;
+
+    Int_t num = 1;
+
+    // Get the geometry information (neighbors) of this pixel
+    const MGeomPix &gpix = (*fCam)[idx];
+
+    // Now do the same with all its neighbors and sum the
+    // sizes which they correspond to
+    const Int_t n = gpix.GetNumNeighbors();
+    for (int i=0; i<n; i++)
+        num += CountPixels(gpix.GetNeighbor(i));
+
+    // return size of this (sub)cluster
+    return num;
+}
+*/
+void MFSoftwareTrigger::ResetBits(Int_t bits) const
+{
+    TObject *obj=0;
+
+    TIter Next(*fEvt);
+    while ((obj=Next()))
+        obj->ResetBit(bits);
+}
+
+// --------------------------------------------------------------------------
+//
+// Check if there is at least one pixel which fullfills the condition
+//
+Bool_t MFSoftwareTrigger::ClusterTrigger() const
+{
+    ResetBits(kWasChecked);
+
+    // Reset bit
+    MCerPhotPix *pix=0;
+
+    // We could loop over all indices which looks more straight
+    // forward but should be a lot slower (assuming zero supression)
+    TIter Next(*fEvt);
+    while ((pix=static_cast<MCerPhotPix*>(Next())))
+    {
+        // Check if trigger condition is fullfilled for this pixel
+        const Int_t idx = pix->GetPixId();
+        if (CountPixels(idx, (*fTme)[idx]) >= fNumNeighbors)
+            return kTRUE;
+    }
+
+    return kFALSE;
+}
+/*
+Int_t MFSoftwareTrigger::CheckCoincidence(Int_t idx, Float_t tm0) const
+{
+    // Try to get the pixel information of a pixel with this index
+    MCerPhotPix *pix = fEvt->GetPixById(idx);
+
+    // If a pixel with this index is not existing... do nothing.
+    if (!pix)
+        return 0;
+
+    // If pixel already assigned to a cluster
+    if (pix->TestBit(kWasChecked))
+        return 0;
+
+    if (pix->IsPixelUnmapped())
+        return 0;
+
+    // Assign the new island number num to this used pixel
+    pix->SetBit(kWasChecked);
+
+    const Double_t size = pix->GetNumPhotons();
+    if (size<fThreshold)
+        return 0;
+
+    const Float_t tm1 = (*fTme)[idx];
+    if (TMath::Abs(tm1-tm0)>fTimeWindow)
+        return 0;
+
+    pix->SetBit(kIsCoincident);
+
+
+    Int_t num = 1;
+
+    // Get the geometry information (neighbors) of this pixel
+    const MGeomPix &gpix = (*fCam)[idx];
+
+    Int_t cnt = 0;
+
+    // Now do the same with all its neighbors and sum the
+    // sizes which they correspond to
+    const Int_t n = gpix.GetNumNeighbors();
+    for (int i=0; i<n; i++)
+    {
+        const Int_t rc = CheckCoincidence(gpix.GetNeighbor(i), tm0);
+        if (fEvt->GetPixById(gpix.GetNeighbor(i))->TestBit(kIsCoincident))
+            cnt++;
+        num += rc;
+    }
+
+    // return size of this (sub)cluster
+    return cnt<2 ? 0 : num;
+
+}
+
+Bool_t MFSoftwareTrigger::MagicLvl1Trigger() const
+{
+    // Reset bit
+    MCerPhotPix *pix=0;
+
+    // We could loop over all indices which looks more straight
+    // forward but should be a lot slower (assuming zero supression)
+    TIter Next(*fEvt);
+    while ((pix=static_cast<MCerPhotPix*>(Next())))
+    {
+        ResetBits(kWasChecked|kIsCoincident);
+
+        const Int_t idx = pix->GetPixId();
+        if (CheckCoincidence(idx, (*fTme)[idx])<fNumNeighbors)
+            continue;
+
+        return kTRUE;
+    }
+    return kFALSE;
+}
+*/
+
+Bool_t MFSoftwareTrigger::CheckPixel(const MCerPhotPix &pix) const
+{
+    if (!pix.IsPixelUsed())
+        return kFALSE;
+
+    if (pix.GetNumPhotons()*fCam->GetPixRatio(pix.GetPixId())<fThreshold)
+        return kFALSE;
+
+    if ((*fCam)[pix.GetPixId()].IsInOutermostRing())
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Software single pixel coincidence trigger
+//
 Bool_t MFSoftwareTrigger::SwTrigger() const
 {
@@ -78,33 +326,30 @@
     for (Int_t i=0; i<entries; i++)
     {
-        const MCerPhotPix &pix = (*fEvt)[i];
-        if (!pix.IsPixelUsed())
+        const MCerPhotPix &pix0 = (*fEvt)[i];
+        if (!CheckPixel(pix0))
             continue;
 
-        if (pix.GetNumPhotons()<fNumMinPhotons)
-            continue;
-
-        // this pixel is used and has the required no.of photons
-        // check whether this is also true for a neigboring pixel
-        MGeomPix &gpix = (*fCam)[pix.GetPixId()];
-        if (gpix.IsInOutermostRing())
-            continue;
-
         Int_t num = 1;
+
+        const MGeomPix &gpix = (*fCam)[pix0.GetPixId()];
 
         const Int_t nneighbors = gpix.GetNumNeighbors();
         for (Int_t n=0; n<nneighbors; n++)
         {
-            const Int_t id = gpix.GetNeighbor(n);
-            if (!fEvt->IsPixelUsed(id))
+            const Int_t idx1 = gpix.GetNeighbor(n);
+            if (!CheckPixel(*fEvt->GetPixById(idx1)))
                 continue;
 
-            if ((*fCam)[id].IsInOutermostRing())
-                continue;
-
-            const Double_t photons = fEvt->GetPixById(id)->GetNumPhotons();
-            if (photons >= fNumMinPhotons)
-                if (++num==fNumNeighbors)
-                    return kTRUE;
+            if (fTimeWindow>0)
+            {
+                const Float_t t0 = (*fTme)[pix0.GetPixId()];
+                const Float_t t1 = (*fTme)[idx1];
+
+                if (TMath::Abs(t0-t1)>fTimeWindow)
+                    continue;
+            }
+
+            if (++num==fNumNeighbors)
+                return kTRUE;
         }
     }
@@ -132,4 +377,12 @@
     }
 
+    fTme = (MArrivalTime*)pList->FindObject("MArrivalTime");
+    if (!fTme)
+    {
+        *fLog << err << "MArrivalTime not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
     memset(fCut, 0, sizeof(fCut));
 
@@ -143,5 +396,13 @@
 Int_t MFSoftwareTrigger::Process()
 {
-    fResult = SwTrigger();
+    switch (fType)
+    {
+    case kSinglePixelNeighbors:
+        fResult = SwTrigger();
+        break;
+    case kAnyPattern:
+        fResult = ClusterTrigger();
+        break;
+    }
 
     fCut[fResult ? 0 : 1]++;
@@ -157,4 +418,15 @@
     if (GetNumExecutions()==0)
         return kTRUE;
+
+    TString type;
+    switch (fType)
+    {
+    case kSinglePixelNeighbors:
+        type = " single pixel trigger";
+        break;
+    case kAnyPattern:
+        type = " any pattern trigger";
+        break;
+    }
 
     *fLog << inf << endl;
@@ -164,11 +436,58 @@
     *fLog << " " << setw(7) << fCut[0] << " (" << setw(3) ;
     *fLog << (int)(fCut[0]*100/GetNumExecutions());
-    *fLog << "%) Evts fullfilled software trigger";
-    *fLog << " (NumPhotons>=" << fNumMinPhotons << ", NumNeighbors>=";
-    *fLog << (int)fNumNeighbors << ")" << endl;
+    *fLog << "%) Evts fullfilled" << type;
+    *fLog << " (Thresh>=" << fThreshold << ", Num>=";
+    *fLog << (int)fNumNeighbors << ", Win=" << fTimeWindow << ")" << endl;
     *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
     *fLog << (int)(fCut[1]*100/GetNumExecutions());
-    *fLog << "%) Evts didn't fullfill software trigger."  << endl;
+    *fLog << "%) Evts didn't fullfill" << type << "."  << endl;
 
     return kTRUE;
 }
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv, eg:
+//   MFSoftwareTrigger.Threshold:    5
+//   MFSoftwareTrigger.NumNeighbors: 4
+//   MFSoftwareTrigger.TimeWindow: 3.3
+//   MFSoftwareTrigger.TriggerType: SinglePixel, AnyPattern
+//
+// To switch off time-coincidence use
+//   MFSoftwareTrigger.TimeWindow: -1
+//
+Int_t MFSoftwareTrigger::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kFALSE;
+    if (IsEnvDefined(env, prefix, "Threshold", print))
+    {
+        rc = kTRUE;
+        SetThreshold(GetEnvValue(env, prefix, "Threshold", fThreshold));
+    }
+    if (IsEnvDefined(env, prefix, "NumNeighbors", print))
+    {
+        rc = kTRUE;
+        SetNumNeighbors(GetEnvValue(env, prefix, "NumNeighbors", fNumNeighbors));
+    }
+    if (IsEnvDefined(env, prefix, "TimeWindow", print))
+    {
+        rc = kTRUE;
+        SetTimeWindow(GetEnvValue(env, prefix, "TimeWindow", fTimeWindow));
+    }
+
+    if (IsEnvDefined(env, prefix, "TriggerType", print))
+    {
+        TString dat = GetEnvValue(env, prefix, "TriggerType", "");
+        dat = dat.Strip(TString::kBoth);
+        dat.ToLower();
+
+        if (dat == (TString)"singlepixel")
+            SetTriggerType(kSinglePixelNeighbors);
+        if (dat == (TString)"anypattern")
+            SetTriggerType(kAnyPattern);
+
+        rc = kTRUE;
+    }
+
+    return rc;
+}
Index: /trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h	(revision 6458)
+++ /trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h	(revision 6459)
@@ -8,7 +8,10 @@
 #pragma link C++ class MJCalib+;
 #pragma link C++ class MSequence+;
+#pragma link C++ class MDataSet+;
 
+#pragma link C++ class MJCut+;
 #pragma link C++ class MJStar+;
 #pragma link C++ class MJPedestal+;
+//#pragma link C++ class MJOptimize+;
 #pragma link C++ class MJCalibration+;
 #pragma link C++ class MJCalibrateSignal+;
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6458)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6459)
@@ -553,5 +553,5 @@
 
     // The second rule is for the case reading raw-files!
-    MWriteRootFile write(2, Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()), fOverwrite);
+    MWriteRootFile write(2, Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()), fOverwrite?"RECREATE":"NEW");
     // Run Header
     write.AddContainer("MRawRunHeader",             "RunHeaders");
Index: /trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 6458)
+++ /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 6459)
@@ -54,8 +54,10 @@
 #include "MReadMarsFile.h"
 #include "MFDeltaT.h"
+#include "MFSoftwareTrigger.h"
 #include "MContinue.h"
 #include "MGeomApply.h"
 #include "MEventRateCalc.h"
 #include "MImgCleanStd.h"
+#include "MSrcPosCalc.h"
 #include "MHillasCalc.h"
 #include "MFillH.h"
@@ -187,7 +189,14 @@
  */
     //MBadPixelsMerge        merge(&badpix);
+
+    MFSoftwareTrigger swtrig;
+    MContinue contsw(&swtrig, "FilterSwTrigger", "Software trigger");
+    contsw.SetInverted();
+
+
     MImgCleanStd           clean;
     clean.SetNamePedPhotCam("MPedPhotFromExtractorRndm");
 
+    MSrcPosCalc            poscalc;
     MHillasCalc            hcalc;
 
@@ -243,5 +252,5 @@
     // ------------------ Setup write task ----------------
 
-    MWriteRootFile write(2, Form("%s{s/_Y_/_I_}", fPathOut.Data()), fOverwrite);
+    MWriteRootFile write(2, Form("%s{s/_Y_/_I_}", fPathOut.Data()), fOverwrite?"RECREATE":"NEW");
     // Data
     write.AddContainer("MHillas",       "Events");
@@ -253,29 +262,28 @@
     //write.AddContainer("MImageParTime", "Events");
     write.AddContainer("MRawEvtHeader", "Events");
+    write.AddContainer("MPointingPos",  "Events");
     if (ismc)
     {
-        write.AddContainer("MPointingPos",        "Events");
         // Monte Carlo
-        write.AddContainer("MMcEvt",              "Events");
-        write.AddContainer("MMcTrig",             "Events");
+        write.AddContainer("MMcEvt",               "Events");
+        write.AddContainer("MMcTrig",              "Events");
         // Monte Carlo Headers
-        write.AddContainer("MMcRunHeader",        "RunHeaders");
-        write.AddContainer("MMcTrigHeader",       "RunHeaders");
-        write.AddContainer("MMcConfigRunHeader",  "RunHeaders");
-        write.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
+        write.AddContainer("MMcRunHeader",         "RunHeaders");
+        write.AddContainer("MMcTrigHeader",        "RunHeaders");
+        write.AddContainer("MMcConfigRunHeader",   "RunHeaders");
+        write.AddContainer("MMcCorsikaRunHeader",  "RunHeaders");
     }
     else
     {
-        write.AddContainer("MTime",               "Events");
+        write.AddContainer("MTime",                "Events");
         // Run Header
-        write.AddContainer("MRawRunHeader",       "RunHeaders");
-        write.AddContainer("MBadPixelsCam",       "RunHeaders");
-        write.AddContainer("MGeomCam",            "RunHeaders");
+        write.AddContainer("MRawRunHeader",        "RunHeaders");
+        write.AddContainer("MBadPixelsCam",        "RunHeaders");
+        write.AddContainer("MGeomCam",             "RunHeaders");
         //write.AddContainer("MObservatory", "RunHeaders");
         // Drive
         //write.AddContainer("MSrcPosCam",   "Drive");
-        write.AddContainer("MPointingPos",        "Drive");
-        write.AddContainer("MReportDrive",        "Drive");
-        write.AddContainer("MTimeDrive",          "Drive");
+        write.AddContainer("MReportDrive",         "Drive");
+        write.AddContainer("MTimeDrive",           "Drive");
         // Effective On Time
         write.AddContainer("MEffectiveOnTime",     "EffectiveOnTime");
@@ -283,9 +291,11 @@
     }
 
-    MTaskList tlist2;
+    MTaskList tlist2("Events");
     tlist2.AddToList(&apply);
     if (!ismc)
-    {
         tlist2.AddToList(&cont);
+    tlist2.AddToList(&contsw);
+    if (!ismc)
+    {
         tlist2.AddToList(&rate);
         //tlist2.AddToList(&rate1);
@@ -301,4 +311,5 @@
     tlist2.AddToList(&fill0b);
     //tlist2.AddToList(&fill0r);
+    tlist2.AddToList(&poscalc);
     tlist2.AddToList(&hcalc);
     tlist2.AddToList(&fill1);
@@ -314,5 +325,5 @@
     //MSrcPosFromModel srcpos;
 
-    MTaskList tlist3;
+    MTaskList tlist3("Drive");
     tlist3.AddToList(&pcalc);
     //tlist3.AddToList(&srcpos);
Index: /trunk/MagicSoft/Mars/mjobs/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/Makefile	(revision 6458)
+++ /trunk/MagicSoft/Mars/mjobs/Makefile	(revision 6459)
@@ -26,5 +26,7 @@
 
 SRCFILES = MSequence.cc \
+           MDataSet.cc \
            MJob.cc \
+           MJCut.cc \
            MJCalib.cc \
 	   MJStar.cc \
@@ -35,4 +37,6 @@
            MJCalibTest.cc
 
+#           MJOptimize.cc \
+
 ############################################################
 
Index: /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 6458)
+++ /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 6459)
@@ -252,5 +252,5 @@
     //  --> ReInit tasklist
     //
-    return tlist->ReInit(fParList);
+    return tlist->ReInit(fParList) ? kTRUE : kERROR;
 }
 
