Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2134)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2135)
@@ -1,3 +1,48 @@
                                                  -*-*- END OF LINE -*-*-
+ 2003/05/23: Thomas Bretz
+
+   * Makefile:
+     - added mreflector
+     
+   * manalysis/MCerPhotAnal.cc, manalysis/MCerPhotCalc.cc:
+     - use FixSize instead of InitSize
+     
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - replaced InitSize by FixSize (seems to be more logical)
+     
+   * manalysis/MMcPedestalNSBAdd.cc:
+     - replaced GetR by GetPixRatio
+
+   * manalysis/MPedestalCam.cc:
+     - replaced GetEntries by GetEntriesFast
+     
+   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
+     - added MReadRflFile
+
+   * mgeom/MGeomCam.[h,cc], mgeom/MGeomPix.[h,cc], 
+     mgeom/MGeomCamMagic.[h,cc]:
+     - replaced R by D
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added TClonesArray to display reflector events
+     - added FillRflEvent
+     - added ShowRflEvent
+     - adapted Paint function
+     
+   * mgui/MHexagon.[h,cc]:
+     - replaced GetR by GetD
+     - added DistanceToPrimitive (capital T)
+     
+   * mgui/Makefile:
+     - added mreflector
+
+   * mfileio/MReadRflFile.[h,cc]:
+     - added
+
+   * mreflector, mreflector/Makefile, mreflector/ReflectorLinkDef.h,
+     mreflector/MRflEvtData.[h,cc], mreflector/MRflSinglePhoton.[h,cc]:
+     - added
+
+
 
  2003/05/22: Abelardo Moralejo
@@ -12,4 +57,6 @@
        as well (in theta, phi or whatever).
 
+
+
  2003/05/22: Wolfgang Wittek
 
@@ -20,4 +67,5 @@
        original Theta is stored in the container "ThetaOrig"
        the discretized Theta is stored in MMcEvt.fTelescopeTheta
+
 
 
Index: /trunk/MagicSoft/Mars/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/Makefile	(revision 2134)
+++ /trunk/MagicSoft/Mars/Makefile	(revision 2135)
@@ -39,4 +39,5 @@
           meventdisp \
           mfileio \
+          mreflector \
           mhist \
           mdatacheck \
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 2134)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 2135)
@@ -65,4 +65,8 @@
        + MHillasExt now derives from MParContainer instead of MHillas
      --> Files written with the old definition are more or less unreadable
+
+   - implemented reading of reflector files
+
+   - implemented displaying data from reflectro files in the camera
 
 
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal.cc	(revision 2135)
@@ -118,5 +118,5 @@
 Bool_t MCerPhotAnal::Process()
 {
-    fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
+    //fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
 
     MRawEvtPixelIter pixel(fRawEvt);
@@ -201,4 +201,5 @@
     }
 
+    fCerPhotEvt->FixSize();
     fCerPhotEvt->SetReadyToSave();
 
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 2135)
@@ -164,5 +164,5 @@
 Bool_t MCerPhotCalc::Process()
 {
-    fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
+    //fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
 
     MRawEvtPixelIter pixel(fRawEvt);
@@ -212,4 +212,5 @@
     }
 
+    fCerPhotEvt->FixSize();
     fCerPhotEvt->SetReadyToSave();
 
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 2135)
@@ -75,5 +75,13 @@
 {
     fNumPixels = 0;
-    fPixels->Delete();
+    //fPixels->Delete();
+}
+
+void MCerPhotEvt::FixSize()
+{
+    if (fPixels->GetEntriesFast() == (Int_t)fNumPixels)
+        return;
+
+    fPixels->ExpandCreateFast(fNumPixels);
 }
 
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 2134)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 2135)
@@ -23,5 +23,5 @@
 
     UInt_t GetNumPixels() const { return fNumPixels; }
-    void   InitSize(UInt_t num) { fPixels->Expand(num); }
+    //void   InitSize(UInt_t num) { fPixels->Expand(num); }
 
     void   AddPixel(Int_t id, Float_t nph, Float_t er)
@@ -29,4 +29,6 @@
         new ((*fPixels)[fNumPixels++]) MCerPhotPix(id, nph, er);
     }
