Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2235)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2236)
@@ -1,3 +1,39 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/06/26: Thomas Bretz
+
+  * macros/CT1EgyEst.C:
+    - converted from dos to unix type
+
+   * macros/rootlogon.C:
+     - removed "-fno-rtti" from options for Aclic
+     
+   * mbase/MLog.h:
+     - added a comment
+     
+   * mgeom/MGeomCam.[h,cc], mgeom/MGeomPix.[h,cc],
+     mgeom/MGeomCamCT1.cc, mgeom/MGeomCamECO1000.cc,
+     mgeom/MGeomCamECO1000HG.cc, mgeom/MGeomCamMagicHG.cc:
+     - added support for sectors
+   
+   * megom/MGeomCamMagic.[h,cc]:
+     - added sectors
+     
+   * mhist/MHCamera.[h,cc]:
+     - convert Option_t in Paint to lower case
+     - remove 'hist' if detected from Option_t 
+     - check for min==max
+     - added DrawSectorIndices()
+     - added TArrayC to AddCamContent
+     - added TArrayC to SetCamContent
+     - simplified DistancetoPrimitive
+     
+   * mraw/MRawEvtData.cc:
+     - simplified Draw by converting option string to lower case
+     
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - added GetNumMaxLoGainSample
+
+
 
  2003/06/25: Thomas Bretz
Index: /trunk/MagicSoft/Mars/macros/rootlogon.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 2235)
+++ /trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 2236)
@@ -110,5 +110,5 @@
     if (TString("linux")==gSystem->GetBuildArch())
     {
-        TString options = " -O -pipe -Wall -Woverloaded-virtual -fno-rtti -fno-exceptions -fPIC ";
+        TString options = " -O -pipe -Wall -Woverloaded-virtual -fno-exceptions -fPIC ";
 
         TString s = "cd $BuildDir ; ";
Index: /trunk/MagicSoft/Mars/mbase/MLog.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MLog.h	(revision 2235)
+++ /trunk/MagicSoft/Mars/mbase/MLog.h	(revision 2236)
@@ -167,4 +167,5 @@
     }
 
+    // FIXME: Switch off colors when on....
     void SetNullOutput(Bool_t n=kTRUE) { fIsNull = n; }
 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 2236)
@@ -97,4 +97,25 @@
 // --------------------------------------------------------------------------
 //
+// Calculate the highest sector index+1 of all pixels, please make sure
+// the the sector numbers are continous.
+//
+void MGeomCam::CalcNumSectors()
+{
+    fNumSectors = 0;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MGeomPix &pix = (*this)[i];
+        const UInt_t s = pix.GetSector();
+
+        if (s>fNumSectors)
+            fNumSectors = s;
+    }
+
+    fNumSectors++;
+}
+
+// --------------------------------------------------------------------------
+//
 // Calculate the maximum radius of the camera. This is ment for GUI layout.
 //
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 2236)
@@ -22,6 +22,9 @@
     TObjArray fPixels;     // Array of singel pixels storing the geometry
 
+    UInt_t    fNumSectors; // Number of sectors
+
 protected:
     void CalcMaxRadius();
+    void CalcNumSectors();
     void InitOuterRing();
 
@@ -32,9 +35,10 @@
     virtual TObject *Clone(const char *newname=NULL) const;
 
-    Float_t GetCameraDist() const      { return fCamDist; }
-    Float_t GetConvMm2Deg() const      { return fConvMm2Deg; }
+    Float_t GetCameraDist() const { return fCamDist; }
+    Float_t GetConvMm2Deg() const { return fConvMm2Deg; }
 
-    UInt_t  GetNumPixels() const       { return fNumPixels; }
-    Float_t GetMaxRadius() const       { return fMaxRadius; }
+    UInt_t  GetNumPixels() const  { return fNumPixels; }
+    Float_t GetMaxRadius() const  { return fMaxRadius; }
+    UInt_t  GetNumSectors() const { return fNumSectors; }
     Float_t GetPixRatio(UInt_t i) const;
 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc	(revision 2236)
