Index: trunk/MagicSoft/Mars/msimreflector/MMirror.cc
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MMirror.cc	(revision 9328)
+++ trunk/MagicSoft/Mars/msimreflector/MMirror.cc	(revision 9332)
@@ -126,6 +126,6 @@
     psf /= 2;                        // The factor two because of the doubleing of the angle in the reflection
     psf /= F;                        // Scale the Gauss to the size of the PSF
-    psf *= n.Z();                    // Normalize the addon vector to the normal vector
-    //psf *= n.Mag();                // Alternative! (Gaussian projected on the surface of a sphere)
+    //psf *= n.Z();                  // 
+    psf *= n.Mag();                  // This means that the PSF is measured in the focal distance
 
     TVector3 dn(gx*psf, gy*psf, 0);  // Instead of psf/F also atan(psf/F) might make sense
@@ -136,4 +136,6 @@
 }
 
+// --------------------------------------------------------------------------
+//
 void MMirror::Print(Option_t *o) const
 {
@@ -141,4 +143,6 @@
     gLog << fNorm.X() << " " << fNorm.Y() << " " << fNorm.Z() << " ";
     gLog << fFocalLength << " ";
+    if (fSigmaPSF>0)
+        gLog << fSigmaPSF << " ";
 
     const TString n = ClassName();
Index: trunk/MagicSoft/Mars/msimreflector/MMirror.h
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MMirror.h	(revision 9328)
+++ trunk/MagicSoft/Mars/msimreflector/MMirror.h	(revision 9332)
@@ -36,4 +36,6 @@
     TVector2 operator-(const MMirror &m) const;// { return TVector2(X()-m.X(), Y()-m.Y()); }
 
+    void SetSigmaPSF(Double_t psf) { fSigmaPSF = psf; }
+    void SetFocalLength(Double_t f) { fFocalLength = f; }
     void SetPosition(const TVector3 &v) { fPos = v; }
     void SetNorm(const TVector3 &n) {
@@ -54,4 +56,7 @@
     const TVector3 &GetNorm() const { return fNorm; }
 
+    Double_t GetFocalLength() const { return fFocalLength; }
+    Double_t GetSigmaPSF() const { return fSigmaPSF; }
+
     Double_t GetDist() const { return fPos.Perp(); }
 
@@ -63,7 +68,4 @@
 
     // ----- Basic function for parabolic mirror -----
-    void SetFocalLength(Double_t f) { fFocalLength = f; }
-    Double_t GetFocalLength() const { return fFocalLength; }
-
     Bool_t ExecuteReflection(MQuaternion &p, MQuaternion &u) const;
 
Index: trunk/MagicSoft/Mars/msimreflector/MMirrorDisk.cc
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MMirrorDisk.cc	(revision 9328)
+++ trunk/MagicSoft/Mars/msimreflector/MMirrorDisk.cc	(revision 9332)
@@ -144,8 +144,8 @@
 Int_t MMirrorDisk::ReadM(const TObjArray &tok)
 {
-    if (tok.GetSize()<9)
+    if (tok.GetEntries()!=1)
         return -1;
 
-    Double_t r = atof(tok[8]->GetName());
+    Double_t r = atof(tok[0]->GetName());
 
     if (r<=0)
Index: trunk/MagicSoft/Mars/msimreflector/MMirrorHex.cc
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MMirrorHex.cc	(revision 9328)
+++ trunk/MagicSoft/Mars/msimreflector/MMirrorHex.cc	(revision 9332)
@@ -163,8 +163,8 @@
 Int_t MMirrorHex::ReadM(const TObjArray &tok)
 {
-    if (tok.GetSize()<9)
+    if (tok.GetEntries()!=1)
         return -1;
 
-    const Double_t d = atof(tok[8]->GetName());
+    const Double_t d = atof(tok[0]->GetName());
 
     if (d<=0)
Index: trunk/MagicSoft/Mars/msimreflector/MMirrorSquare.cc
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MMirrorSquare.cc	(revision 9328)
+++ trunk/MagicSoft/Mars/msimreflector/MMirrorSquare.cc	(revision 9332)
@@ -160,8 +160,8 @@
 Int_t MMirrorSquare::ReadM(const TObjArray &tok)
 {
-    if (tok.GetSize()<9)
+    if (tok.GetEntries()!=1)
         return -1;
 
-    Double_t l = atof(tok[8]->GetName());
+    Double_t l = atof(tok[0]->GetName());
 
     if (l<=0)
Index: trunk/MagicSoft/Mars/msimreflector/MReflector.cc
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MReflector.cc	(revision 9328)
+++ trunk/MagicSoft/Mars/msimreflector/MReflector.cc	(revision 9332)
@@ -65,4 +65,13 @@
 // --------------------------------------------------------------------------
 //
+// Set the SigmaPSF of all mirrors currently stored.
+//
+void MReflector::SetSigmaPSF(Double_t psf)
+{
+    fMirrors.ForEach(MMirror, SetSigmaPSF)(psf);
+}
+
+// --------------------------------------------------------------------------
+//
 // Calculate the maximum radius of th ereflector. This is not meant as
 // a precise number but as a rough estimate e.g. to bin a histogram.
@@ -118,8 +127,105 @@
 // --------------------------------------------------------------------------
 //
+// I/O helper for ReadFile to avoid calling "delete arr" before every return
+//
+MMirror *MReflector::EvalTokens(TObjArray &arr, Double_t defpsf) const
+{
+    if (arr.GetEntries()<9)
+    {
+        *fLog << err << "ERROR - Not enough arguments..." << endl;
+        return 0;
+    }
+
+    const TVector3 pos(atof(arr[0]->GetName()),
+                       atof(arr[1]->GetName()),
+                       atof(arr[2]->GetName()));
+
+    const TVector3 norm(atof(arr[3]->GetName()),
+                        atof(arr[4]->GetName()),
+                        atof(arr[5]->GetName()));
+
+    const Double_t F = atof(arr[6]->GetName());
+
+    const TString val = arr[7]->GetName();
+
+    const Double_t psf = val.IsFloat() ? val.Atof() : -1;
+
+    const UInt_t n = val.IsFloat() ? 9 : 8;
+
+    TString type = arr[n-1]->GetName();
+    type.Prepend("MMirror");
+
+    for (UInt_t i=0; i<n; i++)
+        delete arr.RemoveAt(i);
+    arr.Compress();
+
+    TString msg;
+    TClass *cls = MParContainer::GetClass(type);
+    if (!cls)
+    {
+        *fLog << err << "ERROR - Class " << type << " not in dictionary." << endl;
+        return 0;
+    }
+
+    if (!cls->InheritsFrom(MMirror::Class()))
+    {
+        *fLog << err << "ERROR - Cannot create new instance of class " << type << ": " << endl;
+        *fLog << "Class doesn't inherit from MMirror." << endl;
+        return 0;
+    }
+
+    MMirror *m = static_cast<MMirror*>(cls->New());
+    if (!m)
+    {
+        *fLog << err << "ERROR - Cannot create new instance of class " << type << ": " << endl;
+        *fLog << " - Class has no default constructor." << endl;
+        *fLog << " - An abstract member functions of a base class is not overwritten." << endl;
+        return 0;
+    }
+
+    m->SetFocalLength(F);
+    m->SetPosition(pos);
+    m->SetNorm(norm);
+    m->SetSigmaPSF(psf>=0 ? psf : defpsf);
+
+    if (m->ReadM(arr)>=0)
+        return m;
+
+    *fLog << err << "ERROR - " << type << "::ReadM failed." << endl;
+
+    delete m;
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
 // Read a reflector setup from a file. This needs improvemtn.
-// FIXME: Documentation missing!
-//
-Bool_t MReflector::ReadFile(TString fname)
+//
+// The file structur is like:
+//
+//     x y z nx ny nz F [psf] Type ...
+//
+//  x:      x-coordinate of the mirror's center
+//  y:      y-coordinate of the mirror's center
+//  z:      z-coordinate of the mirror's center
+//  nx:     x-component of the normal vecor in the mirror center
+//  ny:     y-component of the normal vecor in the mirror center
+//  nz:     z-component of the normal vecor in the mirror center
+//  F:      Focal distance of a spherical mirror
+//  [psf]:  This number is the psf given in the units of x,y,z and
+//          defined at the focal distance F. It can be used to overwrite
+//          the second argument given in ReadFile for individual mirrors.
+//  Type:   A instance of a mirrot of the class Type MMirrorType is created
+//          (Type can be, for example, Hex for for MMirrorHex).
+//  ...:    Additional arguments as defined in MMirrorType::ReadM
+//
+//
+// Coordinate System:
+//  The coordinate system is local in the reflectors frame.
+//  It is defined viewing from the back side of the reflector
+//  towards the camera. (x "right", y "up", z from reflector to camera)
+//  Note, that it is left-handed!
+//
+Bool_t MReflector::ReadFile(TString fname, Double_t defpsf)
 {
     SetTitle(fname);
@@ -145,4 +251,6 @@
     */
 
+    Int_t cnt = 0;
+
     while (1)
     {
@@ -152,78 +260,36 @@
             break;
 
+        // Count lines
+        cnt++;
+
+        // Skip comments
         if (line.BeginsWith("#"))
-        {
-            //cout << line << endl;
             continue;
-        }
-
+
+        // Remove leading and trailing whitespaces
         line=line.Strip(TString::kBoth);
 
+        // Skip empty lines
         if (line.IsNull())
             continue;
 
+        // Tokenize line
         TObjArray *arr = line.Tokenize(' ');
 
-        if (arr->GetSize()<8)
+        // Evaluate tokens
+        MMirror *m = EvalTokens(*arr, defpsf);
+
+        // Delete now obsolete array
+        delete arr;
+
+        // Check if a new mirror could be created successfully
+        if (!m)
         {
-            cout << "Skip3: " <<line << endl;
-            delete arr;
-            continue;
-        }
-
-        const TVector3 pos(atof((*arr)[0]->GetName()),
-                           atof((*arr)[1]->GetName()),
-                           atof((*arr)[2]->GetName()));
-
-        const TVector3 norm(atof((*arr)[3]->GetName()),
-                            atof((*arr)[4]->GetName()),
-                            atof((*arr)[5]->GetName()));
-
-        const Double_t F = atof((*arr)[6]->GetName());
-
-        TString type = (*arr)[7]->GetName();
-        type.Prepend("MMirror");
-
-        TString msg;
-        TClass *cls = MParContainer::GetClass(type);
-        if (!cls)
-        {
-            *fLog << err << dbginf << "ERROR - Class " << type << " not in dictionary." << endl;
+            *fLog << err << "Error in line " << cnt << ": " << line << endl;
             return kFALSE;
         }
 
-        if (!cls->InheritsFrom(MMirror::Class()))
-        {
-            *fLog << err << dbginf << "Cannot create new instance of class " << type << ": " << endl;
-            *fLog << "Class doesn't inherit from MMirror." << endl;
-            return kFALSE;
-        }
-
-        MMirror *m = (MMirror*)cls->New();
-        if (!m)
-        {
-            *fLog << err << dbginf << "Cannot create new instance of class " << type << ": " << endl;
-            *fLog << " - Class has no default constructor." << endl;
-            *fLog << " - An abstract member functions of a base class is not overwritten." << endl;
-            return kFALSE;
-        }
-
-        m->SetFocalLength(F);
-        m->SetPosition(pos);
-        m->SetNorm(norm);
-
-        Int_t n = m->ReadM(*arr);
-        if (n<=0)
-        {
-            *fLog << err << dbginf << "ERROR - ReadM failed." << endl;
-            return kFALSE;
-        }
-
+        // Add new mirror to array
         fMirrors.Add(m);
-
-        //maxr = TMath::Max(maxr, TMath::Hypot(pos[i].X()+24.75, pos[i].Y()+24.75));
-        //maxr = TMath::Max(maxr, TMath::Hypot(pos.X()+24.75, pos.Y()+24.75));
-
-        delete arr;
     }
 
@@ -285,13 +351,28 @@
 // --------------------------------------------------------------------------
 //
+// SigmaPSF: -1
 // FileName: reflector.txt
 //
+// SigmaPSF can be used to set a default for the psf of the mirrors
+// read from the file. Note, that this can be overwritten for individual
+// mirrors in the file.
+//
+// For details on the file structure see MReflector::ReadFile
+//
 Int_t MReflector::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
     Bool_t rc = kFALSE;
+
+    Double_t psf = -1;
+    if (IsEnvDefined(env, prefix, "SetSigmaPSF", print))
+    {
+        rc = kTRUE;
+        psf = GetEnvValue(env, prefix, "SetSigmaPSF", -1);
+    }
+
     if (IsEnvDefined(env, prefix, "FileName", print))
     {
         rc = kTRUE;
-        if (!ReadFile(GetEnvValue(env, prefix, "FileName", "")))
+        if (!ReadFile(GetEnvValue(env, prefix, "FileName", ""), psf))
             return kERROR;
     }
Index: trunk/MagicSoft/Mars/msimreflector/MReflector.h
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MReflector.h	(revision 9328)
+++ trunk/MagicSoft/Mars/msimreflector/MReflector.h	(revision 9332)
@@ -28,4 +28,7 @@
     void InitMaxR();
 
+    // Helper for I/O
+    MMirror *EvalTokens(TObjArray &arr, Double_t defpsf) const;
+
     // MParContainer
     Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
@@ -39,5 +42,5 @@
     const MMirror *GetMirror(UInt_t idx) const { return idx>=GetNumMirrors()?0:*(GetFirstPtr()+idx); }
 
-    Bool_t ReadFile(TString fname);
+    Bool_t ReadFile(TString fname, Double_t defpsf=-1);
 
     Double_t GetMaxR() const { return fMaxR; }
@@ -46,4 +49,6 @@
 
     Int_t ExecuteReflector(MQuaternion &p, MQuaternion &u) const;
+
+    void SetSigmaPSF(Double_t psf);
 
     // TObject
