Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 5377)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 5378)
@@ -20,4 +20,37 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/11/11: Thomas Bretz
+
+   * callisto.cc:
+     - fixed a typo in the screen output
+
+   * mastro/MAstroCamera.cc:
+     - made a simple simplification
+
+   * mmuon/MMuonSearchParCalc.cc:
+     - changed some log-output to be standard
+
+   * mpedestal/MPedCalcFromLoGain.[h,cc]:
+     - Updated fTitle
+     - Fixed AddToBranchList entries
+     - invented a new function (ResetArrays)
+     - added a return value to SetCheckRange
+     - added a return value to SetCheckRange
+     - changed arguments of SetExtractWindow to UShort_t which is more
+       intuitive
+     - changed arguments of SetExtractWindow to UShort_t which is more
+       intuitive
+     - changed some log-output to be more standard
+     - changed return type of GetSlice to UShort_t
+     - fixed names of resources to fit variable names
+     - implemented Print()
+     - changed types of default to UShort_t
+
+   * mraw/MRawRead.cc:
+     - fixed a bug which caused the special pixel indices to be 2,3,4,...
+       instead of 0,1,2,3,...
+
+
+
  2004/11/10: Abelardo Moralejo
 
@@ -80,4 +113,5 @@
        weights are quasi randomly chosen and applied to the first slices
        available in the set range
+
    * msignal/MC_weights.dat
     - new weights file using 6 slices for the digital filter, especially
Index: /trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- /trunk/MagicSoft/Mars/callisto.cc	(revision 5377)
+++ /trunk/MagicSoft/Mars/callisto.cc	(revision 5378)
@@ -70,5 +70,5 @@
     gLog << "   --print-files             Print Files taken from Sequence" << endl;
     gLog << "   --print-only              Do not excute anything except print" << endl;
-    gLog << "   --config=callisto.rc      Resource file [default=callistop.rc]" << endl;
+    gLog << "   --config=callisto.rc      Resource file [default=callisto.rc]" << endl;
     gLog << endl;
     gLog << "   -?, -h, --help            This help" << endl << endl;
Index: /trunk/MagicSoft/Mars/mastro/MAstroCamera.cc
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MAstroCamera.cc	(revision 5377)
+++ /trunk/MagicSoft/Mars/mastro/MAstroCamera.cc	(revision 5378)
@@ -394,8 +394,5 @@
             {
                 TMarker *m=new TMarker(spot(0), spot(1), 1);
-		TVector3 pos=mirror->GetMirrorCenter();
-		Float_t r=pos.Mag();
-
-                m->SetMarkerColor((Int_t)(6*r)+51);
+                m->SetMarkerColor((Int_t)(6*mirror->GetMirrorCenter().Mag())+51);
                 m->SetMarkerStyle(kDot);
                 fMapG.Add(m);
Index: /trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.cc	(revision 5377)
+++ /trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.cc	(revision 5378)
@@ -89,5 +89,5 @@
     if (!fHillas)
     {
-        *fLog << err << dbginf << "MHillas not found... aborting." << endl;
+        *fLog << err << fHillasInput << " [MHillas] not found... aborting." << endl;
         return kFALSE;
     }
@@ -96,5 +96,5 @@
     if (!fCerPhotEvt)
     {
-        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        *fLog << err << fCerPhotName << " [MCerPhotEvt] not found... aborting." << endl;
         return kFALSE;
     }
@@ -103,5 +103,5 @@
     if (!fGeomCam)
     {
-        *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        *fLog << err << "MGeomCam not found... aborting." << endl;
         return kFALSE;
     }
Index: /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 5377)
+++ /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 5378)
@@ -31,8 +31,5 @@
 /////////////////////////////////////////////////////////////////////////////
 // 
-// 
-//
 //   MPedCalcLoGain
-//
 //
 //  This task is devide form MPedCalcPedRun, described below. However, It 
@@ -157,9 +154,9 @@
 using namespace std;
 
