Index: trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc	(revision 4373)
+++ trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc	(revision 4374)
@@ -61,11 +61,16 @@
 using namespace std;
 
-const Int_t   MExtractBlindPixel::fgBlindPixelIdx  = 559;
-const Int_t   MExtractBlindPixel::fgNSBFilterLimit =  70;
-const Byte_t  MExtractBlindPixel::fgHiGainFirst    =  10;
-const Byte_t  MExtractBlindPixel::fgHiGainLast     =  29;
-const Byte_t  MExtractBlindPixel::fgLoGainFirst    =   0;
-const Byte_t  MExtractBlindPixel::fgLoGainLast     =   6;
-const Float_t MExtractBlindPixel::fgResolution    = 0.003;
+const UInt_t  MExtractBlindPixel::fgBlindPixelIds[3] = { 559, 560, 561 };
+const UInt_t  MExtractBlindPixel::fgBlindPixelIdx    = 559;
+const Byte_t  MExtractBlindPixel::fgFirst            =   0;
+const Byte_t  MExtractBlindPixel::fgLast             =   7;
+const Byte_t  MExtractBlindPixel::fgHiGainFirst      =  10;
+const Byte_t  MExtractBlindPixel::fgHiGainLast       =  29;
+const Byte_t  MExtractBlindPixel::fgLoGainFirst      =   0;
+const Byte_t  MExtractBlindPixel::fgLoGainLast       =   6;
+const Int_t   MExtractBlindPixel::fgNSBFilterLimit   =  70;
+const Float_t MExtractBlindPixel::fgResolution       = 0.003;
+const UInt_t  MExtractBlindPixel::gkModificationRun  = 31693;
+const Float_t MExtractBlindPixel::gkOverflow         = 300.;
 // --------------------------------------------------------------------------
 //
@@ -76,4 +81,5 @@
 // - fNSBFilterLimit to fgNSBFilterLimit
 // - fResolution to fgResolution
+// - fExtractionType to kAmplitude
 //
 // Calls:
@@ -91,22 +97,77 @@
   AddToBranchList("MRawEvtData.*");
 
-  fBlindPixelIdx.Set(1);
-  
-  SetBlindPixelIdx();
   SetResolution();
   SetNSBFilterLimit();
   SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
-
-}
-
+  
+  SetFirst();
+  SetLast();
+
+  SetExtractionType();
+
+  Clear();
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor: 
+// 
+// - Deletes, (if not NULL):
+//   fHiGainSignal;
+//   fHiGainFirstDeriv;
+//   fHiGainSecondDeriv;
+// 
 MExtractBlindPixel::~MExtractBlindPixel()
 {
 
   if (fHiGainSignal)
-    delete fHiGainSignal;
+    delete [] fHiGainSignal;
   if (fHiGainFirstDeriv)
-    delete fHiGainFirstDeriv;
+    delete [] fHiGainFirstDeriv;
   if (fHiGainSecondDeriv)
-    delete fHiGainSecondDeriv;
+    delete [] fHiGainSecondDeriv;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Clear
+//
+// Initializes:
+// - fModified to kFALSE
+// - fBlindPixelIdx to 0
+// 
+// Calls:
+// - SetBlindPixelIdx()
+// 
+// Deletes and sets to NULL (if exists):
+// - fHiGainSignal
+// - fHiGainFirstDeriv
+// - fHiGainSecondDeriv
+//
+void MExtractBlindPixel::Clear( const Option_t *o)
+{
+
+  fModified = kFALSE;
+
+  fBlindPixelIdx.Set(0);
+  SetBlindPixelIdx();
+
+  if (fHiGainSignal)
+    {
+      delete [] fHiGainSignal;
+      fHiGainSignal = NULL;
+    }
+  if (fHiGainFirstDeriv)
+    {
+      delete [] fHiGainFirstDeriv;
+      fHiGainFirstDeriv = NULL;
+    }
+  if (fHiGainSecondDeriv)
+    {
+      delete [] fHiGainSecondDeriv;
+      fHiGainSecondDeriv = NULL;
+    }
 
 }
@@ -129,6 +190,8 @@
 // --------------------------------------------------------------------------
 //
-// The PreProcess searches for the following input containers:
-//  - MRawEvtData
+// Calls: 
+// - MExtractor::PreProcess(pList)
+//
+// Sets fModified to kTRUE if the current run number is greater or equal gkModificationRun
 //
 // The following output containers are also searched and created if
@@ -137,4 +200,6 @@
 //  - MExtractedBlindPixel
 //
+// 
+//
 Int_t MExtractBlindPixel::PreProcess(MParList *pList)
 {
@@ -142,22 +207,9 @@
   if (!MExtractor::PreProcess(pList))
     return kFALSE;
-  
+
   fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel"));
   if (!fBlindPixel)
     return kFALSE;
 
-  fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx.At(0));
-  fBlindPixel->SetUsedFADCSlices(fHiGainFirst, fHiGainLast);
-  
-  MPedestalPix &pedpix  = (*fPedestals)[fBlindPixelIdx.At(0)];    
-  
-  if (&pedpix)
-    {
-      fBlindPixel->SetPed      ( pedpix.GetPedestal()   * fNumLoGainSamples );
-      fBlindPixel->SetPedErr   ( pedpix.GetPedestalRms()* fNumLoGainSamples 
-                                 / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()) );
-      fBlindPixel->SetPedRms   ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples) );
-      fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2. );
-    }
   
   return kTRUE;
