Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2562)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2563)
@@ -4,4 +4,49 @@
 
                                                  -*-*- END OF LINE -*-*-
+  2003/11/23: Thomas Bretz
+
+   * star.cc:
+     - fixed a typo
+     
+   * manalysis/MCerPhotCalc.cc:
+     - fixed logging stream
+     
+   * mbase/MStatusDisplay.[h,cc]:
+     - made fLog available to derived classes
+     - added Reset()-function
+     - added some debug messages to CloseWindow()
+     - put 'return' back into HandleConfigureNotify (fixes the
+       problem with the random size of the Mona display)
+     - added a new workaround in HandleEvent which fixed a crash
+       when switching back to the 'main' tab in MEventDisplay
+       This is NOT understood!
+     - changed bit 14/15 to 15/16. BIT(14) is used in TGMainFrame
+       already
+     
+   * mfilter/MFRealTimePeriod.h:
+     - added Setter for timeout
+     
+   * mhist/MHCamEvent.cc:
+     - fill the rms for each event. This may be switched off by
+       a status bit in the future for speed reasons.
+       
+   * mhist/MHCamera.[h,cc]:
+     - removed Profile() from GetMaximum/GetMinimum if no
+       autoscale is done
+     - added 'content' Draw option
+     
+   * mhist/MHEvent.cc:
+     - fixed a typo: GetNumEvents() --> GetRunNumber()
+     
+   * mhist/MHTriggerLvl0.cc:
+     - small changes to output
+     
+   * mraw/MRawSocketRead.[h,cc]:
+     - renamed fRawEvtTime to fTime
+     - changed 'MRawEvtTime' to 'MTime'
+     - added some debugging output in case of kContinue
+
+
+
   2003/11/22: Thomas Bretz
 
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 2562)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 2563)
@@ -97,5 +97,5 @@
     if (!fRunHeader)
     {
-        *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
         return kFALSE;
     }
@@ -104,5 +104,5 @@
     if (!fRawEvt)
     {
-        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        *fLog << err << "MRawEvtData not found... aborting." << endl;
         return kFALSE;
     }
@@ -111,5 +111,5 @@
     if (!fPedestals)
     {
-        *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
+        *fLog << err << "MPedestalCam not found... aborting." << endl;
         return kFALSE;
     }
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 2562)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 2563)
@@ -560,5 +560,5 @@
 //
 MStatusDisplay::MStatusDisplay(Long_t t)
-: TGMainFrame(NULL, 1, 1), fTab(NULL), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLog(&gLog), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0)
+: TGMainFrame(NULL, 1, 1), fLog(&gLog), fTab(NULL), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0)
 {
     // p==NULL means: Take gClient->GetRoot() if not in batch mode
@@ -587,11 +587,4 @@
     fList = new MGList;
     fList->SetOwner();
-
-    //
-    // set the smallest and biggest size of the Main frame
-    // and move it to its appearance position
-    SetWMSizeHints(570, 480, 1280, 980, 1, 1);
-    Move(rand()%100+50, rand()%100+50);
-    Resize(570, 480);
 
     //
@@ -612,4 +605,10 @@
         AddStatusBar();
     }
+
+    //
+    // set the smallest and biggest size of the Main frame
+    // and move it to its appearance position
+    SetWMSizeHints(570, 480, 1280, 980, 1, 1);
+    MoveResize(rand()%100+570, rand()%100+480, 570, 480);
 
     //
@@ -1052,4 +1051,10 @@
  */
 
+void MStatusDisplay::Reset()
+{
+    for (int i=fTab->GetNumberOfTabs()-1; i>0; i--)
+        RemoveTab(i);
+}
+
 // --------------------------------------------------------------------------
 //
@@ -1077,6 +1082,5 @@
 
     case kFileReset:
