Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 7348)
+++ trunk/MagicSoft/Mars/NEWS	(revision 7349)
@@ -8,4 +8,19 @@
    * general: added a new game. Start it from the interpreter with
         MagicJam j;
+
+   * callisto: MBadPixelsCalc now raises an error instead of simply stopping
+     the eventloop if something went wrong. This is necessary for the
+     automatic processing
+
+   * callisto: Fixed a bug in the treatment of times in the bad pixel
+     treatment. No neighbors have been taken into account, the new
+     arrival time was always calculated by the pixels 0 to 5.
+
+   * callisto: Fixed a bug which caused the random and peak-search pedestal
+     extracted with an extractor to be exchanged for the first (roughly)
+     500 events. (The were simple exchanged in callisto.cc) This bug might
+     have been introduced in Mars 0.9.4 when the order of calculation of the
+     two types of pedestal in callisto got exchanged. The bug only effects
+     the first seconds of data of each sequence.
 
 
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 7349)
@@ -598,5 +598,5 @@
 
         // Where to search for calibration files
-        if (!job4.Process(job1.GetPedestalCam(), job2.GetPedestalCam(), job3.GetPedestalCam()))
+        if (!job4.Process(job1.GetPedestalCam(), job3.GetPedestalCam(), job2.GetPedestalCam()))
             return 2;
 
Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc	(revision 7349)
@@ -137,5 +137,5 @@
 // too high pedestal Rms with respect to the mean.
 // 
-Bool_t MBadPixelsCalc::CheckPedestalRms(MBadPixelsPix::UnsuitableType_t type) const
+Int_t MBadPixelsCalc::CheckPedestalRms(MBadPixelsPix::UnsuitableType_t type) const
 {
     const Bool_t checklo = fPedestalLevelVarianceLo>0;
@@ -310,5 +310,8 @@
 Int_t MBadPixelsCalc::Process()
 {
-    return fCheckInProcess ? CheckPedestalRms(MBadPixelsPix::kUnsuitableEvt) : kTRUE;
+    if (!fCheckInProcess)
+        return kTRUE;
+
+    return CheckPedestalRms(MBadPixelsPix::kUnsuitableEvt) ? kTRUE : kERROR;
 }
 
Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc	(revision 7349)
@@ -441,6 +441,8 @@
         for (unsigned int j=0; j<time.GetSize(); j++)
         {
-            const Double_t t = (*fEvt)[j].GetArrivalTime();
-            if (t>=0)
+            const Int_t nn = gpix.GetNeighbor(j);
+
+            const Double_t t = (*fEvt)[nn].GetArrivalTime();
+            if (t>=0 && !IsPixelBad(nn))
                 time[n0++] = t;
         }
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 7349)
@@ -2045,5 +2045,5 @@
         //if (!GetCanvas(c->GetName()))
         if (!tab || c->GetName()==(TString)tab)
-            DrawClonePad(AddTab(c->GetName()), *c);
+            DrawClonePad(c->GetName(), *c);
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 7348)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 7349)
@@ -204,4 +204,9 @@
      void   Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
 
+     void DrawClonePad(const char *tab, TCanvas &oldc)
+     {
+         DrawClonePad(AddTab(tab), oldc);
+     }
+
      void SetNoContextMenu(Bool_t flag=kTRUE);
 
Index: trunk/MagicSoft/Mars/mgui/MCamEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamEvent.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mgui/MCamEvent.cc	(revision 7349)
@@ -55,2 +55,22 @@
     InitSize(geom.GetNumPixels());
 }
+
+// --------------------------------------------------------------------------
+//
+// Return the mean of all corresponding GetPixelContent
+//
+Double_t MCamEvent::GetCameraMean(const MGeomCam &cam, Int_t type) const
+{
+    Int_t    num  = 0;
+    Double_t mean = 0;
+    for (unsigned int i=0; i<cam.GetNumPixels(); i++)
+    {
+        Double_t val;
+        if (!GetPixelContent(val, i, cam, type))
+            continue;
+
+        mean += val;
+        num ++;
+    }
+    return num == 0 ? 0 : mean/num;
+}
Index: trunk/MagicSoft/Mars/mgui/MCamEvent.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamEvent.h	(revision 7348)
+++ trunk/MagicSoft/Mars/mgui/MCamEvent.h	(revision 7349)
@@ -17,4 +17,6 @@
     virtual void   InitSize(const UInt_t i) { } // Used by MGeomApply see Init()
 
+    virtual Double_t GetCameraMean(const MGeomCam &cam, Int_t type=0) const;
+
     ClassDef(MCamEvent, 0) // A camera event
 };
