Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1464)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1465)
@@ -1,3 +1,30 @@
                                                                   -*-*- END -*-*-
+
+ 2002/08/01: Thomas Bretz
+
+   * manalysis/MHillas.[h,cc]:
+     - don't draw ellipse if values are invalid
+     - add used and core pixels to Print-output
+
+   * manalysis/MHillasExt.cc:
+     - reordered some comments
+
+   * mdata/MDataChain.[h,cc]:
+     - fixed a bug causing usage of '-' sometime not to work
+     - added handling of '+' sign
+
+   * mfileio/MReadTree.h:
+     - changed some comments
+
+   * mhist/MBinning.[h,cc]:
+     - added Apply
+
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc], 
+     mhist/MHHillasExt.[h,cc]:
+     - added default binning (usefull for the Magic Camera)
+     - some changes to the layout
+     - added support for the sign in MHHillasExt
+
+
 
  2002/07/31: Thomas Bretz
Index: /trunk/MagicSoft/Mars/manalysis/MHillas.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 1464)
+++ /trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 1465)
@@ -126,11 +126,13 @@
     *fLog << all;
     *fLog << "Basic Image Parameters (" << GetName() << ")" << endl;
-    *fLog << " - Length   [mm]  = " << fLength << endl;
-    *fLog << " - Width    [mm]  = " << fWidth  << endl;
-    *fLog << " - Delta    [deg] = " << fDelta*kRad2Deg << endl;
-    *fLog << " - Size     [1]   = " << fSize   << " #CherPhot"   << endl;
-    *fLog << " - Meanx    [mm]  = " << fMeanX  << endl;
-    *fLog << " - Meany    [mm]  = " << fMeanY  << endl;
-    *fLog << " - atg(y/x) [deg] = " << atg     << endl;
+    *fLog << " - Length      [mm]  = " << fLength << endl;
+    *fLog << " - Width       [mm]  = " << fWidth  << endl;
+    *fLog << " - Delta       [deg] = " << fDelta*kRad2Deg << endl;
+    *fLog << " - Size        [1]   = " << fSize   << " #CherPhot"   << endl;
+    *fLog << " - Meanx       [mm]  = " << fMeanX  << endl;
+    *fLog << " - Meany       [mm]  = " << fMeanY  << endl;
+    *fLog << " - atg(y/x)    [deg] = " << atg     << endl;
+    *fLog << " - Used Pixels [#]   = " << fNumUsedPixels << " Pixels" << endl;
+    *fLog << " - Core Pixels [#]   = " << fNumCorePixels << " Pixels" << endl;
 }
 
@@ -160,4 +162,7 @@
 
     Clear();
+
+    if (fLength<0 || fWidth<0)
+        return;
 
     fEllipse = new TEllipse(fMeanX, fMeanY, fLength, fWidth,
Index: /trunk/MagicSoft/Mars/manalysis/MHillas.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 1464)
+++ /trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 1465)
@@ -22,9 +22,9 @@
     Float_t fMeanY;         // [mm]        y-coordinate of center of ellipse
 
+    Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning
+    Short_t fNumCorePixels; // number of core pixels
+
     Float_t fSinDelta;      //! [1] sin of Delta (to be used in derived classes)
     Float_t fCosDelta;      //! [1] cos of Delta (to be used in derived classes)
-
-    Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning
-    Short_t fNumCorePixels; // number of core pixels
 
     TEllipse *fEllipse;     //! Graphical Object to Display Ellipse
Index: /trunk/MagicSoft/Mars/manalysis/MHillasExt.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasExt.cc	(revision 1464)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasExt.cc	(revision 1465)
@@ -18,4 +18,5 @@
 !   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
 !   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
 !
 !   Copyright: MAGIC Software Development, 2000-2002
@@ -36,6 +37,16 @@
 // fM3Long   third moment along major axis
 // fM3Trans  third moment along minor axis
+// fLeakage1 ratio : (photons in most outer ring of pixels) over fSize
+// fLeakage2 ratio : (photons in the 2 outer rings of pixels) over fSize
+//
+// WARNING: Before you can use fAsym, fM3Long and fM3Trans you must
+//          multiply by the sign of MHillasSrc::fCosAlphaDelta
 //
 ////////////////////////////////////////////////////////////////////////////
+/*
+ // fAsymna   d/(d na) of ( sum(x*q^na)/sum(q^na), sum(y*q^na)/sum(q^na) )
+ //           projected onto the major axis
+ // fAsym0    (F-B)/(F+B) along the major axis
+ */
 #include "MHillasExt.h"
 
