Index: trunk/MagicSoft/Mars/mtemp/mucm/classes/MDataSetIter.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mucm/classes/MDataSetIter.cc	(revision 4690)
+++ trunk/MagicSoft/Mars/mtemp/mucm/classes/MDataSetIter.cc	(revision 4691)
@@ -719,6 +719,6 @@
     TString file;
 
-    *fLog << endl << " pedestal runs: " << endl;
-    *fLog << " -------------- " << endl;
+    *fLog << all << endl << " pedestal runs: " << endl;
+    *fLog << "---------------" << endl;
     while( !(file=fPedRuns->Next()).IsNull() )
 	*fLog << file << endl;
@@ -726,5 +726,5 @@
    	   
     *fLog << endl << " calibration runs: " << endl; 
-    *fLog << " ----------------- " << endl;
+    *fLog << "------------------" << endl;
     while( !(file=fCalRuns->Next()).IsNull() )
 	*fLog << file << endl;
@@ -732,5 +732,5 @@
 
     *fLog << endl << " data runs: " << endl;
-    *fLog << "----------- " << endl;
+    *fLog << "-----------" << endl;
     while( !(file=fDataRuns->Next()).IsNull() )
 	*fLog << file << endl;
Index: trunk/MagicSoft/Mars/mtemp/mucm/classes/MExtrapolatePointingPos.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mucm/classes/MExtrapolatePointingPos.cc	(revision 4690)
+++ trunk/MagicSoft/Mars/mtemp/mucm/classes/MExtrapolatePointingPos.cc	(revision 4691)
@@ -66,12 +66,14 @@
 // ---------------------------------------------------------------------------
 //
