Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 4827)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 4828)
@@ -19,6 +19,41 @@
 
                                                  -*-*- END OF LINE -*-*-
-
- 2004/09/1: Thomas Bretz
+ 2004/09/02: Thomas Bretz
+
+   * star.cc:
+     - fixed treatment of batch-mode
+
+   * mbase/MParContainer.h:
+     - added a comment
+
+   * mbase/MParList.[h,cc]:
+     - added FindTaskListWithTask
+
+   * mbase/MTaskList.[h,cc]:
+     - added sanity checks in AddToList
+     - added FindTaskList
+
+   * mhbase/MH3.[h,cc]:
+     - moved some drawing code from Draw to Paint
+     - added possibility to set logarithmic axis manually
+
+   * mhist/MHAlpha.cc:
+     - paint significance
+
+   * mhvstime/MHVsTime.[h,cc]:
+     - added option to average data
+
+   * mjobs/MJCalibrateSignal.cc:
+     - added MPointingPosCalc for "Drive"
+
+   * mmain/MEventDisplay.cc:
+     - fixed some problems with the display
+
+   * msignal/MArrivalTime.[h,cc]:
+     - added Print()
+
+
+
+ 2004/09/01: Thomas Bretz
 
    * mfileio/MWriteRootFile.[h,cc]:
Index: /trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 4827)
+++ /trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 4828)
@@ -101,5 +101,7 @@
     virtual void SetDisplay(MStatusDisplay *d) { fDisplay = d; }
 
-    // FIXME: Change to ostream!
+    // FIXME: Change to ostream! Seems to be difficult, because
+    //        MTaskListStreamPrimitive calls SavePrimitive(ofstream&).
+    //        Maybe with a cast?
     virtual void StreamPrimitive(ofstream &out) const;
 
Index: /trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 4828)
@@ -51,4 +51,5 @@
 
 #include "MIter.h"
+#include "MTaskList.h"
 
 ClassImp(MParList);
@@ -376,4 +377,46 @@
     TObject *l = FindObject(tlist, "MTaskList");
     return (MTask*)(l ? l->FindObject(name) : NULL);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find a tasklist which contains a task with name name