@@ -56,4 +56,5 @@
     CreateCam();
     CreateNN();
+    CalcNumSectors();
     CalcMaxRadius();
 } 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCamECO1000.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCamECO1000.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCamECO1000.cc	(revision 2236)
@@ -52,4 +52,5 @@
     CreateCam();
     CreateNN();
+    CalcNumSectors();
     CalcMaxRadius();
 }
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCamECO1000HG.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCamECO1000HG.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCamECO1000HG.cc	(revision 2236)
@@ -56,4 +56,5 @@
     CreateCam();
     CreateNN();
+    CalcNumSectors();
     CalcMaxRadius();
 }
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc	(revision 2236)
@@ -53,4 +53,5 @@
     CreateCam();
     CreateNN();
+    CalcNumSectors();
     CalcMaxRadius();
 }
@@ -221,5 +222,5 @@
         -034.641                                                                         // 576
     };
-
+/*
     const Float_t dtemp[577] = {
         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //   0
@@ -296,11 +297,43 @@
         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 568
         60.00  };                                                // 576
+*/
+    const Byte_t sector[577] = {
+        0, 1, 2, 3, 4, 5, 6, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+        1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 1,
+        1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
+        6, 6, 6, 6, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
+        4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 1, 1, 1, 1,
+        1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
+        4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1,
+        1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
+        4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 1, 1,
+        1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
+        3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
+        6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
+        2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
+        4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
+        6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
+        2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
+        4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
+        6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+        3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
+        5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1, 1,
+        1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4,
+        4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1,
+        1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4,
+        4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6,
+        1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
+        3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
+        5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4,
+        4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
+        6, 6, 6, 6, 6, 6, 6 };
 
     //
     //   fill the pixels list with this data
     //
-
     for (UInt_t i=0; i<GetNumPixels(); i++)
-        (*this)[i].Set(xtemp[i], ytemp[i], dtemp[i]) ;
+        (*this)[i].Set(xtemp[i], ytemp[i], i>396?60:30, sector[i]);
 }
 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCamMagicHG.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCamMagicHG.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCamMagicHG.cc	(revision 2236)
@@ -53,4 +53,5 @@
     CreateCam();
     CreateNN();
+    CalcNumSectors();
     CalcMaxRadius();
 }
@@ -983,5 +984,5 @@
 
     for (UInt_t i=0; i<GetNumPixels(); i++)
-        (*this)[i].Set(xtemp[i], ytemp[i], dtemp[i]) ;
+        (*this)[i].Set(xtemp[i], ytemp[i], dtemp[i]);
 }
 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 2236)
@@ -56,5 +56,5 @@
 // Initializes one pixel
 //
-MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r) : fX(x), fY(y), fD(r)
+MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s) : fX(x), fY(y), fD(r), fSector(s)
 {
     //  default constructor
Index: /trunk/MagicSoft/Mars/mgeom/MGeomPix.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 2235)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 2236)
@@ -25,10 +25,12 @@
     Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry)
 
+    UInt_t fSector; // Number of sector the pixels corresponds to
+
 public:
-    MGeomPix(Float_t x=0, Float_t y=0, Float_t d=0);
+    MGeomPix(Float_t x=0, Float_t y=0, Float_t d=0, UInt_t s=0);
 
     void Print(Option_t *opt=NULL) const;
 
-    void Set(Float_t x, Float_t y, Float_t d) { fX=x; fY=y; fD=d; }
+    void Set(Float_t x, Float_t y, Float_t d, UInt_t s=0) { fX=x; fY=y; fD=d; fSector=s; }
 
     void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
@@ -36,12 +38,15 @@
 
     void CheckOuterRing(const MGeomCam &cam);
