Index: trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 8452)
@@ -16,7 +16,4 @@
 #pragma link C++ class MCalibConstCam+;
 #pragma link C++ class MCalibConstPix+;
-
-#pragma link C++ class MCalibrationIntensityCam+;
-#pragma link C++ class MCalibrationIntensityChargeCam+;
 
 #pragma link C++ class MCalibrationCam+;
Index: trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc	(revision 8452)
@@ -30,8 +30,6 @@
 //  Input Containers:
 //   MParList
-//   MCalibrationIntensityChargeCam
 //
 //  Output Containers:
-//   MCalibrationIntensityChargeCam
 //
 // Class version 2:
@@ -55,10 +53,9 @@
 #include "MHCalibrationCam.h"
 
-#include "MCalibrationIntensityChargeCam.h"
-
 #include "MBadPixelsCam.h"
 
 #include "MCalibrationQECam.h"
 #include "MCalibrationBlindCam.h"
+#include "MCalibrationChargeCam.h"
 #include "MCalibrationChargePix.h"
 #include "MCalibrationChargeCalc.h"
@@ -83,5 +80,5 @@
 MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
     : fGeom(NULL), fParList(NULL), fRunHeader(NULL),
-    fIntensCharge(NULL), fBlindCam(NULL), fQECam(NULL), fBadPixels(NULL),
+    fCharge(NULL), fBlindCam(NULL), fQECam(NULL), fBadPixels(NULL),
     fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
     fNumCam(0), fNumEvents(0), fUpdateWithFFactorMethod(kTRUE), fUpdateNumPhes(kTRUE),
@@ -133,5 +130,5 @@
 
   //
-  // Look for the MBadPixels Intensity Cam
+  // Look for the MCalibrationQECam
   //
   fQECam = (MCalibrationQECam*)pList->FindObject("MCalibrationQECam");
@@ -143,6 +140,5 @@
 
   // 
-  // Look for the MFillH-class "MHCalibrationBlindCam". In case yes, initialize the 
-  // corresponding IntensityCam
+  // Look for the MFillH-class "MHCalibrationBlindCam".
   //
   if (pList->FindObject(AddSerialNumber("MHCalibrationBlindCam")))
@@ -156,20 +152,12 @@
 
   //