@@ -172,4 +183,10 @@
         /*
          //
+         // power na for calculating fAsymna;
+         // the value 1.5 was suggested by Thomas Schweizer
+         //
+         Double_t na = 1.5;
+
+         //
          // get sums for calculating fAsymna
          // the outer pixels are 4 times as big (in area)
@@ -201,11 +218,4 @@
 
     /*
-
-     //
-     // power na for calculating fAsymna;
-     // the value 1.5 was suggested by Thomas Schweizer
-     //
-     Double_t na = 1.5;
-
      fLeakage1 = edgepix1 / GetSize();
      fLeakage2 = edgepix2 / GetSize();
Index: /trunk/MagicSoft/Mars/mdata/MDataChain.cc
===================================================================
--- /trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 1464)
+++ /trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 1465)
@@ -162,7 +162,10 @@
 {
     int l = txt.Length();
-    for (int i = 0; i<l; i++)
-        if (!isalnum(txt[i]) && txt[i]!='.' && txt[i]!='-')
+    for (int i=0; i<l; i++)
+    {
+        if (!isalnum(txt[i]) && txt[i]!='.' &&
+            ((txt[i]!='-' && txt[i]!='+') || i!=0))
             return i;
+    }
 
     return l;
@@ -210,4 +213,5 @@
     if (txt=="sgn")   return kESgn;
     if (txt[0]=='-')  return kENegative;
+    if (txt[0]=='+')  return kEPositive;
 
     return kENoop;
@@ -324,5 +328,5 @@
         case '8':
         case '9':
-            if (txt[0]!='-' || isdigit(txt[1]) || txt[1]=='.')
+            if ((txt[0]!='-' && txt[0]!='+') || isdigit(txt[1]) || txt[1]=='.')
             {
                 char *end;
@@ -360,5 +364,5 @@
             txt = txt.Strip(TString::kBoth);
 
-            if (txt.IsNull() || txt[0]!='(')
+            if ((txt.IsNull() || txt[0]!='(') && text[0]!='-' && text[0]!='+')
             {
                 newmember = new MDataMember(text.Data());
@@ -376,5 +380,5 @@
 
             Int_t first = GetBracket(txt);
-            TString sub = op==kENegative ? text.Remove(0,1) + txt : txt(1, first-1);
+            TString sub = op==kENegative || op==kEPositive ? text.Remove(0,1) + txt : txt(1, first-1);
             txt.Remove(0, first+1);
 
@@ -435,4 +439,5 @@
     case kESgn:      return val<0 ? -1 : 1;
     case kENegative: return -val;
+    case kEPositive: return val;
     case kENoop:     return val;
     }
@@ -466,4 +471,5 @@
     case kESgn:      *fLog << "sgn"   << flush; break;
     case kENegative: *fLog << "-" << flush; break;
+    case kEPositive: *fLog << "+" << flush; break;
     case kENoop:
         break;
Index: /trunk/MagicSoft/Mars/mdata/MDataChain.h
===================================================================
--- /trunk/MagicSoft/Mars/mdata/MDataChain.h	(revision 1464)
+++ /trunk/MagicSoft/Mars/mdata/MDataChain.h	(revision 1465)
@@ -37,4 +37,5 @@
         kEExp,
         kESgn,
+        kEPositive,
         kENegative
     } OperatorType_t;
Index: /trunk/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 1464)
+++ /trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 1465)
@@ -89,6 +89,7 @@
         // This is the code from TChain::LoadTree but skips the
         // notification in LoadTree. If LoadTree raises the notification
-        // a flag is set and the notification is done by hand. If it
-        // has not been successfull -15 is returned.
+        // a flag is set and the notification is done by hand. This
+        // is done to be able to catch the return value from Notify. If
+        // it has not been successfull -15 is returned.
         // This is to support return values from Notify()/Reinit()
         //
Index: /trunk/MagicSoft/Mars/mhist/MBinning.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MBinning.cc	(revision 1464)
+++ /trunk/MagicSoft/Mars/mhist/MBinning.cc	(revision 1465)
@@ -31,4 +31,6 @@
 #include "MBinning.h"
 
+#include "MH.h"
+
 ClassImp(MBinning);
 
@@ -49,2 +51,7 @@
 }
 
+
+void MBinning::Apply(TH1 &h)
+{
+    MH::SetBinning(&h, this);
+}
Index: /trunk/MagicSoft/Mars/mhist/MBinning.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MBinning.h	(revision 1464)
+++ /trunk/MagicSoft/Mars/mhist/MBinning.h	(revision 1465)
@@ -10,4 +10,6 @@
 #endif
 
+class TH1;
+
 class MBinning : public MParContainer
 {
@@ -20,9 +22,5 @@
     void SetEdges(const TArrayD &arr)
     {
-        fEdges = arr;/*
-        const Int_t nbins = arr.GetSize();
-        fEdges.Set(nbins);
-        for (int i=0; i<nbins; i++)
-            fEdges[i] = (*(TArrayD*)(&arr))[i];*/
+        fEdges = arr;
     }
 