-const Int_t MPedCalcFromLoGain::fgCheckWinFirst      = 0;
-const Int_t MPedCalcFromLoGain::fgCheckWinLast       = 29;
-const Int_t MPedCalcFromLoGain::fgExtractWinFirst    = 15;
-const Int_t MPedCalcFromLoGain::fgExtractWinSize     = 6;
-const Int_t MPedCalcFromLoGain::fgMaxSignalVar       = 40;
+const UShort_t MPedCalcFromLoGain::fgCheckWinFirst   =  0;
+const UShort_t MPedCalcFromLoGain::fgCheckWinLast    = 29;
+const UShort_t MPedCalcFromLoGain::fgExtractWinFirst = 15;
+const UShort_t MPedCalcFromLoGain::fgExtractWinSize  =  6;
+const UShort_t MPedCalcFromLoGain::fgMaxSignalVar    = 40;
 
 // --------------------------------------------------------------------------
@@ -177,20 +174,32 @@
 //
 MPedCalcFromLoGain::MPedCalcFromLoGain(const char *name, const char *title)
-    : fGeom(NULL), fPedContainerName("MPedestalCam")
-{
-
-  fName  = name  ? name  : "MPedCalcFromLoGain";
-  fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
-  
-  AddToBranchList("fHiGainPixId");
-  AddToBranchList("fHiGainFadcSamples");
-  
-  SetCheckRange(fgCheckWinFirst, fgCheckWinLast);
-  SetExtractWindow(fgExtractWinFirst, fgExtractWinSize);
-
-  SetMaxSignalVar(fgMaxSignalVar);
-  SetPedestalUpdate(kTRUE);
-  Clear();
-
+    : fGeom(NULL), fNamePedestalCam("MPedestalCam")
+{
+    fName  = name  ? name  : "MPedCalcFromLoGain";
+    fTitle = title ? title : "Task to calculate pedestals from lo-gains";
+
+    AddToBranchList("fHiGainPixId");
+    AddToBranchList("fLoGainPixId");
+    AddToBranchList("fHiGainFadcSamples");
+    AddToBranchList("fLoGainFadcSamples");
+
+    SetCheckRange(fgCheckWinFirst, fgCheckWinLast);
+    SetExtractWindow(fgExtractWinFirst, fgExtractWinSize);
+
+    SetMaxSignalVar(fgMaxSignalVar);
+    SetPedestalUpdate(kTRUE);
+
+    Clear();
+}
+
+void MPedCalcFromLoGain::ResetArrays()
+{
+    // Reset contents of arrays.
+    fSumx.Reset();
+    fSumx2.Reset();
+    fSumAB0.Reset();
+    fSumAB1.Reset();
+    fNumEventsUsed.Reset();
+    fTotalCounter.Reset();
 }
 
@@ -219,13 +228,5 @@
   // If the size is yet set, set the size
   if (fSumx.GetSize()>0)
-  {
-      // Reset contents of arrays.
-      fSumx.Reset();
-      fSumx2.Reset();
-      fSumAB0.Reset();
-      fSumAB1.Reset();
-      fNumEventsUsed.Reset();
-      fTotalCounter.Reset();
-  }
+      ResetArrays();
 }
 
@@ -237,53 +238,48 @@
 // Exits, if the the last argument is smaller than the first
 //