+
+    void FixSize();
 
     //Bool_t  AddEvent(const MCerPhotEvt &evt);
Index: /trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 2135)
@@ -209,17 +209,13 @@
     fPedCam->InitSize(num);
 
-    const Float_t size0 = (*fGeom)[0].GetR() * (*fGeom)[0].GetR();
-
     for (int i=0; i<num; i++)
     {
-        MPedestalPix   &pix     = (*fPedCam)[i];
-	const MGeomPix &pixgeom = (*fGeom)[i];
+        MPedestalPix &pix    = (*fPedCam)[i];
 
         const Float_t pedrms = pix.GetSigma();
-        const Float_t size   = pixgeom.GetR()*pixgeom.GetR()/size0;
-
+        const Float_t ratio  = fGeom->GetPixRatio(i);
         const Float_t ampl   = fFadc->GetAmplitud();
 
-	pix.SetSigma(sqrt(pedrms*pedrms + dnsbpix*ampl*ampl*size));
+	pix.SetSigma(sqrt(pedrms*pedrms + dnsbpix*ampl*ampl*ratio));
     }
 
Index: /trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2135)
@@ -82,5 +82,5 @@
 Int_t MPedestalCam::GetSize() const
 {
-    return fArray->GetEntries();
+    return fArray->GetEntriesFast();
 }
 