-  // Look for the MFillH-class "MHCalibrationChargeCam". In case yes, initialize the 
-  // corresponding IntensityCam
+  // Look for the MFillH-class "MHCalibrationChargeCam". 
   //
   if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
   {
 
-    fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
-    if (!fIntensCharge)
-        return kFALSE;
-
-    MCalibrationChargeCam *chargeinit = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam");
-
-    if (chargeinit)
-      fIntensCharge->SetCam(chargeinit,0);
-    else
-      *fLog << "Could not find initial MCalibrationChargeCam, cannot initialize intensity cam" << endl;
+    fCharge = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
+    if (!fCharge)
+        return kFALSE;
 
     if (!fChargeCalc)
@@ -194,12 +182,8 @@
 
   // 
-  // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the 
-  // corresponding IntensityCam
+  // Look for the MFillH name "FillRelTimeCam".
   //
   if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
   {
-    // if (!pList->FindCreateObj("MCalibrationIntensityRelTimeCam"))
-    //    return kFALSE;
-
     if (!fRelTimeCalc)
       fRelTimeCalc   = (MCalibrationRelTimeCalc*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCalc"));
@@ -252,8 +236,8 @@
 //
 // - Initializes new containers in the 
-// - Intensity Cams, if the number of calibration events has reach fNumEventsDump. 
+// - if the number of calibration events has reach fNumEventsDump.
 // - Executes Finalize() of the MCalibration*Calc classes in that case.
 // - Sets the latest MCalibrationChargeCam as update class into MCalibrateData
-// - Initialize new MCalibration*Cams into the intensity cams.
+// - clean MCalibration*Cams
 //
 Int_t MCalibCalcFromPast::Process()
@@ -263,5 +247,5 @@
 
   // Replace the old cams by (empty) new ones
-  // MCalibrationChargeCam: fIntensCharge
+  // MCalibrationChargeCam: fCharge
   // MCalibrationQECam:     fIntensQE
   // MCalibrationBlindCam:  fIntensBlind
@@ -276,5 +260,5 @@
   *fLog << inf << "Finalize calibration histograms:" << endl;
 
-  // This fills the IntensityCam which are newly created by
+  // This fills the Cams which are cleared by
   // ReInitialize with the result of the last calib cycle
   Finalize("MHCalibrationChargeCam");
@@ -299,5 +283,5 @@
         if (fUpdateNumPhes)
         {
-          MCalibrationChargePix &avpix =(MCalibrationChargePix&)fIntensCharge->GetCam()->GetAverageArea(0);
+          MCalibrationChargePix &avpix =(MCalibrationChargePix&)fCharge->GetAverageArea(0);
           fPhes   [fNumPhes] = avpix.GetPheFFactorMethod();
           fPhesVar[fNumPhes] = avpix.GetPheFFactorMethodVar();
@@ -329,6 +313,5 @@
 
   if (fCalibrate)
-    return fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL
-                                               : (MCalibrationChargeCam*)fIntensCharge->GetCam() );
+    return fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL : fCharge);
 
   return kTRUE;
@@ -358,7 +341,5 @@
 // --------------------------------------------------------------------------
 //
-// Re-Intitializes new containers inside the Intensity Cams. 
-// From now on, a call to the IntensityCam functions returns pointers 
-// to the newly created Containers.
+// Clear contents of cams
 //
 Bool_t MCalibCalcFromPast::ReInitialize()
@@ -391,19 +372,9 @@
   // IF SIMPLE ENOUGH, REMOVE THE FUNCTION!
 
-  if (fIntensCharge)
-  {
-        *fLog << "MCalibrationChargeCam...";
-        MCalibrationChargeCam *cold = (MCalibrationChargeCam*)fIntensCharge->GetCam();
-
-        fIntensCharge->AddToList(Form("MCalibrationChargeCam%04d",fNumCam),*fGeom);
-
-        MCalibrationChargeCam *cnew = (MCalibrationChargeCam*)fIntensCharge->GetCam();
-        cnew->SetRunNumber(runnumber);
-
-        if (cold)
-        {
-            cnew->MergeHiLoConversionFactors(*cold);
-            fIntensCharge->DeleteOldCam(cold);
-        }
+  if (fCharge)
+  {
+      *fLog << "MCalibrationChargeCam...";
+      fCharge->Clear();
+      fCharge->SetRunNumber(runnumber);
   }
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h	(revision 8452)
@@ -17,5 +17,5 @@
 class MCalibrationRelTimeCalc;
 class MCalibrateData;
-class MCalibrationIntensityChargeCam;
+class MCalibrationChargeCam;
 class MCalibrationBlindCam;
 class MCalibrationQECam;
@@ -32,5 +32,5 @@
   MParList                        *fParList;         //! Parameter List
   MRawRunHeader                   *fRunHeader;       //! Run header storing the run number
-  MCalibrationIntensityChargeCam  *fIntensCharge;    //! Intensity Charge Cam (to be created)
+  MCalibrationChargeCam           *fCharge;          //! Intensity Charge Cam (to be created)
 
   MCalibrationBlindCam            *fBlindCam;        //! Blind  Cam
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc	(revision 8452)
@@ -33,8 +33,6 @@
 //   MCalibrationPattern
 //   MParList
-//   MCalibrationIntensityChargeCam
 //
 //  Output Containers:
-//   MCalibrationIntensityChargeCam
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -55,6 +53,4 @@
 #include "MBadPixelsCam.h"
 
-#include "MCalibrationIntensityChargeCam.h"
-
 #include "MCalibrationPattern.h"
 #include "MCalibrationQECam.h"
@@ -76,6 +72,5 @@
 //
 MCalibColorSteer::MCalibColorSteer(const char *name, const char *title)
-    : fCalibPattern(NULL), fGeom(NULL), fParList(NULL), 
-      fIntensCharge(NULL),
+    : fCalibPattern(NULL), fGeom(NULL), fParList(NULL), fCharge(NULL),
       fBad(NULL), fChargeCalc(NULL), fRelTimeCalc(NULL), fHistCopy(kFALSE)
 {
@@ -148,6 +143,5 @@
 
   // 
-  // Look for the MFillH name "FillChargeCam". In case yes, initialize the 
-  // corresponding IntensityCam
+  // Look for the MFillH name "FillChargeCam".
   //
   if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
@@ -155,6 +149,6 @@
       *fLog << inf << "Found MHCalibrationChargeCam ... " << flush;
 
-      fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
-      if (!fIntensCharge)
+      fCharge = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
+      if (!fCharge)
           return kFALSE;
 
@@ -172,6 +166,5 @@
 
   // 
-  // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the 
-  // corresponding IntensityCam
+  // Look for the MFillH name "FillRelTimeCam".
   //
   if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
@@ -199,6 +192,6 @@
 // --------------------------------------------------------------------------
 //
-// Reads the pattern from MCalibrationPattern and initializes new containers in the 
-// Intensity Cams, if the pattern has changed. Executes Finalize of the 
+// Reads the pattern from MCalibrationPattern and clear
+// Cams, if the pattern has changed. Executes Finalize of the
 // MCalibration*Calc classes in that case.
 //
@@ -256,6 +249,6 @@
 // --------------------------------------------------------------------------
 //
-// Reads the pattern from MCalibrationPattern and initializes new containers in the 
-// Intensity Cams, if the pattern has changed. Executes Finalize of the 
+// Reads the pattern from MCalibrationPattern and clear
+// Cams, if the pattern has changed. Executes Finalize of the
 // MCalibration*Calc classes in that case.
 //
@@ -290,5 +283,5 @@
 
   hist->Finalize();
-  CopyHist(name);
+  //CopyHist(name);
   hist->ResetHists();
   hist->SetColor( fCalibPattern->GetPulserColor());
@@ -298,7 +291,5 @@
 // --------------------------------------------------------------------------
 //
-// Re-Intitializes new containers inside the Intensity Cams. 
-// From now on, a call to the IntensityCam functions returns pointers 
-// to the newly created Containers.
+// Clear cams
 //
 Bool_t MCalibColorSteer::ReInitialize()
@@ -310,22 +301,22 @@
 
   fBad->Clear(); // FIXME:::::: MERGE PreExcl!!!!
-  fQECam->Clear();
+
+  if (fQECam)
+      fQECam->Clear();
 
   fBlindCam->Clear();
   fBlindCam->SetPulserColor(fCalibPattern->GetPulserColor());
 
-  fRelTimeCam->Clear();
-  fRelTimeCam->SetPulserColor(fCalibPattern->GetPulserColor());
-
-  if (fIntensCharge)
-    {
-      MCalibrationChargeCam *oldcam = (MCalibrationChargeCam*)fIntensCharge->GetCam();
-      fIntensCharge->AddToList(Form("MCalibrationChargeCam%s",namep.Data()),*fGeom);
-      MCalibrationChargeCam *cam    = (MCalibrationChargeCam*)fIntensCharge->GetCam();
-      cam->SetPulserColor(fCalibPattern->GetPulserColor());
-      if (!cam->MergeHiLoConversionFactors(*oldcam))
-          return kFALSE;
-      *fLog << inf << "New MCalibrationChargeCam with name: " << cam->GetName() << endl;
-    }
+  if (fRelTimeCam)
+  {
+      fRelTimeCam->Clear();
+      fRelTimeCam->SetPulserColor(fCalibPattern->GetPulserColor());
+  }
+
+  if (fCharge)
+  {
+      fCharge->Clear();
+      fCharge->SetPulserColor(fCalibPattern->GetPulserColor());
+  }
 
   return kTRUE;
@@ -360,26 +351,2 @@
   return result;
 }
-
-// --------------------------------------------------------------------------
-//
-// Copies the histogram classes into the intensity cams
-//
-void MCalibColorSteer::CopyHist(const char* name)
-{
-  MHCalibrationCam *hcam = (MHCalibrationCam*)fParList->FindObject(name);
-  TString n(name);
-  if (n.Contains("ChargeCam"))
-    {
-      if (fIntensCharge)
-	  fIntensCharge->AddHist((MHCalibrationCam*)hcam->Clone());
-    }
-//  if (n.Contains("Blind"))
-//    if (fIntensBlind)
-//	  fIntensBlind->AddHist((MHCalibrationCam*)hcam->Clone());
-
-//  if (n.Contains("RelTime"))
-//    if (fIntensRelTime)
-//	  fIntensRelTime->AddHist((MHCalibrationCam*)hcam->Clone());
-}
-
-// --------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.h	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.h	(revision 8452)
@@ -16,6 +16,6 @@
 class MRawRunHeader;
 class MCalibrationChargeCalc;
+class MCalibrationChargeCam;
 class MCalibrationRelTimeCalc;
-class MCalibrationIntensityChargeCam;
 class MCalibrationRelTimeCam;
 class MCalibrationBlindCam;
@@ -30,28 +30,28 @@
   MGeomCam                        *fGeom;            //!
   MParList                        *fParList;         //!
-  MCalibrationIntensityChargeCam  *fIntensCharge;    //!
+  MCalibrationChargeCam           *fCharge;          //!
   MCalibrationRelTimeCam          *fRelTimeCam;      //!
   MCalibrationBlindCam            *fBlindCam;        //!
   MCalibrationQECam               *fQECam;           //!
   MBadPixelsCam                   *fBad;             //!
-  
+
   MCalibrationChargeCalc          *fChargeCalc;      //!
   MCalibrationRelTimeCalc         *fRelTimeCalc;     //!
-                                                     
+
   MCalibrationCam::PulserColor_t   fColor;
   Float_t                          fStrength;
 
   Bool_t                           fHistCopy;        // Decide whether MHCalibrationCams will get copied
-  
+
   Int_t  PreProcess(MParList *pList);
   Int_t  Process();
   Int_t  PostProcess();
-  
+
   Bool_t ReInitialize();
   Bool_t Finalize(const char* name);
 
-  void    CopyHist(const char* name);
+  //void    CopyHist(const char* name);
   TString GetNamePattern();
-  
+
 public:
     MCalibColorSteer(const char *name=NULL, const char *title=NULL);
Index: trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 8452)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.67 2007-04-20 11:48:08 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.68 2007-04-27 10:04:46 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -114,5 +114,4 @@
 #include "MPedestalPix.h"
 
-#include "MCalibrationIntensityChargeCam.h"
 #include "MCalibrationChargeCam.h"
 #include "MCalibrationChargePix.h"
@@ -155,5 +154,5 @@
 //
 MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title) 
-    : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL), fIntensCalib(NULL),
+    : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL),
       fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
     fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1.)
