Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4840)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4841)
@@ -19,4 +19,31 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2004/09/03: Wolfgang Wittek
+
+   * mbadpixels/MHBadPixels.[h,cc]
+     - new class; histograms for bad pixels
+
+   * mbadpixels/Makefile
+                BadPixelsLinkdef.h
+     - MHBadPixels added
+
+   * mhist/MHSigmaTheta.[h,cc]
+     - remove MSigmabar stuff
+
+   * mhist/Makefile
+           HistLinkdef.h
+     - MHSigmaTheta added
+   
+   * manalysis/Makefile
+               AnalysisLinkdef.h
+     - remove MPedestalWorkaround and MSourcePosFromStarPos
+     - add MPad
+
+   * manalysis/MPad.[h,cc]
+     - remove *BlindPixel* stuff
+     - remove MSigmabar stuff
+
+
  2004/09/03: Thomas Bretz
 
Index: trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 4840)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 4841)
@@ -51,8 +51,13 @@
 #pragma link C++ class MFiltercutsCalc+;
 
-#pragma link C++ class MPedestalWorkaround+;
-
-#pragma link C++ class MSourcePosfromStarPos+;
+#pragma link C++ class MPad+;
 #pragma link C++ class MMcCalibrationUpdate+;
 
 #endif
+
+
+
+
+
+
+
Index: trunk/MagicSoft/Mars/manalysis/MPad.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPad.cc	(revision 4840)
+++ trunk/MagicSoft/Mars/manalysis/MPad.cc	(revision 4841)
@@ -67,5 +67,4 @@
 
 #include "MBinning.h"
-#include "MSigmabar.h"
 #include "MPointingPos.h"
 #include "MLog.h"
@@ -82,11 +81,11 @@
 #include "MPedPhotPix.h"
 
-#include "MBlindPixels.h"
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
 
 #include "MRead.h"
 #include "MFilterList.h"
 #include "MTaskList.h"
-#include "MBlindPixelCalc.h"
-#include "MHBlindPixels.h"
+#include "MHBadPixels.h"
 #include "MFillH.h"
 #include "MHSigmaTheta.h"
@@ -124,15 +123,9 @@
   fHgOFF = NULL;
 
-  fHBlindPixIdThetaMC  = NULL;
-  fHBlindPixIdThetaON  = NULL;
-  fHBlindPixIdThetaOFF = NULL;
-
-  fHBlindPixNThetaMC   = NULL;
-  fHBlindPixNThetaON   = NULL;
-  fHBlindPixNThetaOFF  = NULL;
-
   fHSigmaPedestal = NULL;
   fHPhotons       = NULL;
   fHNSB           = NULL;
+
+  fNamePedPhotCam = "MPedPhotCamFromData";
 }
 
@@ -150,6 +143,4 @@
   delete fHSigmaPixTheta;
   delete fHDiffPixTheta;
-  delete fHBlindPixNTheta;
-  delete fHBlindPixIdTheta;
 
   delete fHSigmaPedestal;
@@ -386,9 +377,6 @@
 Bool_t MPad::MergeONOFFMC(
    TH2D& sigthmc,  TH3D& diffpixthmc,  TH3D& sigmapixthmc,
-   TH2D& blindidthmc,  TH2D& blindnthmc,
    TH2D& sigthon,  TH3D& diffpixthon,  TH3D& sigmapixthon,
-   TH2D& blindidthon,  TH2D& blindnthon,
-   TH2D& sigthoff, TH3D& diffpixthoff, TH3D& sigmapixthoff,
-   TH2D& blindidthoff, TH2D& blindnthoff)
+   TH2D& sigthoff, TH3D& diffpixthoff, TH3D& sigmapixthoff)
 {
   //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
@@ -439,13 +427,4 @@
   *fLog << "after booking fHSigmaPixTheta" << endl;
 
-  fHBlindPixNTheta = new TH2D( (const TH2D&) blindnthon );
-  fHBlindPixNTheta->SetNameTitle("2D-ThetaBlindN", "2D-ThetaBlindN (target)");
-
-  *fLog << "after booking fHBlindPixNTheta" << endl;
-
-  fHBlindPixIdTheta = new TH2D( (const TH2D&) blindidthon );
-  fHBlindPixIdTheta->SetNameTitle("2D-ThetaBlindId", "2D-ThetaBlindId (target)");
-
-  *fLog << "after booking fHBlindPixIdTheta" << endl;
   *fLog << all << "Histograms for the merged padding plots were booked" 
         << endl;
@@ -460,26 +439,4 @@
 
   //*fLog << all << "addresses of SigmaTheta padding plots were copied" 
-  //      << endl;
-
-  //--------------------------
-  fHBlindPixNThetaMC = &blindnthmc;
-  fHBlindPixNThetaMC->SetNameTitle("2D-ThetaBlindNMC", "2D-ThetaBlindNMC (orig.)");
-  fHBlindPixNThetaON = &blindnthon;
-  fHBlindPixNThetaON->SetNameTitle("2D-ThetaBlindNON", "2D-ThetaBlindNON (orig.)");
-  fHBlindPixNThetaOFF = &blindnthoff;
-  fHBlindPixNThetaOFF->SetNameTitle("2D-ThetaBlindNOFF", "2D-ThetaBlindNOFF (orig.)");
-
-  //*fLog << all << "addresses of BlindPixTheta padding plots were copied" 
-  //      << endl;
-
-  //--------------------------
-  fHBlindPixIdThetaMC = &blindidthmc;
-  fHBlindPixIdThetaMC->SetNameTitle("2D-ThetaBlindIdMC", "2D-ThetaBlindIdMC (orig.)");
-  fHBlindPixIdThetaON = &blindidthon;
-  fHBlindPixIdThetaON->SetNameTitle("2D-ThetaBlindIdON", "2D-ThetaBlindIdON (orig.)");
-  fHBlindPixIdThetaOFF = &blindidthoff;
-  fHBlindPixIdThetaOFF->SetNameTitle("2D-ThetaBlindIdOFF", "2D-ThetaBlindIdOFF (orig.)");
-
-  //*fLog << all << "addresses of BlindPixIdTheta padding plots were copied" 
   //      << endl;
 
@@ -713,7 +670,4 @@
   //               (they are calculated as 
   //               averages of the ON and OFF distributions)
-  //        fHBlindPixNTheta, fHBlindPixIdTheta
-  //               (they are calculated as 
-  //               the sum of the ON and OFF distributions)
   // (fHDiffPixTheta will be used in the padding of MC events)
 
@@ -739,6 +693,4 @@
     TH2D *histOFF;
 
-    TH1D *hist1;
-    TH1D *hist1OFF;
 
     // weights for ON and OFF distrubtions when
@@ -812,58 +764,4 @@
     delete hist;
     delete histOFF;
-
-
-    //------------------------------------------------------------------
-    // define target distribution  'number of blind pixels per event'
-    ay = blindnthon.GetYaxis();
-    Int_t nbinsn = ay->GetNbins();
-
-    hist1    = fHBlindPixNThetaON->ProjectionY("", j, j, "");
-    hist1->SetName("dummy");
-    hist1OFF = fHBlindPixNThetaOFF->ProjectionY("", j, j, "");
-
-    normON  = hist1->Integral();
-    normOFF = hist1OFF->Integral();
-    if (normON  != 0.0) hist1->Scale(1.0/normON);
-    if (normOFF != 0.0) hist1OFF->Scale(1.0/normOFF);
-
-    // sum of ON and OFF distributions
-    hist1->Add(hist1OFF, 1.0); 
-    Stat_t sum1 = hist1->Integral();
-    if (sum1 != 0.0) hist1->Scale( 1.0/sum1 );
-
-    for (Int_t k=1; k<=nbinsn; k++)
-      {
-        Double_t cont = hist1->GetBinContent(k);
-        fHBlindPixNTheta->SetBinContent(j, k, cont);  
-      }
-
-    delete hist1;
-    delete hist1OFF;
-
-    //------------------------------------------------------------------
-    // define target distribution  'id of blind pixel'
-    ay = blindidthon.GetYaxis();
-    Int_t nbinsid = ay->GetNbins();
-
-    hist1    = fHBlindPixIdThetaON->ProjectionY("", j, j, "");
-    hist1->SetName("dummy");
-    hist1OFF = fHBlindPixIdThetaOFF->ProjectionY("", j, j, "");
-
-    // divide by the number of events (from fHBlindPixNTheta)
-    if (normON  != 0.0) hist1->Scale(1.0/normON);
-    if (normOFF != 0.0) hist1OFF->Scale(1.0/normOFF);
-
-    // sum of ON and OFF distributions
-    hist1->Add(hist1OFF, 1.0); 
-
-    for (Int_t k=1; k<=nbinsid; k++)
-      {
-        Double_t cont = hist1->GetBinContent(k);
-        fHBlindPixIdTheta->SetBinContent(j, k, cont);  
-      }
-
-    delete hist1;
-    delete hist1OFF;
   }
   //............   end of new loop over Theta bins   ....................