Index: /trunk/MagicSoft/Mars/mfileio/structures_rfl.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/structures_rfl.h	(revision 2135)
+++ /trunk/MagicSoft/Mars/mfileio/structures_rfl.h	(revision 2135)
@@ -0,0 +1,262 @@
+#ifndef __RFL_HEADER__
+#define __RFL_HEADER__
+
+
+/*  Event header of reflector files ver <= 0.5  */ 
+typedef struct
+{   float	EvtNumber;
+    float	PrimaryID;
+    float	Etotal;   
+    float	Thick0;   
+    float	FirstTarget;
+    float	zFirstInt;
+    float	p[3];     
+    float	Theta; 
+    float	Phi; 
+
+    float	NumRndSeq;
+    float	RndData[10][3];
+  
+    float	RunNumber;
+    float	DateRun;
+    float	Corsika_version;
+
+    float	NumObsLev;  /* Should be 1 for MAGIC simulation */
+    float	HeightLev;  /* Observation Level */
+
+    /* Changed meaning of next 9 variables. June 2002, A.Moralejo: */
+    float       num_mirrors;
+    float       mean_reflectivity;
+    float       longi_Nmax;
+    float       longi_t0;
+    float       longi_tmax;
+    float       longi_a;
+    float       longi_b;
+    float       longi_c;
+    float       longi_chi2;
+
+    float	SlopeSpec;
+    float	ELowLim;   
+    float	EUppLim;   
+
+    float	ThetaMin;
+    float	ThetaMax;
+    float	PhiMin;
+    float	PhiMax;
+
+    float	CWaveLower;       
+    float	CWaveUpper;       
+    float	CorePos[2][20];   
+    float	TimeFirst;
+    float	TimeLast;
+
+    /* AM, 23/05/2002: Changed meaning of following
+     * three variables (which were unused before): 
+     */
+    float	telescopePhi;    /* rad */
+    float	telescopeTheta;  /* rad */
+  
+    float	ViewConeRadius; /* Degrees.
+				 * Radius of "view cone" when the primaries'
+				 * directions generated by Corsika lie within
+				 * a cone around a fixed direction. This is
+				 * only possible with Corsika>6 versions. In
+				 * that case, PhiMin=PhiMax  and 
+				 * ThetaMin=ThetaMax (also in this header) 
+				 * indicate the axis of this cone.   
+				 * If ViewConeRadius==0, it means that
+				 * the VIEWCONE option was not used.
+				 */
+
+
+    float	CORSIKAPhs;	/*  Original photons written by Corsika	*/
+    float	AtmAbsPhs;	/*  Photons absorbed by the atmosphere	*/
+    float	MirrAbsPhs;	/*  Photons absorbed by the mirror	*/
+    float	OutOfMirrPhs;	/*  Photons outside the mirror		*/
+    float	BlackSpotPhs;	/*  Photons lost in the "black spot"	*/
+    float	OutOfChamPhs;	/*  Photons outside the camera		*/
+    float	CPhotons;	/*  Photons reaching the camera         */
+
+}   RflEventHeader_old;
+
+
+/* Reflector files run header (same as CORSIKA's cer files run header): */
+
+typedef struct
+{   char RUNH[4];
+    float RunNumber;
+    float date;
+    float Corsika_version;
+    float NumObsLev;
+    float HeightLev[10];
+    float SlopeSpec;  /* Slope of primaries' energy spectrum */
+    float ELowLim;  
+    float EUppLim;    /* Limits of energy range for generation */
+    float EGS4_flag;
+    float NKG_flag;
+    float Ecutoffh;  
+    float Ecutoffm;  
+    float Ecutoffe;  
+    float Ecutoffg;  
+    /* Physical constants and interaction flags (see CORSIKA manual): */
+    float C[50];
+    float wobble_mode;
+    float atmospheric_model;
+    float dummy1[18]; /* not used */
+    float CKA[40];
+    float CETA[5];
+    float CSTRBA[11];
+    float dummy2[104]; /* not used */
+    float AATM[5];
+    float BATM[5];
+    float CATM[5];
+    float NFL[4];
+
+}   RflRunHeader;
+
+
+/*  Event header of reflector_0.6 files: */ 
+
+typedef struct			
+{   char	EVTH[4];
+    float	EvtNumber;
+    float	PrimaryID;
+    float	Etotal;   
+    float	Thick0;   
+    float	FirstTarget;
+    float	zFirstInt;
+    float	p[3];     
+    float	Theta; 
+    float	Phi; 
+
+    float	NumRndSeq;
+    float	RndData[10][3];
+  
+    float	RunNumber;
+    float	DateRun;
+    float	Corsika_version;
+
+    float	NumObsLev;
+    float	HeightLev[10]; 
+
+    float	SlopeSpec;
+    float	ELowLim;   
+    float	EUppLim;   
+
+    float	Ecutoffh;  
+    float	Ecutoffm;  
+    float	Ecutoffe;  
+    float	Ecutoffg;  
+
+    float	NFLAIN;
+    float	NFLDIF;
+    float	NFLPI0;
+    float	NFLPIF;
+    float	NFLCHE;
+    float	NFRAGM; 
+ 
+    float	Bx;
+    float	By;
+  
+    float	EGS4yn;
+    float	NKGyn;
+    float	GHEISHAyn;
+    float	VENUSyn;
+    float	CERENKOVyn;
+    float	NEUTRINOyn;
+    float	HORIZONTyn;
+    float	COMPUTER;
+
+    float	ThetaMin;
+    float	ThetaMax;
+    float	PhiMin;
+    float	PhiMax;
+
+    float	CBunchSize;
+    float	CDetInX,CDetInY;
+    float	CSpacInX,CSpacInY;
+    float	CLenInX,CLenInY;
+    float	COutput;
+
+    float	AngleNorthX;
+    float	MuonInfo;
+
+    float	StepLength;
+    float	CWaveLower;       
+    float	CWaveUpper;       
+    float	Multipl;       
+    float	CorePos[2][20];   
+    float       SIBYLL[2];
+    float       QGSJET[2];
+    float       DPMJET[2];
+    float       VENUS_cross;
+    float       mu_mult_scat;
+    float       NKG_range;
+    float       EFRCTHN[2];
+    float       WMAX[2];
+    float       rthin_rmax;
+
+    float       viewcone_angles[2]; 
+    /* (degrees) Inner and outer angles in 
+     * Corsika's VIEWCONE option. This is
+     * only possible with Corsika>6 versions. In
+     * that case, PhiMin=PhiMax  and 
+     * ThetaMin=ThetaMax (also in this header) 
+     * indicate the axis of this cone.   
+     */
+
+    /* ^^^ Up to here, the info from the CORSIKA event header. */
+
+    /* Telescope orientation: */
+    float	telescopePhi;    /* rad */
+    float	telescopeTheta;  /* rad */
+
+    /* Time of first and last photon: */
+    float	TimeFirst;
+    float	TimeLast;
+
+    /* 6 parameters and chi2 of the NKG fit to the longitudinal 
+     * particle distribution (see CORSIKA manual for explanation): 
+     */
+    float       longi_Nmax;
+    float       longi_t0;
+    float       longi_tmax;
+    float       longi_a;
+    float       longi_b;
+    float       longi_c;
+    float       longi_chi2;
+
+    /* Now the photon statistics of the event: */
+    float	CORSIKAPhs;	/*  Original photons written by Corsika	*/
+    float	AtmAbsPhs;	/*  Photons absorbed by the atmosphere	*/
+    float	MirrAbsPhs;	/*  Photons absorbed by the mirror	*/
+    float	OutOfMirrPhs;	/*  Photons outside the mirror		*/
+    float	BlackSpotPhs;	/*  Photons lost in the "black spot"	*/
+    float	OutOfChamPhs;	/*  Photons outside the camera		*/
+    float	CPhotons;	/*  Photons reaching the camera         */
+ 
+    /* Now follow the fraction of photons reaching the camera produced by
+     * electrons, muons and other particles respectively: 
+     */ 
+    float       elec_cph_fraction;
+    float       muon_cph_fraction;
+    float       other_cph_fraction;
+
+    float       dummy[7];      /* not used */
+}   RflEventHeader;
+
+/*Photons data estructure*/
+typedef struct
+{   float w,                    /*  cphoton wavelength (nm)             */
+      x, y,			/*  (camera) imp. point (cm)            */
+      u, v,			/*  direction cosines                   */
+      t,			/*  arrival time (ns)                   */
+      h,			/*  production height (cm)              */
+      phi;			/*  (camera) inc. angle (rad)           */
+    }   cphoton;
+
+#endif
+
+
+
+
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 2135)
@@ -102,7 +102,7 @@
         const Float_t x = pix.GetX();
         const Float_t y = pix.GetY();
