Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2801)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2802)
@@ -12,4 +12,7 @@
        rms = 0 later resulted in the pixel being eliminated in the 
        image cleaning.
+
+
+
 
  2004/01/14: Thomas Bretz
@@ -41,5 +44,15 @@
    * mreport/MReportFileRead.cc:
      - moved code from MReportHelp to new file
-     - removed usage of MRepoort class completely
+     - removed usage of MReport class completely
+
+   * mfilter/MFGeomag.[h,cc]:
+     - fixed a bug which causes MFGeomag to fail if MARSSYS is not set
+     - changed the second loop from 0->1151 to 1152->2304
+     - removed dummy arrays used for reading
+     - output filename in case of 'file not found'
+     - removed obsolete data members
+     - removed obsolete Init function
+     - removed forbidden underscore from member variable
+     - changed wrong 0/1 in allocation of fResult into kFALSE/TRUE
 
 
Index: trunk/MagicSoft/Mars/mfilter/MFGeomag.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFGeomag.cc	(revision 2801)
+++ trunk/MagicSoft/Mars/mfilter/MFGeomag.cc	(revision 2802)
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): R.K.Bock 11/2003     <mailto:rkb@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Author(s): R.K.Bock 11/2003 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -39,6 +39,8 @@
 #include "MFGeomag.h"
 
-#include "fstream"        //for ifstream
-#include "TRandom.h"      //for gRandom
+#include <fstream>        //for ifstream
+
+#include <TRandom.h>      //for gRandom
+#include <TSystem.h>
 
 #include "MLog.h"
@@ -49,6 +51,4 @@
 #include "MMcEvt.hxx"
 
-#include <TSystem.h>
-
 ClassImp(MFGeomag);
 
@@ -57,24 +57,14 @@
 // --------------------------------------------------------------------------
 //
-MFGeomag::MFGeomag(const char *cname, const char type, const Int_t val,
-                           const char *name, const char *title) : fMcEvt(NULL)
-{
-    fContName = cname;
-    Init(type, val, name, title);
-}
-
-// --------------------------------------------------------------------------
-//
-void MFGeomag::Init(const char type, const Int_t val,
-                        const char *name, const char *title)
-
+MFGeomag::MFGeomag(const char *name, const char *title) : fMcEvt(NULL)
 {
     fName  = name  ? name  : "MFGeomag";
     fTitle = title ? title : "Filter using geomagnetic field";
 
-    fGamm_elec = kFALSE;  // logical variable, will not take gammas as electrons (default)
-
-    AddToBranchList(Form("%s.fPartId", (const char*)fContName));
+    fGammaElectron = kFALSE;  // logical variable, will not take gammas as electrons (default)
+
+    AddToBranchList("MMcEvt.fPartId");
 }
+
 // --------------------------------------------------------------------------
 //