@@ -887,12 +785,4 @@
   fHSigmaPixThetaON->SetDirectory(NULL);
   fHSigmaPixThetaOFF->SetDirectory(NULL);
-
-  fHBlindPixIdThetaMC->SetDirectory(NULL);
-  fHBlindPixIdThetaON->SetDirectory(NULL);
-  fHBlindPixIdThetaOFF->SetDirectory(NULL);
-
-  fHBlindPixNThetaMC->SetDirectory(NULL);
-  fHBlindPixNThetaON->SetDirectory(NULL);
-  fHBlindPixNThetaOFF->SetDirectory(NULL);
 
   fHgMC->SetDirectory(NULL);
@@ -1001,7 +891,5 @@
 Bool_t MPad::MergeONMC(
    TH2D& sigthmc,  TH3D& diffpixthmc,  TH3D& sigmapixthmc,
-   TH2D& blindidthmc,  TH2D& blindnthmc,
-   TH2D& sigthon,  TH3D& diffpixthon,  TH3D& sigmapixthon,
-   TH2D& blindidthon,  TH2D& blindnthon)
+   TH2D& sigthon,  TH3D& diffpixthon,  TH3D& sigmapixthon)
 {
   *fLog << all << "----------------------------------------------------------------------------------" << endl;
@@ -1017,10 +905,4 @@
   fHSigmaPixTheta = new TH3D( (TH3D&) sigmapixthon );
   fHSigmaPixTheta->SetNameTitle("3D-ThetaPixSigma", "3D-ThetaPixSigma (target)");
-
-  fHBlindPixNTheta = new TH2D( (TH2D&) blindnthon );
-  fHBlindPixNTheta->SetNameTitle("2D-ThetaBlindN", "2D-ThetaBlindN (target)");
-
-  fHBlindPixIdTheta = new TH2D( (TH2D&) blindidthon );
-  fHBlindPixIdTheta->SetNameTitle("2D-ThetaBlindId", "2D-ThetaBlindId (target)");
 
   //--------------------------
@@ -1029,16 +911,4 @@
   fHSigmaThetaON = &sigthon;
   fHSigmaThetaON->SetNameTitle("2D-ThetaSigmabarON", "2D-ThetaSigmabarON (orig.)");
-
-  //--------------------------
-  fHBlindPixNThetaMC = &blindnthmc;
-  fHBlindPixNThetaMC->SetNameTitle("2D-ThetaBlindNMC", "2D-ThetaBlindNMC (orig.)");
-  fHBlindPixNThetaON = &blindnthon;
-  fHBlindPixNThetaON->SetNameTitle("2D-ThetaBlindNON", "2D-ThetaBlindNON (orig.)");
-
-  //--------------------------
-  fHBlindPixIdThetaMC = &blindidthmc;
-  fHBlindPixIdThetaMC->SetNameTitle("2D-ThetaBlindIdMC", "2D-ThetaBlindIdMC (orig.)");
-  fHBlindPixIdThetaON = &blindidthon;
-  fHBlindPixIdThetaON->SetNameTitle("2D-ThetaBlindIdON", "2D-ThetaBlindIdON (orig.)");
 
   //--------------------------
@@ -1166,7 +1036,4 @@
   //               (they are calculated as 
   //               averages of the ON and MCdistributions)
-  //        fHBlindPixNTheta, fHBlindPixIdTheta
-  //               (they are calculated as 
-  //               the sum of the ON and MC distributions)
   // (fHDiffPixTheta will be used in the padding of MC events)
 
@@ -1191,6 +1058,4 @@
     TH2D *histMC;
 
-    TH1D *hist1;
-    TH1D *hist1MC;
 
     // weights for ON and MC distrubtions when
@@ -1264,58 +1129,5 @@
     delete hist;
     delete histMC;
-
-
     //------------------------------------------------------------------
-    // define target distribution  'number of blind pixels per event'
-    ay = blindnthon.GetYaxis();
-    Int_t nbinsn = ay->GetNbins();
-
-    hist1    = fHBlindPixNThetaON->ProjectionY("", j, j, "");
-    hist1->SetName("dummy");
-    hist1MC  = fHBlindPixNThetaMC->ProjectionY("", j, j, "");
-
-    normON  = hist1->Integral();
-    normMC  = hist1MC->Integral();
-    if (normON  != 0.0) hist1->Scale(1.0/normON);
-    if (normMC  != 0.0) hist1MC->Scale(1.0/normMC);
-
-    // sum of ON and MC distributions
-    hist1->Add(hist1MC, 1.0); 
-    Stat_t sum1 = hist1->Integral();
-    if (sum1 != 0.0) hist1->Scale( 1.0/sum1 );
-
-    for (Int_t k=1; k<=nbinsn; k++)
-      {
-        Double_t cont = hist1->GetBinContent(k);
-        fHBlindPixNTheta->SetBinContent(j, k, cont);  
-      }
-
-    delete hist1;
-    delete hist1MC;
-
-    //------------------------------------------------------------------
-    // define target distribution  'id of blind pixel'
-    ay = blindidthon.GetYaxis();
-    Int_t nbinsid = ay->GetNbins();
-
-    hist1    = fHBlindPixIdThetaON->ProjectionY("", j, j, "");
-    hist1->SetName("dummy");
-    hist1MC = fHBlindPixIdThetaMC->ProjectionY("", j, j, "");
-
-    // divide by the number of events (from fHBlindPixNTheta)
-    if (normON  != 0.0) hist1->Scale(1.0/normON);
-    if (normMC  != 0.0) hist1MC->Scale(1.0/normMC);
-
-    // sum of ON and MC distributions
-    hist1->Add(hist1MC, 1.0); 
-
-    for (Int_t k=1; k<=nbinsid; k++)
-      {
-        Double_t cont = hist1->GetBinContent(k);
-        fHBlindPixIdTheta->SetBinContent(j, k, cont);  
-      }
-
-    delete hist1;
-    delete hist1MC;
   }
   //............   end of new loop over Theta bins   ....................
