Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2910)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2911)
@@ -4,4 +4,14 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2004/01/26: Markus Gaug
+
+   * manalysis/MArrivalTime.[h,cc]:
+   * manalysis/MArrivalTimeCalc.[h,cc]:
+     - moved calculation of arrival time from MArrivalTime to 
+       MArrivalTimeCalc. MArrivalTime does not do any Process -job any 
+       more 
+     - TSpline5 now on stack. 
+
 
  2004/01/26: Thomas Bretz
Index: /trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc	(revision 2910)
+++ /trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc	(revision 2911)
@@ -65,8 +65,9 @@
 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;
+  //
+  // 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;
 }
 
@@ -80,44 +81,7 @@
 // Set the arrival time in one pixel
 //
-void MArrivalTime::SetTime(Int_t i, Float_t t)
+void MArrivalTime::SetTime(const Int_t i, const Float_t t)
 {
     fData[i] = t;
-}
-
-// -------------------------------------------------------------------------
-//
-// Calculates the arrival time for each pixel 
-// Possible Methods 
-// Case 1: Spline5 (From TSpline5 Root Class)
-// 
-//
-void MArrivalTime::Calc(const Byte_t *fadcSamples, const Short_t nSlice,
-                        const Short_t idx)
-{
-
-//Some casts are needed because TSpline5 constructor accepts only Double_t values
-    Double_t ptr[nSlice];
-
-    for (Int_t i = 0; i < nSlice; i++)
-	ptr[i]=(Double_t)fadcSamples[i];
-
-    TSpline5 *spline = new TSpline5("spline",(Double_t) 0,
-				    (Double_t)(nSlice - 1),ptr,nSlice);
-//Now find the maximum evaluating the spline function at every 1/10 time slice
-    Double_t abscissa=0.0;
-    Double_t maxAb=0.0;
-    Double_t maxOrd=0.0;
-    Double_t swap;
-    while (abscissa <= nSlice - 1) 
-    {
-	swap=spline->Eval(abscissa);
-	if (swap > maxOrd)
-	{
-	    maxOrd = swap;
-	    maxAb  = abscissa;
-	}
-	abscissa += 0.1;
-    }
-    fData[idx]=maxAb;
 }
 
Index: /trunk/MagicSoft/Mars/manalysis/MArrivalTime.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MArrivalTime.h	(revision 2910)
+++ /trunk/MagicSoft/Mars/manalysis/MArrivalTime.h	(revision 2911)
@@ -38,12 +38,13 @@
     UInt_t GetNumPixels() const { return fData.GetSize(); }
 
-    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);
     void EvalClusters(const MRawEvtData &evt, const MGeomCam &geom);
     void CheckNeighbours(const MRawEvtData &evt, const MGeomCam &geom,
                          Short_t idx, Short_t *dimCluster);
+
+    void SetTime(const Int_t i, const Float_t time);
+    
+    const TArrayF &GetData() const { return fData; }
+
+    Double_t operator[](int i) { return fData[i]; }
 
     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 2910)
+++ /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc	(revision 2911)
@@ -61,4 +61,5 @@
 MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
 {
+
     fName  = name  ? name  : "MArrivalTimeCalc";
     fTitle = title ? title : "Calculate photons arrival time";
@@ -111,5 +112,4 @@
 }
 
-
 // --------------------------------------------------------------------------
 //
@@ -119,29 +119,91 @@
 Int_t MArrivalTimeCalc::Process()
 {
-    MRawEvtPixelIter pixel(fRawEvt);
-
-    while (pixel.Next())
-    {
-	const UInt_t idx = pixel.GetPixelId();
-
-        // If pixel is saturated we use LoGains
-        if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  while (pixel.Next())
+    {
+      
+      const UInt_t idx = pixel.GetPixelId();
+      Float_t max = 0.;
+
+
+      //
+      // If pixel is saturated we use LoGains
+      //
+      if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
+        {
+          
+          const Short_t nslices = fRawEvt->GetNumLoGainSamples();
+          max = Calc(pixel.GetLoGainSamples(),nslices);
+        }
+      
+
+      //
+      // Use HiGains
+      //
+      else if (pixel.HasLoGain())
+        {
+          
+          const Short_t nslices = fRawEvt->GetNumHiGainSamples();
+          max = Calc(pixel.GetHiGainSamples(),nslices);
+        }
+      
+      //
+      // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
+      //
+      fArrTime->SetTime(idx,max);
+      
+    }
+    
+  fArrTime->SetReadyToSave();
+  
+  return kTRUE;
+}
+
+//
+// Calculates the arrival time for each pixel 
+// Possible Methods 
+// Case 1: Spline5 (From TSpline5 Root Class)
+// 
+//
+Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices)
+{
+
+  //
+  // Initialize a double pointer with filled FADC slices
+  //
+  Double_t ptr[nslices];
+
+  //
+  // Initialize the spline
+  //
+  for (Int_t i = 0; i < nslices; i++)
+    ptr[i]=(Double_t)fadcSamples[i];
+  
+  TSpline5 spline("spline",0.,(Double_t)(nslices - 1),ptr,nslices);
+
+  //
+  // Now find the maximum evaluating the spline function at every 1/10 time slice
+  //
+  Double_t abscissa=0.0;
+  Double_t maxAb=0.0;
+  Double_t maxOrd=0.0;
+  Double_t swap = 0.0;
+
+  while (abscissa <= nslices - 1) 
+    {
+
+      swap = spline.Eval(abscissa);
+
+      if (swap > maxOrd)
 	{
-	    const Byte_t *ptr = pixel.GetLoGainSamples();
-	    const Short_t nSlice = fRawEvt->GetNumLoGainSamples();
-	    fArrTime->Calc(ptr, nSlice, idx);
+          maxOrd = swap;
+          maxAb  = abscissa;
 	}
-        // Use HiGains
-        else
-	{
-            const Byte_t *ptr = pixel.GetHiGainSamples();
-	    const Short_t nSlice = fRawEvt->GetNumHiGainSamples();
-	    fArrTime->Calc(ptr, nSlice, idx);
-	}
-        // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
-    }
-    
-    fArrTime->SetReadyToSave();
-
-    return kTRUE;
-}
+      abscissa += 0.1;
+    }
+
+  return (Float_t)maxAb;
+}
+
Index: /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h	(revision 2910)
+++ /trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h	(revision 2911)
@@ -7,17 +7,22 @@
 
 class MRawEvtData;
+class MRawRunHeader;
 class MArrivalTime;
 
 class MArrivalTimeCalc : public MTask
 {
-private:
-    MRawEvtData  *fRawEvt;     // raw event data (time slices)
-    MArrivalTime *fArrTime;    // Container with the photons arrival times
 
+    MRawEvtData    *fRawEvt;     // raw event data (time slices)
+    MRawRunHeader  *fRunHeader;  // RunHeader information
+
+    MArrivalTime   *fArrTime;    // Container with the photons arrival times
+
+    Int_t PreProcess(MParList *pList);
     Bool_t ReInit(MParList *pList);
-    Int_t  PreProcess(MParList *pList);
-    Int_t  Process();
-    Int_t  PostProcess() {return kTRUE;}
+    Int_t Process();
+    Int_t PostProcess() {return kTRUE;}
 
+    Float_t Calc(const Byte_t *fadcSamples, const Short_t nslices);
+    
 public:
     MArrivalTimeCalc(const char *name=NULL, const char *title=NULL);