@@ -184,9 +236,41 @@
   
   if (fHiGainSignal)
-    delete fHiGainSignal;
+    delete [] fHiGainSignal;
   if (fHiGainFirstDeriv)
-    delete fHiGainFirstDeriv;
+    delete [] fHiGainFirstDeriv;
   if (fHiGainSecondDeriv)
-    delete fHiGainSecondDeriv;
+    delete [] fHiGainSecondDeriv;
+
+  if ( fRunHeader->GetRunNumber() >= gkModificationRun )
+  {
+      fModified = kTRUE;
+      SetRange(fFirst,fLast);
+      for (Int_t i=0;i<3;i++)
+      {
+	  SetBlindPixelIdx(fgBlindPixelIds[i],i);
+	  fBlindPixel->SetBlindPixelIdx(fgBlindPixelIds[i],i);
+      }
+  }
+  else
+  {
+      fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx.At(0));
+  }
+
+  fBlindPixel->SetUsedFADCSlices(fHiGainFirst, fHiGainLast);
+  
+  for (Int_t i=0;i<fBlindPixelIdx.GetSize();i++)
+  {
+
+      MPedestalPix &pedpix  = (*fPedestals)[fBlindPixelIdx.At(i)];    
+      
+      if (&pedpix)
+      {
+	  fBlindPixel->SetPed      ( pedpix.GetPedestal()   * fNumLoGainSamples, i );
+	  fBlindPixel->SetPedErr   ( pedpix.GetPedestalRms()* fNumLoGainSamples 
+                                 / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()), i );
+	  fBlindPixel->SetPedRms   ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples), i );
+	  fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2., i );
+      }
+  }
 
   const Int_t firstdesired   = (Int_t)fHiGainFirst;
@@ -194,5 +278,5 @@
   
   if (firstdesired > lastavailable)