@@ -1336,10 +1148,4 @@
   fHSigmaPixThetaMC->SetDirectory(NULL);
   fHSigmaPixThetaON->SetDirectory(NULL);
-
-  fHBlindPixIdThetaMC->SetDirectory(NULL);
-  fHBlindPixIdThetaON->SetDirectory(NULL);
-
-  fHBlindPixNThetaMC->SetDirectory(NULL);
-  fHBlindPixNThetaON->SetDirectory(NULL);
 
   fHgMC->SetDirectory(NULL);
@@ -1594,134 +1400,4 @@
 
     //------------------------------------
-      /*
-      fHBlindPixIdTheta = 
-      (TH2D*) gROOT->FindObject("2D-ThetaBlindId");
-      if (!fHBlindPixIdTheta)
-	{
-          *fLog << all 
-                << "MPad : Object '2D-ThetaBlindId' not found on root file" 
-                << endl;
-          return kFALSE;
-	}
-      */
-      fHBlindPixIdTheta = new TH2D;
-      fHBlindPixIdTheta->Read("2D-ThetaBlindId");
-      *fLog << all 
-            << "MPad : Object '2D-ThetaBlindId' was read in" << endl;
-
-      /*
-      fHBlindPixIdThetaMC = 
-      (TH2D*) gROOT->FindObject("2D-ThetaBlindIdMC");
-      if (!fHBlindPixIdThetaMC)
-	{
-          *fLog << all 
-                << "MPad : Object '2D-ThetaBlindIdMC' not found on root file" 
-                << endl;
-          return kFALSE;
-	}
-      */
-      fHBlindPixIdThetaMC = new TH2D;
-      fHBlindPixIdThetaMC->Read("2D-ThetaBlindIdMC");
-      *fLog << all 
-            << "MPad : Object '2D-ThetaBlindIdMC' was read in" << endl;
-
-      /*
-      fHBlindPixIdThetaON = 
-      (TH2D*) gROOT->FindObject("2D-ThetaBlindIdON");
-      if (!fHBlindPixIdThetaON)
-	{
-          *fLog << all 
-                << "MPad : Object '2D-ThetaBlindIdON' not found on root file" 
-                << endl;
-          return kFALSE;
-	}
-      */
-      fHBlindPixIdThetaON = new TH2D;
-      fHBlindPixIdThetaON->Read("2D-ThetaBlindIdON");
-      *fLog << all 
-            << "MPad : Object '2D-ThetaBlindIdON' was read in" << endl;
-
-      /*
-      fHBlindPixIdThetaOFF = 
-      (TH2D*) gROOT->FindObject("2D-ThetaBlindIdOFF");
-      if (!fHBlindPixIdThetaOFF)
-	{
-          *fLog << all 
-                << "MPad : Object '2D-ThetaBlindIdOFF' not found on root file" 
-                << endl;
-          return kFALSE;
-	}
-      */
-      fHBlindPixIdThetaOFF = new TH2D;
-      fHBlindPixIdThetaOFF->Read("2D-ThetaBlindIdOFF");
-      *fLog << all 
-            << "MPad : Object '2D-ThetaBlindIdOFF' was read in" << endl;
-
-    //------------------------------------
-      /*
-      fHBlindPixNTheta = 
-      (TH2D*) gROOT->FindObject("2D-ThetaBlindN");
-      if (!fHBlindPixNTheta)
-	{
-          *fLog << all 
-                << "MPad : Object '2D-ThetaBlindN' not found on root file" 
-                << endl;
-          return kFALSE;
-	}
-      */
-      fHBlindPixNTheta = new TH2D;
-      fHBlindPixNTheta->Read("2D-ThetaBlindN");
-      *fLog << all 
-            << "MPad : Object '2D-ThetaBlindN' was read in" << endl;
-
-      /*
-      fHBlindPixNThetaMC = 
-      (TH2D*) gROOT->FindObject("2D-ThetaBlindNMC");
-      if (!fHBlindPixNThetaMC)
-	{
-          *fLog << all 
-                << "MPad : Object '2D-ThetaBlindNMC' not found on root file" 
-                << endl;
-          return kFALSE;
-	}
-      */
-      fHBlindPixNThetaMC = new TH2D;
-      fHBlindPixNThetaMC->Read("2D-ThetaBlindNMC");
-      *fLog << all 
-            << "MPad : Object '2D-ThetaBlindNMC' was read in" << endl;
-
-      /*
-      fHBlindPixNThetaON = 
-      (TH2D*) gROOT->FindObject("2D-ThetaBlindNON");
-      if (!fHBlindPixNThetaON)
-	{
-          *fLog << all 
-                << "MPad : Object '2D-ThetaBlindNON' not found on root file" 
-                << endl;
-          return kFALSE;
-	}
-      */
-      fHBlindPixNThetaON = new TH2D;
-      fHBlindPixNThetaON->Read("2D-ThetaBlindNON");
-      *fLog << all 
-            << "MPad : Object '2D-ThetaBlindNON' was read in" << endl;
-
-      /*
-      fHBlindPixNThetaOFF = 
-      (TH2D*) gROOT->FindObject("2D-ThetaBlindNOFF");
-      if (!fHBlindPixNThetaOFF)
-	{
-          *fLog << all 
-                << "MPad : Object '2D-ThetaBlindNOFF' not found on root file" 
-                << endl;
-          return kFALSE;
-	}
-      */
-      fHBlindPixNThetaOFF = new TH2D;
-      fHBlindPixNThetaOFF->Read("2D-ThetaBlindNOFF");
-      *fLog << all 
-            << "MPad : Object '2D-ThetaBlindNOFF' was read in" << endl;
-
-    //------------------------------------
 
   return kTRUE;