-        const Float_t r = pix.GetR();
+        const Float_t d = pix.GetD();
 
-        const Float_t maxr = sqrt(x*x+y*y) + r;
+        const Float_t maxr = sqrt(x*x+y*y) + d;
 
         if (maxr>fMaxRadius)
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 2135)
@@ -42,6 +42,4 @@
     MGeomPix &operator[](Int_t i) const { return *(MGeomPix*)fPixels->UncheckedAt(i); }
 
-
-
     virtual void Print(Option_t *opt=NULL) const;
 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc	(revision 2135)
@@ -222,5 +222,5 @@
     };
 
-    const Float_t rtemp[577] = {
+    const Float_t dtemp[577] = {
         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //   0
         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //   8
@@ -302,5 +302,5 @@
 
     for (UInt_t i=0; i<GetNumPixels(); i++)
-        (*this)[i].Set(xtemp[i], ytemp[i], rtemp[i]) ;
+        (*this)[i].Set(xtemp[i], ytemp[i], dtemp[i]) ;
 }
 
@@ -892,8 +892,8 @@
     };
 
-  for (Int_t i=0; i<577; i++)
-      (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
-                              nn[i][3], nn[i][4], nn[i][5]);
-
-  InitOuterRing();
+    for (Int_t i=0; i<577; i++)
+        (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
+                                nn[i][3], nn[i][4], nn[i][5]);
+
+    InitOuterRing();
 }
Index: /trunk/MagicSoft/Mars/mgeom/MGeomPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 2135)
@@ -52,5 +52,5 @@
 // Initializes one pixel
 //
-MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r) : fX(x), fY(y), fR(r)
+MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r) : fX(x), fY(y), fD(r)
 {
     //  default constructor
@@ -63,5 +63,5 @@
 Float_t MGeomPix::GetA() const
 {
-    return fR*fR*tan(60/kRad2Deg);
+    return fD*fD*tan(60/kRad2Deg);
 }
 
@@ -121,5 +121,5 @@
     *fLog << all << "MPixGeom:  x= " << fX
         << "  y= " << fY
-        << "  r= " << fR
+        << "  d= " << fD
         << endl ;
 }
Index: /trunk/MagicSoft/Mars/mgeom/MGeomPix.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 2135)
@@ -20,5 +20,5 @@
     Float_t fX;  // [mm] the x coordinate of the center
     Float_t fY;  // [mm] the y coordinate of the center