-void MPedCalcFromLoGain::SetCheckRange(Int_t chfirst, Int_t chlast)
-{
-
-  if(chfirst<0)
-    {
-      *fLog << warn << GetDescriptor() 
-            << ": First slice in window to check for Signal <0, adjust:" << endl;
-      exit(-1);
-    }
-
-  if(chlast<=chfirst)
-    {
-      *fLog << warn << GetDescriptor() 
-            << ": Last slice in Check window smaller than first slice in window, adjust:" << endl;
-      exit(-1);
-    }
-  
-  fCheckWinFirst = chfirst;
-  fCheckWinLast = chlast;
-
-}
-
-// --------------------------------------------------------------------------
-//
-// Exits:
+Bool_t MPedCalcFromLoGain::SetCheckRange(UShort_t chfirst, UShort_t chlast)
+{
+    Bool_t rc = kTRUE;
+
+    if (chlast<=chfirst)
+    {
+        *fLog << warn << GetDescriptor();
+        *fLog << " - WARNING: Last slice in SetCheckRange smaller than first slice... set to first+2" << endl;
+        chlast = chfirst+1;
+        rc = kFALSE;
+    }
+
+    fCheckWinFirst = chfirst;
+    fCheckWinLast  = chlast;
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks:
 // - if a window is odd
-//
-void MPedCalcFromLoGain::SetExtractWindow(Int_t windowf, Int_t windows)
-{
- 
-  if(windowf<0)
-    {
-      *fLog << warn << GetDescriptor() 
-            << Form(": First slice in Extract window has to be >0, adjust:")<< endl;
-      exit(-1);
-    }
- 
-  Int_t odd  = windows & 0x1;
- 
-  if (odd||(windows==0))
-    {
-      *fLog << warn << GetDescriptor() << ": Extract window size has to be even and larger 0, adjust!"<< endl;
-      exit(-1);
-    }
-  
-  fExtractWinSize  = windows;
-  fExtractWinFirst = windowf;
-  fExtractWinLast  = fExtractWinFirst+fExtractWinSize-1;
-  
+// 
+Bool_t MPedCalcFromLoGain::SetExtractWindow(UShort_t windowf, UShort_t windows)
+{
+    Bool_t rc = kTRUE;
+
+    const Int_t odd  = windows & 0x1;
+
+    if (odd || windows==0)
+    {
+        *fLog << warn << GetDescriptor();
+        *fLog << " - WARNING: Window size in SetExtraxtWindow has to be even and > 0... adjusting!" << endl;
+        windows += 1;
+        rc = kFALSE;
+    }
+
+    fExtractWinSize  = windows;
+    fExtractWinFirst = windowf;
+    fExtractWinLast  = fExtractWinFirst+fExtractWinSize-1;
+
+//
+//  NO RANGE CHECK IMPLEMENTED, YET
+//
 /*
     const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1;
@@ -309,5 +305,7 @@
         fWindowSizeLoGain = availlorange;
     }
-*/
+    */
+
+  return rc;
 }
 
@@ -330,8 +328,8 @@
     Clear();
 
-    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
     if (!fRawEvt)
     {
-        *fLog << err << "MRawEvtData not found... aborting." << endl;
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
         return kFALSE;
     }
@@ -344,22 +342,18 @@
     }
 
-    fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+    fGeom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (!fGeom)
     {
-        *fLog << err << "MGeomCam not found... aborting." << endl;
+        *fLog << err << AddSerialNumber("MGeomCam") << " not found... aborting." << endl;
         return kFALSE;
     }
 
-
-    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam", AddSerialNumber(fPedContainerName));
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam", AddSerialNumber(fNamePedestalCam));
     if (!fPedestals)
         return kFALSE;
 
-    
-    *fLog << inf << "Parameters used for pedestal calculation:"<<endl;
-    *fLog << inf <<"Flag Pedestal Update: "<<fPedestalUpdate<<endl;
-    *fLog << inf <<"CheckWindow: First slice: "<<fCheckWinFirst<<"; Last slice: "<<fCheckWinLast<<endl;
-    *fLog << inf <<"ExtractWindow: First slice: "<<fExtractWinFirst<<"; Last slice: "<<fExtractWinLast<<endl;
-    *fLog << inf <<"Max allowed signal variation: "<<fMaxSignalVar<<endl;
+    *fLog << inf;
+    Print();
+
     return kTRUE;
 }