@@ -1740,14 +1416,4 @@
 
   TFile outfile(namefileout, "RECREATE");
-
-  fHBlindPixNTheta->Write();
-  fHBlindPixNThetaMC->Write();
-  fHBlindPixNThetaON->Write();
-  fHBlindPixNThetaOFF->Write();
-
-  fHBlindPixIdTheta->Write();
-  fHBlindPixIdThetaMC->Write();
-  fHBlindPixIdThetaON->Write();
-  fHBlindPixIdThetaOFF->Write();
 
   fHSigmaThetaMC->Write();
@@ -1801,6 +1467,4 @@
   if ( !fHSigmaThetaMC     || !fHSigmaThetaON     || !fHSigmaThetaOFF      ||  
        !fHDiffPixThetaMC   || !fHDiffPixThetaON   || !fHDiffPixThetaOFF    ||
-       !fHBlindPixIdThetaMC|| !fHBlindPixIdThetaON|| !fHBlindPixIdThetaOFF ||
-       !fHBlindPixNThetaMC || !fHBlindPixNThetaON || !fHBlindPixNThetaOFF  ||
        !fHgMC              || !fHgON              || !fHgOFF                 )
   { 
@@ -1819,11 +1483,12 @@
     }
   
-   fPed = (MPedPhotCam*)pList->FindObject("MPedPhotCam");
-   if (!fPed)
-     {
-       *fLog << err << "MPad : MPedPhotCam not found... aborting." 
-             << endl;
-       return kFALSE;
-     }
+    fPed = (MPedPhotCam*)pList->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
+    if (!fPed)
+    {
+        *fLog << err << AddSerialNumber(fNamePedPhotCam) 
+              << "[MPedPhotCam] not found... aborting." << endl;
+        return kFALSE;
+    }
+
 
    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
@@ -1844,18 +1509,13 @@
      }
 
-   fSigmabar = (MSigmabar*)pList->FindCreateObj("MSigmabar");
-   if (!fSigmabar)
+
+   fBad = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+   if (!fBad)
      {
-       *fLog << err << "MPad : MSigmabar not found... aborting." << endl;
-       return kFALSE;
+       *fLog << inf 
+             << "MPad : MBadPixelsCam container not present... continue." 
+             << endl;
      }
 
-   fBlindPix = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
-   if (!fBlindPix)
-     {
-       *fLog << err << "MPad : MBlindPixels not found... aborting." 
-             << endl;
-       return kFALSE;
-     }
    
    if (fType !="ON"  &&  fType !="OFF"  &&  fType !="MC")
@@ -1905,6 +1565,5 @@
 // input for the padding : 
 //  - the matrices fHgON, fHgOFF, fHgMC
-//  - the original distributions fHBlindPixNTheta, fHBlindPixIdTheta
-//                               fHSigmaTheta, fHDiffPixTheta
+//  - the original distributions fHSigmaTheta, fHDiffPixTheta
 //
 
@@ -1963,15 +1622,15 @@
   //
 
-  fSigmabar->Calc(*fCam, *fPed, *fEvt);
   //*fLog << all << "MPad::Process(); before padding : " << endl;
-  //fSigmabar->Print("");
 
   // inner sigmabar/sqrt(area)
-  Double_t sigbarInnerold_phot = fSigmabar->GetSigmabarInner();
+  Double_t ratioinn = fCam->GetPixRatio(0);
+  Double_t sigbarInnerold_phot = (fPed->GetArea(0)).GetRms() * sqrt(ratioinn);
   Double_t sigbarInnerold  = sigbarInnerold_phot * fPEperPhoton;
   Double_t sigbarInnerold2 = sigbarInnerold*sigbarInnerold;
 
   // outer sigmabar/sqrt(area)
-  Double_t sigbarOuterold_phot = fSigmabar->GetSigmabarOuter();
+  Double_t ratioout = fCam->GetPixRatio(500);
+  Double_t sigbarOuterold_phot = (fPed->GetArea(1)).GetRms() * sqrt(ratioout);
   Double_t sigbarOuterold  = sigbarOuterold_phot * fPEperPhoton;
   Double_t sigbarOuterold2 = sigbarOuterold*sigbarOuterold;
@@ -1981,10 +1640,10 @@
   //*fLog << all << "theta = " << theta << endl;
 