-    Float_t fR;  // [mm] the r coordinate of the pixel (dist between two parallel sides)
+    Float_t fD;  // [mm] the d coordinate of the pixel (dist between two parallel sides)
 
     Byte_t  fNumNeighbors; // number of valid neighbors
@@ -26,9 +26,9 @@
 
 public:
-    MGeomPix(Float_t x=0, Float_t y=0, Float_t r=0);
+    MGeomPix(Float_t x=0, Float_t y=0, Float_t d=0);
 
     void Print(Option_t *opt=NULL) const;
 
-    void Set(Float_t x, Float_t y, Float_t r) { fX=x; fY=y; fR=r; }
+    void Set(Float_t x, Float_t y, Float_t d) { fX=x; fY=y; fD=d; }
 
     void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
@@ -39,9 +39,9 @@
     void SetX(Float_t x) { fX = x; }
     void SetY(Float_t y) { fY = y; }
-    void SetR(Float_t r) { fR = r; }
+    void SetD(Float_t d) { fD = d; }
 
     Float_t GetX() const  { return fX; }
     Float_t GetY() const  { return fY; }
-    Float_t GetR() const  { return fR; }
+    Float_t GetD() const  { return fD; }
 
     Float_t GetA() const;
Index: /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 2135)
@@ -41,5 +41,7 @@
 #include <TLatex.h>
 #include <TStyle.h>
+#include <TMarker.h>
 #include <TCanvas.h>
+#include <TArrayF.h>
 #include <TClonesArray.h>
 
@@ -48,4 +50,6 @@
 
 #include "MGeomCam.h"
+
+#include "MRflEvtData.h"
 
 #include "MCerPhotPix.h"
@@ -99,4 +103,6 @@
     //    register BIT(8) as kNoContextMenu. If an object has this bit set it will
     //    not get an automatic context menu when clicked with the right mouse button.
+
+    fPhotons = new TClonesArray("TMarker", 0);
 
     //
@@ -180,8 +186,10 @@
     fLegend->Delete();
     fLegText->Delete();
+    fPhotons->Delete();
 
     delete fPixels;
     delete fLegend;
     delete fLegText;
+    delete fPhotons;
 
     delete fArrowX;
@@ -322,15 +330,6 @@
 
     //
-    // Paint primitives
-    //
-    for (UInt_t i=0; i<fNumPixels; i++)
-        (*this)[i].Paint();
-
-    for (Int_t i=0; i<kItemsLegend; i++)
-    {
-        GetBox(i)->Paint();
-        GetText(i)->Paint();
-    }
-
+    // Paint Legend
+    //
     fArrowX->Paint(">");
     fArrowY->Paint(">");
@@ -338,4 +337,12 @@
     fLegRadius->Paint();
     fLegDegree->Paint();
+
+    //
+    // Paint primitives (pixels, color legend, photons, ...)
+    //
+    { fPixels->ForEach(TObject, Paint)(); }
+    { fLegend->ForEach(TObject, Paint)(); }
+    { fLegText->ForEach(TObject, Paint)(); }
+    { fPhotons->ForEach(TObject, Paint)(); }
 }
 
@@ -671,4 +678,91 @@
 // ------------------------------------------------------------------------
 //
