Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2135)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2136)
@@ -42,4 +42,8 @@
    * mreflector, mreflector/Makefile, mreflector/ReflectorLinkDef.h,
      mreflector/MRflEvtData.[h,cc], mreflector/MRflSinglePhoton.[h,cc]:
+     mreflector/MRflEvtHeader.[h,cc], mreflector/MRflRunHeader.[h,cc]:
+     - added
+
+   * macros/readRfl.C:
      - added
 
Index: /trunk/MagicSoft/Mars/macros/readRfl.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/readRfl.C	(revision 2136)
+++ /trunk/MagicSoft/Mars/macros/readRfl.C	(revision 2136)
@@ -0,0 +1,99 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+Bool_t HandleInput()
+{
+    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+    while (1)
+    {
+        //
+        // While reading the input process gui events asynchronously
+        //
+        timer.TurnOn();
+        TString input = Getline("Type 'q' to exit, <return> to go on: ");
+        timer.TurnOff();
+
+        if (input=="q\n")
+            return kFALSE;
+
+        if (input=="\n")
+            return kTRUE;
+    };
+
+    return kFALSE;
+}
+
+Bool_t JumpTo(MTaskList &tlist, MReadRflFile &read, int runno, int evtno)
+{
+    if (runno<0 || evtno<0)
+        return tlist.Process();
+
+    return read.SearchFor(runno, evtno);
+}
+
+void readRfl(int runno=-1, int evtno=-1, const char *fname="Gamma_zbin1_0_7_1140_w0.rfl")
+{
+    MParList plist;
+
+    MGeomCamMagic geomcam;
+    MRflEvtData   event;
+    MRflEvtHeader evthead;
+    MRflRunHeader runhead;
+    MTaskList     tlist;
+
+    plist.AddToList(&geomcam);
+    plist.AddToList(&event);
+    plist.AddToList(&evthead);
+    plist.AddToList(&runhead);
+    plist.AddToList(&tlist);
+
+    MReadRflFile read(fname);
+    tlist.AddToList(&read);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.PreProcess())
+        return;
+
+    MCamDisplay display(&geomcam);
+    display.Draw();
+
+    while (JumpTo(tlist, read, runno, evtno))
+    {
+        runno = -1;
+
+        cout << "Run #" << runhead.GetRunNumber() << "   ";
+        cout << "Event #" << evthead.GetEvtNumber() << endl;
+
+        display.FillRflEvent(event);
+        display.ShowRflEvent(&event);
+        gPad->Modified();
+        gPad->Update();
+        if (!HandleInput())
+            break;
+    } 
+
+    evtloop.PostProcess();
+}
Index: /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 2135)
+++ /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 2136)
@@ -914,24 +914,18 @@
     // read in the number of cerenkov photons and add the 'new' pixel
     // too the list with it's id, number of photons and error
-    //
-    fNphot->InitSize(iMAXNUMPIX);
-
     // number of photoelectrons measured in each pixel only the
     // actual number of pixels (outputpars.inumpixels) is written out
     // short spixsig_10thphot[iMAXNUMPIX];
-    //*fLog << "spixsig_10thphot : " << endl;
+    //
     for (Int_t i=0; i<iMAXNUMPIX; i++)
     {
-      //*fLog << event.spixsig_10thphot[i] << " ";
-
-      // next 2 statements commented out by WW
-      //if (event.spixsig_10thphot[i]==0)
-      //      continue;
+        // next 2 statements commented out by WW
+        //if (event.spixsig_10thphot[i]==0)
+        //      continue;
 
         fNphot->AddPixel(i, 0.1*event.spixsig_10thphot[i],
                          (*fPedest)[i].GetMeanRms());
     }
-    //*fLog << "" << endl;
-
+    fNphot->FixSize();
     fNphot->SetReadyToSave();
 
Index: /trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc	(revision 2135)
+++ /trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc	(revision 2136)
@@ -40,4 +40,6 @@
 #include "MParList.h"
 #include "MRflEvtData.h"
+#include "MRflEvtHeader.h"
+#include "MRflRunHeader.h"
 
 #include "MLog.h"
@@ -69,10 +71,18 @@
         RflEventHeader_old revth;
         fIn->read(&revth, sizeof(RflEventHeader_old));