Index: trunk/MagicSoft/Mars/mhflux/MHThreshold.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHThreshold.h	(revision 7348)
+++ trunk/MagicSoft/Mars/mhflux/MHThreshold.h	(revision 7349)
@@ -15,5 +15,5 @@
 {
 private:
-    const MMcEvt *fMcEvt; //! POinter to MC energy
+    const MMcEvt *fMcEvt; //! Pointer to MC energy
 
     TH1D fHEnergy;
Index: trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc	(revision 7349)
@@ -86,5 +86,5 @@
 using namespace std;
 
-const TString MHSectorVsTime::gsDefName  = "MSectorHVsTime";
+const TString MHSectorVsTime::gsDefName  = "MHSectorVsTime";
 const TString MHSectorVsTime::gsDefTitle = "Graph of sector mean vs. time";
 
Index: trunk/MagicSoft/Mars/mjobs/MDataSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 7349)
@@ -110,5 +110,11 @@
     while (!runs.IsNull())
     {
-        TString num = runs(regexp);
+        const TString num = runs(regexp);
+
+        if (num.IsNull())
+        {
+            *fLog << warn << "WARNING - Sequence is NaN (not a number): " << runs << endl;
+            break;
+        }
 
         const Int_t seq = atoi(num.Data());
@@ -122,5 +128,5 @@
 
         if (i<n)
-            *fLog << warn << "WARNING - Sequence #" << seq << " alraedy in list... skipped." << endl;
+            *fLog << warn << "WARNING - Sequence #" << seq << " already in list... skipped." << endl;
         else
         {
Index: trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7349)
@@ -171,4 +171,5 @@
     p += "/";
     p += fNameOutput.IsNull() ? Form("ganymed%08d.root", num) : fNameOutput.Data();
+    gSystem->ExpandPathName(p);
     return p;
 }
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 7349)
@@ -166,5 +166,11 @@
     while (!runs.IsNull())
     {
-        TString num = runs(regexp);
+        const TString num = runs(regexp);
+
+        if (num.IsNull())
+        {
+            *fLog << warn << "WARNING - Run is NaN (not a number): " << runs << endl;
+            break;
+        }
 
         const Int_t run = atoi(num.Data());
@@ -178,5 +184,5 @@
 
         if (i<n)
-            *fLog << warn << "WARNING - Run #" << run << " alraedy in list... skipped." << endl;
+            *fLog << warn << "WARNING - Run #" << run << " already in list... skipped." << endl;
         else
         {
Index: trunk/MagicSoft/Mars/mpedestal/MPedPhotCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedPhotCam.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/mpedestal/MPedPhotCam.cc	(revision 7349)
@@ -357,5 +357,5 @@
         break;
     case 5:
-        val = (*this)[idx].GetRms()*TMath::Sqrt(cam.GetPixRatio(idx));
+        val = (*this)[idx].GetRms()*cam.GetPixRatioSqrt(idx);
         break;
     default:
Index: trunk/MagicSoft/Mars/msignal/MSignalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MSignalCam.cc	(revision 7348)
+++ trunk/MagicSoft/Mars/msignal/MSignalCam.cc	(revision 7349)
@@ -252,5 +252,5 @@
         Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
         if (geom)
-            testval *= TMath::Sqrt(geom->GetPixRatio(i/*pix.GetPixId()*/));
+            testval *= geom->GetPixRatioSqrt(i/*pix.GetPixId()*/);
 
         if (testval < minval)
@@ -280,5 +280,5 @@
         Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
         if (geom)
-            testval *= TMath::Sqrt(geom->GetPixRatio(i/*pix.GetPixId()*/));
+            testval *= geom->GetPixRatioSqrt(i/*pix.GetPixId()*/);
 
         if (testval > maxval)
Index: trunk/MagicSoft/Mars/msignal/MSignalCam.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MSignalCam.h	(revision 7348)
+++ trunk/MagicSoft/Mars/msignal/MSignalCam.h	(revision 7349)
@@ -46,4 +46,8 @@
     }
 
+    // Setter functions for use in image cleaning classes only
+    void SetSinglePixels(Short_t num, Float_t size)  { fNumSinglePixels=num; fSizeSinglePixels=size; }
+    void SetNumPixelsSaturated(UInt_t hi, UInt_t lo) { fNumPixelsSaturatedHiGain=hi;fNumPixelsSaturatedLoGain=lo; }
+
     // Getter functions
     UInt_t  GetNumPixels() const { return fPixels->GetEntriesFast(); }
@@ -55,8 +59,4 @@
     Int_t   GetNumPixelsSaturatedHiGain() const { return fNumPixelsSaturatedHiGain; }
     Int_t   GetNumPixelsSaturatedLoGain() const { return fNumPixelsSaturatedLoGain; }
-
-    // Setter functions for use in image cleaning classes only
-    void SetSinglePixels(Short_t num, Float_t size)  { fNumSinglePixels=num; fSizeSinglePixels=size; }
-    void SetNumPixelsSaturated(UInt_t hi, UInt_t lo) { fNumPixelsSaturatedHiGain=hi;fNumPixelsSaturatedLoGain=lo; }
 
     Bool_t  IsPixelExisting(Int_t id) const;