@@ -384,29 +378,26 @@
 Bool_t MPedCalcFromLoGain::ReInit(MParList *pList)
 {
-
-  Int_t lastavailableslice = (Int_t)fRunHeader->GetNumSamplesHiGain()
-                            +(Int_t)fRunHeader->GetNumSamplesLoGain()-1;
-  Int_t lastextractslice   =  fExtractWinSize+ fExtractWinFirst - 1;
-
-   if ( lastextractslice  > lastavailableslice ) //changed to override check
-    {
-      *fLog << endl; 
-      *fLog << warn << GetDescriptor()
-            << Form(": Selected Extract Window ranges out of the available limits adjust. Last available slice is %2i",
-		    lastavailableslice) << endl;
-      return kFALSE;
-    }
-
-  if ( fCheckWinLast  > lastavailableslice ) //changed to override check
-    {
-      *fLog << endl; 
-      *fLog << warn << GetDescriptor()
-            << Form(": Last Check Window slice is out of the available limits adjust. Last available slice is %2i",
-		    lastavailableslice) << endl;
-      return kFALSE;
-    }
-
-
- 
+  Int_t lastavailableslice = fRunHeader->GetNumSamplesHiGain()+fRunHeader->GetNumSamplesLoGain()-1;
+  Int_t lastextractslice   = fExtractWinSize + fExtractWinFirst - 1;
+
+   if (lastextractslice>lastavailableslice)//changed to override check
+   {
+       *fLog << warn << GetDescriptor();
+       *fLog << " - WARNING: Selected Extract Window ranges out of range...adjusting to last available slice ";
+       *fLog << lastavailableslice << endl;
+
+       lastextractslice=lastavailableslice;
+   }
+
+   if (fCheckWinLast>lastavailableslice)//changed to override check
+   {
+       *fLog << warn << GetDescriptor();
+       *fLog << " - WARNING: Last Check Window slice out of range...adjusting to last available slice ";
+       *fLog << lastavailableslice << endl;
+
+       fCheckWinLast=lastavailableslice;
+   }
+
+
   // If the size is not yet set, set the size
   if (fSumx.GetSize()==0)
@@ -421,11 +412,5 @@
       fTotalCounter.Set(npixels);
 
-      // Reset contents of arrays.
-      fSumx.Reset();
-      fSumx2.Reset();
-      fSumAB0.Reset();
-      fSumAB1.Reset();
-      fNumEventsUsed.Reset();
-      fTotalCounter.Reset();
+      ResetArrays();
   }
   
@@ -473,21 +458,14 @@
 // Returns the pointer to slice "slice".
 //