+// Show a reflector event. EMarkerStyle is defined in root/include/Gtypes.h
+// To remove the photons from the display call FillRflEvent(NULL)
+//
+void MCamDisplay::ShowRflEvent(const MRflEvtData *event, EMarkerStyle ms)
+{
+    const Int_t num = event ? event->GetNumPhotons() : 0;
+
+    fPhotons->ExpandCreate(num);
+    if (num < 1)
+        return;
+
+    Int_t i=num-1;
+    do
+    {
+        const MRflSinglePhoton &ph = event->GetPhoton(i);
+        TMarker &m = (TMarker&)*fPhotons->UncheckedAt(i);
+        m.SetX(ph.GetX());
+        m.SetY(ph.GetY());
+        m.SetMarkerStyle(ms);
+    } while (i--);
+}
+
+// ------------------------------------------------------------------------
+//
+// Fill a reflector event. Sums all pixels in each pixel as the
+// pixel contents.
+//
+// WARNING: Due to the estimation in DistanceToPrimitive and the
+//          calculation in pixels instead of x, y this is only a
+//          rough estimate.
+//
+void MCamDisplay::FillRflEvent(const MRflEvtData &event)
+{
+    //
+    // reset pixel colors to background color
+    //
+    Reset();
+
+    //
+    // sum the photons content in each pixel
+    //
+    const Int_t entries = event.GetNumPhotons();
+
+    TArrayF arr(fNumPixels);
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MRflSinglePhoton &ph = event.GetPhoton(i);
+
+        UInt_t id;
+        for (id=0; id<fNumPixels; id++)
+        {
+            if ((*this)[id].DistanceToPrimitive(ph.GetX(), ph.GetY())<0)
+                break;
+        }
+        if (id==fNumPixels)
+            continue;
+
+        arr[id] += 1;
+    }
+
+    //
+    // Scale with the area and determin maximum
+    //
+    Float_t max = 0;
+    for (UInt_t id=0; id<fNumPixels; id++)
+    {
+        arr[id] *= fGeomCam->GetPixRatio(id);
+        if (arr[id]>max)
+            max = arr[id];
+    }
+
+    //
+    // Update legend
+    //
+    if (fAutoScale)
+        UpdateLegend(0, max==0 ? 1 : max);
+
+    //
+    // Set color of pixels
+    //
+    for (UInt_t id=0; id<fNumPixels; id++)
+        if (arr[id]>0)
+            (*this)[id].SetFillColor(GetColor(arr[id], 0, max));
+}
+
+// ------------------------------------------------------------------------
+//
 // Reset the all pixel colors to a default value
 //
Index: /trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 2135)
@@ -4,4 +4,7 @@
 #ifndef MARS_MAGIC
 #include "MAGIC.h"
+#endif
+#ifndef ROOT_Gtypes
+#include <Gtypes.h>
 #endif
 #ifndef ROOT_TClonesArray
@@ -15,4 +18,5 @@
 class MGeomCam;
 class MHexagon;
+class MRflEvtData;
 class MCerPhotEvt;
 class MCerPhotPix;
@@ -42,5 +46,6 @@
     TClonesArray  *fLegend;      // array of all color bars
     TClonesArray  *fLegText;     // array of all texts
-
+    TClonesArray  *fPhotons;     // array of reflector photons
+ 
     UInt_t         fW;           // Width of canvas
     UInt_t         fH;           // Height of canvas
@@ -74,4 +79,6 @@
     void FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean);
     void FillPedestals(const MPedestalCam &event);
+    void FillRflEvent(const MRflEvtData &event);
+    void ShowRflEvent(const MRflEvtData *event=NULL, EMarkerStyle m=kFullDotMedium);
 
     void DrawPixelNumbers();
Index: /trunk/MagicSoft/Mars/mgui/MHexagon.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 2135)
@@ -67,5 +67,5 @@
     fX = pix.GetX();
     fY = pix.GetY();
-    fD = pix.GetR();
+    fD = pix.GetD();
 }
 
@@ -139,6 +139,6 @@
     // comput the distance of hexagon center to pixel border
     //
-    const Double_t dx = fD * cosa / 2;
-    const Double_t dy = fD * sina / 2;
+    const Double_t dx = fD/2 * cosa;
+    const Double_t dy = fD/2 * sina;
 
     const Int_t pxborder = gPad->XtoAbsPixel(fX + dx);
@@ -155,4 +155,26 @@
     //
     return distborder < disthex ? (int)(disthex-distborder+1) : 0;
+}
+
+// ------------------------------------------------------------------------
+//
+// compute the distance of a point (px,py) to the Hexagon in world
+// coordinates. Return -1 if inside.
+//
+Float_t MHexagon::DistanceToPrimitive(Float_t px, Float_t py)
+{
+    //
+    //  compute the distance of the Point to the center of the Hexagon
+    //
+    const Double_t dx = px-fX;
+    const Double_t dy = py-fY;
+
+    const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy);
+
+    //
+    //  compute the distance from the border of Pixel
+    //  here in the first implementation is just circle inside
+    //
+    return fD*0.5772 < disthex ? disthex-fD*0.5772 : -1;
 }
 
Index: /trunk/MagicSoft/Mars/mgui/MHexagon.h
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MHexagon.h	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgui/MHexagon.h	(revision 2135)
@@ -50,5 +50,6 @@
         ;
 
