Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7124)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7125)
@@ -21,4 +21,28 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2005/06/02 Thomas Bretz
+
+   * callisto.cc:
+     - made "-raw" the default
+     - switched bad pixel check on for MJPedestalC2
+
+   * callisto_Dec04Jan05.rc:
+     - reduced MJPedestalY2.ExtractWinRight from 4.0 to 2.0
+
+   * mhflux/MHThetaSq.[h,cc]:
+     - added missing InitMapping
+
+   * mjobs/MJCalib.cc:
+     - set default for fDataFlag to kIsUseRawData
+
+   * mjobs/MJOptimizeCuts.cc:
+     - added some sanity checks if CreateHistNew couldn't create
+       the histogram
+
+   * mjobs/MJPedestal.[h,cc]:
+     - implemented a possible deadpixel check
+
+
+
  2005/06/01 Thomas Bretz
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 7124)
+++ trunk/MagicSoft/Mars/NEWS	(revision 7125)
@@ -50,4 +50,13 @@
      pixel sizes or sectors also kUnsuitableEvt is now taken into
      account - not only kUnsuitableRun
+
+   - callisto: '-raw' option is now the default
+   
+   - callisto: A dead pixel check has been implemented in MJPedestalC2.
+     This has the advantage that mean values in the calibration (eg
+     arrival times) are calculated more accuratly.
+
+   - callisto: In the resource file callisto_Dec04Jan05.rc
+     MJPedestalY2.ExtractWinRight has been reduced from 4.0 to 2.0
 
    - star: fixed a bug which caused the first bin of the histograms
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 7124)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 7125)
@@ -54,7 +54,7 @@
     gLog << "   -y                        Extract and calibrate signal" << endl << endl;
     gLog << " Data Type (exclusive):" << endl;
-    gLog << "   -raw                      Read input from raw-data" << endl;
+    gLog << "   -raw                      Read input from raw-data <default>" << endl;
     gLog << "   -mc                       Input root-files are monte carlo files" << endl;
-    gLog << "   -root                     Read input from root-files (merpped) <default>" << endl << endl;
+    gLog << "   -root                     Read input from root-files (merpped)" << endl << endl;
     gLog << " Options:" << endl;
     gLog.Usage();
@@ -184,5 +184,7 @@
           Bool_t  kModeY      = arg.HasOnlyAndRemove("-y");
 
-    MJCalib::DataType_t kDataType = MJCalib::kIsUseRootData; // root
+    MJCalib::DataType_t kDataType = MJCalib::kIsUseRawData; // root
+    if (arg.HasOnlyAndRemove("-root"))
+        kDataType = MJCalib::kIsUseRootData; // root
     if (arg.HasOnlyAndRemove("-raw"))
         kDataType = MJCalib::kIsUseRawData;  // raw
@@ -383,4 +385,5 @@
         job2.SetDataType(kDataType);
         job2.SetUseHists(kMoon);
+        job2.SetDeadPixelCheck();
         // job1.SetPathOut(kOutpathC); // not yet needed
         // job1.SetPathIn(kInpathC);   // not yet needed
Index: trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc
===================================================================
--- trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 7124)
+++ trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 7125)
@@ -339,5 +339,5 @@
 #MJPedestalY2.PulsePosCheck: yes
 MJPedestalY2.ExtractWinLeft:  3.0
-MJPedestalY2.ExtractWinRight: 4.0
+MJPedestalY2.ExtractWinRight: 2.0
 #MJCalibrateSignal.ModifiedExtractWin: yes
 # -------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mhflux/MHThetaSq.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHThetaSq.cc	(revision 7124)
+++ trunk/MagicSoft/Mars/mhflux/MHThetaSq.cc	(revision 7125)
@@ -158,2 +158,45 @@
     return static_cast<const MParameterD*>(fParameter)->GetVal();
 }
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of
+// MMcEvt. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MHHadronness::Fill
+// will take the values from the matrix instead of the containers.
+//
+// It takes fSkipHist* into account!
+//
+void MHThetaSq::InitMapping(MHMatrix *mat, Int_t type)
+{
+    if (fMatrix)
+        return;
+
+    fMatrix = mat;
+
+    fMap[0] = -1;
+    fMap[1] = -1;
+    fMap[2] = -1;
+    fMap[3] = -1;
+    fMap[4] = -1;
+
+    if (!fSkipHistEnergy)
+        if (type==0)
+        {
+            fMap[1] = fMatrix->AddColumn("MEnergyEst.fVal");
+            fMap[2] = -1;
+        }
+        else
+        {
+            fMap[1] = -1;
+            fMap[2] = fMatrix->AddColumn("MHillas.fSize");
+        }
+
+    if (!fSkipHistTheta)
+        fMap[3] = fMatrix->AddColumn("MPointingPos.fZd");
+
+   // if (!fSkipHistTime)
+   //     fMap[4] = fMatrix->AddColumn("MTime.GetAxisTime");
+}
Index: trunk/MagicSoft/Mars/mhflux/MHThetaSq.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHThetaSq.h	(revision 7124)
+++ trunk/MagicSoft/Mars/mhflux/MHThetaSq.h	(revision 7125)
@@ -21,4 +21,5 @@
 
     Bool_t SetupFill(const MParList *pl);
