Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3496)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3497)
@@ -18,24 +18,45 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/03/15: Thomas Bretz
+
+   * mastro/MObservatory.[h,cc]:
+     - implemented RotationAngle(ra, dec, time)
+
+   * mbase/MTask.[h,cc]:
+     - implemented usage of a TStopwatch to retriev time consumtion
+       informations
+     - changed PrintStatistics not to print classes having no
+       Process() function
+
+   * mbase/MTaskList.[h,cc], mfileio/MReadReports.[h,cc]:
+     - changed PrintStatistics according to changes in MTask
+
+   * mraw/MRawEvtHeader.cc:
+     - added a comment to Fill member function
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added fLut.Set to FixSize and resize fLut by a factor of 2
+       instead of +1 which acelerates creation of all pixels a lot
+
+
+
  2004/03/13: Markus Gaug 
 
-   * mcalib/MCalibrationChargeCalc.cc
-   * mcalib/MCalibrationChargePix.[h,cc]
-   * mcalib/MCalibrationChargeCam.cc
-   * mcalib/MHCalibrationChargeCam.cc
-   * mcalib/MHCalibrationChargeLoGainPix.cc
+   * mcalib/MCalibrationChargeCalc.cc, mcalib/MCalibrationChargeCam.cc,
+     mcalib/MCalibrationChargePix.[h,cc], 
+     mcalib/MHCalibrationChargeCam.cc,
+     mcalib/MHCalibrationChargeLoGainPix.cc:
      - fixed Low Gain calibration
 
-
-   * mcalib/MHGausEvents.cc
+   * mcalib/MHGausEvents.cc:
      - changed default fit prob. limit from 0.005 to 0.001
 
-   * mbadpixels/MBadPixelsPix.h 
+   * mbadpixels/MBadPixelsPix.h :
      - IsCalibrationResultOK does not ask for FitOK any more
 
-   * mcalib/MHCalibrationChargeCam.cc
+   * mcalib/MHCalibrationChargeCam.cc:
      - replaced Rel. Err. Limit for outliers in Phe's from 5 sigma to 7
 
-   * mraw/MRawEvtPixelIter.[h,cc]
+   * mraw/MRawEvtPixelIter.[h,cc]:
      - function GetIdxMaxLoGainSamples can be called optionally with 
        offset (because first "loGain" samples are often in reality 
@@ -43,8 +64,11 @@
 
 
+
  2004/03/12: Sebastian Raducci
 
    * manalysis/Makefile
      - added mastro in the include directories
+
+
 
  2004/03/12: Thomas Bretz
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 3496)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 3497)
@@ -103,4 +103,6 @@
 void MCerPhotEvt::FixSize()
 {
+    fLut.Set(fNumPixels);
+
     if (fPixels->GetEntriesFast() == (Int_t)fNumPixels)
         return;
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 3496)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 3497)
@@ -43,6 +43,6 @@
         {
             const Int_t n = fLut.GetSize();
-            fLut.Set(idx+1);
-            for (int i=n; i<idx; i++)
+            fLut.Set(idx*2+1); //idx+1 is slower than idx*2+1
+            for (int i=n; i<idx*2+1; i++)
                 fLut[i] = -1;
         }
Index: /trunk/MagicSoft/Mars/mastro/MObservatory.cc
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MObservatory.cc	(revision 3496)
+++ /trunk/MagicSoft/Mars/mastro/MObservatory.cc	(revision 3497)
@@ -34,4 +34,7 @@
 #include "MObservatory.h"
 
+#include <TVector3.h>
+
+#include "MTime.h"
 #include "MAstro.h"
 
@@ -169,2 +172,26 @@
     return TMath::ASin((fCosLatitude*sinp) / denom);
 }