-    virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
+    virtual Int_t   DistancetoPrimitive(Int_t px, Int_t py);
+    virtual Float_t DistanceToPrimitive(Float_t px, Float_t py);
     virtual void  DrawHexagon(Float_t x, Float_t y, Float_t d);
 
Index: /trunk/MagicSoft/Mars/mgui/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mgui/Makefile	(revision 2134)
+++ /trunk/MagicSoft/Mars/mgui/Makefile	(revision 2135)
@@ -22,5 +22,6 @@
 #  connect the include files defined in the config.mk file
 #
-INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis -I../mimage -I../mhist
+INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis -I../mimage -I../mhist \
+	   -I../mreflector
 
 #------------------------------------------------------------------------------
Index: /trunk/MagicSoft/Mars/mreflector/MRflEvtData.cc
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/MRflEvtData.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/mreflector/MRflEvtData.cc	(revision 2135)
@@ -1,2 +1,40 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRflEvtData
+//
+// All Photons of a event from the reflector program
+//
+// Should be filled like this:
+//   MRflEvtData evt;
+//   evt.Reset();
+//   for (int i=0; i<10; i++)
+//      MRflSinglePhoton &ph = evt.GetNewPhoton();
+//   evt.FixSize();
+//
+/////////////////////////////////////////////////////////////////////////////
 #include "MRflEvtData.h"
 
@@ -17,4 +55,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Dump informations off all photons
+//
 void MRflEvtData::Print(Option_t *o="") const
 {
@@ -23,4 +65,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Add a new photon to the list
+//
 MRflSinglePhoton &MRflEvtData::GetNewPhoton()
 {
@@ -31,4 +77,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// If you have added all photon fix the size of the container.
+//
 void MRflEvtData::FixSize()
 {
Index: /trunk/MagicSoft/Mars/mreflector/MRflEvtData.h
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/MRflEvtData.h	(revision 2134)
+++ /trunk/MagicSoft/Mars/mreflector/MRflEvtData.h	(revision 2135)
@@ -28,5 +28,6 @@
 
     void Print(Option_t *o="") const;
-    ClassDef(MRflEvtData, 0)
+
+    ClassDef(MRflEvtData, 0) // All Photons of a event from the reflector program
 };
 
Index: /trunk/MagicSoft/Mars/mreflector/MRflSinglePhoton.cc
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/MRflSinglePhoton.cc	(revision 2134)
+++ /trunk/MagicSoft/Mars/mreflector/MRflSinglePhoton.cc	(revision 2135)
@@ -1,2 +1,33 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRflSinglePhoton
+//
+// Single Photon of a event from the reflector program
+//
+/////////////////////////////////////////////////////////////////////////////
 #include "MRflSinglePhoton.h"
 
@@ -6,4 +37,8 @@
 ClassImp(MRflSinglePhoton);
 
+// --------------------------------------------------------------------------
+//
+// Dump all photon information
+//
 void MRflSinglePhoton::Print(Option_t *o="") const
 {
Index: /trunk/MagicSoft/Mars/mreflector/MRflSinglePhoton.h
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/MRflSinglePhoton.h	(revision 2134)
+++ /trunk/MagicSoft/Mars/mreflector/MRflSinglePhoton.h	(revision 2135)
@@ -28,5 +28,6 @@
     void Print(Option_t *o="") const;
 
-    ClassDef(MRflSinglePhoton, 0)
+    ClassDef(MRflSinglePhoton, 0) // Single Photon of a event from the reflector program
+
 };
 
Index: /trunk/MagicSoft/Mars/mreflector/ReflectorIncl.h
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/ReflectorIncl.h	(revision 2135)
+++ /trunk/MagicSoft/Mars/mreflector/ReflectorIncl.h	(revision 2135)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /trunk/MagicSoft/Mars/mreflector/ReflectorLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mreflector/ReflectorLinkDef.h	(revision 2135)
+++ /trunk/MagicSoft/Mars/mreflector/ReflectorLinkDef.h	(revision 2135)
@@ -0,0 +1,10 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MRflEvtData+;
+#pragma link C++ class MRflSinglePhoton+;
+
+#endif