+        fEvtHeader->SetEvtNumber(revth.EvtNumber);
+//        *fLog << "Event Number: " << revth.EvtNumber;
+//        *fLog << "  Primary ID: " << revth.PrimaryID;
+//        *fLog << "  Run Number: " << revth.RunNumber << endl;
         return (bool)*fIn;
     }
     else
     {
-        RflEventHeader revth_new;
-        fIn->read(&revth_new, sizeof(RflEventHeader));
+        RflEventHeader revth;
+        fIn->read(&revth, sizeof(RflEventHeader));
+        fEvtHeader->SetEvtNumber(revth.EvtNumber);
+//        *fLog << "Event Number: " << revth.EvtNumber;
+//        *fLog << "  Primary ID: " << revth.PrimaryID;
+//        *fLog << "  Run Number: " << revth.RunNumber << endl;
         return (bool)*fIn;
     }
@@ -84,6 +94,6 @@
     kStartOfRun,
     kEndOfRun,
-    kStartOfEvt,
-    kEndOfEvt,
+    kStartOfEvtData,
+    kEndOfEvtData,
     kUndefined
 };
@@ -107,7 +117,7 @@
         return kStartOfRun;
     if (FlagIsA(flag, FLAG_END_OF_EVENT))
-        return kEndOfEvt;
+        return kEndOfEvtData;
     if (FlagIsA(flag, FLAG_START_OF_EVENT))
-        return kStartOfEvt;
+        return kStartOfEvtData;
 
     return kUndefined;
@@ -134,5 +144,5 @@
             break;
 
-        MRflSinglePhoton &ph = fEvt->GetNewPhoton();
+        MRflSinglePhoton &ph = fEvtData->GetNewPhoton();
         ph.SetXY(data.x*10, data.y*10);
         ph.SetCosUV(data.u, data.v);
@@ -142,5 +152,5 @@
     }
 
-    fEvt->FixSize();
+    fEvtData->FixSize();
     return rc;
 }
@@ -172,4 +182,11 @@
             {
                 *fLog << inf << "FIXME: Call ReInit" << endl;
+
+                fRunHeader->SetRunNumber(rrunh.RunNumber);
+                *fLog << underline << "RunHeader:" << endl;
+                *fLog << " Run Number:   " << rrunh.RunNumber << endl;
+                *fLog << " Date:         " << rrunh.date << endl;
+                *fLog << " Corsika Ver.: " << rrunh.Corsika_version << endl;
+
                 break;
             }
@@ -180,5 +197,5 @@
         return kUndefined;
 
-    case kStartOfEvt:
+    case kStartOfEvtData:
     case kEndOfRun:
         break;
@@ -217,5 +234,5 @@
             continue;
 
-        case kStartOfEvt:
+        case kStartOfEvtData:
             break;
         }
@@ -231,6 +248,14 @@
 Bool_t MReadRflFile::PreProcess(MParList *plist)
 {
-    fEvt=(MRflEvtData*)plist->FindCreateObj("MRflEvtData");
-    if (!fEvt)
+    fEvtData=(MRflEvtData*)plist->FindCreateObj("MRflEvtData");
+    if (!fEvtData)
+        return kFALSE;
+
+    fEvtHeader=(MRflEvtHeader*)plist->FindCreateObj("MRflEvtHeader");
+    if (!fEvtHeader)
+        return kFALSE;
+
+    fRunHeader=(MRflRunHeader*)plist->FindCreateObj("MRflRunHeader");
+    if (!fRunHeader)
         return kFALSE;
 
@@ -334,10 +359,4 @@
 }
 
-
-Bool_t MReadRflFile::PostProcess()
-{
-    return kTRUE;
-}
-
 // --------------------------------------------------------------------------
 //
@@ -404,2 +423,23 @@
 }
 
+
+Bool_t MReadRflFile::SearchFor(Int_t runno, Int_t eventno)
+{
+    if (!fEvtHeader)
+        return kFALSE;
+
+    fNumFile = 0;
+    if (!OpenNextFile())
+        return kFALSE;
+
+    while (1)
+    {
+        fEvtData->Reset();
+        if (!Process())
+            return kFALSE;
+
+        if (fEvtHeader->GetEvtNumber()==eventno &&
+            fRunHeader->GetRunNumber()==runno)
+            return kTRUE;
+    }
+}
Index: /trunk/MagicSoft/Mars/mfileio/MReadRflFile.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MReadRflFile.h	(revision 2135)
+++ /trunk/MagicSoft/Mars/mfileio/MReadRflFile.h	(revision 2136)
@@ -12,4 +12,6 @@
 class TList;
 class MRflEvtData;
