Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3760)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3761)
@@ -46,4 +46,7 @@
      - set the fAvNorm variables to 1 in Clean()
 
+   * manalysis/MPedPhotCalc.[h,cc]
+     - included possibility to use an MBadPixelsCam
+ 
 
  2004/04/14: Thomas Bretz
Index: trunk/MagicSoft/Mars/manalysis/MPedPhotCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedPhotCalc.cc	(revision 3760)
+++ trunk/MagicSoft/Mars/manalysis/MPedPhotCalc.cc	(revision 3761)
@@ -18,4 +18,5 @@
 !   Author(s): Josep Flix 1/2004 <mailto:jflix@ifae.es>
 !   Author(s): Javier Rico 1/2004 <mailto:jrico@ifae.es>
+!   Author(s): Markus Gaug 4/2004 <mailto:markus@ifae.es>
 !
 !   Copyright: MAGIC Software Development, 2000-2004
@@ -55,4 +56,7 @@
 #include "MPedPhotCam.h"
 
+#include "MBadPixelsPix.h"
+#include "MBadPixelsCam.h"
+
 ClassImp(MPedPhotCalc);
 
@@ -63,7 +67,8 @@
 //
 MPedPhotCalc::MPedPhotCalc(const char *name, const char *title)
+    : fPedestals(NULL), fCerPhot(NULL), fBadPixels(NULL)
 {
   fName  = name  ? name  : "MPedPhotCalc";
-  fTitle = title ? title : "Task to calculate pedestals from the charge computed from pedestal runs (in units of photons)";
+  fTitle = title ? title : "Task to calculate pedestals in units of photons";
 }
 
@@ -73,4 +78,5 @@
 //
 //  - MCerPhotEvt
+//  - MBadPixelsCam
 // 
 // The following output containers are also searched and created if
@@ -87,4 +93,11 @@
       *fLog << err << "MPedPhotCalc::PreProcess Error: MCerPhotEvt not found... aborting." << endl;
       return kFALSE;
+    }
+
+
+  fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+  if (!fBadPixels)
+    {
+      *fLog << warn << "MPedPhotCalc::PreProcess Warning: No MBadPixelsCam found." << endl;
     }
 
@@ -130,4 +143,5 @@
   }
 
+
   return kTRUE;
 }
@@ -142,11 +156,18 @@
     for(UInt_t i=0;i<fCerPhot->GetNumPixels();i++)
     {
-        const MCerPhotPix &pix = (*fCerPhot)[i];
+ 
+       const MCerPhotPix &pix = (*fCerPhot)[i];
+
+        if (fBadPixels)
+          {
+            const MBadPixelsPix &bad = (*fBadPixels)[i];
+            if (bad.IsBad())
+              continue;
+          }
 
         const Float_t nphot = pix.GetNumPhotons();
-        const Int_t idx     = pix.GetPixId();
-
-        fSumx[idx]  += nphot;
-        fSumx2[idx] += nphot*nphot;
+
+        fSumx[i]  += nphot;
+        fSumx2[i] += nphot*nphot;
     }
 
@@ -168,11 +189,19 @@
     for(Int_t i=0; i<npix; i++)
     {
-        const Float_t sum  = fSumx[i];
-	const Float_t sum2 = fSumx2[i];
-
-        const Float_t photped = sum/n;
-        const Float_t photrms = TMath::Sqrt((sum2-sum*sum/n)/(n-1.));
-
-        (*fPedestals)[i].Set(photped,photrms);
+
+      if (fBadPixels)
+        {
+          const MBadPixelsPix &bad = (*fBadPixels)[i];
+          if (bad.IsBad())
+            continue;
+        }
+
+      const Float_t sum  = fSumx[i];
+      const Float_t sum2 = fSumx2[i];
+      
+      const Float_t photped = sum/n;
+      const Float_t photrms = TMath::Sqrt((sum2-sum*sum/n)/(n-1.));
+      
+      (*fPedestals)[i].Set(photped,photrms);
     }
 
Index: trunk/MagicSoft/Mars/manalysis/MPedPhotCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedPhotCalc.h	(revision 3760)
+++ trunk/MagicSoft/Mars/manalysis/MPedPhotCalc.h	(revision 3761)
@@ -12,23 +12,25 @@
 class MPedPhotCam;
 class MCerPhotEvt;
-
+class MBadPixelsCam;
 class MPedPhotCalc : public MTask
 {
-    MPedPhotCam  *fPedestals;  // Pedestals of all pixels in the camera
-    MCerPhotEvt  *fCerPhot;
 
-    TArrayF fSumx;   // sum of values
-    TArrayF fSumx2;  // sum of squared values
+  MPedPhotCam   *fPedestals;  // Pedestals of all pixels in the camera
+  MCerPhotEvt   *fCerPhot;    // Calibrated Cherenkov events 
+  MBadPixelsCam *fBadPixels;  // Bad Pixels
+  
+  TArrayF fSumx;   // sum of values
+  TArrayF fSumx2;  // sum of squared values
 
-    Bool_t ReInit(MParList *pList);
+  Bool_t ReInit(MParList *pList);
 
-    Int_t PreProcess(MParList *pList);
-    Int_t Process();
-    Int_t PostProcess();
+  Int_t PreProcess(MParList *pList);
+  Int_t Process();
+  Int_t PostProcess();
+  
+public:
+  MPedPhotCalc(const char *name=NULL, const char *title=NULL);
 
-public:
-    MPedPhotCalc(const char *name=NULL, const char *title=NULL);
-
-    ClassDef(MPedPhotCalc, 0)//Task to calculate pedestals from the charge computed from pedestal runs (in units of photons)
+  ClassDef(MPedPhotCalc, 0) //Task to calculate pedestals in units of photons
 };
 