+//
+MTaskList *MParList::FindTaskListWithTask(const char *name) const
+{
+    TIter Next(fContainer);
+    TObject *o=0;
+    while ((o=Next()))
+    {
+        MTaskList *l1 = dynamic_cast<MTaskList*>(o);
+        if (!l1)
+            continue;
+
+        MTaskList *l2 = l1->FindTaskList(name);
+        if (l2)
+            return l2;
+    }
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find a tasklist which contains a task task
+//
+MTaskList *MParList::FindTaskListWithTask(const MTask *task) const
+{
+    TIter Next(fContainer);
+    TObject *o=0;
+    while ((o=Next()))
+    {
+        MTaskList *l1 = dynamic_cast<MTaskList*>(o);
+        if (!l1)
+            continue;
+
+        MTaskList *l2 = l1->FindTaskList(task);
+        if (l2)
+            return l2;
+    }
+    return 0;
 }
 
Index: /trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParList.h	(revision 4827)
+++ /trunk/MagicSoft/Mars/mbase/MParList.h	(revision 4828)
@@ -22,4 +22,5 @@
 class MLog;
 class MTask;
+class MTaskList;
 
 class MParList : public MParContainer
@@ -53,11 +54,13 @@
     void SetDisplay(MStatusDisplay *d);
 
-    TObject *FindObject(const char *name) const;
-    TObject *FindObject(const TObject *obj) const;
+    TObject   *FindObject(const char *name) const;
+    TObject   *FindObject(const TObject *obj) const;
 
-    TObject *FindObject(const char *name, const char *classname) const;
-    TObject *FindObject(const TObject *obj, const char *classname) const;
+    TObject   *FindObject(const char *name, const char *classname) const;
+    TObject   *FindObject(const TObject *obj, const char *classname) const;
 
-    MTask   *FindTask(const char *name, const char *tlist="MTaskList") const;
+    MTask     *FindTask(const char *name, const char *tlist="MTaskList") const;
+    MTaskList *FindTaskListWithTask(const char *name) const;
+    MTaskList *FindTaskListWithTask(const MTask *task) const;
 
     MParContainer *FindCreateObj(const char *classname, const char *objname=NULL);
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 4828)
@@ -229,4 +229,12 @@
 Bool_t MTaskList::AddToListBefore(MTask *task, const MTask *where, const char *type)
 {
+    if (task==this)
+    {
+        *fLog << warn << "WARNING - You cannot add a tasklist to itself.  This" << endl;
+        *fLog << "          would create infinite recursions...ignored." << endl;
+        return kFALSE;
+
+    }
+
     // FIXME: We agreed to put the task into list in an ordered way.
     if (!CheckAddToList(task, type, where))
@@ -249,6 +257,13 @@
 Bool_t MTaskList::AddToListAfter(MTask *task, const MTask *where, const char *type)
 {
+    if (task==this)
+    {
+        *fLog << warn << "WARNING - You cannot add a tasklist to itself.  This" << endl;
+        *fLog << "          would create infinite recursions...ignored." << endl;
+        return kFALSE;
+
+    }
+
     // FIXME: We agreed to put the task into list in an ordered way.
-
     if (!CheckAddToList(task, type, where))
         return kFALSE;
@@ -270,6 +285,13 @@
 Bool_t MTaskList::AddToList(MTask *task, const char *type)
 {
+    if (task==this)
+    {
+        *fLog << warn << "WARNING - You cannot add a tasklist to itself.  This" << endl;
+        *fLog << "          would create infinite recursions...ignored." << endl;
+        return kFALSE;
+
+    }
+
     // FIXME: We agreed to put the task into list in an ordered way.
-
     if (!CheckAddToList(task, type))
         return kFALSE;
@@ -301,4 +323,51 @@
 {
     return fTasks->FindObject(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+// find recursively a tasklist which contains a task with name task
+//
+MTaskList *MTaskList::FindTaskList(const char *task)
+{
+    if (FindObject(task))
+        return this;
+
+    TIter Next(fTasks);
+    TObject *o = 0;
+    while ((o=Next()))
+    {
+        MTaskList *l = dynamic_cast<MTaskList*>(o);
+        if (!l)
+            continue;
+
+        if (l->FindObject(task))
+            return l;
+    }
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// find recursively a tasklist which contains a task task
+//
+MTaskList *MTaskList::FindTaskList(const MTask *task)
+{
+    if (FindObject(task))
+        return this;
+
+    TIter Next(fTasks);
+    TObject *o = 0;
+    while ((o=Next()))
+    {
+        MTaskList *l = dynamic_cast<MTaskList*>(o);
+        if (!l)
+            continue;
+
+        if (l->FindObject(task))
+            return l;
+    }
+
+    return 0;
 }
 
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 4827)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 4828)
@@ -62,4 +62,6 @@
         return (MTask*)FindObject(obj);
     }
+    MTaskList *FindTaskList(const char *task);
+    MTaskList *FindTaskList(const MTask *task);
 
     Bool_t ReInit(MParList *pList=NULL);
Index: /trunk/MagicSoft/Mars/mhbase/MH3.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 4828)
@@ -113,5 +113,5 @@
 
     fName  = gsDefName;
-    fTitle = Form(gsDefTitle.Data(), 1);
+    fTitle = Form(gsDefTitle.Data(), fDimension);
 
     if (fHist)
@@ -514,4 +514,61 @@
 */
 
+/*
+void MH3::Paint(Option_t *opt)
+{
+    if (fHist->TestBit(kIsLogx)) pad->SetLogx();
+    if (fHist->TestBit(kIsLogy)) pad->SetLogy();
+    if (fHist->TestBit(kIsLogz)) pad->SetLogz();
+}
+*/
+
+void MH3::Paint(Option_t *o)
+{
+    TString str(o);
+
+    // FIXME: Do it in Paint()
+    if (str.Contains("COL", TString::kIgnoreCase))
+        SetColors();
+
+    if (fHist->TestBit(kIsLogx) && fHist->GetEntries()>0) gPad->SetLogx();
+    if (fHist->TestBit(kIsLogy) && fHist->GetEntries()>0) gPad->SetLogy();
+    if (fHist->TestBit(kIsLogz) && fHist->GetEntries()>0) gPad->SetLogz();
+
+    // Set pretty color palette
+    gStyle->SetPalette(1, 0);
+
+    TVirtualPad *padsave = gPad;
+
+    TProfile* h0;
+    if ((h0 = (TProfile*)gPad->FindObject("_pfx")))
+    {
+        // Get projection for range
+        TProfile *p = ((TH2*)fHist)->ProfileX("_pfx", -1, 9999, "s");
+
+        // Move contents from projection to h3
+        h0->Reset();
+        h0->Add(p);
+        delete p;
+
+        // Set Minimum as minimum value Greater Than 0
+        //h0->SetMinimum(GetMinimumGT(*h0));
+    }
+    if ((h0 = (TProfile*)gPad->FindObject("_pfy")))
+    {
+        // Get projection for range
+        TProfile *p = ((TH2*)fHist)->ProfileY("_pfy", -1, 9999, "s");
+
+        // Move contents from projection to h3
+        h0->Reset();
+        h0->Add(p);
+        delete p;
+
+        // Set Minimum as minimum value Greater Than 0
+        //h0->SetMinimum(GetMinimumGT(*h0));
+    }
+
+    gPad = padsave;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -534,13 +591,7 @@
     pad->SetBorderMode(0);
 
-    AppendPad("");
+    fHist->SetFillStyle(4000);
 
     TString str(opt);
-
-    // FIXME: Do it in Paint()
-    if (str.Contains("COL", TString::kIgnoreCase))
-        SetColors();
-
-    fHist->SetFillStyle(4000);
 
     Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2;
@@ -565,10 +616,12 @@
     }
 
+    AppendPad("");
+/*
     if (fHist->TestBit(kIsLogx)) pad->SetLogx();
     if (fHist->TestBit(kIsLogy)) pad->SetLogy();
     if (fHist->TestBit(kIsLogz)) pad->SetLogz();
-
-    pad->Modified();
-    pad->Update();
+  */
+    //pad->Modified();
+    //pad->Update();
 }
 
Index: /trunk/MagicSoft/Mars/mhbase/MH3.h
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH3.h	(revision 4827)
+++ /trunk/MagicSoft/Mars/mhbase/MH3.h	(revision 4828)
@@ -41,4 +41,8 @@
     void SetScaleZ(Double_t scale) { fScale[2] = scale; }
 
+    void SetLogx(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogx) : fHist->ResetBit(kIsLogx); }
+    void SetLogy(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogy) : fHist->ResetBit(kIsLogy); }
+    void SetLogz(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogz) : fHist->ResetBit(kIsLogz); }
+
     Int_t GetDimension() const { return fDimension; }
     Int_t GetNbins() const;