-  Int_t binTheta = fHBlindPixNTheta->GetXaxis()->FindBin(theta);
-  if ( binTheta < 1  ||  binTheta > fHBlindPixNTheta->GetNbinsX() )
+  Int_t binTheta = fHSigmaThetaON->GetXaxis()->FindBin(theta);
+  if ( binTheta < 1  ||  binTheta > fHSigmaThetaON->GetNbinsX() )
   {
     *fLog << warn 
           << "MPad::Process(); binNumber out of range : theta, binTheta = "
-          << theta << ",  " << binTheta << ";  aborting " << endl;
+          << theta << ",  " << binTheta << endl;
 
     rc = 2;
@@ -2037,139 +1696,4 @@
  
   //-------------------------------------------
-  // for the current theta :
-  //     generate blind pixels according to the histograms 
-  //     fHBlindPixNTheta and fHBlindPixIDTheta
-  //
-  // ON  : add the blind pixels from the OFF data
-  // OFF : add the blind pixels from the ON data
-  // MC  : add the blind pixels from the ON and OFF data
-
-  //-----------------------------------
-  if (fType == "ON"  ||  fType == "MC")
-  {
-    // numBlind is the number of blind pixels in an event
-    TH1D *nblind;
-    UInt_t numBlind;
-
-    nblind = fHBlindPixNThetaOFF->ProjectionY("", binTheta, binTheta, "");
-    if ( nblind->Integral() == 0.0 )
-    {
-      *fLog << warn << "MPad::Process(); projection of '"
-            << fHBlindPixNThetaOFF->GetName() << "' for Theta bin " 
-            << binTheta << " has no entries; aborting " << endl;
-      // event cannot be padded; skip event
-      delete nblind;
-
-      rc = 7;
-      fErrors[rc]++;
-      return kCONTINUE;
-    }
-    else
-    {
-      numBlind = (Int_t) (nblind->GetRandom()+0.5);
-    }
-    delete nblind;
-
-
-    // throw the Id of numBlind different pixels in this event
-    if ( numBlind > 0)
-    {
-      TH1D *hblind;
-      UInt_t idBlind;
-      UInt_t listId[npix];
-      UInt_t nlist = 0;
-      Bool_t equal;
-
-      hblind = fHBlindPixIdThetaOFF->ProjectionY("", binTheta, binTheta, "");
-      if ( hblind->Integral() > 0.0 )
-        for (UInt_t i=0; i<numBlind; i++)
-        {
-          while(1)
-          {
-            idBlind = (Int_t) (hblind->GetRandom()+0.5);
-            equal = kFALSE;
-            for (UInt_t j=0; j<nlist; j++)
-              if (idBlind == listId[j])
-  	      { 
-                equal = kTRUE;
-                break;
-	      }
-            if (!equal) break;
-          }
-          listId[nlist] = idBlind;
-          nlist++;
-
-          fBlindPix->SetPixelBlind(idBlind);
-          //*fLog << all << "idBlind = " << idBlind << endl;
-        }
-      fBlindPix->SetReadyToSave();
-
-      delete hblind;
-    }
-  }
-
-  //------------------------------------
-  if (fType == "OFF"  ||  fType == "MC")
-  {
-    // throw numBlind;
-    // numBlind is the number of blind pixels in an event
-    TH1D *nblind;
-    UInt_t numBlind;
-
-    nblind = fHBlindPixNThetaON->ProjectionY("", binTheta, binTheta, "");
-    if ( nblind->Integral() == 0.0 )
-    {
-      *fLog << warn << "MPad::Process(); projection of '" 
-            << fHBlindPixNThetaON->GetName() << "' for Theta bin " 
-            << binTheta << " has no entries; Skip event " << endl;
-      delete nblind;
-
-      rc = 7;
-      fErrors[rc]++;
-      return kCONTINUE;
-    }
-    else
-    {
-      numBlind = (Int_t) (nblind->GetRandom()+0.5);
-    }
-    delete nblind;
-
-
-    // throw the Id of numBlind different pixels in this event
-    if ( numBlind > 0)
-    {
-      TH1D *hblind;
-      UInt_t idBlind;
-      UInt_t listId[npix];
-      UInt_t nlist = 0;
-      Bool_t equal;
-
-      hblind = fHBlindPixIdThetaON->ProjectionY("", binTheta, binTheta, "");
-      if ( hblind->Integral() > 0.0 )
-        for (UInt_t i=0; i<numBlind; i++)
-        {
-          while(1)
-          {
-            idBlind = (Int_t) (hblind->GetRandom()+0.5);
-            equal = kFALSE;
-            for (UInt_t j=0; j<nlist; j++)
-              if (idBlind == listId[j])
-  	      { 
-                equal = kTRUE;
-                break;
-	      }
-            if (!equal) break;
-          }
-          listId[nlist] = idBlind;
-          nlist++;
-
-          fBlindPix->SetPixelBlind(idBlind);
-          //*fLog << all << "idBlind = " << idBlind << endl;
-        }
-      fBlindPix->SetReadyToSave();
-
-      delete hblind;
-    }
-  }
 
   //******************************************************************
@@ -2332,5 +1856,5 @@
   // do the padding for each pixel
   //
-  // pad only pixels   - which are used and not blind (before image cleaning)
+  // pad only pixels   - which are used and not bad (before image cleaning)
   //
 
@@ -2403,10 +1927,10 @@
     MPedPhotPix &ppix = (*fPed)[j];
 
-    if ( fBlindPix != NULL  &&  fBlindPix->IsBlind(j) )
+    if ( fBad != NULL  &&  (*fBad)[j].IsUnsuitable() )
     {
-       // this should never occur, because blind pixels should have
-       // been set unused by MBlindPixelsCalc2::UnMap()
-       //*fLog << all << "MPad::Process; blind pixel found which is used, j = "
-       //       << j << "... go to next pixel." << endl;
+       // this should never occur, because bad pixels should have
+       // been set unused 
+       *fLog << all << "MPad::Process; bad pixel found which is used, j = "
+              << j << "... go to next pixel." << endl;
        continue;
     }	
@@ -2569,7 +2093,5 @@
   // Calculate sigmabar again and crosscheck
 
-  fSigmabar->Calc(*fCam, *fPed, *fEvt);
   //*fLog << all << "MPad::Process(); after padding : " << endl;
-  //fSigmabar->Print("");
 
   //*fLog << all << "Exit MPad::Process();" << endl;
@@ -2612,8 +2134,4 @@
           << (int)(fErrors[4]*100/GetNumExecutions()) 
           << "%) Evts skipped due to: Target sigma <= Sigmabar_old" << endl;
-
-    *fLog << " " << setw(7) << fErrors[7] << " (" << setw(3) 
-          << (int)(fErrors[7]*100/GetNumExecutions()) 
-          << "%) Evts skipped due to: No data for generating Blind pixels" << endl;
 
     *fLog << " " << setw(7) << fErrors[8] << " (" << setw(3) 
@@ -2656,24 +2174,4 @@
     fHSigmaTheta->DrawCopy();     
     fHSigmaTheta->SetBit(kCanDelete);     
-    */
-
-    //--------------------------------------------------------------------
-
-    /*
-    c.cd(7);
-    fHBlindPixNTheta->SetDirectory(NULL);
-    fHBlindPixNTheta->SetTitle("(Target) 2D : no.of blind pixels, \\Theta");
-    fHBlindPixNTheta->DrawCopy();     
-    fHBlindPixNTheta->SetBit(kCanDelete);     
-    */
-
-    //--------------------------------------------------------------------
-
-    /*
-    c.cd(10);
-    fHBlindPixIdTheta->SetDirectory(NULL);
-    fHBlindPixIdTheta->SetTitle("(Target) 2D : blind pixel Id, \\Theta");
-    fHBlindPixIdTheta->DrawCopy();     
-    fHBlindPixIdTheta->SetBit(kCanDelete);     
     */
 
Index: trunk/MagicSoft/Mars/manalysis/MPad.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPad.h	(revision 4840)
+++ trunk/MagicSoft/Mars/manalysis/MPad.h	(revision 4841)
@@ -20,5 +20,5 @@
 class MSigmabar;
 class MParList;
-class MBlindPixels;
+class MBadPixelsCam;
 class MRead;
 class MFilterList;
@@ -33,6 +33,7 @@
     MPointingPos   *fPointPos;
     MPedPhotCam    *fPed;
-    MBlindPixels   *fBlindPix;
+    MBadPixelsCam  *fBad;
 
+    TString  fNamePedPhotCam;       // name of the 'MPedPhotCam' container
     TString        fType;           // type of data to be padded
     TFile          *fInfile;        // input file containing padding histograms
@@ -46,16 +47,5 @@
     // plots used for the padding
     // for all plots it is assumed that the pedestal RMS is given in units of "number of photons"
-    TH2D  *fHBlindPixIdTheta;    // 2D-histogram (blind pixel Id vs. Theta)
-    TH2D  *fHBlindPixIdThetaMC;  // 2D-histogram (blind pixel Id vs. Theta)
-    TH2D  *fHBlindPixIdThetaON;  // 2D-histogram (blind pixel Id vs. Theta)
-    TH2D  *fHBlindPixIdThetaOFF; // 2D-histogram (blind pixel Id vs. Theta)
 
-    //---------------------
-    TH2D  *fHBlindPixNTheta;    // 2D-histogram (no.of blind pixels vs. Theta)
-    TH2D  *fHBlindPixNThetaMC;  // 2D-histogram (no.of blind pixels vs. Theta)
-    TH2D  *fHBlindPixNThetaON;  // 2D-histogram (no.of blind pixels vs. Theta)
-    TH2D  *fHBlindPixNThetaOFF; // 2D-histogram (no.of blind pixels vs. Theta)
-
-    //---------------------
     TH2D  *fHSigmaTheta;       // 2D-histogram (sigmabar vs. Theta)
     TH2D  *fHSigmaThetaMC;     // 2D-histogram (sigmabar vs. Theta)
@@ -99,17 +89,14 @@
     ~MPad();
 
+    void SetNamePedPhotCam(const char *name)  { fNamePedPhotCam = name; }
+
     Bool_t MergeONOFFMC(
       TH2D& sigthmc,  TH3D& diffpixthmc, TH3D& sigmapixthmc,
-      TH2D& blindidthmc,  TH2D& blindnthmc,
       TH2D& sigthon,  TH3D& diffpixthon, TH3D& sigmapixthon,
-      TH2D& blindidthon,  TH2D& blindnthon,
-      TH2D& sigthoff, TH3D& diffpixthoff,TH3D& sigmapixthoff,
-      TH2D& blindidthoff, TH2D& blindnthoff);
+      TH2D& sigthoff, TH3D& diffpixthoff,TH3D& sigmapixthoff);
 
     Bool_t MergeONMC(
       TH2D& sigthmc,  TH3D& diffpixthmc, TH3D& sigmapixthmc,
-      TH2D& blindidthmc,  TH2D& blindnthmc,
-      TH2D& sigthon,  TH3D&diffpixthon, TH3D& sigmapixthon,
-      TH2D& blindidthon,  TH2D& blindnthon);
+      TH2D& sigthon,  TH3D&diffpixthon, TH3D& sigmapixthon);
 
     Bool_t ReadPaddingDist(const char *filein);
