Index: /trunk/MagicSoft/Mars/mcalib/MExtractPINDiode.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MExtractPINDiode.cc	(revision 3181)
+++ /trunk/MagicSoft/Mars/mcalib/MExtractPINDiode.cc	(revision 3182)
@@ -49,5 +49,5 @@
 using namespace std;
 
-const UInt_t MExtractPINDiode::fgPINDiodeId      = 254;
+const UInt_t MExtractPINDiode::fgPINDiodeIdx     = 999;
 const Byte_t MExtractPINDiode::fgSaturationLimit = 254;
 const Byte_t MExtractPINDiode::fgFirst =  1;
@@ -61,11 +61,12 @@
     : fSaturationLimit(fgSaturationLimit)
 {
-
-    fName  = name  ? name  : "MExtractPINDiode";
-    fTitle = title ? title : "Task to extract the signal from the FADC slices";
-
-    AddToBranchList("MRawEvtData.*");
-
-    SetRange();
+  
+  fName  = name  ? name  : "MExtractPINDiode";
+  fTitle = title ? title : "Task to extract the signal from the FADC slices";
+  
+  AddToBranchList("MRawEvtData.*");
+  
+  SetRange();
+  SetPINDiodeIdx();
 }
 
@@ -147,5 +148,5 @@
     fPINDiode->Clear();
 
-    pixel.Jump(fgPINDiodeId);
+    pixel.Jump(fPINDiodeIdx);
  
     UInt_t sum  = 0;
@@ -161,8 +162,20 @@
                sum, sum2, sat, max);
     
-    const MPedestalPix &ped   = (*fPedestals)[fgPINDiodeId]; 
-    
-    const Float_t pedes  = ped.GetPedestal();
-    const Float_t pedrms = ped.GetPedestalRms();
+    const MPedestalPix &ped   = (*fPedestals)[fPINDiodeIdx]; 
+
+    Float_t pedes  = -999.;
+    Float_t pedrms = -999.;
+
+    if (&ped)
+      {
+        pedes  = ped.GetPedestal();
+        pedrms = ped.GetPedestalRms();
+      }
+    else
+      {
+        *fLog << warn << " Cannot find MPedestalPix of the PIN Diode (idx=" 
+              << fPINDiodeIdx << ")" << endl;
+
+      }
 
     const Float_t var = ((Float_t)sum2 - (Float_t)sum*sum/fNumSamples)/(fNumSamples-1);
Index: /trunk/MagicSoft/Mars/mcalib/MExtractPINDiode.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MExtractPINDiode.h	(revision 3181)
+++ /trunk/MagicSoft/Mars/mcalib/MExtractPINDiode.h	(revision 3182)
@@ -24,5 +24,5 @@
 private:
 
-  static const UInt_t fgPINDiodeId;  
+  static const UInt_t fgPINDiodeIdx;  
   static const Byte_t fgSaturationLimit;
   static const Byte_t fgFirst;
@@ -38,9 +38,8 @@
   Byte_t  fLast;
   Byte_t  fNumSamples;
-
   Float_t fSqrtSamples;
-
   Byte_t  fSaturationLimit;
-
+  UInt_t  fPINDiodeIdx;
+  
   void   FindSignal(Byte_t *ptr, Int_t size, UInt_t &sum, UInt_t &sum2, UInt_t &sat, UInt_t &max) const;
   
@@ -52,7 +51,9 @@
 
   MExtractPINDiode(const char *name=NULL, const char *title=NULL);
-  
-  void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast);
-  void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+  // Setters
+  void SetRange(const Byte_t hifirst=fgFirst, const Byte_t hilast=fgLast);
+  void SetSaturationLimit(const Byte_t lim) { fSaturationLimit = lim; }
+  void SetPINDiodeIdx(const UInt_t idx=fgPINDiodeIdx) { fPINDiodeIdx = idx; }  
 
   ClassDef(MExtractPINDiode, 0) // Task to fill the Extracted PINDiode Containers from raw data