-    {
+  {
       const Int_t diff = firstdesired - lastavailable;
       *fLog << endl;
@@ -235,11 +319,10 @@
   const Int_t range = fHiLoFirst ? fHiLoLast - fHiLoFirst + 1 : fHiGainLast - fHiGainFirst + fHiLoLast + 1;
 
-  fHiGainSignal = new Float_t[range];
+  fHiGainSignal      = new Float_t[range];
   memset(fHiGainSignal,0,range*sizeof(Float_t));
-  fHiGainFirstDeriv = new Float_t[range];
+  fHiGainFirstDeriv  = new Float_t[range];
   memset(fHiGainFirstDeriv,0,range*sizeof(Float_t));
   fHiGainSecondDeriv = new Float_t[range];
   memset(fHiGainSecondDeriv,0,range*sizeof(Float_t));
-
 
   *fLog << endl;
@@ -267,5 +350,5 @@
 // - Add contents of *logain to sum
 // 
-void MExtractBlindPixel::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const
+void MExtractBlindPixel::FindIntegral(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
 {
 
@@ -309,5 +392,5 @@
 // - Add contents of *logain to sum
 // 
-void MExtractBlindPixel::FindAmplitude(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const
+void MExtractBlindPixel::FindAmplitude(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) 
 {
 
@@ -325,9 +408,35 @@
 
       range = fHiGainLast - fHiGainFirst + 1;
+
       end   = ptr + range;
       //
       // Check for saturation in all other slices
       //
-      while (++p<end)
+      while (p++<end)
+        {
+          
+          fHiGainSignal[count] = (Float_t)*p;
+          summ += *p;
+
+          if (*p > max)
+            {
+              max    = *p;
+              maxpos =  count;
+            }
+          
+          count++;
+
+          if (*p >= fSaturationLimit)
+              sat++;
+        }
+    }
+  
+  if (fHiLoLast != 0)
+    {
+      
+      p    = logain + fHiLoFirst;
+      end  = logain + fHiLoLast + 1;
+      
+      while (p<end)
         {
           
@@ -344,49 +453,17 @@
           count++;
 
-          if (*p >= fSaturationLimit)
-            {
+          if (*p++ >= fSaturationLimit)
               sat++;
-              break;
-            }
         }
     }
-  
-  if (fHiLoLast != 0)
-    {
-      
-      p    = logain + fHiLoFirst;
-      end  = logain + fHiLoLast + 1;
-      
-      while (p<end)
-        {
-          
-          fHiGainSignal[count] = (Float_t)*p;
-          summ += *p;
-
-          if (*p > max)
-            {
-              max    = *p;
-              maxpos =  count;
-            }
-          
-          range++;
-          count++;
-
-          if (*p++ >= fSaturationLimit)
-            {
-              sat++;
-              break;
-            }
-        }
-    }
-
-  //  sum = (Float_t)summ;
-  //  return;
-  
+
   //
   // allow one saturated slice 
   //
   if (sat > 1)
+  {
+    sum = gkOverflow;
     return;
+  }
 
   //
@@ -394,9 +471,10 @@
   //
   if (maxpos < 2)
+  {
+    sum = (Float_t)max;
     return;
+  }
 
   Float_t pp;
-  fHiGainSecondDeriv[0] = 0.;
-  fHiGainFirstDeriv[0]  = 0.;
 
   for (Int_t i=1;i<range-1;i++)
@@ -586,23 +664,30 @@
     {
   
-      pixel.Jump(fBlindPixelIdx.At(id));
+      pixel.Jump(fBlindPixelIdx[id]);
       
       Int_t sum   = 0;
       Byte_t sat  = 0;
 
-      FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat);
-
-      if (sum > fNSBFilterLimit)
-        {
-          fBlindPixel->SetExtractedSignal(-1.);
-          fBlindPixel->SetNumSaturated(sat);
-          fBlindPixel->SetReadyToSave();
-          continue;
-        }
-      
+      if (!fModified)
+      {
+
+	  FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat);
+	  
+	  if (sum > fNSBFilterLimit)
+	  {
+	      fBlindPixel->SetExtractedSignal(-1.);
+	      fBlindPixel->SetNumSaturated(sat);
+	      fBlindPixel->SetReadyToSave();
+	      continue;
+	  }
+      }
+
       Float_t newsum = 0.;
       sat = 0;
       
-      FindSignalHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
+      if (IsExtractionType(kAmplitude))
+	FindAmplitude   (pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
+      else
+	FindIntegral    (pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
   
       fBlindPixel->SetExtractedSignal(newsum,id);
@@ -614,2 +699,24 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sets the extraction type. Available are: kAmplitude and kIntegral
+//
+Bool_t MExtractBlindPixel::IsExtractionType( const ExtractionType_t typ )
+{
+  
+  return TESTBIT( fExtractionType, typ );
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the extraction type. Available are: kAmplitude and kIntegral
+//
+void MExtractBlindPixel::SetExtractionType( const ExtractionType_t typ )
+{
+  
+  fExtractionType = 0;
+  SETBIT( fExtractionType, typ );
+
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.h	(revision 4373)
+++ trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.h	(revision 4374)
@@ -1,13 +1,4 @@
 #ifndef MARS_MExtractBlindPixel
 #define MARS_MExtractBlindPixel
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MExtractBlindPixel                                                      //
-//                                                                         //
-// Integrates the time slices of the all pixels of a calibration event     //
-// and substract the pedestal value                                        //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
 
 #ifndef MARS_MExtractor
@@ -24,15 +15,22 @@
 private:
 
-  static const Int_t  fgBlindPixelIdx;
-  static const Int_t  fgNSBFilterLimit;  
-  static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (currently set to: 0) 
-  static const Byte_t fgHiGainLast;      // Last FADC slice Hi-Gain (currently set to: 11) 
-  static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (currently set to: 0) 
-  static const Byte_t fgLoGainLast;      // Last FADC slice Lo-Gain (currently set to:  2) 
-  static const Float_t fgResolution;     // Default for fResolution   (now set to: 0.003)
-  
-  MExtractedSignalBlindPixel  *fBlindPixel;   // Extracted signal of the Blind Pixel
+  static const UInt_t  fgBlindPixelIds[3]; //! Default blind pixel indices after modification run
+  static const UInt_t  fgBlindPixelIdx;    //! Default blind pixels index before modification run
+  static const Byte_t  fgFirst;            //! Default First FADC slice after modification run (currently set to: 2  ) 
+  static const Byte_t  fgLast ;            //! Default Last  FADC slice after modification run (currently set to: 13 ) 
+  static const Byte_t  fgHiGainFirst;      //! Default First FADC slice Hi-Gain Signal (currently set to: 10   ) 
+  static const Byte_t  fgHiGainLast;       //! Default Last  FADC slice Hi-Gain Signal (currently set to: 29   ) 
+  static const Byte_t  fgLoGainFirst;      //! Default First FADC slice Filter         (currently set to: 0    ) 
+  static const Byte_t  fgLoGainLast;       //! Default Last  FADC slice Filter         (currently set to: 6    ) 
+  static const Int_t   fgNSBFilterLimit;   //! Default for fNSBFilterLimit
+  static const Float_t fgResolution;       //! Default for fResolution         (currently set to: 0.003)
+  static const UInt_t  gkModificationRun;  //! The run number from which on three blind pixels are used
+  static const Float_t gkOverflow;         //! Default sum to assign overflow in case of saturation
 
-  Byte_t  fHiLoFirst;
+  MExtractedSignalBlindPixel  *fBlindPixel;  // Extracted signal of the Blind Pixel
+
+  Byte_t   fFirst;
+  Byte_t   fLast;
+  Byte_t   fHiLoFirst;
   Float_t *fHiGainSignal;                     // Need fast access to the signals in a float way
   Float_t *fHiGainFirstDeriv;
@@ -43,7 +41,12 @@
   Int_t   fNSBFilterLimit;  
 
-  void FindAmplitude(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const;
-  void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const;
-  void FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const;
+  Bool_t  fModified;
+  Byte_t  fExtractionType;                    
+
+  enum ExtractionType_t { kAmplitude, kIntegral };
+
+  void FindAmplitude   (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
+  void FindIntegral    (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
+  void FindSignalFilter(Byte_t *ptr,                          Int_t &sum, Byte_t &sat) const;
   
   Int_t  PreProcess(MParList *pList);
@@ -55,9 +58,18 @@
   MExtractBlindPixel(const char *name=NULL, const char *title=NULL);
   ~MExtractBlindPixel();
+
+  void Clear( const Option_t *o ="");
   
+  // Getters
+  Bool_t IsExtractionType ( const ExtractionType_t typ );
+
   // Setters
-  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+  void SetExtractionType( const ExtractionType_t typ=kAmplitude );
+  void SetFirst( const Byte_t first=fgFirst) { fFirst = first; }
+  void SetLast ( const Byte_t last =fgLast)  { fLast  = last; }
+  void SetRange( const Byte_t hifirst=0, const Byte_t hilast=0, 
+		 const Byte_t lofirst=0, const Byte_t lolast=0);
   void SetBlindPixelIdx(  const  Int_t idx=fgBlindPixelIdx, const Int_t nr=0) {
-    if (nr>fBlindPixelIdx.GetSize()+1)
+    if (nr>fBlindPixelIdx.GetSize()-1)
       fBlindPixelIdx.Set(nr+1);
     fBlindPixelIdx.AddAt(idx,nr); }
Index: trunk/MagicSoft/Mars/msignal/MExtractedSignalBlindPixel.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractedSignalBlindPixel.cc	(revision 4373)
+++ trunk/MagicSoft/Mars/msignal/MExtractedSignalBlindPixel.cc	(revision 4374)
@@ -27,9 +27,10 @@
 // MExtractedSignalBlindPixel
 //
-// This is the storage container to hold informations about the extracted signal 
-// (offset) value of the calibration Blind Pixel. 
-//
+// The storage container of the extracted signal of the calibration Blind Pixel(s). 
+// Additionally, the number of saturated Slices are stored. 
 // There is place for various blind pixels set into the camera in  July. Default 
 // is one blind pixel.
+//
+// Default values for the extracted signals are: gkSignalInitializer
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -47,10 +48,16 @@
 // ------------------------------------------------------------------------
 //
-// MExtractedSignalBlindPixel holds the extracted signal
-// of the FADC slices and its error. 
 //
-// Additionally, the number of saturated Slices are stored. 
-// 
-// Default values for the extracted signals are: 99999.9 
+// Sets:
+// - the dimenstion of fBlindPixelIdx to 1
+// - the dimenstion of fExtractedSignal to 1
+// - the dimenstion of fNumSaturated to 1
+// - the dimenstion of fPed. to 1;      
+// - the dimenstion of fPedErr. to 1;)   
+// - the dimenstion of fPedRms. to 1;   
+// - the dimenstion of fPedRmsErr. to 1;
+//
+// Calls:
+// - Clear()
 //
 MExtractedSignalBlindPixel::MExtractedSignalBlindPixel(const char* name, const char* title)
@@ -74,5 +81,8 @@
 // ------------------------------------------------------------------------
 //
-// Invalidate values
+// Set values of:
+// - fNumSaturated   
+// - fExtractedSignal
+// to gkSignalInitializer
 //
 void MExtractedSignalBlindPixel::Clear(Option_t *o)
@@ -83,12 +93,11 @@
       fNumSaturated   .AddAt(gkSignalInitializer,i);
       fExtractedSignal.AddAt(gkSignalInitializer,i);
-      fPed            .AddAt(gkSignalInitializer,i);      
-      fPedErr         .AddAt(gkSignalInitializer,i);   
-      fPedRms         .AddAt(gkSignalInitializer,i);   
-      fPedRmsErr      .AddAt(gkSignalInitializer,i);  
     }
-  
 }
 
+// ------------------------------------------------------------------------
+//
+// Set number num of used FADC slices, starting from (including) first 
+//
 void MExtractedSignalBlindPixel::SetUsedFADCSlices(const Byte_t first, const Byte_t num)   
 {
@@ -97,5 +106,8 @@
 }
 
-
+// --------------------------------------------------------------------------------------------
+//
+// Returns true, if fExtractedSignal is greater or equal 0 and smaller than gkSignalInitializer
+//
 Bool_t MExtractedSignalBlindPixel::IsValid( const Int_t i ) const
 {
@@ -103,4 +115,8 @@
 }
 
+// --------------------------------------------------------------------------------------------
+//
+// Prints for all stored blind pixels the ID, the signal and the number of saturated slices
+//
 void MExtractedSignalBlindPixel::Print(Option_t *o) const
 {