@@ -61,4 +65,5 @@
     void SetColors() const;
     void Draw(Option_t *opt=NULL);
+    void Paint(Option_t *opt="");
 
     MParContainer *New() const;
Index: /trunk/MagicSoft/Mars/mhist/MHAlpha.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHAlpha.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/mhist/MHAlpha.cc	(revision 4828)
@@ -43,6 +43,6 @@
 #include <TGraph.h>
 #include <TStyle.h>
+#include <TLatex.h>
 #include <TCanvas.h>
-#include <TPaveText.h>
 #include <TStopwatch.h>
 
@@ -58,4 +58,5 @@
 #include "MHMatrix.h"
 
+#include "MMath.h"
 #include "MBinning.h"
 #include "MParList.h"
@@ -220,4 +221,15 @@
     func.SetLineColor(kGreen);
     func.Paint("same");
+
+    const Double_t w=fHist.GetXaxis()->GetBinWidth(1);
+
+    const Double_t s   = func.Integral(0, sigint)/w;
+    func.SetParameter(0, 0);
+    func.SetParameter(2, 1);
+    const Double_t b   = func.Integral(0, sigint)/w;
+    const Double_t sig = MMath::SignificanceLiMaSigned(s, b);
+
+    TLatex text;
+    text.PaintLatex(35, fHist.GetMaximum()*1.1, 0, 0.05, Form("\\sigma=%.1f E=%d", sig, (int)(s-b)));
 }
 