@@ -132,2 +119,3 @@
 
 
+
Index: trunk/MagicSoft/Mars/manalysis/Makefile
===================================================================
--- trunk/MagicSoft/Mars/manalysis/Makefile	(revision 4840)
+++ trunk/MagicSoft/Mars/manalysis/Makefile	(revision 4841)
@@ -56,6 +56,5 @@
            MMinuitInterface.cc \
            MFiltercutsCalc.cc \
-           MPedestalWorkaround.cc \
-           MSourcePosfromStarPos.cc \
+           MPad.cc \
            MMcCalibrationUpdate.cc
 
Index: trunk/MagicSoft/Mars/mbadpixels/BadPixelsLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/BadPixelsLinkDef.h	(revision 4840)
+++ trunk/MagicSoft/Mars/mbadpixels/BadPixelsLinkDef.h	(revision 4841)
@@ -13,4 +13,5 @@
 
 #pragma link C++ class MMcBadPixelsSet+;
+#pragma link C++ class MHBadPixels+;
 
 #endif
Index: trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.cc
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.cc	(revision 4841)
+++ trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.cc	(revision 4841)
@@ -0,0 +1,201 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHBadPixels
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHBadPixels.h" 
+
+#include <TCanvas.h>
+
+#include "MPointingPos.h"
+#include "MBadPixelsCam.h"
+#include "MGeomCam.h"
+#include "MPedPhotCam.h"
+#include "MParList.h"
+#include "MBinning.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHBadPixels);
+
+using namespace std;
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHBadPixels::MHBadPixels(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHBadPixels";
+    fTitle = title ? title : "Histogram for Bad Pixels vs. Theta";
+
+    fBadId.SetName("2D-IdBadPixels");
+    fBadId.SetTitle("2D-IdBadPixels");
+    fBadId.SetDirectory(NULL);
+    fBadId.SetXTitle("\\Theta [\\circ]");
+    fBadId.SetYTitle("pixel Id");
+
+    fBadN.SetName("2D-NBadPixels");
+    fBadN.SetTitle("2D-NBadPixels");
+    fBadN.SetDirectory(NULL);
+    fBadN.SetXTitle("\\Theta [\\circ]");
+    fBadN.SetYTitle("number of bad pixels");
+
+    fNamePedPhotCam = "MPedPhotCamFromData";
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histogram
+//
+Bool_t MHBadPixels::SetupFill(const MParList *plist)
+{
+    MGeomCam *fCam = (MGeomCam*)plist->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fCam)    
+    {
+        *fLog << err << "MHBadPixels::SetupFill; MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
+    if (!fPointPos)
+    {
+        *fLog << err << "MPointingPos not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    
+    fPedPhot = (MPedPhotCam*)plist->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
+    if (!fPedPhot)
+    {
+        *fLog << err << AddSerialNumber(fNamePedPhotCam) 
+              << "[MPedPhotCam] not found... aborting." << endl;
+        return kFALSE;
+    }
+    //fPedPhot->InitSize(fCam->GetNumPixels());
+
+
+    // Get Theta Binning
+    MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
+    if (!binstheta)
+    {
+        *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl;
+        return kFALSE;
+    }
+
+    // Get binning for pixel number
+    const UInt_t npix1 = fPedPhot->GetSize()+1;
+
+    MBinning binspix("BinningPixel");
+    binspix.SetEdges(npix1, -0.5, npix1-0.5);
+
+    // Set binnings in histograms
+    SetBinning(&fBadId, binstheta, &binspix);
+    SetBinning(&fBadN,  binstheta, &binspix);
+
+    return kTRUE;
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHBadPixels::Draw(Option_t *option)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    pad->Divide(2,2);
+
+    TH1D *h;
+
+    pad->cd(1);
+    fBadId.Draw(option);
+
+    pad->cd(2);
+    fBadN.Draw(option);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    h = ((TH2*)&fBadId)->ProjectionY("ProjY-pixId", -1, 9999, "");
+    h->SetDirectory(NULL);
+    h->SetTitle("Distribution of bad pixel Id");
+    h->SetXTitle("Id of bad pixel");
+    h->SetYTitle("No. of events");
+    h->Draw(option);
+    h->SetBit(kCanDelete);
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    h = ((TH2*)&fBadN)->ProjectionY("ProjY-pixN", -1, 9999, "");
+    h->SetDirectory(NULL);
+    h->SetTitle("Distribution of no.of bad pixels");
+    h->SetXTitle("No. of bad pixels");
+    h->SetYTitle("No. of events");
+    h->Draw(option);
+    h->SetBit(kCanDelete);
+
+    pad->Modified();
+    pad->Update();
+}
+
+Bool_t MHBadPixels::Fill(const MParContainer *par, const Stat_t w)
+{
+    if (!par)
+        return kFALSE;
+
+    Double_t theta = fPointPos->GetZd();
+
+    const MBadPixelsCam *fBadPixels = (MBadPixelsCam*)par;
+
+    UShort_t entries = fCam->GetNumPixels();
+    UInt_t nb = 0;
+    for (UInt_t i=0; i<entries; i++)
+    {
+      if ( (*fBadPixels)[i].IsUnsuitable() )
+      {
+          fBadId.Fill(theta, i, w);
+          nb++;
+      }   
+    }
+    fBadN.Fill(theta, nb, w);
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
Index: trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.h
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.h	(revision 4841)
+++ trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.h	(revision 4841)
@@ -0,0 +1,51 @@
+#ifndef MARS_MHBadPixels
+#define MARS_MHBadPixels
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MPedPhotCam;
+class MPointingPos;
+class MParList;
+class MGeomCam;
+
+class MHBadPixels : public MH
+{
+private:
+    MGeomCam      *fCam;      //!
+    MPedPhotCam   *fPedPhot;  //!
+    MPointingPos  *fPointPos; //!
+
+    TString  fNamePedPhotCam; //! name of the 'MPedPhotCam' container
+
+    TH2D          fBadId; // 2D-histogram : pixel Id vs. Theta
+    TH2D          fBadN;  // 2D-histogram : no.of bad pixels vs. Theta
+
+public:
+    MHBadPixels(const char *name=NULL, const char *title=NULL);
+
+    void SetNamePedPhotCam(const char *name)  { fNamePedPhotCam = name; }
+
+    const TH2D *GetBadId()       { return &fBadId; }
+    const TH2D *GetBadId() const { return &fBadId; }
+
+    const TH2D *GetBadN()       { return &fBadN; }
+    const TH2D *GetBadN() const { return &fBadN; }
+
+    TH2 *GetBadIdByName(const TString name) { return &fBadId; }
+    TH2 *GetBadNByName(const TString name) { return &fBadN; }
+
+    void Draw(Option_t* option = "");
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    ClassDef(MHBadPixels, 1)  // Histogram of bad pixel Id vs. Theta
+};
+
+#endif
+
+
Index: trunk/MagicSoft/Mars/mbadpixels/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/Makefile	(revision 4840)
+++ trunk/MagicSoft/Mars/mbadpixels/Makefile	(revision 4841)
@@ -20,5 +20,6 @@
 #
 INCLUDES = -I. -I../mbase -I../manalysis -I../mgeom -I../mgui \
-           -I../mmc -I../mpedestal -I../msignal
+           -I../mmc -I../mpedestal -I../msignal -I../mpointing \
+           -I../mhbase
 # MBadPixelsCalc  (manalysis): MPedPhotCam, MSigmabar
 # MBadPixelsCalc  (mgeom):     MGeomCam
@@ -35,5 +36,6 @@
            MBadPixelsCalc.cc \
            MBadPixelsTreat.cc \
-           MMcBadPixelsSet.cc
+           MMcBadPixelsSet.cc \
+           MHBadPixels.cc
 
 ############################################################
Index: trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 4840)
+++ trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 4841)
@@ -19,4 +19,5 @@
 #pragma link C++ class MHGamma+;
 #pragma link C++ class MHFlux;
+#pragma link C++ class MHSigmaTheta;
 #pragma link C++ class MHEffOnTime+;
 #pragma link C++ class MHTimeDiffTime+;
Index: trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc	(revision 4840)
+++ trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc	(revision 4841)
@@ -44,8 +44,8 @@
 #include "MBinning.h"
 #include "MParList.h"
-#include "MSigmabar.h"
 
 #include "MGeomCam.h"
-#include "MBlindPixels.h"
+#include "MGeomPix.h"
+#include "MBadPixelsCam.h"
 
 #include "MPedPhotCam.h"
@@ -114,4 +114,6 @@
     SetBinning(&fSigmaPixTheta,   &binst, &binspix, &binsb);
     SetBinning(&fDiffPixTheta,    &binst, &binspix, &binsd);
+
+    fNamePedPhotCam = "MPedPhotCamFromData";
 }
 