@@ -238,8 +237,4 @@
     if (fCalibrationMode>kNone)
     {
-        fIntensCalib = (MCalibrationIntensityChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));
-        if (fIntensCalib)
-          *fLog << inf << "Found MCalibrationIntensityChargeCam ... " << endl;
-
         fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
         if (!fCalibrations)
@@ -465,7 +460,5 @@
     if (fCalibrationMode > kNone)
     {
-
-        const MCalibrationCam *chargecam = fIntensCalib ? fIntensCalib->GetCam() : fCalibrations;
-        if (chargecam->GetSize() != npixels)
+        if (fCalibrations->GetSize() != npixels)
         {
             *fLog << "Size mismatch between MGeomCam and MCalibrationChargeCam... abort!" << endl;
@@ -478,6 +471,6 @@
             return kFALSE;
         }
-      }
-    
+    }
+
     fCalibConsts  .Set(npixels);
     fCalibFFactors.Set(npixels);
@@ -512,10 +505,4 @@
     fHiLoConv.Reset();
     fHiLoConvErr.Reset();
-
-    MCalibrationChargeCam *chargecam = NULL;
-    if (updatecam)
-        chargecam = fCalibrations;
-    else
-        chargecam = fIntensCalib ? (MCalibrationChargeCam*)fIntensCalib->GetCam() : fCalibrations;
 
     //
@@ -546,14 +533,14 @@
              }
             
-            const MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[pixidx];
-            const MCalibrationChargePix &avpix = (MCalibrationChargePix&)chargecam->GetAverageArea(0);
+            const MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*fCalibrations)[pixidx];
+            const MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCalibrations->GetAverageArea(0);
 
             hiloconv   = pix.GetConversionHiLo     ();
             hiloconverr= pix.GetConversionHiLoSigma();
-            
+
             calibConv    = pix.GetMeanConvFADC2Phe();
             calibConvVar = pix.GetMeanConvFADC2PheVar();
             calibFFactor = pix.GetMeanFFactorFADC2Phot();
-            
+
             const MCalibrationQEPix &qe = (MCalibrationQEPix&)(*fQEs)[pixidx];
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrateData.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrateData.h	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrateData.h	(revision 8452)
@@ -20,6 +20,4 @@
 class MCalibrationChargeCam;
 class MCalibrationQECam;
-
-class MCalibrationIntensityChargeCam;
 
 class MCalibrateData : public MTask
@@ -63,5 +61,4 @@
   MBadPixelsCam                  *fBadPixels;     //! Bad Pixels information
   MCalibrationChargeCam          *fCalibrations;  //! Calibration constants
-  MCalibrationIntensityChargeCam *fIntensCalib;   //! Calibration constants from interlaced calib.
   MCalibrationQECam              *fQEs;           //! Quantum efficiencies
   MExtractedSignalCam            *fSignals;       //! Integrated charge in FADCs counts
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 8452)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.176 2007-04-20 13:21:11 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.177 2007-04-27 10:04:46 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -200,4 +200,7 @@
 //   -  TString fOutputFile
 //
+//  ClassVersion 6:
+//   -  Bool_t fContinousCalibration
+//
 //////////////////////////////////////////////////////////////////////////////
 #include "MCalibrationChargeCalc.h"
@@ -220,6 +223,4 @@
 #include "MPedestalCam.h"
 #include "MPedestalPix.h"
-
-#include "MCalibrationIntensityChargeCam.h"
 
 #include "MHCalibrationChargeCam.h"
@@ -362,5 +363,4 @@
 
     fBadPixels   = NULL;
-    fIntensCam   = NULL;
     fCam         = NULL;
     fHCam        = NULL;
@@ -440,5 +440,5 @@
 // Search for the following input containers and abort if not existing:
 //  - MGeomCam
-// -  MCalibrationIntensityChargeCam or MCalibrationChargeCam
+// -  MCalibrationChargeCam
 //  - MCalibrationQECam
 //  - MBadPixelsCam
@@ -455,5 +455,4 @@
 // It defines the PixId of every pixel in:
 //
-// - MCalibrationIntensityChargeCam 
 // - MCalibrationChargeCam 
 // - MCalibrationQECam
@@ -495,20 +494,14 @@
   
     //
-    // Intensity containers
+    // MCalibrationChargeCam
     //