-        for (int i=fTab->GetNumberOfTabs()-1; i>0; i--)
-            RemoveTab(i);
+        Reset();
         return kTRUE;
         /*
@@ -1217,7 +1221,7 @@
     switch (submsg)
     {
-    case kCM_MENU:
+    case kCM_MENU: // 1
         return ProcessMessageCommandMenu(mp1); // mp2=userdata
-    case kCM_TAB:
+    case kCM_TAB:  // 8
         /*
          for (int i=0; i<fTab->GetNumberOfTabs(); i++)
@@ -1238,25 +1242,25 @@
         return kTRUE;
 #ifdef DEBUG
-    case kCM_MENUSELECT:
+    case kCM_MENUSELECT: // 2
         cout << "Command-Menuselect #" << mp1 << " (UserData=" << (void*)mp2 << ")" << endl;
         return kTRUE;
 
-    case kCM_BUTTON:
+    case kCM_BUTTON: // 3
         cout << "Command-Button." << endl;
         return kTRUE;
 
-    case kCM_CHECKBUTTON:
+    case kCM_CHECKBUTTON: // 4
         cout << "Command-CheckButton." << endl;
         return kTRUE;
 
-    case kCM_RADIOBUTTON:
+    case kCM_RADIOBUTTON: // 5
         cout << "Command-RadioButton." << endl;
         return kTRUE;
 
-    case kCM_LISTBOX:
+    case kCM_LISTBOX: // 6
         cout << "Command-Listbox #" << mp1 << " (LineId #" << mp2 << ")" << endl;
         return kTRUE;
 
-    case kCM_COMBOBOX:
+    case kCM_COMBOBOX: // 7
         cout << "Command-ComboBox." << endl;
         return kTRUE;
@@ -1351,15 +1355,17 @@
 {
     // Can be found in WidgetMessageTypes.h
+#ifdef DEBUG
     cout << "Msg: " << GET_MSG(msg) << " Submsg:" << GET_SUBMSG(msg);
     cout << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
+#endif
     switch (GET_MSG(msg))
     {
-    case kC_COMMAND:
+    case kC_COMMAND:  // 1
         return ProcessMessageCommand(GET_SUBMSG(msg), mp1, mp2);
 
-    case kC_TEXTVIEW:
+    case kC_TEXTVIEW: // 9
         return ProcessMessageTextview(GET_SUBMSG(msg), mp1, mp2);
 
-    case kC_USER:
+    case kC_USER:     // 1001
         return ProcessMessageUser(GET_SUBMSG(msg), mp1, mp2);
     }
@@ -1387,12 +1393,17 @@
     gLog << dbg << "MStatusDisplay is on heap: " << (int)IsOnHeap() << endl;
 
-    if (TestBit(kExitLoopOnExit))
+    if (TestBit(kExitLoopOnExit) || TestBit(kExitLoopOnClose))
+    {
+        gLog << dbg << "CloseWindow() calling ExitLoop." << endl;
         gSystem->ExitLoop();
-    if (TestBit(kExitLoopOnClose))
-        gSystem->ExitLoop();
+    }
 
     if (fIsLocked<=0 && IsOnHeap())
+    {
+        gLog << dbg << "delete MStatusDisplay;" << endl;
         delete this;
+    }
     fStatus = kFileExit;
+    gLog << dbg << "MStatusDisplay.fStatus=kFileExit;" << endl;
 }
 
@@ -2117,14 +2128,14 @@
      */
 
-    //Bool_t wchanged = w!=GetWidth();
+    Bool_t wchanged = w!=GetWidth();
     Bool_t hchanged = h!=GetHeight();
-    /*
+
     if (!wchanged && !hchanged)
     {
         Layout();
         // FIXME: Make sure that this doesn't result in endless loops.
-        // return kTRUE;
-    }
-    */
+        return kTRUE;
+    }
+
 
     if (GetWidth()==1 && GetHeight()==1)
@@ -2149,4 +2160,12 @@
 Bool_t MStatusDisplay::HandleEvent(Event_t *event)
 {
+#if ROOT_VERSION_CODE == ROOT_VERSION(3,05,07)
+    // Strange... crashes on the LP machines...
+    if (event->fType==kClientMessage)
+        if (event->fHandle == gROOT_MESSAGE)
+            if (event->fUser[0]==264 && event->fUser[1] == 0 && event->fUser[2]==0)
+                return kTRUE;
+#endif
+
     Bool_t rc = TGMainFrame::HandleEvent(event);
 
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 2562)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 2563)
@@ -56,9 +56,11 @@
     enum
     {
-        kExitLoopOnExit  = BIT(14),
-        kExitLoopOnClose = BIT(15)
+        // TGMainFrame::kDontCallClose = BIT(14)
+        kExitLoopOnExit  = BIT(15),
+        kExitLoopOnClose = BIT(16)
      };
 
 protected:
+    MLog             *fLog;
     MGList           *fList;
     TGCompositeFrame *fUserFrame;
