Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8304)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8310)
@@ -465,7 +465,16 @@
         // The window size of the extractor is not yet initialized,
         // so we have to stick to the extraction range
-        const Int_t f = extractor1->GetHiGainFirst();
-        const Int_t l = extractor1->GetHiGainLast();
-        const Int_t w = (l-f+1)&~1;
+        //
+        // Even if we would like to use a range comparable to the
+        // hi-gain extraction we use the lo-gain range to make
+        // sure that exclusions (eg. due to switching noise)
+        // are correctly handled.
+        //
+        const Int_t f = extractor1->GetLoGainFirst();
+        const Int_t l = extractor1->GetLoGainLast();
+        const Int_t w = (l-f+1);
+        //const Int_t f = extractor1->GetHiGainFirst();
+        //const Int_t l = extractor1->GetHiGainLast();
+        //const Int_t w = (l-f+1)&~1;
 
         pedlo1.SetExtractWindow(f, w);
Index: trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 8304)
+++ trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 8310)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2007
 !
 !
@@ -51,5 +51,6 @@
 #include "MReadReports.h"
 #include "MReadMarsFile.h"
-#include "MF.h"
+#include "MFDataPhrase.h"
+#include "MFilterList.h"
 #include "MFDataMember.h"
 #include "MFDeltaT.h"
@@ -209,7 +210,11 @@
     // ------------------ Setup histograms and fill tasks ----------------
     MHCamEvent evt0a(0, "Cleaned", "Signal after Cleaning;;S [\\gamma]");
+    MHCamEvent evt0c(0, "Cleaned", "Signal after Cleaning and Spark cuts;;S [\\gamma]");
+    MHCamEvent evt0d(0, "Cleaned", "Signal after Cleaning for Spark cuts;;S [\\gamma]");
     MHCamEvent evt0b(0, "UsedPix", "Fraction of Events in which Pixels are used;;Fraction");
     evt0a.SetErrorSpread(kFALSE);
     evt0b.SetErrorSpread(kFALSE);
+    evt0c.SetErrorSpread(kFALSE);
+    evt0d.SetErrorSpread(kFALSE);
     evt0b.SetThreshold(0);
 
@@ -223,4 +228,6 @@
     MFillH fill0a(&evt0a,             "MSignalCam",      "FillSignalCam");
     MFillH fill0b(&evt0b,             "MSignalCam",      "FillCntUsedPixels");
+    MFillH fill0c(&evt0c,             "MSignalCam",      "FillSignalCamSparkless");
+    MFillH fill0d(&evt0d,             "MSignalCam",      "FillSignalCamSparks");
     MFillH fill1("MHHillas",          "MHillas",         "FillHillas");
     MFillH fill2("MHHillasExt",       "",                "FillHillasExt");
@@ -232,4 +239,6 @@
     //fillvs.SetNameTab("Rate");
     fill9.SetNameTab("EffOnTime");
+    fill0c.SetNameTab("Sparkless");
+    fill0d.SetNameTab("Sparks");
 
     // ------------------ Setup write task ----------------
@@ -327,9 +336,22 @@
         tlist2.AddToList(&writet);
     }
+
+    // Spark cut
+    MFDataPhrase fsparks("log10(MNewImagePar.fConc1) < (-0.371)*log10(MHillas.fSize) + 0.596", "SparkCut");
+    fill0c.SetFilter(&fsparks);
+
+    // Inverted spark cut (need not to be a member of the task list
+    // because it fsparks is
+    MFilterList fnsparks(&fsparks);
+    fill0d.SetFilter(&fnsparks);
+
     tlist2.AddToList(&clean);
-    tlist2.AddToList(&fill0a);
-    tlist2.AddToList(&fill0b);
     tlist2.AddToList(&poscalc);
     tlist2.AddToList(&hcalc);
+    tlist2.AddToList(&fsparks);
+    tlist2.AddToList(&fill0a);
+    tlist2.AddToList(&fill0c);
+    tlist2.AddToList(&fill0d);
+    tlist2.AddToList(&fill0b);
     tlist2.AddToList(&fill1);
     tlist2.AddToList(&fill2);
@@ -340,12 +362,12 @@
     // ----------------------- Muon Analysis ----------------------
     // Filter to start muon analysis
-    MF fmuon1("MHillas.fSize>150", "MuonPreCut");
+    MFDataPhrase fmuon1("MHillas.fSize>150", "MuonPreCut");
     // Filter to calculate further muon parameters
-    MF fmuon2("(MMuonSearchPar.fRadius>180) && (MMuonSearchPar.fRadius<400) &&"
-              "(MMuonSearchPar.fDeviation<45)", "MuonSearchCut");
+    MFDataPhrase fmuon2("(MMuonSearchPar.fRadius>180) && (MMuonSearchPar.fRadius<400) &&"
+                        "(MMuonSearchPar.fDeviation<45)", "MuonSearchCut");
     // Filter to fill the MHMuonPar
-    MF fmuon3("(MMuonCalibPar.fArcPhi>190) && (MMuonSearchPar.fDeviation<35) &&"
-              "(MMuonCalibPar.fArcWidth<0.20) && (MMuonCalibPar.fArcWidth>0.04)",
-              "MuonFinalCut");
+    MFDataPhrase fmuon3("(MMuonCalibPar.fArcPhi>190) && (MMuonSearchPar.fDeviation<35) &&"
+                        "(MMuonCalibPar.fArcWidth<0.20) && (MMuonCalibPar.fArcWidth>0.04)",
+                        "MuonFinalCut");
     // Filter to write Muons to Muon tree
     MFDataMember fmuon4("MMuonCalibPar.fArcPhi", '>', -0.5, "MuonWriteCut");
