Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 3426)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 3427)
@@ -154,15 +154,9 @@
   SetHiGainFitted           ( kFALSE );
   SetLoGainFitted           ( kFALSE );
-  SetHiGainOscillating      ( kFALSE );
-  SetLoGainOscillating      ( kFALSE );
   SetExcluded               ( kFALSE );
-  SetChargeValid            ( kFALSE );
   SetBlindPixelMethodValid  ( kFALSE );
   SetFFactorMethodValid     ( kFALSE );
   SetPINDiodeMethodValid    ( kFALSE );
   SetCombinedMethodValid    ( kFALSE );
-
-  SetMeanTimeInFirstBin     ( kFALSE );
-  SetMeanTimeInLastBin      ( kFALSE );
 
   fHiGainMeanCharge                 =  -1.;
@@ -357,13 +351,4 @@
 // --------------------------------------------------------------------------
 //
-// Set the Excluded Bit from outside 
-//
-void MCalibrationChargePix::SetChargeValid(Bool_t b )    
-{ 
-  b ?  SETBIT(fFlags, kChargeValid) : CLRBIT(fFlags, kChargeValid); 
-}
-
-// --------------------------------------------------------------------------
-//
 // Set the Fitted Bit from outside 
 //
@@ -380,22 +365,4 @@
 { 
   b ?  SETBIT(fFlags, kLoGainFitted) : CLRBIT(fFlags, kLoGainFitted); 
-}
-    
-// --------------------------------------------------------------------------
-//
-// Set the Ocillating Bit from outside 
-//
-void MCalibrationChargePix::SetHiGainOscillating(const Bool_t b )
-{ 
-  b ?  SETBIT(fFlags, kHiGainOscillating) : CLRBIT(fFlags, kHiGainOscillating); 
-}
-    
-// --------------------------------------------------------------------------
-//
-// Set the Ocillating Bit from outside 
-//
-void MCalibrationChargePix::SetLoGainOscillating(const Bool_t b )
-{ 
-  b ?  SETBIT(fFlags, kLoGainOscillating) : CLRBIT(fFlags, kLoGainOscillating); 
 }
     
@@ -452,14 +419,4 @@
 }
 
-void MCalibrationChargePix::SetMeanTimeInFirstBin(const Bool_t b)
-{
-  b ? SETBIT(fFlags,kMeanTimeInFirstBin) : CLRBIT(fFlags,kMeanTimeInFirstBin);
-}
-
-void MCalibrationChargePix::SetMeanTimeInLastBin(const Bool_t b)
-{
-  b ? SETBIT(fFlags,kMeanTimeInLastBin) : CLRBIT(fFlags,kMeanTimeInLastBin);
-}
-
 Float_t  MCalibrationChargePix::GetMeanCharge()   const 
 {
@@ -492,20 +449,4 @@
 }
 
-Bool_t  MCalibrationChargePix::IsOscillating()  const 
-{
-  return  IsHiGainSaturation() ? IsLoGainOscillating() :  IsHiGainOscillating();
-}
-
-Bool_t MCalibrationChargePix::IsMeanTimeInFirstBin() const
-{
-  return TESTBIT(fFlags,kMeanTimeInFirstBin);
-}
-
-Bool_t MCalibrationChargePix::IsMeanTimeInLastBin() const
-{
-  return TESTBIT(fFlags,kMeanTimeInLastBin);
-}
-
-
 
 Bool_t MCalibrationChargePix::IsExcluded()     const
@@ -524,9 +465,4 @@
 }
 
-Bool_t MCalibrationChargePix::IsChargeValid()         const 
-{
-  return TESTBIT(fFlags, kChargeValid);  
-}
-
 Bool_t MCalibrationChargePix::IsHiGainFitted()        const 
 { 
@@ -537,14 +473,4 @@
 { 
   return TESTBIT(fFlags, kLoGainFitted);    
-}
-
-Bool_t MCalibrationChargePix::IsHiGainOscillating()    const
-{ 
-  return TESTBIT(fFlags, kHiGainOscillating);
-}
-
-Bool_t MCalibrationChargePix::IsLoGainOscillating()    const
-{ 
-  return TESTBIT(fFlags, kLoGainOscillating);
 }
 
@@ -578,5 +504,5 @@
 // 4) Pixel has a charge sigma bigger than its Pedestal RMS
 // 
-void MCalibrationChargePix::CheckChargeValidity(MBadPixelsPix *bad)
+Bool_t MCalibrationChargePix::CheckChargeValidity(MBadPixelsPix *bad)
 {
  
@@ -588,8 +514,12 @@
       *fLog << warn << "WARNING: Fitted Charge is smaller than "
             << fChargeLimit << " Pedestal RMS in Pixel  " << fPixId << endl;
-      bad->SetCalcChargePedestal();
+      if (bad)
+        bad->SetCalcChargePedestal();
+      else 
+        return kFALSE;
     }
   else
-    bad->SetNoCalcChargePedestal();
+    if (bad)
+      bad->SetNoCalcChargePedestal();
       
   
@@ -598,8 +528,12 @@
       *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
             << fChargeErrLimit << " in Pixel  " << fPixId << endl;
-      bad->SetNoCalcChargeErrValid();
+      if (bad)
+        bad->SetNoCalcChargeErrValid();
+      else 
+        return kFALSE;
     }
   else
