Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 4332)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 4333)
@@ -36,4 +36,5 @@
   Float_t fPedVar;                          // Variance of pedestal 
   Float_t fPedRms;                          // Pedestal RMS (from MPedestalPix) times sqrt nr. FADC slices
+  Float_t fPedRmsVar;                       // Pedestal RMS (from MPedestalPix) times sqrt nr. FADC slices
   Float_t fPheFFactorMethod;                // Number Phe's calculated (F-factor method)
   Float_t fPheFFactorMethodVar;             // Variance number of Phe's (F-factor method)
@@ -66,4 +67,6 @@
   void SetMeanFFactorFADC2Phot  ( const Float_t f)                          { fMeanFFactorFADC2Phot   = f; }
   void SetPedestal              ( const Float_t ped, const Float_t pedrms, const Float_t pederr);
+  void SetPed                   ( const Float_t ped, const Float_t pederr);  
+  void SetPedRMS              ( const Float_t pedrms, const Float_t pedrmserr);  
   void SetPheFFactorMethod      ( const Float_t f)                          { fPheFFactorMethod       = f; }
   void SetPheFFactorMethodVar   ( const Float_t f)                          { fPheFFactorMethodVar    = f; }  
@@ -89,5 +92,5 @@
   Float_t GetMeanFFactorFADC2PhotVar () const { return fMeanFFactorFADC2PhotVar; }    
   Float_t GetPed                     () const { return fPed;                     }
-  Float_t GetPedErr                  () const;
+  Float_t GetPedErr                  () const { return TMath::Sqrt(fPedVar);     }
   Float_t GetPedRms                  () const;
   Float_t GetPedRmsErr               () const;
@@ -110,5 +113,5 @@
   Bool_t CalcMeanFFactor   ( const Float_t nphotons, const Float_t nphotonsrelvar );
   
-  ClassDef(MCalibrationChargePix, 1)	// Container Charge Calibration Results Pixel
+  ClassDef(MCalibrationChargePix, 2)	// Container Charge Calibration Results Pixel
 };
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 4332)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 4333)
@@ -98,4 +98,5 @@
   SetExcluded          ( kFALSE );
   SetValid             ( kFALSE );
+  SetDebug             ( kFALSE );
 
 }
@@ -110,4 +111,12 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Set the Valid Bit from outside 
+//
+void MCalibrationPix::SetDebug(Bool_t b )
+{ 
+    b ?  SETBIT(fFlags, kDebug) : CLRBIT(fFlags, kDebug); 
+}
 
 // --------------------------------------------------------------------------
@@ -255,10 +264,10 @@
 
   if (IsHiGainSaturation())
-    if (fLoGainMeanVar < 0.)
+    if (fLoGainMeanVar < 0. || fLoGainMean < 0.)
       return -1.;
     else
       return fLoGainMeanVar / (fLoGainMean * fLoGainMean);
   else
-    if (fHiGainMeanVar < 0.)
+    if (fHiGainMeanVar < 0. || fHiGainMean < 0.)
       return -1.;
     else
@@ -377,4 +386,13 @@
 // --------------------------------------------------------------------------
 //
+// Test bit kDebug
+//
+Bool_t MCalibrationPix::IsDebug()     const
+{ 
+   return TESTBIT(fFlags,kDebug);  
+}
+
+// --------------------------------------------------------------------------
+//
 // Test bit kExcluded
 //
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 4332)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 4333)
@@ -27,5 +27,5 @@
   Float_t fLoGainProb;        // Probability of fit to low gain values
 
-  enum { kHiGainSaturation, kExcluded, kValid };   // Possible bits to be sets
+  enum { kHiGainSaturation, kExcluded, kValid, kDebug };   // Possible bits to be sets
 
 public:
@@ -60,5 +60,6 @@
   void SetSigma      ( const Float_t f ) { IsHiGainSaturation() ? fLoGainSigma       = f : fHiGainSigma       = f     ; }
   void SetSigmaVar   ( const Float_t f ) { IsHiGainSaturation() ? fLoGainSigmaVar    = f : fHiGainSigmaVar    = f  ; }
-  
+
+  void SetDebug           ( const Bool_t  b = kTRUE );  
   void SetExcluded        ( const Bool_t  b = kTRUE );
   void SetHiGainSaturation( const Bool_t  b = kTRUE );
@@ -100,4 +101,5 @@
   
   Bool_t  IsHiGainSaturation() const;
+  Bool_t  IsDebug   ()         const;
   Bool_t  IsExcluded()         const;
   Bool_t  IsValid   ()         const;
