Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2909)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2910)
@@ -9,4 +9,17 @@
    * mraw/MRawEvtPixelIter.[h,cc]:
      - removed member function GetNumPixels. For more details see mantis.
+
+   * manalysis/MArrivalTime.[h,cc]:
+     - reorganized includes
+     - fixed InitSize and ClearArray (now Reset) to fit MParContainer
+       definition
+     - for the moment removed usage of fPixelChecked - THIS WILL CRASH YOUR
+       PROGRAM
+
+   * manalysis/MArrivalTimeCalc.[h,cc]:
+     - reorganized includes
+     - removed many obsolete code, exspecially copy&paste relicts!
+     - fixed usage of InitSize
+     - removed CleanArray. Reset() is called automatically before Process()
 
 
Index: /trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc	(revision 2909)
+++ /trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc	(revision 2910)
@@ -18,5 +18,5 @@
 !   Author(s): Sebastian Raducci, 12/2003 <mailto:raducci@fisica.uniud.it>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -32,4 +32,6 @@
 #include "MArrivalTime.h"
 
+#include <TSpline.h>
+
 #include "MGeomCam.h"
 #include "MGeomPix.h"
@@ -45,4 +47,6 @@
 using namespace std;
 
+#warning Commented out all usage of fPixelCehcked - THIS WILL CRASH YOUR PROGRAM!
+
 // --------------------------------------------------------------------------
 //
@@ -55,20 +59,22 @@
 }
 
+// -------------------------------------------------------------------------
+//
 // Sets every pixel arrival time to -1
-void MArrivalTime::CleanArray(const MGeomCam &geom)
-{
-    fData.Set(geom.GetNumPixels());
-    fData.Reset(-1.0);
+//
+void MArrivalTime::Reset()
+{
+    // Do not use 'TArray::Reset()' or memset. It sets all single
+    // bytes to -1 (in other words, it fills the array with 0xff)
+    for (int i=0; i<fData.GetSize(); i++)
+        fData[i] = -1;
 }
 
 void MArrivalTime::InitSize(Int_t i)
 {
-  
-  if (fData.GetSize() >= i)
-    return;
-  else
     fData.Set(i);
 }
 
+// -------------------------------------------------------------------------
 // 
 // Set the arrival time in one pixel
@@ -76,11 +82,8 @@
 void MArrivalTime::SetTime(Int_t i, Float_t t)
 {
-
-  if (i >= fData.GetSize())
-      fData.Set(i+1);
-
-  fData.AddAt(t,i);
-}
-
+    fData[i] = t;
+}
+
+// -------------------------------------------------------------------------
 //
 // Calculates the arrival time for each pixel 
@@ -89,7 +92,6 @@
 // 
 //