Index: /trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc	(revision 4828)
@@ -82,4 +82,6 @@
     fGraph = new TGraph;
     fData = new MDataChain(rule);
+
+    fGraph->SetMarkerStyle(kFullDotMedium);
 }
 
@@ -131,4 +133,7 @@
 
     fGraph->SetNameTitle(fName, title);
+
+    fMean = 0;
+    fN    = 0;
 
     return kTRUE;
@@ -186,5 +191,13 @@
         fGraph->RemovePoint(0);
 
-    fGraph->SetPoint(fGraph->GetN(), t, v);
+    fMean += v;
+    fN++;
+
+    if (fN==fNumEvents)
+    {
+        fGraph->SetPoint(fGraph->GetN(), t, fMean/fN);
+        fMean = 0;
+        fN = 0;
+    }
 
     return kTRUE;
Index: /trunk/MagicSoft/Mars/mhvstime/MHVsTime.h
===================================================================
--- /trunk/MagicSoft/Mars/mhvstime/MHVsTime.h	(revision 4827)
+++ /trunk/MagicSoft/Mars/mhvstime/MHVsTime.h	(revision 4828)
@@ -13,8 +13,13 @@
 protected:
     // Could be const but root < 3.02/06 doesn't like this...
-    TGraph     *fGraph;  // Histogram to fill
-    MDataChain *fData;   // Object from which the data is filled
-    Double_t    fScale;  // Scale for axis (eg unit)
-    Int_t       fMaxPts; // Maximum number of data points
+    TGraph     *fGraph;     // Histogram to fill
+    MDataChain *fData;      // Object from which the data is filled
+    Double_t    fScale;     // Scale for axis (eg unit)
+    Int_t       fMaxPts;    // Maximum number of data points
+
+    Int_t       fNumEvents; // Number of events to average
+    Double_t    fMean;      //! Mean value
+    Int_t       fN;
+
 
     enum {
@@ -51,4 +56,5 @@
 
     void SetUseEventNumber(Bool_t use = kTRUE) { fUseEventNumber = use; }
+    void SetNumEvents(Int_t n) { fNumEvents=n; }
 
     void Draw(Option_t *opt=NULL);
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 4828)
@@ -59,4 +59,5 @@
 #include "MReadReports.h"
 #include "MGeomApply.h"
+#include "MPointingPosCalc.h"
 #include "MPedCalcFromLoGain.h"
 #include "MExtractor.h"
@@ -345,4 +346,5 @@
     write.AddContainer("MTimeTrigger",        "Trigger", kFALSE);
     // Slow-Control: Drive
+    write.AddContainer("MPointingPos",        "Drive", kFALSE);
     write.AddContainer("MReportDrive",        "Drive", kFALSE);
     write.AddContainer("MTimeDrive",          "Drive", kFALSE);
@@ -371,7 +373,11 @@
     tlist2.AddToList(&fill5);
 
+    // Setup List for Drive-tree
+    MPointingPosCalc pcalc;
+
     // Now setup main tasklist
     tlist.AddToList(&read);
     tlist.AddToList(&tlist2, "Events");
+    tlist.AddToList(&pcalc,  "Drive");
     tlist.AddToList(&write);
 
Index: /trunk/MagicSoft/Mars/mmain/MEventDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 4828)
@@ -73,5 +73,5 @@
 #include "MImgCleanStd.h"         // MImgCleanStd
 #include "MHillasCalc.h"          // MHillasCalc
-#include "MHillasSrcCalc.h"       // MHillasSrcCalc
+//#include "MHillasSrcCalc.h"       // MHillasSrcCalc
 //#include "MBlindPixelCalc.h"      // MBlindPixelCalc
 #include "MArrivalTimeCalc.h"     // MArrivalTimeCalc