@@ -54,4 +52,6 @@
     Double_t *GetEdges() const { return fEdges.GetArray(); }
 
+    void Apply(TH1 &);
+
     ClassDef(MBinning, 1) //Container to store the binning of a histogram
 };
Index: /trunk/MagicSoft/Mars/mhist/MHHillas.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1464)
+++ /trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1465)
@@ -99,5 +99,5 @@
     fSize->GetXaxis()->SetLabelOffset(-0.015);
 
-    MH::SetBinning(fSize, &bins);
+    bins.Apply(*fSize);
 
     fCenter = new TH2F("Center", "Center of Ellipse", 51, -445, 445, 51, -445, 445);
@@ -138,5 +138,5 @@
     const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     if (!geom)
-        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
     else
     {
Index: /trunk/MagicSoft/Mars/mhist/MHHillasExt.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillasExt.cc	(revision 1464)
+++ /trunk/MagicSoft/Mars/mhist/MHHillasExt.cc	(revision 1465)
@@ -43,6 +43,10 @@
 
 #include "MGeomCam.h"
+
 #include "MParList.h"
+
+#include "MBinning.h"
 #include "MHillasExt.h"
+#include "MHillasSrc.h"
 
 ClassImp(MHHillasExt);
@@ -88,4 +92,18 @@
     fHM3Long.SetYTitle("Counts");
     fHM3Trans.SetYTitle("Counts");
+
+
+    MBinning bins;
+
+    bins.SetEdges(100, 0, 1);
+    bins.Apply(fHConc);
+    bins.Apply(fHConc1);
+
+    bins.SetEdges(101, -326, 326);
+    bins.Apply(fHM3Long);
+    bins.Apply(fHM3Trans);
+
+    bins.SetEdges(89, -297, 593);
+    bins.Apply(fHAsym);
 }
 
