Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9355)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9356)
@@ -90,5 +90,7 @@
      - clean isolated pixels away before calculating image parameters
      - don't clean calibration runs
-     - correct displayed az ba magnetic field
+     - correct displayed az by magnetic field
+     - added auto range for the 2D histograms
+     - set automatic binning for dist
 
    * readcorsika.cc:
@@ -107,4 +109,5 @@
    * ceres.rc:
      - added units for psf
+     - some small updates
 
    * msimreflector/MSimReflector.cc:
@@ -116,4 +119,13 @@
      - don't write PoinitingCorsika anymore. ARRANg already includes
        the rotation
+
+   * mgeom/MGeomCamMagic.[h,cc]:
+     - added a constructor which allows to set the focal distance
+
+   * msimcamera/MSimAPD.cc, msimcamera/MSimGeomCam.cc,
+     msimcamera/MSimRandomPhotons.cc, msimreflector/MSimReflector.cc:
+     - don't create an object if MGeomCam not found, try "MGeomCam"
+       as default instead
+
 
 
Index: trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc	(revision 9355)
+++ trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc	(revision 9356)
@@ -19,5 +19,5 @@
 !   Author(s): Harald Kornmayer 1/2001
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -45,4 +45,18 @@
 MGeomCamMagic::MGeomCamMagic(const char *name)
     : MGeomCam(577, 17, name, "Geometry information of Magic Camera")
+{
+    CreateCam();
+    CreateNN();
+    InitGeometry();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Magic camera has 577 pixels. For geometry and Next Neighbor info see
+//  CreateCam and CreateNN. You can give the distance dist from
+//  the mirror center to the focal plane.
+//
+MGeomCamMagic::MGeomCamMagic(Double_t dist, const char *name)
+    : MGeomCam(577, dist, name, "Geometry information of Magic Camera")
 {
     CreateCam();
Index: trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.h
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.h	(revision 9355)
+++ trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.h	(revision 9356)
@@ -14,4 +14,5 @@
 public:
     MGeomCamMagic(const char *name=NULL);
+    MGeomCamMagic(Double_t dist, const char *name=NULL);
 
     Bool_t HitFrame(MQuaternion p, const MQuaternion &u) const;
Index: trunk/MagicSoft/Mars/mjobs/MJSimulation.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9355)
+++ trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9356)
@@ -189,4 +189,5 @@
     hist.InitName("Impact;Impact;Impact");
     hist.InitTitle("Impact;West <--> East [m];South <--> North [m]");
+    hist.SetAutoRange();
 
     hist.AddHist("MCorsikaEvtHeader.fFirstInteractionHeight/100000");
@@ -198,4 +199,5 @@
     hist.InitTitle("Sky Origin;Az [deg];Zd [deg]");
     hist.SetDrawOption("colz");
+    hist.SetAutoRange();
 
     TString sin2 = "sin(MCorsikaEvtHeader.fZd)*sin(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
@@ -346,5 +348,5 @@
     MBinning binse( 100,     1,   100000, "BinningEnergy", "log");
     MBinning binss( 100,     1, 10000000, "BinningSize",   "log");
-    MBinning binsi(  50,  -250,      250, "BinningImpact");
+    MBinning binsi( 100,  -500,      500, "BinningImpact");
     MBinning binsh( 150,     0,       50, "BinningHeight");
     MBinning binsaz(720,  -360,      360, "BinningAz");
@@ -352,4 +354,6 @@
     MBinning binsvc( 45,     0,        9, "BinningViewCone");
     MBinning binsew(150,     0,       50, "BinningEvtWidth");
+    MBinning binsd("BinningDistC");
+    MBinning binsd0("BinningDist");
     MBinning binstr("BinningTrigPos");
 
@@ -363,4 +367,6 @@
     plist.AddToList(&binsew);
     plist.AddToList(&binstr);