-  fIntensCam = (MCalibrationIntensityChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));
-  if (fIntensCam)
-    *fLog << inf << "Found MCalibrationIntensityChargeCam... " << flush;
-  else
-    {
-      fCam = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
-      if (!fCam)
-        {
-          *fLog << err << "Cannot find MCalibrationChargeCam ... abort." << endl;
-          *fLog << "Maybe you forget to call an MFillH for the MHCalibrationChargeCam before..." << endl;
-          return kFALSE;
-        }
-    }
-  
+  fCam = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
+  if (!fCam)
+  {
+      *fLog << err << "Cannot find MCalibrationChargeCam ... abort." << endl;
+      *fLog << "Maybe you forget to call an MFillH for the MHCalibrationChargeCam before..." << endl;
+      return kFALSE;
+  }
+
   //
   // Blind pixel calibration
@@ -550,25 +543,10 @@
   // Further initialization
   //
-  MCalibrationChargeCam *chargecam = fIntensCam 
-    ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
-
-  const UInt_t npixels = fGeom->GetNumPixels();
-  
-  for (UInt_t i=0; i<npixels; i++)
-    {
-
-      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];
-
-      if ((*fBadPixels)[i].IsBad())
-      {
-          MCalibrationQEPix &pqe = (MCalibrationQEPix&)(*fQECam)[i];
-          pix.SetExcluded();
-          pqe.SetExcluded();
-          continue;
-      }
-
-      if (IsDebug())
-        pix.SetDebug();
-    }
+  if (IsDebug())
+  {
+      const UInt_t npixels = fGeom->GetNumPixels();
+      for (UInt_t i=0; i<npixels; i++)
+          (*fCam)[i].SetDebug();
+  }
 
   fResultFlags.Set(fGeom->GetNumAreas());
@@ -606,30 +584,27 @@
   // Now retrieve the colour and check if not various colours have been used
   //
-  if (!fIntensCam)
-    {
-      if (fPulserColor != MCalibrationCam::kNONE)
-        {
-          *fLog << warn << "Multiple colours used simultaneously!" << flush;
-          fHCam->Finalize();
-          if (fHBlindCam)
-            fHBlindCam->Finalize();
-
-          Finalize();
-
-          fHCam->ResetHists();
-          if (fHBlindCam)
-            fHBlindCam->ResetHists();
-
-          *fLog << inf << "Starting next calibration... " << flush;
-
-          fHCam->SetColor(col);
-          if (fHBlindCam)
-            fHBlindCam->SetColor(col);
-
-          fCam->SetPulserColor(col);
-          if (fBlindCam)
-            fBlindCam->SetPulserColor(col);
-        }
-    }
+  if (!fContinousCalibration && fPulserColor != MCalibrationCam::kNONE)
+  {
+      *fLog << warn << "Multiple colours used simultaneously!" << flush;
+      fHCam->Finalize();
+      if (fHBlindCam)
+          fHBlindCam->Finalize();
+
+      Finalize();
+
+      fHCam->ResetHists();
+      if (fHBlindCam)
+          fHBlindCam->ResetHists();
+
+      *fLog << inf << "Starting next calibration... " << flush;
+
+      fHCam->SetColor(col);
+      if (fHBlindCam)
+          fHBlindCam->SetColor(col);
+
+      fCam->SetPulserColor(col);
+      if (fBlindCam)
+          fBlindCam->SetPulserColor(col);
+  }
 
   //
@@ -655,15 +630,11 @@
   // Distribute new color to all containers
   //
+  fCam->SetPulserColor(col);
+  if (fBlindCam)
+    fBlindCam->SetPulserColor(col);
+
   fHCam->SetColor(col);
   if (fHBlindCam)
     fHBlindCam->SetColor(col);
-
-  MCalibrationChargeCam *chargecam = fIntensCam 
-    ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
-
-  chargecam->SetPulserColor(col);
-
-  if (fBlindCam)
-    fBlindCam->SetPulserColor(col);
   if (fPINDiode)
     fPINDiode->SetColor(col);
@@ -724,6 +695,6 @@
 // Call  FinalizeUnsuitablePixels()
 //  
-// Call MParContainer::SetReadyToSave() for fIntensCam, fCam, fQECam, fBadPixels and 
-//                                          fBlindCam and fPINDiode if they exist
+// Call MParContainer::SetReadyToSave() for fCam, fQECam, fBadPixels and
+//      fBlindCam and fPINDiode if they exist
 //
 // Print out some statistics
@@ -749,6 +720,4 @@
       }
 
-  MCalibrationChargeCam *chargecam = fIntensCam   ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
-
   //
   // First loop over pixels, call FinalizePedestals and FinalizeCharges
@@ -759,5 +728,5 @@
     {
 
-      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[pixid];
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[pixid];
       //
       // Check if the pixel has been excluded from the fits
@@ -786,5 +755,5 @@
   if (nvalid == 0)
   {
-    if (!fIntensCam)
+      if (!fContinousCalibration)
       {
         *fLog << warn << GetDescriptor() << ": All pixels have non-valid calibration. " 
@@ -801,5 +770,5 @@
 
       const MPedestalPix    &ped = fPedestals->GetAverageArea(aidx);
-      MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
       const MArrayI &arr         = fHCam->GetAverageAreaNum();
 
@@ -814,6 +783,6 @@
       pix.SetSigma (pix.GetSigma()/pix.GetFFactorFADC2Phe());
 
-      FinalizeCharges(pix, chargecam->GetAverageBadArea(aidx),"area id");
-      FinalizeArrivalTimes(pix, chargecam->GetAverageBadArea(aidx), "area id");
+      FinalizeCharges(pix, fCam->GetAverageBadArea(aidx),"area id");
+      FinalizeArrivalTimes(pix, fCam->GetAverageBadArea(aidx), "area id");
     }
   
@@ -825,5 +794,5 @@
       const MPedestalPix     &ped = fPedestals->GetAverageSector(sector);
 
-      MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageSector(sector);
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
       FinalizePedestals(ped,pix, 0);
     }
@@ -840,11 +809,11 @@
   //
   if (FinalizeFFactorMethod())
-    chargecam->SetFFactorMethodValid(kTRUE);
+    fCam->SetFFactorMethodValid(kTRUE);
   else
     {
       *fLog << warn << "Could not calculate the photons flux from the F-Factor method " << endl;
-      chargecam->SetFFactorMethodValid(kFALSE); 
-      if (!fIntensCam)
-	return kFALSE;
+      fCam->SetFFactorMethodValid(kFALSE);
+      if (!fContinousCalibration)
+          return kFALSE;
     }
 
@@ -916,6 +885,6 @@
                     "Deviating F-Factor:                     ");
 