-    bad->SetCalcChargeErrValid();
+      if (bad)
+        bad->SetCalcChargeErrValid();
       
    if (GetMeanCharge() < fChargeRelErrLimit*GetMeanChargeErr()) 
@@ -607,17 +541,27 @@
       *fLog << warn << "WARNING: Fitted Charge is smaller than "
             << fChargeRelErrLimit << "* its error in Pixel  " << fPixId << endl;
-      bad->SetNoCalcChargeRelErrValid();
+      if (bad)
+        bad->SetNoCalcChargeRelErrValid();
+      else 
+        return kFALSE;
     }
    else
-      bad->SetCalcChargeRelErrValid();      
+      if (bad)
+        bad->SetCalcChargeRelErrValid();      
 
   if (GetSigmaCharge() < GetPedRms())
     {
-	*fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel  " << fPixId << endl;
-        bad->SetNoCalcChargeSigmaValid();
+	*fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel  " 
+              << fPixId << endl;
+        if (bad)
+          bad->SetNoCalcChargeSigmaValid();
+        else 
+          return kFALSE;
     }
   else
-    bad->SetCalcChargeSigmaValid();
- 
+    if (bad)
+        bad->SetCalcChargeSigmaValid();
+
+  return kTRUE;
 }
 
@@ -627,26 +571,33 @@
 // The mean arrival time is at least 1.0 slices from the used edge slices 
 //
-void MCalibrationChargePix::CheckTimeValidity(MBadPixelsPix *bad)
-{
-
-    const Float_t loweredge     = IsHiGainSaturation() ? fTimeFirstHiGain   : fTimeFirstLoGain;
-    const Float_t upperedge     = IsHiGainSaturation() ? fTimeLastHiGain    : fTimeLastLoGain;
-
-    if ( fAbsTimeMean < loweredge+1.)
+Bool_t MCalibrationChargePix::CheckTimeValidity(MBadPixelsPix *bad)
+{
+  
+  const Float_t loweredge     = IsHiGainSaturation() ? fTimeFirstHiGain   : fTimeFirstLoGain;
+  const Float_t upperedge     = IsHiGainSaturation() ? fTimeLastHiGain    : fTimeLastLoGain;
+  
+  if ( fAbsTimeMean < loweredge+1.)
     {
-	*fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the Pixel " << fPixId << endl;
+      *fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the Pixel " << fPixId << endl;
+      if (bad)
         bad->SetMeanTimeInFirstBin();
+      else 
+        return kFALSE;
     }
-    else
-      bad->SetNoMeanTimeInFirstBin();
-    
-    if ( fAbsTimeMean > upperedge-1.)
+  else
+    bad->SetNoMeanTimeInFirstBin();
+  
+  if ( fAbsTimeMean > upperedge-1.)
     {
-	*fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the Pixel " << fPixId << endl;
+      *fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the Pixel " << fPixId << endl;
+      if (bad)
         bad->SetMeanTimeInLastBin();
+      else 
+        return kFALSE;
     }
-    else
-      bad->SetNoMeanTimeInLastBin();
-
+  else
+    bad->SetNoMeanTimeInLastBin();
+  
+  return kTRUE;
 }
 
@@ -743,7 +694,4 @@
 {
 
-  if (!IsChargeValid())
-      return kFALSE;
-
   if (fRSigmaCharge < 0.)
       return kFALSE;
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h	(revision 3426)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h	(revision 3427)
@@ -15,4 +15,5 @@
 class MRawEvtData;
 class MGeomCam;
+class MBadPixelsCam;
 class MCalibrationChargeCam;
 class MCalibrationChargePix;
@@ -39,7 +40,9 @@
   MRawEvtData            *fRawEvt;                   //!  Raw event data (time slices)
   MGeomCam               *fGeom;                     //!  MAGIC geometry
+  MBadPixelsCam          *fBadPixels;                //!  Bad Pixels
 
   Int_t fNumInnerPixels;
   Int_t fNumOuterPixels;
+  Int_t fNumExcluded;
 
   void FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist, MCalibrationChargePix &pix);