-UInt_t MPedCalcFromLoGain::GetSlice(MRawEvtPixelIter *pixel, UInt_t slice)
-{
-
- const UInt_t nh = (Int_t)fRunHeader->GetNumSamplesHiGain();
-
- Byte_t *ptr;
-
- if(slice>=nh)
-   {
-     ptr = pixel->GetLoGainSamples();
-     ptr += slice - nh;
-   }
- else
-   {
-     ptr = pixel->GetHiGainSamples();
-     ptr += slice;
-   }
+UShort_t MPedCalcFromLoGain::GetSlice(MRawEvtPixelIter *pixel, UInt_t slice)
+{
+    const UShort_t nh = (Int_t)fRunHeader->GetNumSamplesHiGain();
+
+    Byte_t *ptr;
+
+    if(slice<nh)
+        ptr = pixel->GetHiGainSamples() + slice;
+    else
+        ptr = pixel->GetLoGainSamples() + slice - nh;
 
    return *ptr;
@@ -506,22 +484,17 @@
     while (pixel.Next())
     {
-
-	 const UInt_t idx = pixel.GetPixelId();
-
-        Int_t max = 0;
-        Int_t min = 1025;
-    
+        const UInt_t idx = pixel.GetPixelId();
+
+        UShort_t max = 0;
+        UShort_t min = (UShort_t)-1;
+
         // Find the maximum and minimum signal per slice in the high gain window
-     
-        for(Int_t slice=fCheckWinFirst; slice<=fCheckWinLast; slice++)
-	  {
-    
-	  Int_t svalue = GetSlice(&pixel,slice);
-            if (svalue > max) {
+        for (Int_t slice=fCheckWinFirst; slice<=fCheckWinLast; slice++)
+        {
+            const UShort_t svalue = GetSlice(&pixel,slice);
+            if (svalue > max)
                 max = svalue;
-            }
-            if (svalue < min) {
+            if (svalue < min)
                 min = svalue;
-            }
         }
 
@@ -535,32 +508,27 @@
 	//extract pedestal
 	for(Int_t slice=fExtractWinFirst; slice<=fExtractWinLast; slice++)
-	  {    
-	  UInt_t svalue = GetSlice(&pixel,slice);
-	  sum += svalue;
-	  sqr += svalue*svalue;
+        {
+            const UInt_t svalue = GetSlice(&pixel,slice);
+            sum += svalue;
+            sqr += svalue*svalue;
         }
 
-        const Float_t msum   = (Float_t)sum;
-        const Float_t sqrsum = msum*msum;
-
-        fSumx[idx]  += msum;
-        fSumx2[idx] += sqrsum;
+        fSumx[idx]  += sum;
+        fSumx2[idx] += sum*sum;
+
         fNumEventsUsed[idx]++;
 
         // Calculate the amplitude of the 150MHz "AB" noise
-
-        Int_t abFlag = (fExtractWinFirst + pixel.HasABFlag()) & 0x1;
-
-	//cout << " MPedCalcFromLoGain: idx: " << idx << " abFlag: " << abFlag << endl;
-
-        for (Int_t islice=fExtractWinFirst; islice<=fExtractWinLast; islice+=2)
+        UShort_t abFlag = (fExtractWinFirst + pixel.HasABFlag()) & 0x1;
+
+        for (UShort_t islice=fExtractWinFirst; islice<=fExtractWinLast; islice+=2)
         {
-            Int_t sliceAB0 = islice + abFlag;
-            Int_t sliceAB1 = islice - abFlag + 1;
+            const UShort_t sliceAB0 = islice + abFlag;
+            const UShort_t sliceAB1 = islice - abFlag + 1;
             fSumAB0[idx] += GetSlice(&pixel, sliceAB0);
             fSumAB1[idx] += GetSlice(&pixel, sliceAB1);
         }
 
-        if (!fPedestalUpdate || fNumEventsUsed[idx]<fNumEventsDump)
+        if (!fPedestalUpdate || (UInt_t)fNumEventsUsed[idx]<fNumEventsDump)
           continue;
 
@@ -605,4 +573,13 @@
 
 
+// --------------------------------------------------------------------------
+//
+//  The following resources are available:
+//    FirstCheckWindowSlice: 0
+//    LastCheckWindowSlice: 29
+//    ExtractWindowFirst:   15
+//    ExtractWindowSize:     6
+//    NumEventsDump:
+//
 Int_t MPedCalcFromLoGain::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
@@ -612,13 +589,15 @@
     Bool_t rc=kFALSE;
 
-    Int_t fs =  fCheckWinFirst;
+    // Find resources for CheckWindow
+    Int_t fs = fCheckWinFirst;
     Int_t ls = fCheckWinLast;
-
-    if (IsEnvDefined(env, prefix, "FirstCheckWindowSlice", print)){
-        fs = GetEnvValue(env, prefix, "FirstCheckWindowSlice", fs);
+    if (IsEnvDefined(env, prefix, "CheckWinFirst", print))
+    {
+        fs = GetEnvValue(env, prefix, "CheckWinFirst", fs);
 	rc = kTRUE;
     }
-    if (IsEnvDefined(env, prefix, "LastCheckWindowSlice", print)){
-	ls = GetEnvValue(env, prefix, "LastCheckWindowSlice", ls);
+    if (IsEnvDefined(env, prefix, "CheckWinLast", print))
+    {
+	ls = GetEnvValue(env, prefix, "CheckWinLast", ls);
         rc = kTRUE;
     }
@@ -626,44 +605,52 @@
     SetCheckRange(fs,ls);
 
-
+    // Find resources for ExtractWindow
     Int_t lw = fExtractWinSize;
     Int_t wf = fExtractWinFirst;
-
-    if (IsEnvDefined(env, prefix, "ExtractWindowSize", print)){
-      lw = GetEnvValue(env, prefix, "ExtractWindowSize", lw);
-      rc = kTRUE;
-    }
-
-    if (IsEnvDefined(env, prefix, "ExtractWindowFirst", print)){
-      wf = GetEnvValue(env, prefix, "ExtractWindowFirst", wf);
-    rc = kTRUE;
-    }
-
+    if (IsEnvDefined(env, prefix, "ExtractWinSize", print))
+    {
+        lw = GetEnvValue(env, prefix, "ExtractWinSize", lw);
+        rc = kTRUE;
+    }
+
+    if (IsEnvDefined(env, prefix, "ExtractWinFirst", print))
+    {
+        wf = GetEnvValue(env, prefix, "ExtractWinFirst", wf);
+        rc = kTRUE;
+    }
     SetExtractWindow(wf,lw);
 
-    Int_t num = fNumEventsDump;
+    // find resource for numeventsdump
     if (IsEnvDefined(env, prefix, "NumEventsDump", print))
     {
-        num = GetEnvValue(env, prefix, "NumEventsDump", num);
+        SetNumEventsDump(GetEnvValue(env, prefix, "NumEventsDump", (Int_t)fNumEventsDump));
         rc = kTRUE;
     }
-    SetNumEventsDump(num);
-
-    Int_t max = fMaxSignalVar;
+
+    // find resource for maximum signal variation
     if (IsEnvDefined(env, prefix, "MaxSignalVar", print))
     {
-        max = GetEnvValue(env, prefix, "MaxSignalVar", max);
+        SetMaxSignalVar(GetEnvValue(env, prefix, "MaxSignalVar", fMaxSignalVar));
         rc = kTRUE;
     }
-    SetMaxSignalVar(max);
-
-    Bool_t upd = fPedestalUpdate;
+
+    // find resource for pedestal update
     if (IsEnvDefined(env, prefix, "PedestalUpdate", print))
     {
-        upd = GetEnvValue(env, prefix, "PedestalUpdate", upd);
+        SetPedestalUpdate(GetEnvValue(env, prefix, "PedestalUpdate", fPedestalUpdate));
         rc = kTRUE;
     }
-    SetPedestalUpdate(upd);
 
     return rc;
 }
+
+void MPedCalcFromLoGain::Print(Option_t *o) const
+{
+    *fLog << GetDescriptor() << ":" << endl;
+    *fLog << "Parameters used for pedestal calculation from " << fNamePedestalCam << ":"<<endl;
+    *fLog << "CheckWindow   from slice " << fCheckWinFirst   << " to " << fCheckWinLast << endl;
+    *fLog << "ExtractWindow from slice " << fExtractWinFirst << " to " << fExtractWinLast << endl;
+    *fLog << "Max allowed signal variation: " << fMaxSignalVar << endl;
+    *fLog << "Pedestal Update is " << (fPedestalUpdate?"on":"off") << endl;
+    MExtractor::Print(o);
+}
Index: /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h
===================================================================
--- /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 5377)
+++ /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 5378)
@@ -20,23 +20,24 @@
 class MPedCalcFromLoGain : public MExtractor
 {
-    static const Int_t fgCheckWinFirst;      // First FADC slice to check for signal (currently set to: 0)
-    static const Int_t fgCheckWinLast;       // Last FADC slice to check for signal  (currently set to: 29)
-    static const Int_t fgExtractWinFirst;      // First FADC slice to use for pedestal calculation (currently set to: 15)
-    static const Int_t fgExtractWinSize;       // number of successive slices used to calculate pedestal (currently set to: 6)
-    static const Int_t fgMaxSignalVar;     // The maximum difference between the highest and lowest slice
+    static const UShort_t fgCheckWinFirst;    // First FADC slice to check for signal (currently set to: 0)
+    static const UShort_t fgCheckWinLast;     // Last FADC slice to check for signal  (currently set to: 29)
+    static const UShort_t fgExtractWinFirst;  // First FADC slice to use for pedestal calculation (currently set to: 15)
+    static const UShort_t fgExtractWinSize;   // number of successive slices used to calculate pedestal (currently set to: 6)
+    static const UShort_t fgMaxSignalVar;     // The maximum difference between the highest and lowest slice
 
-    Int_t   fNumEventsDump;      // Number of event after which MPedestalCam gets updated
+    MGeomCam *fGeom;                          // Camera geometry
 
-    Int_t  fMaxSignalVar;
-    Int_t  fCheckWinFirst;
-    Int_t  fCheckWinLast;
-    Int_t  fExtractWinSize;              // Number of slices to calculate the pedestal from
-    Int_t  fExtractWinFirst;
-    Int_t  fExtractWinLast;
+    UInt_t   fNumEventsDump;                  // Number of event after which MPedestalCam gets updated
+
+    UShort_t fMaxSignalVar;
+    UShort_t fCheckWinFirst;
+    UShort_t fCheckWinLast;
+    UShort_t fExtractWinSize;                 // Number of slices to calculate the pedestal from
+    UShort_t fExtractWinFirst;
+    UShort_t fExtractWinLast;
 
     Bool_t  fPedestalUpdate;
 
-    MGeomCam *fGeom;             // Camera geometry
-    TString   fPedContainerName; // name of the 'MPedestalCam' container
+    TString fNamePedestalCam;    // name of the 'MPedestalCam' container
 
     TArrayI fNumEventsUsed;      // Number of events used for pedestal calc for each pixel
@@ -58,5 +59,6 @@
 
     //Helper function to extract slice values by slice number
-    UInt_t GetSlice(MRawEvtPixelIter *pixel, UInt_t slice);
+    UShort_t GetSlice(MRawEvtPixelIter *pixel, UInt_t slice);
+    void ResetArrays();
 
 public:
@@ -65,13 +67,15 @@
     // TObject
     void Clear(const Option_t *o="");
+    void Print(Option_t *o="") const;
 
     // Setter
-    void SetCheckRange(Int_t checkfirst=0, Int_t checklast=29);
-    void SetExtractWindow(Int_t extractfirst=15, Int_t windowsize=6);
-    void SetMaxSignalVar(Int_t maxvar=40)         { fMaxSignalVar = maxvar;    }
+    Bool_t SetCheckRange(UShort_t checkfirst=fgCheckWinFirst, UShort_t checklast=fgCheckWinLast);
+    Bool_t SetExtractWindow(UShort_t extractfirst=fgExtractWinFirst, UShort_t windowsize=fgExtractWinSize);
+
+    void SetMaxSignalVar(UShort_t maxvar=40)       { fMaxSignalVar = maxvar;    }
     void SetNumEventsDump(UInt_t dumpevents = 500) { fNumEventsDump = dumpevents;}
     void SetPedestalUpdate(Bool_t pedupdate)  {fPedestalUpdate = pedupdate;}
 
-    void SetPedContainerName(const char *name) { fPedContainerName = name; }
+    void SetNamePedestalCam(const char *name) { fNamePedestalCam = name; }
 
     // Getter
Index: /trunk/MagicSoft/Mars/mraw/MRawRead.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawRead.cc	(revision 5377)
+++ /trunk/MagicSoft/Mars/mraw/MRawRead.cc	(revision 5378)
@@ -232,5 +232,5 @@
                 fRawEvtData1->ReadPixel(fin,   hwid-1,  TESTBIT(ab, j));
             else
-                fRawEvtData2->ReadPixel(fin, -(hwid-1), TESTBIT(ab, j));
+                fRawEvtData2->ReadPixel(fin, -(hwid+1), TESTBIT(ab, j));
 
         }