-
-    void SetX(Float_t x) { fX = x; }
-    void SetY(Float_t y) { fY = y; }
-    void SetD(Float_t d) { fD = d; }
+    /*
+     void SetX(Float_t x) { fX = x; }
+     void SetY(Float_t y) { fY = y; }
+     void SetD(Float_t d) { fD = d; }
+     void SetSector(UInt_t s) { fSector = s; }
+     */
 
     Float_t GetX() const  { return fX; }
     Float_t GetY() const  { return fY; }
     Float_t GetD() const  { return fD; }
+    UInt_t  GetSector() const { return fSector; }
 
     Float_t GetA() const;
Index: /trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2236)
@@ -364,4 +364,7 @@
     }
 
+    if (min==max)
+        max += 1;
+
     UpdateLegend(min, max, islog);
 
@@ -506,8 +509,11 @@
 void MHCamera::Paint(Option_t *o)
 {
-    const TString opt(o);
-
-    if (opt.Contains("hist", TString::kIgnoreCase))
-    {
+    TString opt(o);
+    opt.ToLower();
+
+    if (opt.Contains("hist"))
+    {
+        opt.ReplaceAll("hist", "");
+
         Int_t mode = gStyle->GetOptStat();
         TVirtualPad *save = gPad;
@@ -525,6 +531,6 @@
     SetRange();
 
-    Bool_t isbox = opt.Contains("box", TString::kIgnoreCase);
-    Bool_t iscol = isbox ? !opt.Contains("nocol", TString::kIgnoreCase) : 1;
+    Bool_t isbox = opt.Contains("box");
+    Bool_t iscol = isbox ? !opt.Contains("nocol") : 1;
 
     // Update Contents of the pixels and paint legend
@@ -595,4 +601,5 @@
 void MHCamera::DrawPixelIndices()
 {
+    // FIXME: Is this correct?
     for (int i=0; i<kItemsLegend; i++)
         fColors[i] = 16;
@@ -609,4 +616,27 @@
         TString num;
         num += i;
+
+        const MGeomPix &h = (*fGeomCam)[i];
+        TText *nt = txt.DrawText(h.GetX(), h.GetY(), num);
+        nt->SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius());
+    }
+}
+
+void MHCamera::DrawSectorIndices()
+{
+    for (int i=0; i<kItemsLegend; i++)
+        fColors[i] = 16;
+
+    if (!gPad)
+        Draw();
+
+    TText txt;
+    txt.SetTextFont(122);
+    txt.SetTextAlign(22);   // centered/centered
+
+    for (Int_t i=0; i<fNcells-2; i++)
+    {
+        TString num;
+        num += (*fGeomCam)[i].GetSector();
 
         const MGeomPix &h = (*fGeomCam)[i];
@@ -678,14 +708,17 @@
 // Only 'used' pixels are added.
 //
-void MHCamera::AddCamContent(const TArrayD &event, Bool_t ispos)
+void MHCamera::AddCamContent(const TArrayD &event, const TArrayC *used)
 {
     if (event.GetSize()!=fNcells-2)
         return;
 
+    if (used && used->GetSize()!=fNcells-2)
+        return;
+
     for (Int_t idx=0; idx<fNcells-2; idx++)
     {
         Fill(idx, const_cast<TArrayD&>(event)[idx]); // FIXME: Slow!
 
-        if (!ispos || fArray[idx+1]>0)
+        if (used && (*used)[idx])
             SetUsed(idx);
     }
@@ -814,4 +847,10 @@
 Int_t MHCamera::GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog)
 {
+    if (TMath::IsNaN(val)) // FIXME: gLog!
+    {
+        cout << "MHCamera::GetColor: " << GetName() << " <" << GetTitle() << "> - Color for val=NaN (Not a Number) requested... set val=min." << endl;
+        val = min;
+    }
+
     //
     //   first treat the over- and under-flows
@@ -833,4 +872,5 @@
     else
         ratio = (val-min) / (max-min);
+
     const Int_t colidx = (Int_t)(ratio*maxcolidx + .5);
     return fColors[colidx];
@@ -930,15 +970,11 @@
         return TH1D::DistancetoPrimitive(px, py);
 
-    Int_t dist = 999999;
-
     for (Int_t i=0; i<fNcells-2; i++)
     {
         MHexagon hex((*fGeomCam)[i]);
-        Int_t d = hex.DistancetoPrimitive(px, py);
-
-        if (d<dist)
-            dist=d;
-    }
-    return dist==0?0:999999;
+        if (hex.DistancetoPrimitive(px, py)==0)
+            return 0;
+    }
+    return 999999;
 }
 
Index: /trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2235)
+++ /trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2236)
@@ -90,7 +90,7 @@
     virtual void     AddCamContent(const MCamEvent &evt, Int_t type=0);
     virtual void     AddCamContent(const MHCamera &evt, Int_t type=0);