-  chargecam->SetReadyToSave();
-  fQECam    ->SetReadyToSave();
+  fCam->SetReadyToSave();
+  fQECam->SetReadyToSave();
   fBadPixels->SetReadyToSave();
 
@@ -1109,5 +1078,5 @@
   if (!cal.CalcConvFFactor())
     {
-      *fLog << warn << desc << "Could not calculate the Conv. FADC counts to Phes" << endl;
+      *fLog << warn << desc << "Could not calculate the conv. FADC cts to phes" << endl;
       bad.SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
       return kFALSE;
@@ -1149,6 +1118,4 @@
 // - MBadPixelsPix::kLoGainOverFlow
 //
-// - Call MCalibrationPix::SetExcluded() for the bad pixels
-//
 // Sets pixel to MBadPixelsPix::kUnreliableRun, if one of the following flags is set:
 // - MBadPixelsPix::kChargeSigmaNotValid 
@@ -1176,5 +1143,5 @@
             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
         }
-      
+
       if (IsCheckDeviatingBehavior())
         {
@@ -1182,14 +1149,14 @@
             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
         }
-      
+
       if (IsCheckHistOverflow())
         {
           if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOverFlow   ))
             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
-          
+
           if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOverFlow   ))
             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
         }
-      
+
       if (IsCheckArrivalTimes())
         {
@@ -1235,7 +1202,4 @@
 Bool_t MCalibrationChargeCalc::FinalizeFFactorMethod()
 {
-  MCalibrationChargeCam *chargecam = fIntensCam 
-    ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
-
   const Int_t npixels  = fGeom->GetNumPixels();
   const Int_t nareas   = fGeom->GetNumAreas();
@@ -1260,5 +1224,5 @@
   for (Int_t i=0; i<npixels; i++)
     {
-      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
 
       MBadPixelsPix &bad = (*fBadPixels)[i];
@@ -1385,5 +1349,5 @@
     {
       
-      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
 
       if (!pix.IsFFactorMethodValid())
@@ -1440,5 +1404,5 @@
     {
 
-      MCalibrationChargePix &apix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
+      MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
 
       if (numareavalid[aidx] == 1)
@@ -1495,5 +1459,5 @@
         }
       
-      MCalibrationChargePix &spix = (MCalibrationChargePix&)chargecam->GetAverageSector(sector);
+      MCalibrationChargePix &spix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
 
       if (sectorweights[sector] < 0. || sectorphes[sector] <= 0.)
@@ -1524,5 +1488,5 @@
     {
       
-      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i];
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
 
       MBadPixelsPix &bad = (*fBadPixels)[i];
@@ -1534,5 +1498,5 @@
         {
           const Int_t            aidx = (*fGeom)[i].GetAidx();
-          MCalibrationChargePix &apix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
+          MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
 
           pix.SetPheFFactorMethod   ( apix.GetPheFFactorMethod()    );
@@ -1726,8 +1690,5 @@
     }
   
-  MCalibrationChargeCam *chargecam = fIntensCam 
-    ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
-
-  MCalibrationChargePix &avpix = (MCalibrationChargePix&)chargecam->GetAverageArea(0);
+  MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCam->GetAverageArea(0);
   MCalibrationQEPix     &qepix = (MCalibrationQEPix&)    fQECam->GetAverageArea(0);
 
@@ -1757,8 +1718,8 @@
   // Set the results in the MCalibrationChargeCam
   //
-  chargecam->SetNumPhotonsFFactorMethod (avphotons);
+  fCam->SetNumPhotonsFFactorMethod (avphotons);
 
   if (avphotrelvar > 0.)
-    chargecam->SetNumPhotonsFFactorMethodErr(TMath::Sqrt( avphotrelvar * avphotons * avphotons));  
+    fCam->SetNumPhotonsFFactorMethodErr(TMath::Sqrt( avphotrelvar * avphotons * avphotons));
 
   TArrayF lowlim           (nareas);
@@ -1775,6 +1736,6 @@
     {
       
-      MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[i];
-      MCalibrationQEPix     &qpix  = (MCalibrationQEPix&)    (*fQECam)   [i];
+      MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*fCam)[i];
+      MCalibrationQEPix     &qpix  = (MCalibrationQEPix&)    (*fQECam)[i];
 
       MBadPixelsPix &bad = (*fBadPixels)[i];
@@ -1895,6 +1856,5 @@
     {
       
-      MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[i];
-
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
       MBadPixelsPix &bad = (*fBadPixels)[i];
 
@@ -1920,6 +1880,6 @@
     {
       
-      MCalibrationChargePix &pix  = (MCalibrationChargePix&)(*chargecam)[i];
-      MCalibrationQEPix     &qpix = (MCalibrationQEPix&)    (*fQECam)   [i];
+      MCalibrationChargePix &pix  = (MCalibrationChargePix&)(*fCam)[i];
+      MCalibrationQEPix     &qpix = (MCalibrationQEPix&)(*fQECam)[i];
 
       if ((*fBadPixels)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
@@ -1957,8 +1917,4 @@
     return;
 
-  MCalibrationChargeCam *chargecam = fIntensCam
-    ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
-
-
   //
   // Set the results in the MCalibrationChargeCam
@@ -1969,5 +1925,5 @@
       const Float_t photons = fBlindCam->GetFluxInsidePlexiglass() * (*fGeom)[0].GetA()
                            / fQECam->GetPlexiglassQE();
-      chargecam->SetNumPhotonsBlindPixelMethod(photons);
+      fCam->SetNumPhotonsBlindPixelMethod(photons);
           
       const Float_t photrelvar = fBlindCam->GetFluxInsidePlexiglassRelVar()
@@ -1975,5 +1931,5 @@
  
       if (photrelvar > 0.)
-        chargecam->SetNumPhotonsBlindPixelMethodErr(TMath::Sqrt( photrelvar * photons * photons));  
+        fCam->SetNumPhotonsBlindPixelMethodErr(TMath::Sqrt( photrelvar * photons * photons));
     }
   
@@ -2002,6 +1958,6 @@
         }
       
-      MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[i];
-      MGeomPix              &geo   =                         (*fGeom)    [i];
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
+      MGeomPix &geo = (*fGeom)[i];
 
       const Float_t qe        = pix.GetPheFFactorMethod() 
@@ -2046,7 +2002,4 @@
   const UInt_t npixels  = fGeom->GetNumPixels();
 
-  MCalibrationChargeCam *chargecam = fIntensCam 
-    ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
-
   if (!fPINDiode)
     return;
@@ -2080,9 +2033,9 @@
           continue;
         }
-      
-      MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[i];
-      MGeomPix              &geo =                           (*fGeom)    [i];
-      
-      const Float_t qe       =  pix.GetPheFFactorMethod() 
+
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
+      MGeomPix &geo = (*fGeom)[i];
+
+      const Float_t qe       =  pix.GetPheFFactorMethod()
                                / fPINDiode->GetFluxOutsidePlexiglass() 
                                / geo.GetA();
@@ -2129,5 +2082,5 @@
 //
 // - Print out statistics about BadPixels of type UnsuitableType_t 
-// - store numbers of bad pixels of each type in fCam or fIntensCam
+// - store numbers of bad pixels of each type in fCam
 //
 Bool_t MCalibrationChargeCalc::FinalizeUnsuitablePixels()
@@ -2143,6 +2096,4 @@
   TArrayI unsuit(nareas);
   TArrayI unrel(nareas);
-
-  MCalibrationChargeCam *chargecam = fIntensCam ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;
 
   Int_t unsuitcnt=0;
@@ -2159,12 +2110,12 @@
       unrelcnt    += unrel[aidx];
 
-      chargecam->SetNumUnsuitable(unsuit[aidx], aidx);
-      chargecam->SetNumUnreliable(unrel[aidx],  aidx);
+      fCam->SetNumUnsuitable(unsuit[aidx], aidx);
+      fCam->SetNumUnreliable(unrel[aidx],  aidx);
   }
 
   TArrayI counts(nareas);
-  for (Int_t i=0; i<chargecam->GetSize(); i++)
+  for (Int_t i=0; i<fCam->GetSize(); i++)
   {
-      MCalibrationPix &pix = (*chargecam)[i];
+      const MCalibrationPix &pix = (*fCam)[i];
       if (pix.IsHiGainSaturation())
       {
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 8452)
@@ -23,8 +23,6 @@
 class MCalibrationChargePINDiode;
 class MHCalibrationChargeBlindCam;
-class MCalibrationIntensityBlindCam;
 class MCalibrationBlindCam;
 class MCalibrationChargePix;
-class MCalibrationIntensityChargeCam;
 class MCalibrationChargeCam;
 class MHCalibrationChargeCam;
@@ -81,12 +79,12 @@
 
   Int_t   fNumProcessed;                       // Number of processed events (for Intensity calibration)
-  
+
+  Bool_t fContinousCalibration;
+
   // Pointers
 //  MBadPixelsIntensityCam         *fIntensBad;      //!  Bad Pixels
   MBadPixelsCam                  *fBadPixels;      //!  Bad Pixels
-  MCalibrationIntensityChargeCam *fIntensCam;      //!  Intensity Calibration results of all pixels   
   MCalibrationChargeCam          *fCam;            //!  Calibrated Charges results of all pixels
   MHCalibrationChargeCam         *fHCam;           //!  Charges histograms of all pixels   
-  MCalibrationIntensityBlindCam  *fIntensBlind;    //!  Intensity Calibration results of the Blind Pixels
   MCalibrationBlindCam           *fBlindCam;       //!  Calibrated Charges of the Blind Pixels
   MHCalibrationChargeBlindCam    *fHBlindCam;      //!  Charges histograms of the Blind Pixels  
@@ -198,4 +196,6 @@
   void SetUseExternalNumPhes(const Bool_t b=kTRUE)     { b ? SETBIT(fFlags, kUseExternalNumPhes)         : CLRBIT(fFlags, kUseExternalNumPhes); }
 
+  void SetContinousCalibration(const Bool_t b=kTRUE)   { fContinousCalibration = b; }
+
   // pointers
   void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
@@ -217,6 +217,6 @@
   void SetPheErrUpperLimit     ( const Float_t f=fgPheErrUpperLimit       ) { fPheErrUpperLimit  = f;    }    
   void SetPulserColor          ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;  }
-  
-  ClassDef(MCalibrationChargeCalc, 5)   // Task calculating Calibration Containers and Quantum Efficiencies
+
+  ClassDef(MCalibrationChargeCalc, 6)   // Task calculating Calibration Containers and Quantum Efficiencies
 };
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 8452)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1.69 2006-10-17 17:18:40 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1.70 2007-04-27 10:04:46 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -216,17 +216,15 @@
 void MCalibrationChargeCam::Clear(Option_t *o)
 {
-
+  // DO NOT RESET THE HI-/LO-GAIN CONSTANTS
   SetFFactorMethodValid    ( kFALSE );
 
-  fNumPhotonsBlindPixelMethod    = 0.; 
-  fNumPhotonsFFactorMethod       = 0.; 
-  fNumPhotonsPINDiodeMethod      = 0.; 
-  fNumPhotonsBlindPixelMethodErr = 0.; 
-  fNumPhotonsFFactorMethodErr    = 0.;  
-  fNumPhotonsPINDiodeMethodErr   = 0.;  
+  fNumPhotonsBlindPixelMethod    = 0.;
+  fNumPhotonsFFactorMethod       = 0.;
+  fNumPhotonsPINDiodeMethod      = 0.;
+  fNumPhotonsBlindPixelMethodErr = 0.;
+  fNumPhotonsFFactorMethodErr    = 0.;
+  fNumPhotonsPINDiodeMethodErr   = 0.;
 
   MCalibrationCam::Clear();
-
-  return;
 }
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 8452)
@@ -64,4 +64,6 @@
 #include "MLogManip.h"
 