-//
-//
-void MExtrapolatePointingPos::ReadDriveReport(const TString filename)
-{
+// Read the drive report file for the whole night, a build from it the splines
+//
+Bool_t MExtrapolatePointingPos::ReadDriveReport(const TString filename)
+{
+
+    *fLog << endl << "["<< GetName() << "]: Loading report file \"" << filename << "\" into TSpline..." << endl;
+
 
     //
     // ParList
-    // -------
     //
     MParList  plist;
@@ -82,7 +84,5 @@
     //
     // TaskList
-    // --------
-    //
-    // Reads the trees of the root file and the analysed branches
+    //
     MReadReports read;
     read.AddTree("Drive");
@@ -90,27 +90,17 @@
     read.AddToBranchList("MReportDrive.*");
     
-    // Add all the task to the task list
     tlist.AddToList(&read);
  
-    
-    
+   
     //
     // EventLoop
-    // ---------
     //
     MEvtLoop evtloop;
     evtloop.SetParList(&plist);
 
-    
-    //
-    // Execute your analysis
-    //
     if (!evtloop.PreProcess())
-        return;
-
-
-    //
-    // Store the ReportTime, CurrentZd, CurrentAz, Ra, Dec and Ha into arrays
-    //
+        return kFALSE;
+
+
     TArrayD ReportTime(10000);
     TArrayD CurrentZd(10000);
@@ -120,14 +110,16 @@
     TArrayD Ra(10000);
     TArrayD Dec(10000);
-    TArrayD Ha(10000);
-    
+
     
     Int_t n=0;
-
     while (tlist.Process())
     { 
-	
 	MReportDrive* report = (MReportDrive*)plist.FindObject("MReportDrive");
 	MTime* reporttime = (MTime*)plist.FindObject("MTimeDrive");
+	
+	if(n==0)
+	    fFirstDriveTime = *reporttime;
+	else 
+	    fLastDriveTime = *reporttime;
 
 	//
@@ -136,5 +128,5 @@
 	if (reporttime->GetTime() == ReportTime[n-1])
 	{ 
-	    //cout << " *********** Error " << endl;
+	    cout << warn <<"["<< GetName() << "]: Warning: this report has the same time that the previous one...skipping it " << endl;
 	    continue;
 	}
@@ -147,10 +139,12 @@
 	Ra[n] = report->GetRa();
 	Dec[n] = report->GetDec();
-	Ha[n] = report->GetHa();
 
 	n++;
     }
 
-    //tlist.PrintStatistics();
+    tlist.PrintStatistics();
+
+    *fLog << "["<< GetName() << "]: loaded " << n << " ReportDrive from " 
+	  << fFirstDriveTime << " to " << fLastDriveTime << endl << endl;
 
 
@@ -165,15 +159,11 @@
     Ra.Set(n);
     Dec.Set(n);
-    Ha.Set(n);
-    
-
-
-    //   for(int i=0;i<time.GetSize();i++)
-//       {
-//  	 cout << i << " " << time[i] << " " << Zd[i] << endl;
-//       }
      
-
-     
+    // for(int i=0;i<ReportTime.GetSize();i++)
+// 	*fLog << i            << " " << ReportTime[i] << " " 
+// 	      << CurrentZd[i] << " " << CurrentAz[i]  << " " 
+// 	      << NominalZd[i] << " " << NominalAz[i]  << " " 
+// 	      << Ra[i]        << " " << Dec[i]        << endl;
+    
 
     fSplineZd = new TSpline3("zenith",
@@ -186,15 +176,20 @@
 			     ReportTime.GetArray(), Dec.GetArray(), n);
 
-
-  //    TCanvas* c = new TCanvas();
-//      c->Divide(2,2);
-//      c->cd(1);
-//      fSplineZd->Draw();
-//      c->cd(2);
-//      fSplineAz->Draw();
-//      c->cd(3);
-//      fSplineRa->Draw(); 
-//      c->cd(4);
-//      fSplineDec->Draw();
+   
+    
+   //  TCanvas* c = new TCanvas();
+//     c->Divide(2,2);
+//     c->cd(1);
+//     fSplineZd->Draw();
+//     c->cd(2);
+//     fSplineAz->Draw();
+//     c->cd(3);
+//     fSplineRa->Draw(); 
+//     c->cd(4);
+//     fSplineDec->Draw();
+//     c->Modified();
+//     c->Update();
+    
+    return kTRUE;
 }
 
@@ -202,22 +197,30 @@
 // --------------------------------------------------------------------------
 //
-// default constructor
+//  Constructor
 //
 MExtrapolatePointingPos::MExtrapolatePointingPos(const TString filename, const char *name, const char *title)
-    
 {
     fName  = name  ? name  : "MExtrapolatePointingPos";
     fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
 
-   
     fFilename = filename;
+
+    // Init
+    fSplineZd  = NULL;
+    fSplineAz  = NULL;
+    fSplineRa  = NULL;
+    fSplineDec = NULL;
 }
 
 MExtrapolatePointingPos::~MExtrapolatePointingPos()
 {
-    delete fSplineZd;
-    delete fSplineAz;
-    delete fSplineRa;    
-    delete fSplineDec;
+    if(fSplineZd)
+	delete fSplineZd;
+    if(fSplineAz)
+	delete fSplineAz;
+    if(fSplineRa)
+	delete fSplineRa;    
+    if(fSplineDec)
+	delete fSplineDec;
 }
 
@@ -252,5 +255,6 @@
 
 
-    ReadDriveReport(fFilename);
+    if( !ReadDriveReport(fFilename) )
+	return kFALSE;
 
 
@@ -261,37 +265,44 @@
 // --------------------------------------------------------------------------
 //
-// Fill the MPedestalCam container with the signal mean and rms for the event.
-// Store the measured signal in arrays fSumx and fSumx2 so that we can 
-// calculate the overall mean and rms in the PostProcess()
+//  Get the run start time, and get the pointing position for that time
 //
 Int_t MExtrapolatePointingPos::Process()
 {
 
-    const MTime* StartRunTime  = &fRunHeader->GetRunStart();
-    Int_t run = fRunHeader->GetRunNumber();
-
-    Long_t time;
-
-     //   if(run < 20000)
-//    	time = fEvtTime->GetTime();
-//        else
-	time = StartRunTime->GetTime();
-
-
- 
-    
-    Double_t zd = fSplineZd->Eval( time );
-    Double_t az = fSplineAz->Eval( time );
-    Double_t ra = fSplineRa->Eval( time );
-    Double_t dec = fSplineDec->Eval( time );
+    //const Int_t run = fRunHeader->GetRunNumber();
+    const MTime* StartRunTime = &fRunHeader->GetRunStart();
+    const Double_t time = StartRunTime->GetTime();
+
+
+    //
+    // Check that we have drive report for this time
+    //
+    if( *StartRunTime<fFirstDriveTime || *StartRunTime>fLastDriveTime)
+    {
+	*fLog << err << dbginf << GetName() << ": Run time " << *StartRunTime
+	      << " outside range of drive reports  (" << fFirstDriveTime 
+	      << ", " << fLastDriveTime << ")" << endl;
+	return kFALSE;
+    }
+
+    //if(run < 20000)
+    //   time = fEvtTime->GetTime();
+    //else
+    //   time = StartRunTime->GetTime();
+
+
+    const Double_t zd = fSplineZd->Eval( time );
+    const Double_t az = fSplineAz->Eval( time );
+    const Double_t ra = fSplineRa->Eval( time );
+    const Double_t dec = fSplineDec->Eval( time );
 
     fPointingPos->SetLocalPosition( zd, az );
     fPointingPos->SetSkyPosition( ra*TMath::DegToRad()/15, dec*TMath::DegToRad());
 
-    //  *fLog << " PointingPos: " << " time = " << time << " " << *fEvtTime << " (zd, az, ra, dec) = (" << zd << ", "  << az << ", " << ra << ", "  << dec << ")" << endl; 
-
-
-  return kTRUE;
-}
-
-
+   //  *fLog << " PointingPos: time = " << time << " (" << *fEvtTime << ")  (zd, az, ra, dec) = (" << zd << ", "  << az << ", " << ra << ", "  << dec << ")" << endl; 
+
+
+    return kTRUE;
+}
+
+
Index: trunk/MagicSoft/Mars/mtemp/mucm/classes/MExtrapolatePointingPos.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mucm/classes/MExtrapolatePointingPos.h	(revision 4690)
+++ trunk/MagicSoft/Mars/mtemp/mucm/classes/MExtrapolatePointingPos.h	(revision 4691)
@@ -18,4 +18,8 @@
 #endif
 
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
 
 class MTime;
@@ -30,4 +34,6 @@
 
     TString fFilename;
+    MTime  fFirstDriveTime;
+    MTime  fLastDriveTime;
 
     MTime  *fEvtTime;            // raw event time
@@ -43,5 +49,5 @@
     Int_t PreProcess(MParList *pList);
     Int_t Process();
-    
+    Bool_t ReadDriveReport(const TString filename);    
 
 
@@ -52,6 +58,4 @@
     ~MExtrapolatePointingPos();
 
-    void ReadDriveReport(const TString filename);
-  
 
     ClassDef(MExtrapolatePointingPos, 1)  