@@ -82,41 +72,49 @@
 {
     //  reading of tables (variables defined as 'private')
-
-    Float_t azim  [2*1152];      // (these variables not used)
-    Float_t thet  [2*1152];
-
-    TString filename = gSystem->Getenv("MARSSYS");
-    filename += "/mfilter/gcplus.txt";
+    TString marssys(gSystem->Getenv("MARSSYS"));
+    if (!marssys.IsNull() && !marssys.EndsWith("/"))
+        marssys += "/";
+
+    //
+    // Read gcminus.txt
+    //
+    TString filename(marssys);
+    filename += "mfilter/gcplus.txt";
 
     ifstream geomagp(filename);
 
-    if (!geomagp) {
-        *fLog << err <<" ERROR gcplus.txt file not found by Geomag"<<endl;
+    if (!geomagp)
+    {
+        *fLog << err << "ERROR - file " << filename << " not found." << endl;
         return kFALSE;
     }
     for (int i=0; i<1152; i++)
     {
-        geomagp >>azim[i]>>thet[i];
-        geomagp >>fRigMin[i]>>fRigMax[i]>>fProb[i];
+        Float_t dummy;
+        geomagp >> dummy >> dummy >> fRigMin[i] >> fRigMax[i] >> fProb[i];
     }
     *fLog << inf << endl;
-    *fLog << "gcplus.txt  read, first line: ";
+    *fLog << "gcplus.txt - first line: ";
     *fLog << Form ("FRigMin=%8f  fRigMax=%8f  fProb=%8f",
                    fRigMin[0], fRigMax[0], fProb[0]) << endl;
 
-    filename = gSystem->Getenv("MARSSYS");
-    filename += "/mfilter/gcminus.txt";
+    //
+    // Read gcminus.txt
+    //
+    filename = marssys;
+    filename += "mfilter/gcminus.txt";
 
     ifstream geomagm(filename);
-    if (!geomagm) {
-        *fLog << err <<" ERROR gcminus.txt file not found by Geomag"<<endl;
-        return kFALSE;
-    }
-    for (int i=0; i<1152; i++)
-    {
-        geomagm >>azim[i+1152]>>thet[i+1152];
-        geomagm >>fRigMin[i+1152]>>fRigMax[i+1152]>>fProb[i+1152];
-    }
-    *fLog << "gcminus.txt read, first line: ";
+    if (!geomagm)
+    {
+        *fLog << err << "ERROR - file " << filename << " not found." << endl;
+        return kFALSE;
+    }
+    for (int i=1152; i<2304; i++)
+    {
+        Float_t dummy;
+        geomagm >> dummy >> dummy >> fRigMin[i] >> fRigMax[i] >> fProb[i];
+    }
+    *fLog << "gcminus.txt - first line: ";
     *fLog << Form ("fRigMin=%8f  fRigMax=%8f  fProb=%8f",
                    fRigMin[1152], fRigMax[1152], fProb[1152]) << endl;
@@ -129,5 +127,5 @@
     if (!fMcEvt)
     {
-        *fLog << err << dbginf << "  [MMcEvt] not found... aborting." << endl;
+        *fLog << err << "MMcEvt not found... aborting." << endl;
         return kFALSE;
     }
@@ -139,5 +137,5 @@
 void MFGeomag::SetGammElec()
 {
-    fGamm_elec = kTRUE;  // logical variable, will take gammas as electrons
+    fGammaElectron = kTRUE;  // logical variable, will take gammas as electrons
     *fLog <<" MFGeomag called to treat gammas as electrons" << endl;
     return;
@@ -157,7 +155,7 @@
     {
     case kGAMMA:
-        if (!fGamm_elec)         //accept gammas if not set to electrons
+        if (!fGammaElectron)         //accept gammas if not set to electrons
 	  {
-	    fResult = 0;
+	    fResult = kFALSE;
 	    return kTRUE;
 	  }
@@ -180,6 +178,5 @@
 
     default:
-        Int_t id = fMcEvt->GetPartId();
-        *fLog << err <<" Unknown Monte Carlo Particle Id#: "<< id << endl;
+        *fLog << err << " Unknown Monte Carlo Particle Id#: "<< fMcEvt->GetPartId() << endl;
         return kFALSE;
     }
@@ -188,18 +185,24 @@
       int ia=(int)(az*11.459156);
       ia = (ia+36) % 72;             // azimuth definitions differ by 180 deg
+
       float r1=fRigMin[72*it+ia+indadd];
       if (rig<=r1) {
-          fResult=1;        // reject
+          fResult=kTRUE;    // reject
           return kTRUE;
       }
+
       float r2=fRigMax[72*it+ia+indadd];
       if (rig>=r2) {
-          fResult=0;        // accept
+          fResult=kFALSE;   // accept
           return kTRUE;
       }
-      float R = gRandom->Rndm(0);        //accept if above intermediate threshold
-      float pr=fProb  [72*it+ia+indadd];    
-      fResult = 0;
-      if (rig < 0.5/pr*R*(r2-r1) + r1)  fResult = 1; // pretty good approximation
+
+      float R = gRandom->Rndm(0);        // accept if above intermediate threshold
+      float pr=fProb[72*it+ia+indadd];
+      fResult = kFALSE;
+
+      if (rig < 0.5/pr*R*(r2-r1) + r1)
+          fResult = kTRUE;               // pretty good approximation
+
       return kTRUE;
    }
Index: trunk/MagicSoft/Mars/mfilter/MFGeomag.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFGeomag.h	(revision 2801)
+++ trunk/MagicSoft/Mars/mfilter/MFGeomag.h	(revision 2802)
@@ -1,10 +1,4 @@
 #ifndef MARS_MFGeomag
 #define MARS_MFGeomag
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MFGeomag                                                                //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
 
 #ifndef MARS_MFilter
@@ -19,19 +13,11 @@
 private:
     MMcEvt *fMcEvt;
-    TString fContName;
-
-    typedef enum { kEEqual, kENotEqual } FilterType_t;
-    FilterType_t fFilterType;
 
     Bool_t fResult;    //!
-    Bool_t fGamm_elec;  // switches gammas to electrons
-    //
+    Bool_t fGammaElectron;  // switches gammas to electrons
+
     Float_t fRigMin[2*1152];    //tables to contain cut limits
     Float_t fRigMax[2*1152];
     Float_t fProb  [2*1152];
-
-    void Init(const char type, const Int_t val,
-              const char *name, const char *title);
-
 
     Int_t PreProcess(MParList *pList);
@@ -39,9 +25,8 @@
 
 public:
-    MFGeomag(const char *cname="MMcEvt", const char type='=', const Int_t val=0,
-                 const char *name=NULL, const char *title=NULL);
+    MFGeomag(const char *name=NULL, const char *title=NULL);
 
     void  SetGammElec();    // allows to use gammas like electrons
-    Bool_t IsExpressionTrue() const {return fResult;};
+    Bool_t IsExpressionTrue() const { return fResult; }
 
     ClassDef(MFGeomag,0) // Filter for MC particles, by geomagnetic field