@@ -88,4 +88,5 @@
 #include "MHillasExt.h"            // MHillasExt::Print(const MGeomCam&)
 #include "MHillasSrc.h"            // MHillasSrc::Print(const MGeomCam&)
+#include "MImagePar.h"             // MImagePar::Print(const MGeomCam&)
 #include "MNewImagePar.h"          // MNewImagePar::Print(const MGeomCam&)
 #include "MHEvent.h"               // MHEvent
@@ -292,9 +293,8 @@
     MFillH             *fill04 = new MFillH(evt04, "MPedPhotCam", "MFillH04");
     MFillH             *fill05 = new MFillH(evt05, "MCameraData", "MFillH05");
-    MFillH             *fill06a= new MFillH(evt06a, "MCameraData", "MFillH06");
-    MFillH             *fill06b= new MFillH(evt06b, "MCameraData", "MFillH06");
-//    MBlindPixelCalc   *blind = new MBlindPixelCalc;
+    MFillH             *fill06a= new MFillH(evt06a, "MCameraData", "MFillH06a");
+    MFillH             *fill06b= new MFillH(evt06b, "MCameraData", "MFillH06b");
+    //MBlindPixelCalc   *blind = new MBlindPixelCalc;
     MHillasCalc        *hcalc  = new MHillasCalc;
-    MHillasSrcCalc     *scalc  = new MHillasSrcCalc;
     MMcTriggerLvl2Calc *trcal  = new MMcTriggerLvl2Calc;
     MFillH             *fill09 = new MFillH(evt09, "MMcTriggerLvl2", "MFillH09");
@@ -362,9 +362,7 @@
     tlist->AddToList(fill06a);
     tlist->AddToList(fill06b);
-//    tlist->AddToList(blind);
+    //tlist->AddToList(blind);
+    tlist->AddToList(fill10);
     tlist->AddToList(hcalc);
-    tlist->AddToList(scalc);
-    tlist->AddToList(fill10);
-
     if ((!pcam || !ccam) && type==2)
     {
@@ -379,5 +377,4 @@
 	tlist->AddToList(fill09);
     }
-
     if (type==1)
     {
@@ -588,6 +585,7 @@
     ((MHillasExt*)  plist->FindObject("MHillasExt"))->Print(*geom);
     ((MHillasSrc*)  plist->FindObject("MHillasSrc"))->Print(*geom);
+    plist->FindObject("MImagePar")->Print();
     ((MNewImagePar*)plist->FindObject("MNewImagePar"))->Print(*geom);
-    
+
     //
     // UpdateDisplay
@@ -635,5 +633,5 @@
     {
         TCanvas *c = GetCanvas(i);
-        c->GetPad(1)->cd(1);
+        c->cd(1);
         hillas->Draw();
     }
Index: /trunk/MagicSoft/Mars/msignal/MArrivalTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MArrivalTime.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/msignal/MArrivalTime.cc	(revision 4828)
@@ -91,5 +91,13 @@
     fDataErr[i] = t;
 }
-      
+
+void MArrivalTime::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ":" << endl;
+    for (int i=0; i<fData.GetSize(); i++)
+        *fLog << fData[i] << " ";
+    *fLog << endl;
+}
+
 // --------------------------------------------------------------------------
 //
Index: /trunk/MagicSoft/Mars/msignal/MArrivalTime.h
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MArrivalTime.h	(revision 4827)
+++ /trunk/MagicSoft/Mars/msignal/MArrivalTime.h	(revision 4828)
@@ -43,4 +43,6 @@
     Double_t operator[](int i) const { return fData[i]; }
 
+    void Print(Option_t *o="") const;
+
     // Do not do such things! It is highly dangerous to use two very similar operators
     // to do completely different things! People won't recognize it...
Index: /trunk/MagicSoft/Mars/star.cc
===================================================================
--- /trunk/MagicSoft/Mars/star.cc	(revision 4827)
+++ /trunk/MagicSoft/Mars/star.cc	(revision 4828)
@@ -72,5 +72,5 @@
     // Evaluate arguments
     //
-    MArgs arg(argc, argv);
+    MArgs arg(argc, argv, kFALSE);
 
     if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