+#include "MMath.h"
+
 #include "MParList.h"
 
@@ -81,9 +83,9 @@
 using namespace std;
 
-const Float_t MCalibrationRelTimeCalc::fgRelTimeResolutionLimit = 0.05;
+const Float_t MCalibrationRelTimeCalc::fgRelTimeResolutionLimit = 5.0;
 
 // --------------------------------------------------------------------------
 //
-// Default constructor. 
+// Default constructor.
 //
 // Sets all pointers to NULL
@@ -98,10 +100,10 @@
     : fGeom(NULL), fFlags(0)
 {
-        
+
   fName  = name  ? name  : "MCalibrationRelTimeCalc";
   fTitle = title ? title : "Task to finalize the relative time calibration";
 
   SetCheckFitResults       ( kFALSE );
-  SetCheckDeviatingBehavior( kFALSE );
+  SetCheckDeviatingBehavior( kTRUE  );
   SetCheckHistOverflow     ( kFALSE );
   SetCheckOscillations     ( kFALSE );
@@ -164,17 +166,9 @@
   }
 
-  const UInt_t npixels = fGeom->GetNumPixels();
-  for (UInt_t i=0; i<npixels; i++)
+  if (IsDebug())
   {
-      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
-
-      if ((*fBadPixels)[i].IsBad())
-      {
-          pix.SetExcluded();
-          continue;
-      }
-
-      if (IsDebug())
-          pix.SetDebug();
+      const UInt_t npixels = fGeom->GetNumPixels();
+      for (UInt_t i=0; i<npixels; i++)
+          (*fCam)[i].SetDebug();
   }
 