+class MRflEvtHeader;
+class MRflRunHeader;
 
 class MReadRflFile : public MRead
@@ -19,5 +21,7 @@
     TList    *fFileNames;   // Array which stores the \0-terminated filenames
 
-    MRflEvtData *fEvt;        //!
+    MRflEvtData *fEvtData;        //!
+    MRflEvtHeader *fEvtHeader;
+    MRflRunHeader *fRunHeader;
 
     UInt_t fNumFile;
@@ -36,5 +40,4 @@
     Bool_t PreProcess(MParList *pList);
     Bool_t Process();
-    Bool_t PostProcess();
 
 public:
@@ -50,4 +53,6 @@
     UInt_t GetEntries() { return fEntries; }
 
+    Bool_t SearchFor(Int_t runno, Int_t eventno);
+
     ClassDef(MReadRflFile, 0) // Reads reflector files
 };
Index: /trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.cc
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.cc	(revision 2136)
+++ /trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.cc	(revision 2136)
@@ -0,0 +1,41 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRflEvtHeader
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRflEvtHeader.h"
+
+ClassImp(MRflEvtHeader);
+
+// --------------------------------------------------------------------------
+//
+MRflEvtHeader::MRflEvtHeader(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MRflEvtHeader";
+    fTitle = title ? title : "Event header information from a reflector event";
+}
+
Index: /trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.h
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.h	(revision 2136)
+++ /trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.h	(revision 2136)
@@ -0,0 +1,21 @@
+#ifndef MARS_MRflEvtHeader
+#define MARS_MRflEvtHeader
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MRflEvtHeader : public MParContainer
+{
+    Int_t fEvtNumber;
+
+public:
+    MRflEvtHeader(const char *name=NULL, const char *title=NULL);
+
+    Int_t GetEvtNumber() const { return fEvtNumber; }
+    void SetEvtNumber(Int_t n) { fEvtNumber = n; }
+
+    ClassDef(MRflEvtHeader, 0) // Header of an event from the reflector program
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mreflector/MRflRunHeader.cc
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/MRflRunHeader.cc	(revision 2136)
+++ /trunk/MagicSoft/Mars/mreflector/MRflRunHeader.cc	(revision 2136)
@@ -0,0 +1,41 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRflRunHeader
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRflRunHeader.h"
+
+ClassImp(MRflRunHeader);
+
+// --------------------------------------------------------------------------
+//
+MRflRunHeader::MRflRunHeader(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MRflRunHeader";
+    fTitle = title ? title : "Run header information from a reflector event";
+}
+
Index: /trunk/MagicSoft/Mars/mreflector/MRflRunHeader.h
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/MRflRunHeader.h	(revision 2136)
+++ /trunk/MagicSoft/Mars/mreflector/MRflRunHeader.h	(revision 2136)
@@ -0,0 +1,21 @@
+#ifndef MARS_MRflRunHeader
+#define MARS_MRflRunHeader
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MRflRunHeader : public MParContainer
+{
+    Int_t fRunNumber;
+
+public:
+    MRflRunHeader(const char *name=NULL, const char *title=NULL);
+
+    Int_t GetRunNumber() const { return fRunNumber; }
+    void SetRunNumber(Int_t n) { fRunNumber = n; }
+
+    ClassDef(MRflRunHeader, 0) // Header of an run from the reflector program
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mreflector/ReflectorLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/ReflectorLinkDef.h	(revision 2135)
+++ /trunk/MagicSoft/Mars/mreflector/ReflectorLinkDef.h	(revision 2136)
@@ -6,4 +6,6 @@
 
 #pragma link C++ class MRflEvtData+;
+#pragma link C++ class MRflEvtHeader+;
+#pragma link C++ class MRflRunHeader+;
 #pragma link C++ class MRflSinglePhoton+;
 