-    virtual void     AddCamContent(const TArrayD &arr, Bool_t ispos=kTRUE);
+    virtual void     AddCamContent(const TArrayD &arr, const TArrayC *used=NULL);
     virtual void     SetCamContent(const MCamEvent &evt, Int_t type=0) { Reset(); AddCamContent(evt, type); }
-    virtual void     SetCamContent(const TArrayD &evt, Bool_t ispos=kTRUE) { Reset(); AddCamContent(evt, ispos); }
+    virtual void     SetCamContent(const TArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); }
     virtual void     SetCamContent(const MHCamera &d, Int_t type=0) { Reset(), AddCamContent(d, type); }
     virtual void     CntCamContent(const MCamEvent &evt, Double_t threshold, Int_t type=0);
@@ -111,4 +111,5 @@
 
     void  DrawPixelIndices();
+    void  DrawSectorIndices();
 
     void  PrintInfo() const { Print(""); } // *MENU*
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 2236)
@@ -224,11 +224,12 @@
 
     TString str(opt);
+    str.ToLower();
 
     UInt_t id = 0;
 
-    if (str.BeginsWith("GRAPH", TString::kIgnoreCase))
+    if (str.BeginsWith("graph"))
         if (str.Length()>5)
             sscanf(&str[5], "%d", &id);
-    if (str.BeginsWith("HIST", TString::kIgnoreCase))
+    if (str.BeginsWith("hist"))
         if (str.Length()>4)
             sscanf(&str[4], "%d", &id);
@@ -250,7 +251,7 @@
     name += pix.GetPixelId();
 
-    Bool_t same = str.Contains("same", TString::kIgnoreCase);
-
-    if (str.BeginsWith("GRAPH", TString::kIgnoreCase))
+    Bool_t same = str.Contains("same");
+
+    if (str.BeginsWith("graph"))
     {
         *fLog << inf << "Drawing Graph: Pixel Idx #" << pix.GetPixelId();
@@ -276,5 +277,5 @@
     }
 
-    if (str.BeginsWith("HIST", TString::kIgnoreCase))
+    if (str.BeginsWith("hist"))
     {
         // FIXME: Add Legend
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc	(revision 2235)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc	(revision 2236)
@@ -228,4 +228,23 @@
 // --------------------------------------------------------------------------
 //
+// Returns the index of the FADC slice the maximum signal in
+//
+Byte_t MRawEvtPixelIter::GetNumMaxLoGainSample() const
+{
+    Byte_t max  = 0;
+    Byte_t maxi = 0;
+
+    for (int i=0; i<fNumLoGainSamples; i++)
+        if (fLoGainPos[i]>max)
+        {
+            max = fLoGainPos[i];
+            maxi = i;
+        }
+
+    return maxi;
+}
+
+// --------------------------------------------------------------------------
+//
 // returns the sum of all lo gain fadc samples of the actual pixel.
 // if no lo gain information is available 0 is returned.
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 2235)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 2236)
@@ -82,4 +82,5 @@
 
     Byte_t GetNumMaxHiGainSample() const;
+    Byte_t GetNumMaxLoGainSample() const;
 
     Bool_t HasLoGain() const