@@ -80,5 +82,4 @@
     TString fPrinter;
 
-    MLog *fLog;
     Int_t fLogIdx;
     TTimer fLogTimer;
@@ -179,4 +180,6 @@
      void UnLock() { if (fIsLocked>0) fIsLocked--; }
 
+     void Reset();
+
      Bool_t CheckTabForCanvas(int num) const;
 
Index: trunk/MagicSoft/Mars/mfilter/MFRealTimePeriod.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFRealTimePeriod.h	(revision 2562)
+++ trunk/MagicSoft/Mars/mfilter/MFRealTimePeriod.h	(revision 2563)
@@ -21,4 +21,6 @@
     }
 
+    void SetTime(UInt_t millis) { fMilliSec = millis; }
+
     Int_t Process();
     Bool_t IsExpressionTrue() const { return fResult; }
Index: trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 2562)
+++ trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 2563)
@@ -124,9 +124,9 @@
     if (!evt)
     {
-        *fLog << err << dbginf << "No MCamEvent found..." << endl;
+        *fLog << err << dbginf << "Got no MCamEvent as argument of Fill()..." << endl;
         return kFALSE;
     }
     fSum->AddCamContent(*evt, fType);
-
+    fRms->SetCamContent(*fSum, 1);
     return kTRUE;
 }
@@ -138,5 +138,5 @@
 Bool_t MHCamEvent::Finalize()
 {
-    fRms->AddCamContent(*fSum, 1);
+    //fRms->AddCamContent(*fSum, 1);
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2562)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2563)
@@ -299,5 +299,5 @@
 {
     if (fMinimum != -1111)
-        return Profile(fMinimum);
+        return fMinimum;
 
     if (fNcells<=1)
@@ -329,5 +329,5 @@
 {
     if (fMaximum!=-1111)
-        return Profile(fMaximum);
+        return fMaximum;
 
     if (fNcells<=1)
@@ -359,14 +359,23 @@
 // To draw a camera into its own pad do something like:
 //
-// MGeomCamMagic m;
-// MHCamera *d=new MHCamera(m);
-//
-// TCanvas *c = new TCanvas;
-// c->Divide(2,1);
-// c->cd(1);
-//
-// d->FillRandom();
-// d->Draw();
-// d->SetBit(kCanDelete);
+//   MGeomCamMagic m;
+//   MHCamera *d=new MHCamera(m);
+//
+//   TCanvas *c = new TCanvas;
+//   c->Divide(2,1);
+//   c->cd(1);
+//
+//   d->FillRandom();
+//   d->Draw();
+//   d->SetBit(kCanDelete);
+//
+// There are several drawing options:
+//   'hist'        Draw as a standard TH1 histogram (value vs. pixel index)
+//   'box'         Draw hexagons which size is in respect to its contents
+//   'nocol'       Leave the 'boxed' hexagons empty
+//   'pixelindex'  Display the pixel index in each pixel
+//   'sectorindex' Display the sector index in each pixel
+//   'content'     Display the relative content aligned to GetMaximum() and
+//                 GeMinimum() ((val-min)/(max-min))
 //
 void MHCamera::Draw(Option_t *option)
@@ -570,7 +579,9 @@
 
     if (opt.Contains("pixelindex"))
-        PaintIndices(kFALSE);
+        PaintIndices(0);
     if (opt.Contains("sectorindex"))
-        PaintIndices(kTRUE);
+        PaintIndices(1);
+    if (opt.Contains("content"))
+        PaintIndices(2);
 }
 
@@ -632,7 +643,13 @@
 }
 
-void MHCamera::PaintIndices(Bool_t sector)
+void MHCamera::PaintIndices(Int_t type)
 {
     if (fNcells<=1)
+        return;
+
+    const Double_t min = GetMinimum();
+    const Double_t max = GetMaximum();
+
+    if (type==2 && max==min)
         return;
 
@@ -646,5 +663,10 @@
 
         TString num;
-        num += sector ? h.GetSector() : i;
+        switch (type)
+        {
+        case 0: num += i; break;
+        case 1: num += h.GetSector(); break;
+        case 2: num += (Int_t)((fArray[i+1]-min)/(max-min)); break;
+        }
 
         txt.SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius()/1.05);
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2562)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2563)
@@ -30,5 +30,5 @@
 public:
     enum {
-        kProfile  = BIT(18),
+        kProfile  = BIT(18), // FIXME: When changing change max/min!
         kFreezed  = BIT(19),
         kNoLegend = BIT(20)
@@ -59,5 +59,5 @@
     Int_t GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog);
 