-
 void MArrivalTime::Calc(const Byte_t *fadcSamples, const Short_t nSlice,
-              const Short_t idx, const MGeomCam &geom)
+                        const Short_t idx)
 {
 
@@ -130,5 +132,4 @@
 //               it becomes stable
 //
-
 void MArrivalTime::EvalClusters(const MRawEvtData &evt, const MGeomCam &geom)
 {
@@ -148,6 +149,6 @@
 // Array that says if a pixel has been already checked or not
 
-    for (Int_t i = 0; i < n; i++)
-        fPixelChecked[i] = kFALSE;
+//    for (Int_t i = 0; i < n; i++)
+//        fPixelChecked[i] = kFALSE;
 
 // This fakeData array will be subsituted with the fData Array.
@@ -166,4 +167,5 @@
     while ( pixel.Next() )
     {
+        /*
 	if (!fPixelChecked[pixel.GetPixelId()])
 	{
@@ -197,5 +199,5 @@
 		    fData2[fCluster[i]]=fakeData[fCluster[i]];
 	    }            
-	}
+	} */
     }
 
@@ -206,14 +208,14 @@
 // Function to check the nearest neighbour pixels arrivaltime
 //
-
 void MArrivalTime::CheckNeighbours(const MRawEvtData &evt, const MGeomCam &geom,
                                    Short_t idx, Short_t *dimCluster)
 {
     Byte_t numNeighbors=geom[idx].GetNumNeighbors();
-    fPixelChecked[idx] = kTRUE;
+    //fPixelChecked[idx] = kTRUE;
 
     for (Byte_t i=0x00; i < numNeighbors; i++)
     {
-	
+
+        /*
 	if (!fPixelChecked[geom[idx].GetNeighbor(i)] &&
             fakeData[idx] == fakeData[geom[idx].GetNeighbor(i)])
@@ -223,5 +225,6 @@
             CheckNeighbours(evt, geom,
 			    geom[idx].GetNeighbor(i), dimCluster);
-	}
+                            }
+                            */
     }
 }
@@ -230,5 +233,4 @@
 // Returns the arrival time value
 //
-
 Bool_t MArrivalTime::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
 {
Index: /trunk/MagicSoft/Mars/manalysis/MArrivalTime.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MArrivalTime.h	(revision 2909)
+++ /trunk/MagicSoft/Mars/manalysis/MArrivalTime.h	(revision 2910)
@@ -1,4 +1,8 @@
 #ifndef MARS_MArrivalTime
 #define MARS_MArrivalTime
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
 
 #ifndef ROOT_TArrayF
@@ -8,18 +12,9 @@
 #include <TArrayS.h>
 #endif
-#ifndef ROOT_TSpline
-#include <TSpline.h>
-#endif
-#ifndef MARS_MCamEvent
-#include "MCamEvent.h"
-#endif
 
-class MGeomPix;
 class MRawEvtData;
-class MRawEvtPixelIter;
 
 class MArrivalTime : public MCamEvent
 {
-
  private:
     TArrayF fData;  // Stores the arrival times
@@ -30,5 +25,5 @@
     TArrayF fData5; // Clusters with at most 5 pix 
 
-    Bool_t  *fPixelChecked; // For each pixel says if it's already been checked
+    //Bool_t  *fPixelChecked; // For each pixel says if it's already been checked
     TArrayS fCluster; // Idxs of the pixels in the current cluster
     TArrayS fakeData; //Test purpose
@@ -39,22 +34,16 @@
     ~MArrivalTime() { }
 
+    void   Reset();
+    void   InitSize(Int_t i);
     UInt_t GetNumPixels() const { return fData.GetSize(); }
 
-    void CleanArray(const MGeomCam &geom); //Sets every arr time to -1
+    void SetTime(Int_t i, Float_t time);
+    const TArrayF &GetData() const { return fData; }
+    Double_t operator[](int i) { return fData[i]; }
 
-    void Calc(const Byte_t *fadcSamples, const Short_t nSlice,
-              const Short_t idx, const MGeomCam &geom); // Calculates arrival times
-
+    void Calc(const Byte_t *fadcSamples, const Short_t nSlice, const Short_t idx);
     void EvalClusters(const MRawEvtData &evt, const MGeomCam &geom);
-
     void CheckNeighbours(const MRawEvtData &evt, const MGeomCam &geom,
-				       Short_t idx, Short_t *dimCluster);
-
-    void SetTime(Int_t i, Float_t time);
-    void InitSize(Int_t i);
-    
-    const TArrayF &GetData() const { return fData; }
-
-    Double_t operator[](int i) { return fData[i]; }
+                         Short_t idx, Short_t *dimCluster);
 
     Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
Index: /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc	(revision 2909)
+++ /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc	(revision 2910)
@@ -18,5 +18,5 @@
 !   Author(s): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
 !
-!   Copyright: MAGIC Software Development, 2002-2003
+!   Copyright: MAGIC Software Development, 2002-2004
 !
 !
@@ -37,20 +37,16 @@
 //   MArrivalTime
 //   MRawEvtData
+//
 //////////////////////////////////////////////////////////////////////////////
-
-#include "MArrivalTime.h"
 #include "MArrivalTimeCalc.h"
-
-#include "MParList.h"
 
 #include "MLog.h"
 #include "MLogManip.h"
 
+#include "MParList.h"
+
 #include "MGeomCam.h"
-#include "MMcRunHeader.hxx"
-
-#include "MRawRunHeader.h"
-#include "MRawEvtData.h"       // MRawEvtData::GetNumPixels
-#include "MCameraData.h"
+#include "MArrivalTime.h"
+#include "MRawEvtData.h"      
 #include "MRawEvtPixelIter.h"
 
@@ -63,14 +59,8 @@
 // Default constructor.
 //
-
 MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
 {
     fName  = name  ? name  : "MArrivalTimeCalc";
     fTitle = title ? title : "Calculate photons arrival time";
-
-//    AddToBranchList("MRawEvtData.fHiGainPixId");
-//    AddToBranchList("MRawEvtData.fLoGainPixId");
-//    AddToBranchList("MRawEvtData.fHiGainFadcSamples");
-//    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
 
 }
@@ -79,35 +69,17 @@
 //
 // The PreProcess searches for the following input containers:
-//  - MRawRunHeader
 //  - MRawEvtData
 //  - MArrivalTime
-//  - MGeomCam
 //
 // The following output containers are also searched and created if
 // they were not found:
 //  - MArrivalTime
-//  - MRawEvtData
 //
-
 Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
 {
-    fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
-    if (!fRunHeader)
-    {
-        *fLog << err << "MRawRunHeader not found... aborting." << endl;
-        return kFALSE;
-    }
-
     fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
     if (!fRawEvt)
     {
         *fLog << err << "MRawEvtData not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
-    if (!fGeom)
-    {
-        *fLog << err << "MGeomCam not found... aborting." << endl;
         return kFALSE;
     }
@@ -120,6 +92,26 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// The ReInit searches for the following input containers:
+//  - MGeomCam
+//
+Bool_t MArrivalTimeCalc::ReInit(MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!cam)
+    {
+        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fArrTime->InitSize(cam->GetNumPixels());
+
+    return kTRUE;
+}
+
 
 // --------------------------------------------------------------------------
+//
 // Evaluation of the mean arrival times (spline interpolation)
 // per pixel and store them in the MArrivalTime container.
@@ -129,25 +121,23 @@
     MRawEvtPixelIter pixel(fRawEvt);
 
-// Every pixel is set to -1
-    fArrTime->CleanArray((const MGeomCam&) *fGeom);
-
     while (pixel.Next())
     {
 	const UInt_t idx = pixel.GetPixelId();
-// If pixel is saturated we use LoGains
+
+        // If pixel is saturated we use LoGains
         if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
 	{
 	    const Byte_t *ptr = pixel.GetLoGainSamples();
 	    const Short_t nSlice = fRawEvt->GetNumLoGainSamples();
-	    fArrTime->Calc(ptr, nSlice, idx, (const MGeomCam&) *fGeom);
+	    fArrTime->Calc(ptr, nSlice, idx);
 	}
-// Use HiGains
+        // Use HiGains
         else
 	{
             const Byte_t *ptr = pixel.GetHiGainSamples();
 	    const Short_t nSlice = fRawEvt->GetNumHiGainSamples();
-	    fArrTime->Calc(ptr, nSlice, idx, (const MGeomCam&) *fGeom);
+	    fArrTime->Calc(ptr, nSlice, idx);
 	}
-// If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
+        // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
     }
     
Index: /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h	(revision 2909)
+++ /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h	(revision 2910)
@@ -1,13 +1,4 @@
 #ifndef MARS_MArrivalTimeCalc
 #define MARS_MArrivalTimeCalc
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MArrivalTimeCalc                                                        //
-//                                                                         //
-// Evaluates the Arrival Times                                             //
-//                                                                         //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
 
 #ifndef MARS_MTask
@@ -16,30 +7,19 @@
 
 class MRawEvtData;
-class MCameraData;
-class MRawRunHeader;
-class MGeomCam;
 class MArrivalTime;
 
 class MArrivalTimeCalc : public MTask
 {
-    MRawEvtData    *fRawEvt;     // raw event data (time slices)
-    MCameraData    *fCamData;    // Cerenkov Photon Event used for calculation
-    MRawRunHeader  *fRunHeader;  // RunHeader information
-    MGeomCam       *fGeom;       // Geometry information
-    MArrivalTime   *fArrTime;    // Container with the photons arrival times
+private:
+    MRawEvtData  *fRawEvt;     // raw event data (time slices)
+    MArrivalTime *fArrTime;    // Container with the photons arrival times
 
-    Bool_t          fEnableFix;  // fix for a bug in files from older camera versions (<=40)
-    Bool_t          fIsMcFile;
-
-    Int_t PreProcess(MParList *pList);
-    Int_t Process();
-    Int_t PostProcess() {return kTRUE;}
-    Bool_t ReInit(MParList *pList) {
-        return kTRUE;
-    }
+    Bool_t ReInit(MParList *pList);
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+    Int_t  PostProcess() {return kTRUE;}
 
 public:
     MArrivalTimeCalc(const char *name=NULL, const char *title=NULL);
-
     ~MArrivalTimeCalc(){}
 
@@ -47,4 +27,3 @@
 };
 
-
 #endif
