Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 8452)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 8497)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1.70 2007-04-27 10:04:46 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1.71 2007-05-11 13:33:40 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -460,223 +460,213 @@
 Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
 {
-
-  if (idx > GetSize())
-    return kFALSE;
-
-  Float_t area = cam[idx].GetA();
-
- if (area == 0)
-    return kFALSE;
-
- MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
-
-  switch (type)
+    if (idx > GetSize())
+        return kFALSE;
+
+    const Float_t area = cam[idx].GetA();
+    if (area == 0)
+        return kFALSE;
+
+    const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
+    switch (type)
     {
     case 0:
-      if (pix.IsExcluded())
+        if (pix.IsExcluded() || pix.GetConvertedMeanErr()<0)
+            return kFALSE;
+        val = pix.GetConvertedMean();
+        return kTRUE;
+    case 1:
+        if (pix.IsExcluded() || pix.GetConvertedMeanErr()<0)
+            return kFALSE;
+        val = pix.GetConvertedMeanErr();
+        return kTRUE;
+    case 2:
+        if (pix.IsExcluded() || pix.GetConvertedSigmaErr()<0)
+            return kFALSE;
+        val = pix.GetConvertedSigma();
+        return kTRUE;
+    case 3:
+        if (pix.IsExcluded() || pix.GetConvertedSigmaErr()<0)
+            return kFALSE;
+        val = pix.GetConvertedSigmaErr();
+        return kTRUE;
+    case 4:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetProb();
+        return val>=0;
+    case 5:
+        if (!pix.IsFFactorMethodValid())
+            return kFALSE;
+        if (pix.GetRSigma() == -1.)
+            return kFALSE;
+        val = pix.GetConvertedRSigma();
+        break;
+    case 6:
+        if (!pix.IsFFactorMethodValid())
+            return kFALSE;
+        if (pix.GetRSigma() == -1.)
+            return kFALSE;
+        val = pix.GetConvertedRSigmaErr();
+        break;
+    case 7:
+        if (!pix.IsFFactorMethodValid())
+            return kFALSE;
+        val = pix.GetRSigmaPerCharge();
+        break;
+    case 8:
+        if (!pix.IsFFactorMethodValid())
+            return kFALSE;
+        val =  pix.GetRSigmaPerChargeErr();
+        break;
+    case 9:
+        //      if (!pix.IsFFactorMethodValid())
+        //        return kFALSE;
+        if (pix.IsExcluded() || pix.GetPheFFactorMethodErr()<0)
+            return kFALSE;
+        val = pix.GetPheFFactorMethod();
+        return kTRUE;
+    case 10:
+        //      if (!pix.IsFFactorMethodValid())
+        //        return kFALSE;
+        if (pix.IsExcluded() || pix.GetPheFFactorMethodErr()<=0)
+            return kFALSE;
+        val = pix.GetPheFFactorMethodErr();
+        return kTRUE;
+    case 11:
+        //      if (!pix.IsFFactorMethodValid())
+        //        return kFALSE;
+        if (pix.IsExcluded() || pix.GetMeanConvFADC2PheErr()<0)
+            return kFALSE;
+        val = pix.GetMeanConvFADC2Phe();
+        return kTRUE;
+    case 12:
+        //      if (!pix.IsFFactorMethodValid())
+        //        return kFALSE;
+        if (pix.IsExcluded() || pix.GetMeanConvFADC2PheErr()<=0)
+            return kFALSE;
+        val = pix.GetMeanConvFADC2PheErr();
+        return kTRUE;
+    case 13:
+        //      if (!pix.IsFFactorMethodValid())
+        //        return kFALSE;
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetMeanFFactorFADC2Phot();
+        break;
+    case 14:
+        //      if (!pix.IsFFactorMethodValid())
+        //        return kFALSE;
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetMeanFFactorFADC2PhotErr();
+        if (val <= 0.)
+            val = 0.00001;
+        break;
+    case 15:
+        if (pix.IsExcluded())
+            return kFALSE;
+        if (!pix.IsFFactorMethodValid())
+            return kFALSE;
+        val = 1;
+        return kTRUE;
+    case 16:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetHiLoMeansDivided();
+        break;
+    case 17:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetHiLoMeansDividedErr();
+        break;
+    case 18:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetHiLoSigmasDivided();
+        break;
+    case 19:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetHiLoSigmasDividedErr();
+        break;
+    case 20:
+        if (!pix.IsExcluded())
+            return kFALSE;
+        val = 1.;
+        return kTRUE;
+    case 21:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetHiGainNumPickup();
+        break;
+    case 22:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetLoGainNumPickup();
+        break;
+    case 23:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetHiGainNumBlackout();
+        break;
+    case 24:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetLoGainNumBlackout();
+        break;
+    case 25:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.IsHiGainSaturation();
+        break;
+    case 26:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetAbsTimeMean();
+        break;
+    case 27:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetAbsTimeRms();
+        break;
+    case 28:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetPed();
+        break;
+    case 29:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetPedErr();
+        break;
+    case 30:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetPedRms();
+        break;
+    case 31:
+        if (pix.IsExcluded())
+            return kFALSE;
+        val = pix.GetPedErr()/2.;
+        break;
+    case 32:
+        if (pix.IsExcluded() || pix.GetRms()<0)
+            return kFALSE;
+        val = pix.GetMean() == 0. ? 0. : pix.GetRms()/pix.GetMean();
+        return kTRUE;
+    case 33:
+        if (pix.IsExcluded() || pix.GetRms()<0)
+            return kFALSE;
+        if (pix.GetMean() == 0.)
+            val = 0.;
+        else
+            val = pix.GetSigmaErr()/pix.GetMean() + pix.GetRms()*pix.GetMeanErr()/pix.GetMean()/pix.GetMean();
+        return kTRUE;
+    default:
         return kFALSE;
-      val = pix.GetConvertedMean();
-      break;
-    case 1:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetConvertedMeanErr();
-      break;
-    case 2:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetConvertedSigma();
-      break;
-    case 3:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetConvertedSigmaErr();
-      break;
-    case 4:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetProb();
-      break;
-    case 5:
-      if (!pix.IsFFactorMethodValid())
-        return kFALSE;
-      if (pix.GetRSigma() == -1.)
-	  return kFALSE;
-      val = pix.GetConvertedRSigma();
-      break;
-    case 6:
-      if (!pix.IsFFactorMethodValid())
-        return kFALSE;    
-      if (pix.GetRSigma() == -1.)
-	  return kFALSE;
-      val = pix.GetConvertedRSigmaErr();
-      break;
-    case 7:
-      if (!pix.IsFFactorMethodValid())
-        return kFALSE;
-      val = pix.GetRSigmaPerCharge();
-      break;
-    case 8:
-      if (!pix.IsFFactorMethodValid())
-        return kFALSE;
-      val =  pix.GetRSigmaPerChargeErr();
-      break;
-    case 9:
-      //      if (!pix.IsFFactorMethodValid())
-      //        return kFALSE;
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetPheFFactorMethod();
-      break;
-    case 10:
-      //      if (!pix.IsFFactorMethodValid())
-      //        return kFALSE;
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetPheFFactorMethodErr();
-      if (val < 0.)
-        val = 0.00001;
-      break;
-    case 11:
-      //      if (!pix.IsFFactorMethodValid())
-      //        return kFALSE;
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetMeanConvFADC2Phe();
-      break;
-    case 12:
-      //      if (!pix.IsFFactorMethodValid())
-      //        return kFALSE;
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetMeanConvFADC2PheErr();
-      if (val < 0.)
-        val = 0.00001;
-      break;
-    case 13:
-      //      if (!pix.IsFFactorMethodValid())
-      //        return kFALSE;
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetMeanFFactorFADC2Phot();
-      break;
-    case 14:
-      //      if (!pix.IsFFactorMethodValid())
-      //        return kFALSE;
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetMeanFFactorFADC2PhotErr();
-      if (val < 0.)
-        val = 0.00001;
-      break;
-    case 15:
-      if (pix.IsExcluded())
-        return kFALSE;
-      if (pix.IsFFactorMethodValid())
-        val = 1;
-      else
-        return kFALSE;
-      break;
-    case 16:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetHiLoMeansDivided();
-      break;
-    case 17:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetHiLoMeansDividedErr();
-      break;
-    case 18:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetHiLoSigmasDivided();
-      break;
-    case 19:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetHiLoSigmasDividedErr();
-      break;
-    case 20:
-      if (pix.IsExcluded())
-        val = 1.;
-      else
-        return kFALSE;
-      break;
-    case 21:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetHiGainNumPickup();
-      break;
-    case 22:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetLoGainNumPickup();
-      break;
-    case 23:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetHiGainNumBlackout();
-      break;
-    case 24:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetLoGainNumBlackout();
-      break;
-    case 25:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.IsHiGainSaturation();
-      break;
-    case 26:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetAbsTimeMean();
-      break;
-    case 27:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetAbsTimeRms();
-      break;
-    case 28:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetPed();
-      break;
-    case 29:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetPedErr();
-      break;
-    case 30:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetPedRms();
-      break;
-    case 31:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetPedErr()/2.;
-      break;
-    case 32:
-      if (pix.IsExcluded())
-        return kFALSE;
-      val = pix.GetMean() == 0. ? 0. : pix.GetRms()/pix.GetMean();
-      break;
-    case 33:
-      if (pix.IsExcluded())
-        return kFALSE;
-      if (pix.GetMean() == 0.)
-        val = 0.;
-      else
-        val = pix.GetSigmaErr()/pix.GetMean() + pix.GetRms()/pix.GetMean()/pix.GetMean()*pix.GetMeanErr();
-      break;
-    default:
-      return kFALSE;
-    }
-
-  return val!=-1.;
-}
-
+    }
+
+    return val!=-1.;
+}
 
 Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &ferr, Float_t &ffactor)