@@ -134,17 +136,19 @@
 
 
-    fPed = (MPedPhotCam*)plist->FindObject("MPedPhotCam");
+
+    fPed = (MPedPhotCam*)plist->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
     if (!fPed)
     {
-        *fLog << err << "MPedPhotCam not found... aborting." << endl;
+        *fLog << err << AddSerialNumber(fNamePedPhotCam) 
+              << "[MPedPhotCam] not found... aborting." << endl;
         return kFALSE;
     }
-    fPed->InitSize(fCam->GetNumPixels());
+    //fPed->InitSize(fCam->GetNumPixels()); 
 
     
-    fBlindPix = (MBlindPixels*)plist->FindObject("MBlindPixels");
-    if (!fBlindPix)
+    fBad = (MBadPixelsCam*)plist->FindObject("MBadPixelsCam");
+    if (!fBad)
     {  
-       *fLog << err << "MBlindPixels not found... continue. " << endl; 
+       *fLog << err << "MBadPixelsCam not found... continue. " << endl; 
     }
 
@@ -157,10 +161,4 @@
     }
 
-    fSigmabar = (MSigmabar*)plist->FindObject("MSigmabar");
-    if (!fSigmabar)
-    {
-        *fLog << err << "MSigmabar not found... aborting." << endl;
-        return kFALSE;
-    }
 
     // Get Theta Binning