+
+// --------------------------------------------------------------------------
+//
+// RotationAngle 
+// 
+// calculates the angle for the rotation of the sky image in the camera;
+// this angle is a function of the sky coordinates, the observatory
+// location and the time
+//
+//  ra  [rad]: Right ascension
+//  dec [rad]: Declination
+//
+// Return RotationAngle in rad
+//
+Double_t MObservatory::RotationAngle(Double_t ra, Double_t dec, const MTime &t) const
+{
+    const Double_t alpha = t.GetGmst() + GetElong();
+
+    TVector3 v;
+    v.SetMagThetaPhi(1, TMath::Pi()/2-dec, alpha-ra);
+    v.RotateY(GetPhi()-TMath::Pi()/2);
+
+    return RotationAngle(v.Theta(), v.Phi());
+}
Index: /trunk/MagicSoft/Mars/mastro/MObservatory.h
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MObservatory.h	(revision 3496)
+++ /trunk/MagicSoft/Mars/mastro/MObservatory.h	(revision 3497)
@@ -5,4 +5,6 @@
 #include "MParContainer.h"
 #endif
+
+class MTime;
 
 class MObservatory : public MParContainer
@@ -56,4 +58,5 @@
     void RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const;
     Double_t RotationAngle(Double_t theta, Double_t phi) const;
+    Double_t RotationAngle(Double_t ra, Double_t dec, const MTime &t) const;
 
     LocationName_t GetObservatoryKey() const { return fObservatoryKey; }
Index: /trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 3496)
+++ /trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 3497)
@@ -90,5 +90,7 @@
 
 #include <fstream>
-#include <TBaseClass.h>
+
+#include <TBaseClass.h> // OverwritesProcess
+#include <TStopwatch.h> // TStopwatch
 
 #include "MLog.h"
@@ -103,5 +105,6 @@
 
 MTask::MTask(const char *name, const char *title)
-    : fFilter(NULL), fSerialNumber(0), fIsPreprocessed(kFALSE), fNumExecutions(0)
+    : fFilter(NULL), fSerialNumber(0), fIsPreprocessed(kFALSE),
+    fNumExecutions(0), fStopwatch(0)
 {
     fName  = name  ? name  : "MTask";
@@ -110,8 +113,11 @@
     fListOfBranches = new TList;
     fListOfBranches->SetOwner();
+
+    fStopwatch = new TStopwatch;
 }
 
 MTask::~MTask()
 {
+    delete fStopwatch;
     delete fListOfBranches;
 }
@@ -184,8 +190,10 @@
 // Mapper function for PreProcess.
 // Sets the preprocessed flag dependend on the return value of PreProcess.
+// Resets number of executions and cpu consumtion timer.
 //
 Int_t MTask::CallPreProcess(MParList *plist)
 {
     fNumExecutions = 0;
+    fStopwatch->Reset();
 
     *fLog << all << fName << "... " << flush;
@@ -218,4 +226,5 @@
 // return value.
 // If Process is executed, the execution counter is increased.
+// Count cpu consumtion time.
 //
 Int_t MTask::CallProcess()
@@ -232,5 +241,10 @@
 
     fNumExecutions++;
-    return Process();
+
+    fStopwatch->Start(kFALSE);
+    const Int_t rc = Process();
+    fStopwatch->Stop();
+
+    return rc;
 }
 
@@ -332,5 +346,24 @@
 // --------------------------------------------------------------------------
 //