-    void  PaintIndices(Bool_t sector);
+    void  PaintIndices(Int_t type);
     void  Update(Bool_t islog, Bool_t isbox, Bool_t iscol);
     void  UpdateLegend(Float_t min, Float_t max, Bool_t islog);
Index: trunk/MagicSoft/Mars/mhist/MHEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHEvent.cc	(revision 2562)
+++ trunk/MagicSoft/Mars/mhist/MHEvent.cc	(revision 2563)
@@ -200,5 +200,5 @@
     {
         s += "Run #";
-        s += fRawRunHeader->GetNumEvents();
+        s += fRawRunHeader->GetRunNumber();
     }
 
Index: trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc	(revision 2562)
+++ trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc	(revision 2563)
@@ -126,5 +126,5 @@
     if (!evt)
     {
-        *fLog << err << dbginf << "No MCamEvent found..." << endl;
+        *fLog << err << dbginf << "Got no MCamEvent as argument of Fill()..." << endl;
         return kFALSE;
     }
Index: trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc	(revision 2562)
+++ trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc	(revision 2563)
@@ -39,5 +39,5 @@
 //   MRawEvtData
 //   MRawCrateArray
-//   MRawEvtTime
+//   MTime
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -147,5 +147,5 @@
 //   MRawEvtData <output>     if not found it is created
 //   MRawCrateArray <output>  if not found it is created
-//   MRawEvtTime <output>     if not found it is created (MTime)
+//   MTime <output>           if not found it is created
 //
 // If all containers are found or created the run header is read from the
@@ -180,6 +180,6 @@
         return kFALSE;
 
-    fRawEvtTime = (MTime*)pList->FindCreateObj("MTime", "MRawEvtTime");
-    if (!fRawEvtTime)
+    fTime = (MTime*)pList->FindCreateObj("MTime");
+    if (!fTime)
         return kTRUE;
 
@@ -268,10 +268,13 @@
 
     if (atoi(size)==fRawRunHeader->GetNumTotalBytes())
+    {
+        *fLog << dbg << "Event contains only run header information... skipped." << endl;
         return kCONTINUE;
+    }
 
     //
     // Give the run header information to the 'sub-classes'
     //
-    fRawEvtHeader->Init(fRawRunHeader, fRawEvtTime);
+    fRawEvtHeader->Init(fRawRunHeader, fTime);
     fRawEvtData  ->Init(fRawRunHeader);
 
@@ -317,5 +320,8 @@
     //
     if (fEvtNumber==fRawEvtHeader->GetDAQEvtNumber())
+    {
+        *fLog << dbg << "Event number #" << dec << fEvtNumber << " didn't change... skipped." << endl;
         return kCONTINUE;
+    }
 
     fEvtNumber=fRawEvtHeader->GetDAQEvtNumber();
Index: trunk/MagicSoft/Mars/mraw/MRawSocketRead.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawSocketRead.h	(revision 2562)
+++ trunk/MagicSoft/Mars/mraw/MRawSocketRead.h	(revision 2563)
@@ -21,5 +21,5 @@
     MRawEvtData    *fRawEvtData;    // raw evt header infomation container to fill from file
     MRawCrateArray *fRawCrateArray; // crate information array container to fill from file
-    MTime          *fRawEvtTime;    // raw evt time information container to fill from file
+    MTime          *fTime;          // raw evt time information container to fill from file
 
     MReadSocket    *fIn;            //! buffered input stream (file to read from)
Index: trunk/MagicSoft/Mars/star.cc
===================================================================
--- trunk/MagicSoft/Mars/star.cc	(revision 2562)
+++ trunk/MagicSoft/Mars/star.cc	(revision 2563)
@@ -52,5 +52,5 @@
     gLog << all << endl;
     gLog << "Sorry the usage is:" << endl;
-    gLog << "   star [-a0] [-vn] [-cn] inputfile[.roor] outputfile[.root]" << endl << endl;
+    gLog << "   star [-a0] [-vn] [-cn] inputfile[.root] outputfile[.root]" << endl << endl;
     gLog << "     input file: Merpped or MC root file." << endl;
     gLog << "     ouput file: Star-file (image parameter file)" << endl;