@@ -110,31 +128,22 @@
 Bool_t MHHillasExt::SetupFill(const MParList *plist)
 {
-    const MBinning* binsc  = (MBinning*)plist->FindObject("BinningConc");
-    const MBinning* binsc1 = (MBinning*)plist->FindObject("BinningConc1");
-    const MBinning* binsa  = (MBinning*)plist->FindObject("BinningAsym");
-    const MBinning* binsl  = (MBinning*)plist->FindObject("BinningM3Long");
-    const MBinning* binst  = (MBinning*)plist->FindObject("BinningM3Trans");
-    if (!binsc || !binsc1 || !binsa || !binsl || !binst)
-    {
-        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    SetBinning(&fHConc,    binsc);
-    SetBinning(&fHConc1,   binsc1);
-    SetBinning(&fHAsym,    binsa);
-    SetBinning(&fHM3Long,  binsl);
-    SetBinning(&fHM3Trans, binst);
-
     const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     if (!geom)
-    {
-        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
-        return kTRUE;
-    }
-
-    fHAsym.SetXTitle("Asym [\\circ]");
-    fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
-    fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Conc",    &fHConc);
+    ApplyBinning(*plist, "Conc1",   &fHConc1);
+    ApplyBinning(*plist, "Asym",    &fHAsym);
+    ApplyBinning(*plist, "M3Long",  &fHM3Long);
+    ApplyBinning(*plist, "M3Trans", &fHM3Trans);
+
+    fHillasSrc = (MHillasSrc*)plist->FindObject("HillasSource");
+    if (!fHillasSrc)
+        *fLog << warn << dbginf << "Sorry 'HillasSource' [MHillasSrc] not found. Histograms will be source independant." << endl;
 
     return MHHillas::SetupFill(plist);
@@ -148,21 +157,16 @@
 Bool_t MHHillasExt::Fill(const MParContainer *par)
 {
-    const MHillasExt &h = *(MHillasExt*)par;
-
-    fHConc.Fill(h.GetConc());
-    fHConc1.Fill(h.GetConc1());
-
-    if (fUseMmScale)
-    {
-        fHAsym.Fill(h.GetAsym());
-        fHM3Long.Fill(h.GetM3Long());
-        fHM3Trans.Fill(h.GetM3Trans());
-    }
-    else
-    {
-        fHAsym.Fill(fMm2Deg*h.GetAsym());
-        fHM3Long.Fill(fMm2Deg*h.GetM3Long());
-        fHM3Trans.Fill(fMm2Deg*h.GetM3Trans());
-    }
+    const MHillasExt &ext = *(MHillasExt*)par;
+
+    const Double_t scale = fHillasSrc ? TMath::Sign(fUseMmScale?1:fMm2Deg, fHillasSrc->GetCosDeltaAlpha()) : 1;
+
+    fHConc.Fill(ext.GetConc());
+    fHConc1.Fill(ext.GetConc1());
+
+    fHAsym.Fill(scale*ext.GetAsym());
+    fHM3Long.Fill(scale*ext.GetM3Long());
+    fHM3Trans.Fill(scale*ext.GetM3Trans());
+    //fHAsymna.Fill(scale*ext.GetAsymna());
+    //fHAsym0.Fill(scale*ext.GetAsym0());
 
     return MHHillas::Fill(par);
@@ -185,13 +189,14 @@
     }
 
-    if (fUseMmScale)
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(&fHAsym,    scale);
+    MH::ScaleAxis(&fHM3Long,  scale);
+    MH::ScaleAxis(&fHM3Trans, scale);
+
+    if (mmscale)
     {
         fHAsym.SetXTitle("Asym [mm]");
         fHM3Long.SetXTitle("3^{rd} M_{l}[mm]");
         fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
-
-        fHAsym.Scale(1./fMm2Deg);
-        fHM3Long.Scale(1./fMm2Deg);
-        fHM3Trans.Scale(1./fMm2Deg);
     }
     else
@@ -200,8 +205,4 @@
         fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
         fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
-
-        fHAsym.Scale(fMm2Deg);
-        fHM3Long.Scale(fMm2Deg);
-        fHM3Trans.Scale(fMm2Deg);
     }
 
@@ -220,6 +221,6 @@
 {
     TCanvas &c = *MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
-                               3*350, 2*250);
-    c.Divide(3, 2);
+                                720, 810);
+    c.Divide(2, 3);
 
     gROOT->SetSelectedPad(NULL);
@@ -231,8 +232,8 @@
     ((TH1F&)fHConc).DrawCopy();
 
-    c.cd(4);
+    c.cd(2);
     ((TH1F&)fHConc1).DrawCopy();
 
-    c.cd(2);
+    c.cd(5);
     ((TH1F&)fHAsym).DrawCopy();
 
@@ -240,5 +241,5 @@
     ((TH1F&)fHM3Long).DrawCopy();
 
-    c.cd(6);
+    c.cd(4);
     ((TH1F&)fHM3Trans).DrawCopy();
 
@@ -260,15 +261,16 @@
 {
     if (!gPad)
-        MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 3*250);
-
-    gPad->Divide(3, 2);
+        MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
+                      720, 810);
+
+    gPad->Divide(2, 3);
 
     gPad->cd(1);
     fHConc.DrawCopy();
 
-    gPad->cd(4);
+    gPad->cd(2);
     fHConc1.DrawCopy();
 
-    gPad->cd(2);
+    gPad->cd(5);
     fHAsym.DrawCopy();
 
@@ -276,5 +278,5 @@
     fHM3Long.DrawCopy();
 
-    gPad->cd(6);
+    gPad->cd(4);
     fHM3Trans.DrawCopy();
 
Index: /trunk/MagicSoft/Mars/mhist/MHHillasExt.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillasExt.h	(revision 1464)
+++ /trunk/MagicSoft/Mars/mhist/MHHillasExt.h	(revision 1465)
@@ -9,7 +9,11 @@
 #endif
 
+class MHillasSrc;
+
 class MHHillasExt : public MHHillas
 {
 private:
+    MHillasSrc *fHillasSrc; //! Pointer to an MHillasSrc to be able to add sign to Asym, M3Long and M3Trans
+
     TH1F fHConc;    // [ratio] concentration ratio: sum of the two highest pixels / fSize
     TH1F fHConc1;   // [ratio] concentration ratio: sum of the highest pixel / fSize
Index: /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1464)
+++ /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1465)
@@ -179,5 +179,5 @@
     if (fMm2Deg<0)
     {
-        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
+        *fLog << warn << GetDescriptor() << ": Warning - Sorry, no conversion factor for conversion available." << endl;
         return;
     }