-//  Prints the number of times all the tasks in the list has been.
+//  Return total CPU execution time of task
+//
+Double_t MTask::GetCpuTime() const
+{
+    return fStopwatch->CpuTime();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return total real execution time of task
+//
+Double_t MTask::GetRealTime() const
+{
+    return fStopwatch->RealTime();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints the relative time spent in Process() (relative means relative to
+//  its parent Tasklist) and the number of times Process() was executed.
 //  For convinience the lvl argument results in a number of spaces at the
 //  beginning of the line. So that the structur of a tasklist can be
@@ -338,8 +371,17 @@
 //  filter is printer in <>-brackets behind the number of executions.
 //  Use MTaskList::PrintStatistics without an argument.
-//
-void MTask::PrintStatistics(const Int_t lvl, Bool_t title) const
-{
-    *fLog << all << setfill(' ') << setw(lvl) << " " << GetDescriptor() << "\t";
+//  For tasks which don't overwrite Process() no action is perfomed.
+//
+void MTask::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
+{
+    if (!OverwritesProcess())
+        return;
+
+    *fLog << all << setfill(' ') << setw(lvl) << " ";
+    if (fStopwatch->CpuTime()>0 && time>0)
+        *fLog << setw(3) << (Int_t)(fStopwatch->CpuTime()/time*100+.5) << "% ";
+    else
+        *fLog << "     ";
+    *fLog << GetDescriptor() << "\t";
     *fLog << dec << fNumExecutions;
     if (fFilter)
Index: /trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTask.h	(revision 3496)
+++ /trunk/MagicSoft/Mars/mbase/MTask.h	(revision 3497)
@@ -15,4 +15,5 @@
 
 class TList;
+class TStopwatch;
 
 class MFilter;
@@ -29,4 +30,6 @@
     Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
     UInt_t fNumExecutions;  //! Number of Excutions
+
+    TStopwatch *fStopwatch; //!
 
     virtual Int_t PreProcess(MParList *pList);
@@ -66,11 +69,16 @@
     virtual ~MTask();
 
+    const TList *GetListOfBranches() const { return fListOfBranches; }
+    Bool_t OverwritesProcess(TClass *cls=NULL) const;
+
+    // Filter functions
     virtual void SetFilter(MFilter *filter) { fFilter=filter; }
     const MFilter *GetFilter() const      { return fFilter; }
     MFilter *GetFilter()  { return fFilter; } // for MContinue only
 
+    // Display functions
     void SetDisplay(MStatusDisplay *d);
-    virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
 
+    // Function for parallel executions
     static TString AddSerialNumber(const char *str, UInt_t num) { TString s(str); if (num==0) return s; s += ";"; s += num; return s; }
     static TString AddSerialNumber(const TString &str, UInt_t num) { return AddSerialNumber((const char*)str, num); }
@@ -83,6 +91,11 @@
     const char *GetDescriptor() const;
 
+    // Task execution statistics
     UInt_t GetNumExecutions() const { return fNumExecutions; }
+    Double_t GetCpuTime() const;
+    Double_t GetRealTime() const;
+    virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
 
+    // Task overwrite functions
     virtual Bool_t ReInit(MParList *pList);
 
@@ -90,8 +103,4 @@
     virtual Int_t CallProcess();
     virtual Int_t CallPostProcess();
-
-    const TList *GetListOfBranches() const { return fListOfBranches; }
-
-    Bool_t OverwritesProcess(TClass *cls=NULL) const;
 
     void SavePrimitive(ofstream &out, Option_t *o="");
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 3496)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 3497)
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -24,42 +24,40 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MTaskList                                                               //
-//                                                                         //
-// Collection of tasks.                                                    //
-//                                                                         //
-// A tasklist is necessary to run the eventloop. It contains the scheduled //
-// tasks, which should be executed in your program.                        //
-//                                                                         //
-// To add a task use AddToList.                                            //
-//                                                                         //
-// The tasklist itself is a task, too. You can add a tasklist to another   //
-// tasklist. This makes sense, if you want to filter the execution of      //
-// more than one task of your tasklist using the same filter.              //
-//                                                                         //
-// The tasks in the list are idetified by their names. If more than one    //
-// task has the same name, the tasklist will still work correctly, but     //
-// you might run into trouble trying to get a pointer to a task by name    //
-// from the list.                                                          //
-//                                                                         //
-// Warning:                                                                //
-//  Be carefull if you are writing your tasklist                           //
-//  (eg. MWriteRootFile("file.root", "MTaskList")) to a file. You may      //
-//  not be able to initialize a new working tasklist from a file if        //
-//   a) Two Paramerer containers with the same names are existing in the   //
-//      MParList.                                                          //
-//   b) You used a container somewhere which is not part of MParList.      //
-//      (eg. You specified a pointer to a MH container in MFillH which is  //
-//      not added to the parameter list.                                   //
-//                                                                         //
+//
+// MTaskList
+//
+// Collection of tasks.
+//
+// A tasklist is necessary to run the eventloop. It contains the scheduled
+// tasks, which should be executed in your program.
+//
+// To add a task use AddToList.
+//
+// The tasklist itself is a task, too. You can add a tasklist to another
+// tasklist. This makes sense, if you want to filter the execution of
+// more than one task of your tasklist using the same filter.
+//
+// The tasks in the list are idetified by their names. If more than one
+// task has the same name, the tasklist will still work correctly, but
+// you might run into trouble trying to get a pointer to a task by name
+// from the list.
+//
+// Warning:
+//  Be carefull if you are writing your tasklist
+//  (eg. MWriteRootFile("file.root", "MTaskList")) to a file. You may
+//  not be able to initialize a new working tasklist from a file if
+//   a) Two Paramerer containers with the same names are existing in the
+//      MParList.
+//   b) You used a container somewhere which is not part of MParList.
+//      (eg. You specified a pointer to a MH container in MFillH which is
+//      not added to the parameter list.
+//
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MTaskList.h"
 
-#include <fstream>        // ofstream, SavePrimitive
-
-#include <TClass.h>
-#include <TSystem.h>        // gSystem
-#include <TOrdCollection.h>
+#include <fstream>           // ofstream, SavePrimitive
+
+#include <TSystem.h>         // gSystem
+#include <TOrdCollection.h>  // TOrdCollection
 
 #include "MLog.h"
@@ -627,9 +625,9 @@
 //  Use MTaskList::PrintStatistics without an argument.
 //
-void MTaskList::PrintStatistics(const Int_t lvl, Bool_t title) const
+void MTaskList::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
 {
     if (lvl==0)
     {
-        *fLog << all << underline << "Execution Statistics:" << endl;
+        *fLog << all << underline << "Process execution Statistics:" << endl;
         *fLog << GetDescriptor();
         if (GetFilter())
@@ -640,10 +638,10 @@
     }
     else
-        MTask::PrintStatistics(lvl, title);
+        MTask::PrintStatistics(lvl, title, time);
 
     //
     //  create the Iterator for the TaskList
     //
-    fTasks->ForEach(MTask, PrintStatistics)(lvl+1, title);
+    fTasks->ForEach(MTask, PrintStatistics)(lvl+1, title, GetCpuTime());
 
     if (lvl==0)
@@ -651,6 +649,8 @@
 }
 
-
-// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//
+// Call 'Print()' of all tasks
+//
 void MTaskList::Print(Option_t *t) const
 {
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 3496)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 3497)
@@ -70,5 +70,5 @@
 
     void Print(Option_t *opt = "") const;
-    void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
+    void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
     void SetOwner(Bool_t enable=kTRUE);
 
Index: /trunk/MagicSoft/Mars/mfileio/MReadReports.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadReports.cc	(revision 3496)
+++ /trunk/MagicSoft/Mars/mfileio/MReadReports.cc	(revision 3497)
@@ -375,7 +375,7 @@
 // PrintStatistics of this task and of the MReadTree tasks in fTress
 //
-void MReadReports::PrintStatistics(const Int_t lvl, Bool_t title) const
-{
-    MRead::PrintStatistics(lvl, title);
-    fTrees->PrintStatistics(lvl, title);
-}
+void MReadReports::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
+{
+    MRead::PrintStatistics(lvl, title, time);
+    fTrees->PrintStatistics(lvl, title, GetCpuTime());
+}
Index: /trunk/MagicSoft/Mars/mfileio/MReadReports.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadReports.h	(revision 3496)
+++ /trunk/MagicSoft/Mars/mfileio/MReadReports.h	(revision 3497)
@@ -55,5 +55,5 @@
     void  AddToBranchList(const char *name);
 
-    void  PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
+    void  PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
 
     void  EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; } // Must be called BEFORE AddTree!
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 3496)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 3497)
@@ -227,5 +227,6 @@
 // --------------------------------------------------------------------------
 //
-// used to set the header information (eg. from MC)
+// Used to set the header information. This is for MC only. NEVER, NEVER
+// use this somewhere else!
 //
 void MRawEvtHeader::FillHeader(UInt_t uiN, Float_t ulTP)