+    void InitMapping(MHMatrix *mat, Int_t type=0);
 
 public:
Index: trunk/MagicSoft/Mars/mjobs/MJCalib.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalib.cc	(revision 7124)
+++ trunk/MagicSoft/Mars/mjobs/MJCalib.cc	(revision 7125)
@@ -48,5 +48,5 @@
 // - fPulsePosCheck to kFALSE
 //
-MJCalib::MJCalib() : fDataFlag(kIsUseRootData), fStorage(0), 
+MJCalib::MJCalib() : fDataFlag(kIsUseRawData), fStorage(0),
                      fIsPixelCheck(kFALSE), fIsPulsePosCheck(kFALSE),
                      fIsHiLoCalibration(kFALSE)
Index: trunk/MagicSoft/Mars/mjobs/MJOptimizeCuts.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJOptimizeCuts.cc	(revision 7124)
+++ trunk/MagicSoft/Mars/mjobs/MJOptimizeCuts.cc	(revision 7125)
@@ -318,4 +318,7 @@
     MHAlpha *histof = CreateNewHist("HistOff");
 
+    if (!histon || !histof)
+        return kFALSE;
+
     const Bool_t rc = RunOnOffCore(*histon, *histof, fname, filter, fit, tree);
 
@@ -332,4 +335,7 @@
     MHAlpha *histon = CreateNewHist();
 
+    if (!histon)
+        return kFALSE;
+
     const Bool_t rc = RunOnCore(*histon, fname, filter, fit);
 
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7124)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7125)
@@ -89,4 +89,10 @@
 #include "MPedCalcFromLoGain.h"
 #include "MFTriggerPattern.h"
+#include "MBadPixelsCalc.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
 
 ClassImp(MJPedestal);
@@ -111,5 +117,6 @@
 MJPedestal::MJPedestal(const char *name, const char *title) 
     : fExtractor(NULL), fDisplayType(kDisplayDataCheck),
-      fExtractType(kUsePedRun), fExtractionType(kFundamental), fIsUseHists(kFALSE)
+    fExtractType(kUsePedRun), fExtractionType(kFundamental),
+    fIsUseHists(kFALSE), fDeadPixelCheck(kFALSE)
 {
     fName  = name  ? name  : "MJPedestal";
@@ -777,4 +784,6 @@
     SetNoStorage(GetEnv("DisableOutput", IsNoStorage()));
 
+    fDeadPixelCheck = GetEnv("DeadPixelsCheck", fDeadPixelCheck);
+
     // Setup an environment task
     MTaskEnv tenv("ExtractSignal");
@@ -1235,4 +1244,20 @@
     }
 
+    if (fDeadPixelCheck)
+    {
+        MBadPixelsCalc calc;
+        calc.SetPedestalLevelVarianceLo(4.5);
+        calc.SetPedestalLevelVarianceHi();
+        calc.SetPedestalLevel();
+        if (!CheckEnv(calc))
+            return kFALSE;
+        calc.SetGeomCam(dynamic_cast<MGeomCam*>(plist.FindObject("MGeomCam")));
+        if (!calc.CheckPedestalRms(fBadPixels, fPedestalCamOut))
+        {
+            *fLog << err << "ERROR - Checking PedestalRMS via MBadPixelsCalc failed...." << endl;
+            return kFALSE;
+        }
+    }
+
     if (fDisplayType!=kDisplayNone)
         DisplayResult(plist);
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 7124)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 7125)
@@ -72,4 +72,5 @@
 
     Bool_t fIsUseHists;                      // Switch on histogramming or not
+    Bool_t fDeadPixelCheck;                  // Should the dead pixel check be done?
 
     MExtractor *ReadCalibration();
@@ -110,4 +111,5 @@
     void SetUseData()                           { fExtractType = kUseData;   }
     void SetUseHists( const Bool_t b=kTRUE)     { fIsUseHists = b;  }
+    void SetDeadPixelCheck(const Bool_t b=kTRUE) { fDeadPixelCheck = b; }
     void SetUsePedRun()                         { fExtractType = kUsePedRun; }
     void SetDataCheckDisplay()                  { fDisplayType = kDisplayDataCheck; }