@@ -233,5 +227,5 @@
 
   PrintUncalibrated(MBadPixelsPix::kDeviatingTimeResolution,    
-                    Form("%s%2.1f%s","Time resol. less than ", fRelTimeResolutionLimit, " FADC sl. from Mean:"));
+                    Form("%s%2.1f%s","Time resol. less than ", fRelTimeResolutionLimit, " med-dev from median:"));
   PrintUncalibrated(MBadPixelsPix::kRelTimeOscillating,   
                     "Pixels with changing Rel. Times over time:");
@@ -245,120 +239,83 @@
 // ----------------------------------------------------------------------------------------------------
 //
-//
-// First loop: Calculate a mean and mean RMS of time resolution per area index 
-//             Include only pixels which are not MBadPixelsPix::kUnsuitableRun or 
-//             MBadPixelsPix::kUnreliableRun (see FinalizeBadPixels())
-//              
-// Second loop: Exclude those deviating by more than fRelTimeResolutionLimit FADC slices
-//              from the mean (obtained in first loop). Set 
-//              MBadPixelsPix::kDeviatingTimeResolution if excluded.
-// 
+// Check for outliers. They are marked with
+// MBadPixelsPix::kDeviatingTimeResolution
+//
 void MCalibrationRelTimeCalc::FinalizeRelTimes()
 {
-
-  const UInt_t npixels  = fGeom->GetNumPixels();
-  const UInt_t nareas   = fGeom->GetNumAreas();
-
-  TArrayF lowlim       (nareas);
-  TArrayF upplim       (nareas);
-  TArrayF areasum      (nareas);
-  TArrayI numareavalid (nareas);
-  TArrayI useunreliable(nareas);
-
-  //
-  // Apero loop: Count number of unreliable pixels:
-  //     
-  for (UInt_t i=0; i<npixels; i++)
-    {
-      MBadPixelsPix &bad = (*fBadPixels)[i];
-      const Int_t  aidx  = (*fGeom)[i].GetAidx();
-
-      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
-        continue;
-
-      if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
-        continue;
-
-      numareavalid[aidx] ++;
-    }
-
-  for (UInt_t aidx=0; aidx<nareas; aidx++)
-    if (numareavalid[aidx] < 100)
-      useunreliable[aidx] = 1;
-
-  numareavalid.Reset();
-  //
-  // First loop: Get mean time resolution the RMS
-  //             The loop is only to recognize later pixels with very deviating numbers
-  //
-  for (UInt_t i=0; i<npixels; i++)
-    {
-
-      const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
-
-      if (pix.IsExcluded())
-        continue;
-
-      MBadPixelsPix &bad = (*fBadPixels)[i];
-      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
-        continue;
-
-      const Int_t   aidx  = (*fGeom)[i].GetAidx();
-
-      if (!useunreliable[aidx])
-        if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
-          continue;
-
-      const Float_t res   = pix.GetTimePrecision();
-
-      areasum     [aidx] += res;
-      //      areasum2    [aidx] += res*res;
-      numareavalid[aidx] ++;
-    }
-
-
-  for (UInt_t aidx=0; aidx<nareas; aidx++)
-    {
-      if (numareavalid[aidx] < 20)
+    const Int_t npixels = fGeom->GetNumPixels();
+    const Int_t nareas  = fGeom->GetNumAreas();
+
+    // Create an array capable of holding all pixels
+    TArrayF arr(npixels);
+
+    for (Int_t aidx=0; aidx<nareas; aidx++)
+    {
+        Int_t n = 0;
+        for (Int_t i=0; i<npixels; i++)
         {
-          *fLog << warn << "Area   " << setw(4) << aidx << ": Less than 20 pixels with valid time resolution found." << endl;
-          continue;
+            // Check for this aidx only
+            if ((*fGeom)[i].GetAidx()!=aidx)
+                continue;
+
+            // check if pixel may not contain a valid value
+            if ((*fBadPixels)[i].IsUnsuitable())
+                continue;
+
+            // check if it was excluded for some reason
+            const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
+            if (pix.IsExcluded())
+                continue;
+
+            // if TimePrecision is valid fill it into array
+            if (pix.GetTimePrecision()>0)
+                arr[n++] = pix.GetTimePrecision();
         }
 
-      // Calculate the rms out of sum2:
-      /*
-      areasum2[aidx]  = (areasum2[aidx] - areasum[aidx]*areasum[aidx]/numareavalid[aidx]);
-      areasum2[aidx] /= (numareavalid[aidx]-1.);
-      */
-      areasum [aidx] /= numareavalid[aidx];
-      lowlim  [aidx]  = 0;
-      upplim  [aidx]  = areasum [aidx] + fRelTimeResolutionLimit;
-
-    }
-  *fLog << endl;  
-
-
-  for (UInt_t i=0; i<npixels; i++)
-    {
-
-      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
-
-      if (pix.IsExcluded())
-        continue;
-
-      MBadPixelsPix &bad = (*fBadPixels)[i];
-      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
-        continue;
-
-      const Float_t res    = pix.GetTimePrecision();
-      const Int_t   aidx   = (*fGeom)[i].GetAidx();
-
-      if ( res < lowlim[aidx] || res > upplim[aidx] )
+        // Check the ratio of valid entries to the ratio of pixels
+        const Float_t ratio = 100*n/fGeom->GetNumPixWithAidx(aidx);
+        if (3*ratio<2)
+            *fLog << warn << "Area   " << setw(4) << aidx << ": Only " << ratio << "% pixels with valid time resolution found." << endl;
+
+        // Calculate median and median deviation
+        Double_t med;
+        const Double_t dev = MMath::MedianDev(n, arr.GetArray(), med);
+
+        // Now find the outliers
+        for (Int_t i=0; i<npixels; i++)
         {
-            *fLog << warn << "Pixel  " << setw(4) << i << ": Deviating time resolution: "
-                << Form("%4.2f",res) << " out of range ["
-                << Form("%4.2f,%4.2f",lowlim[aidx],upplim[aidx]) << "]" << endl;
-          bad.SetUncalibrated( MBadPixelsPix::kDeviatingTimeResolution);
-          pix.SetExcluded();
+            // Search only within this aidx
+            if ((*fGeom)[i].GetAidx()!=aidx)
+                continue;
+
+            // skip pixels already known to be unsuitable
+            if ((*fBadPixels)[i].IsUnsuitable())
+                continue;
+
+            // check if a pixel has been excluded. This
+            const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
+
+            // Check if time precision is valid (might be invalid
+            // for example in cae of empty histograms)
+            const Float_t res = pix.GetTimePrecision();
+            if (res<0) //FIXME!!! How does this happen?
+            {
+                *fLog << warn << "Pixel  " << setw(4) << i << ": Time resolution not calculated." << endl;
+                (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution);
+                continue;
+            }
+
+            // Now compare to a lower and upper limit
+            const Float_t lolim = TMath::Max(med-fRelTimeResolutionLimit*dev, 0.);
+            const Float_t hilim = TMath::Max(med+fRelTimeResolutionLimit*dev, 0.);
+
+            if (res<=lolim || res>=hilim)
+            {
+                *fLog << warn << "Pixel  " << setw(4) << i << ": Deviating time resolution: "
+                    << Form("%4.2f", res) << " out of range "
+                    << Form("[%4.2f,%4.2f]", lolim, hilim) << endl;
+
+                (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution);
+            }
         }
     }
@@ -373,6 +330,4 @@
 // - MBadPixelsPix::kRelTimeRelErrNotValid 
 //
-// - Call MCalibrationPix::SetExcluded() for the bad pixels
-//
 void MCalibrationRelTimeCalc::FinalizeBadPixels()
 {
@@ -380,10 +335,9 @@
   for (Int_t i=0; i<fBadPixels->GetSize(); i++)
     {
-
       MBadPixelsPix &bad = (*fBadPixels)[i];
 
       if (IsCheckDeviatingBehavior())
           if (bad.IsUncalibrated(MBadPixelsPix::kDeviatingTimeResolution))
-              bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
+              bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
 
       if (IsCheckFitResults())
@@ -394,10 +348,4 @@
           if (bad.IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
               bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
-
-      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
-      {
-          MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
-          pix.SetExcluded();
-      }
     }
 
@@ -460,5 +408,5 @@
 void MCalibrationRelTimeCalc::PrintUncalibrated(const char *text, Int_t in, Int_t out) const
 {
-    *fLog << " " << setfill(' ') << setw(56) << setiosflags(ios::left) << text;
+    *fLog << " " << setfill(' ') << setw(48) << setiosflags(ios::left) << text;
     *fLog << " Inner: " << Form("%3i", in);
     *fLog << " Outer: " << Form("%3i", out);
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc	(revision 8452)
@@ -131,5 +131,5 @@
   *fLog << all << GetDescriptor() << ":" << endl;
   int id = 0;
-  
+
   *fLog << all << "Calibrated pixels:" << endl;
   *fLog << all << endl;
@@ -138,26 +138,26 @@
   MCalibrationRelTimePix *pix;
   while ((pix=(MCalibrationRelTimePix*)Next()))
-    {
-      
-      if (!pix->IsExcluded()) 
-	{                            
-
-          *fLog << all 
-                << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Pix  ",pix->GetPixId(),
-                        ":            Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
-                        "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
-		<< endl;
+  {
+      if (!pix->IsExcluded())
+      {
+          *fLog << all
+              << "Pix  " << Form("%4i", pix->GetPixId()) << ":         "
+              << "   Offset: "
+              << Form("%4.2f +- %4,2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr())
+              << "   Precision: "
+              << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr())
+              << endl;
           id++;
-	}
-    }
-  
+      }
+  }
+
   *fLog << all << id << " pixels" << endl;
   id = 0;
-  
-   
+
+
   *fLog << all << endl;
   *fLog << all << "Excluded pixels:" << endl;
   *fLog << all << endl;
-  
+
   id = 0;
 
@@ -177,8 +177,10 @@
   while ((pix=(MCalibrationRelTimePix*)Next5()))
   {
-    *fLog << all 
-          << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Area   ",pix->GetPixId(),
-                  ":  Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
-                  "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
+      *fLog << all
+          << "Average Area   " << Form("%4i", pix->GetPixId()) << ":"
+          << "Offset: "
+          << Form("%4.2f +- %4,2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr())
+          << "   Precision: "
+          << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr())
           << endl;
   }
@@ -187,8 +189,10 @@
   while ((pix=(MCalibrationRelTimePix*)Next5()))
   {
-    *fLog << all 
-          << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Sector ",pix->GetPixId(),
-                  ":  Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
-                  "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
+      *fLog << all
+          << "Average Sector " << Form("%4i", pix->GetPixId()) << ":"
+          << "Offset: "
+          << Form("%4.2f +- %4.2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr())
+          << "   Precision: "
+          << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr())
           << endl;
   }
@@ -232,5 +236,5 @@
         return kFALSE;
       val = pix.GetMean();
-      break;
+      return val!=-1.;
     case 1:
       if (pix.IsExcluded())
@@ -257,6 +261,6 @@
     }
 
-  return val!=-1.;
-
-}
-
+  return val>=0;
+
+}
+
Index: trunk/MagicSoft/Mars/mcalib/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mcalib/Makefile	(revision 8430)
+++ trunk/MagicSoft/Mars/mcalib/Makefile	(revision 8452)
@@ -39,6 +39,4 @@
 	   MCalibrationPatternDecode.cc \
 	   MCalibrateRelTimes.cc \
-           MCalibrationIntensityCam.cc \
-           MCalibrationIntensityChargeCam.cc \
            MCalibrationCam.cc \
            MCalibrationPix.cc  \