+    plist.AddToList(&binsd);
+    plist.AddToList(&binsd0);
 
     MHn mhn1, mhn2, mhn3;
@@ -660,7 +666,16 @@
     //-------------------------------------------
 
+    MGeomCam *cam = static_cast<MGeomCam*>(env2.GetCont());
+
     if (binstr.IsDefault())
         binstr.SetEdgesLin(150, -shape.GetPulseWidth(),
                            header.GetFreqSampling()/1000.*header.GetNumSamples()+shape.GetPulseWidth());
+
+    if (binsd.IsDefault() && cam)
+        binsd.SetEdgesLin(100, 0, cam->GetMaxRadius()*cam->GetConvMm2Deg());
+
+    if (binsd0.IsDefault() && cam)
+        binsd0.SetEdgesLin(100, 0, cam->GetMaxRadius()*cam->GetConvMm2Deg());
+
 
     header.Print();
@@ -711,5 +726,5 @@
             }
 
-            if (env2.GetCont())
+            if (cam)
             {
                 c.cd(4);
@@ -719,5 +734,5 @@
                 gPad->SetGridy();
                 gROOT->SetSelectedPad(0);
-                MHCamera *c = new MHCamera(static_cast<MGeomCam&>(*env2.GetCont()));
+                MHCamera *c = new MHCamera(*cam);
                 c->SetStats(kFALSE);
                 c->SetBit(MHCamera::kNoLegend);
Index: trunk/MagicSoft/Mars/msimcamera/MSimAPD.cc
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimAPD.cc	(revision 9355)
+++ trunk/MagicSoft/Mars/msimcamera/MSimAPD.cc	(revision 9356)
@@ -100,7 +100,10 @@
         *fLog << inf << fNameGeomCam << " [MGeomCam] not found..." << endl;
 
-        fGeom = (MGeomCam*)pList->FindCreateObj(fNameGeomCam);
+        fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
         if (!fGeom)
+        {
+            *fLog << err << "MGeomCam not found... aborting." << endl;
             return kFALSE;
+        }
     }
 
Index: trunk/MagicSoft/Mars/msimcamera/MSimGeomCam.cc
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimGeomCam.cc	(revision 9355)
+++ trunk/MagicSoft/Mars/msimcamera/MSimGeomCam.cc	(revision 9356)
@@ -91,7 +91,10 @@
         *fLog << inf << fNameGeomCam << " [MGeomCam] not found..." << endl;
 
-        fGeom = (MGeomCam*)pList->FindCreateObj(fNameGeomCam);
+        fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
         if (!fGeom)
+        {
+            *fLog << err << "MGeomCam not found... aborting." << endl;
             return kFALSE;
+        }
     }
 
Index: trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc	(revision 9355)
+++ trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc	(revision 9356)
@@ -91,7 +91,10 @@
         *fLog << inf << fNameGeomCam << " [MGeomCam] not found..." << endl;
 
-        fGeom = (MGeomCam*)pList->FindCreateObj(fNameGeomCam);
+        fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
         if (!fGeom)
+        {
+            *fLog << err << "MGeomCam not found... aborting." << endl;
             return kFALSE;
+        }
     }
 
@@ -175,5 +178,5 @@
             // Add a new photon
             // FIXME: SLOW!
-            MPhotonData &ph = fEvt->Add(); 
+            MPhotonData &ph = fEvt->Add();
 
             // Set source to NightSky, time to t and tag to pixel index
Index: trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc	(revision 9355)
+++ trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc	(revision 9356)
@@ -121,7 +121,10 @@
         *fLog << inf << fNameGeomCam << " [MGeomCam] not found..." << endl;
 
-        fGeomCam = (MGeomCam*)pList->FindCreateObj(fNameGeomCam);
+        fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
         if (!fGeomCam)
+        {
+            *fLog << err << "MGeomCam not found... aborting." << endl;
             return kFALSE;
+        }
     }
 