@@ -213,10 +211,10 @@
 {
     Double_t theta = fPointPos->GetZd();
-    fSigmabar->Calc(*fCam, *fPed, *fEvt);
-    Double_t mysig      = fSigmabar->GetSigmabarInner();
-    Double_t mysigouter = fSigmabar->GetSigmabarOuter();
-
-    //*fLog << "theta, mysig, mysigouter = " << theta << ",  " << mysig 
-    //      << ",  " << mysigouter << endl;
+
+    Double_t mysig      = (fPed->GetArea(0)).GetRms();
+    Double_t mysigouter = (fPed->GetArea(1)).GetRms();
+
+    *fLog << "theta, mysig, mysigouter = " << theta << ",  " << mysig 
+          << ",  " << mysigouter << endl;
 
     fSigmaTheta.Fill(theta, mysig);
@@ -239,10 +237,10 @@
         const MPedPhotPix &pix = (*fPed)[id];
 
-        if ( fBlindPix != NULL  &&  fBlindPix->IsBlind(id) )
+        if ( fBad != NULL  &&  ((*fBad)[id]).IsUnsuitable() )
 	{
-          // this should never occur, because blind pixels should have
-          // been set unused by MBlindPixelsCalc2::UnMap()
-          //*fLog << all << "MHSigmaTheta::Fill; blind pixel found which is used, id = "
-          //      << id << "... go to next pixel." << endl;
+          // this should never occur, because bad pixels should have
+          // been set unused 
+          *fLog << all << "MHSigmaTheta::Fill; bad pixel found which is used, id = "
+                << id << "... go to next pixel." << endl;
 	  continue;
 	}
@@ -256,5 +254,6 @@
 
 	Double_t diff;
-        if (ratio > 0.5)
+        const Byte_t aidx = (*fCam)[id].GetAidx();
+        if (aidx == 0)
 	{
           // inner pixel
Index: trunk/MagicSoft/Mars/mhist/MHSigmaTheta.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHSigmaTheta.h	(revision 4840)
+++ trunk/MagicSoft/Mars/mhist/MHSigmaTheta.h	(revision 4841)
@@ -14,11 +14,11 @@
 #endif
 
+
+class MParList;
 class MGeomCam;
 class MCerPhotEvt;
 class MPointingPos;
 class MPedPhotCam;
-class MSigmabar;
-class MParList;
-class MBlindPixels;
+class MBadPixelsCam;
 
 
@@ -29,7 +29,8 @@
     MPedPhotCam    *fPed;        //!
     MCerPhotEvt    *fEvt;        //!
-    MSigmabar      *fSigmabar;   //!
     MPointingPos   *fPointPos;   //!
-    MBlindPixels   *fBlindPix;   //!
+    MBadPixelsCam  *fBad;        //!
+
+    TString  fNamePedPhotCam; //! name of the 'MPedPhotCam' container
 
                            // sigmabar is the average pedestal sigma  
@@ -44,4 +45,6 @@
 public:
     MHSigmaTheta(const char *name=NULL, const char *title=NULL);
+
+    void SetNamePedPhotCam(const char *name)  { fNamePedPhotCam = name; }
 
     Bool_t SetupFill(const MParList *plist);
Index: trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhist/Makefile	(revision 4840)
+++ trunk/MagicSoft/Mars/mhist/Makefile	(revision 4841)
@@ -22,5 +22,5 @@
 	   -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage \
            -I../mmain -I../mmc -I../mreflector -I../mpointing       \
-           -I../mastro -I../mpedestal
+           -I../mastro -I../mpedestal -I../mbadpixels
 
 SRCFILES = MHEvent.cc \
@@ -45,4 +45,5 @@
            MHGamma.cc \
            MHFlux.cc \
+           MHSigmaTheta.cc \
 	   MHSigmaPixel.cc \
 	   MHSigmabarTheta.cc \
