Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9421)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9422)
@@ -18,4 +18,39 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2009/04/16 Thomas Bretz
+
+   * mbase/MEvtLoop.cc:
+     - make sure that no negative values for the estimated time
+       is shown
+
+   * mcorsika/MCorsikaEvtHeader.cc:
+     - calculate impact in the telescope dish plane and not on the
+       ground
+
+   * mhflux/MHCollectionArea.cc:
+     - initialize more variables in the constructor as suggested
+       by valgrind
+
+   * mpointing/MHPointing.cc:
+     - set the maximum such that both axis are scaled correctly
+
+   * msimcamera/MSimBundlePhotons.cc:
+     - added some more output
+
+   * resmc/dwarf-pde-gapd.txt:
+     - used new curve from ETH
+     - extrapolated curve on both ends linearily
+
+   * resmc/dwarf-reflectivity.txt:
+     - extrapolated linearily to 980 nm
+
+   * resmc/magic-pde.txt:
+     - set to 0 at 900nm
+
+   * resmc/magic-reflectivity.txt:
+     - extrpolated to 900nm
+
+
+
  2009/04/01 Thomas Bretz
 
@@ -30,4 +65,8 @@
      - added a cut "Cut" after image parameter calculation
      - updated noise numbers
+
+   * resmc/dwarf-pde-gapd.txt:
+     - upadted with a more reliable curve from theeth meeting page
+       (linear extrapolate below 350nm)
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 9421)
+++ trunk/MagicSoft/Mars/NEWS	(revision 9422)
@@ -21,4 +21,15 @@
    * Added the possibility to add a cut after the image parameter
      calculation (''Cut'')
+
+   * updated the PDE of the GAPDs with a more reliable curve from
+     the meeting page (linear extrapolate below 350nm)
+
+   * The impact distribution in the event distrbutions is now 
+     perpendicular to Alt/Az and the histogram is displayed in 1D
+
+   * The GAPD PDE has been updated
+
+   * PDEs and mirror reflectivities have been linearily extrapolated
+     to match the wavelegth range between 290nm and 900nm
 
  ;callisto:
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 9421)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 9422)
@@ -376,5 +376,5 @@
             txt += (Int_t)speed;
             txt += "Evts/s";
-            if (fNumEvents>0)
+            if (fNumEvents>0 && (Int_t)fNumEvents-num>0)
             {
                 txt += ", est: ";
Index: trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.cc	(revision 9421)
+++ trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.cc	(revision 9422)
@@ -61,9 +61,36 @@
 // --------------------------------------------------------------------------
 //
-//  Return Hypot(x, y)
+// Return Impact (distance of ground incident point from telescope axis)
+//
+// Distance d between a point q and a line u (via p):
+//   d = | ( vec(q) - vec(p) ) x vec(u) |  /  | vec(u) |
+//
+// If p = 0
+//
+//   ==>   d = | vec(q) x vec(u) |  /  | vec(u) |
+//          w :=  q = (x/y/0)
+//          v :=  u = (Alt/Az)
+//
+// For Alt/Az = Theta/Phi:
+//
+//  x = r sin(theta) cos(phi)
+//  y = r sin(theta) sin(phi)
+//  z = r cos(theta)
+//
+//                   (   -q3*u2    )   ( -cos(theta)*y                                     )
+// vec(q) x vec(u) = (    q3*u1    ) = (  cos(theta)*x                                     )
+//                   ( q1*u2-q2*u1 )   ( sin(theta) cos(phi) * y - sin(theta) sin(phi) * x )
+//
+//   ==> d = sqrt( cos(theta)^2 (x^2  + y^2 ) +
+//                 sin(theta)^2 ( cos(phi) y + sin(phi) x)^2 )
 //
 Double_t MCorsikaEvtHeader::GetImpact() const
 {
-    return TMath::Hypot(fX, fY);
+    const Double_t c = TMath::Cos(fZd);
+    const Double_t s = TMath::Sin(fZd);
+
+    const Double_t p = TMath::Cos(fAz)*fX - TMath::Sin(fAz)*fY;
+
+    return TMath::Sqrt(c*c*(fX*fX + fY*fY) + s*s* p*p);
 }
 
Index: trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc	(revision 9421)
+++ trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc	(revision 9422)
@@ -67,5 +67,7 @@
 //
 MHCollectionArea::MHCollectionArea(const char *name, const char *title)
-  : fMcEvt(0), fHeader(0), fMcAreaRadius(-1), fIsExtern(kFALSE)
+    : fMcEvt(0), fHeader(0), fMcAreaRadius(-1),
+    fTotalNumSimulatedShowers(0), fAllEvtsTriggered(kFALSE),
+    fIsExtern(kFALSE)
 { 
     //   initialize the histogram for the distribution r vs E
Index: trunk/MagicSoft/Mars/mpointing/MHPointing.cc
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MHPointing.cc	(revision 9421)
+++ trunk/MagicSoft/Mars/mpointing/MHPointing.cc	(revision 9422)
@@ -332,10 +332,21 @@
     if (fDevTimeCosy.GetN()>0)
         fDevTimeCosy.SetMinimum(0);
+
+
     if (fBrightness.GetN()>0)
+    {
         fBrightness.SetMinimum(0);
+        fBrightness.SetMaximum(95);
+    }
     if (fNumStars.GetN()>0)
+    {
         fNumStars.SetMinimum(0);
+        fNumStars.SetMaximum(95);
+    }
     if (fNumStarsCor.GetN()>0)
+    {
         fNumStarsCor.SetMinimum(0);
+        fNumStarsCor.SetMaximum(95);
+    }
 
     DrawGraph(fDevTimeSG,   "\\Delta [arcmin]");
Index: trunk/MagicSoft/Mars/msimcamera/MSimBundlePhotons.cc
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimBundlePhotons.cc	(revision 9421)
+++ trunk/MagicSoft/Mars/msimcamera/MSimBundlePhotons.cc	(revision 9422)
@@ -106,5 +106,8 @@
     // Make sure that each line has exactly one row
     if (!fLut.HasConstantLength() && fLut.GetMaxEntries()!=1)
-        return kFALSE;
+    {
+        *fLog << err << fFileName << " wrongly formatted." << endl;
+        return kFALSE;
+    }
 
     *fLog << inf << "Using look-up table from " << fFileName << endl;
Index: trunk/MagicSoft/Mars/msimcamera/MSimReadout.cc
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimReadout.cc	(revision 9421)
+++ trunk/MagicSoft/Mars/msimcamera/MSimReadout.cc	(revision 9422)
@@ -163,12 +163,11 @@
     }
 
-    // Get Number of pixels
-    const UInt_t npix = fData->GetNumPixels();
-
-    if (npix!=fCamera->GetNumChannels())
+    // Make sure that we have not more analog channels than pixels
+    // FIXME: Is this really necessary?
+    if (fCamera->GetNumChannels()>fData->GetNumPixels())
     {
         *fLog << err;
         *fLog << "ERROR - Number of analog channels " << fCamera->GetNumChannels();
-        *fLog << " doesn't match number of pixels " << fData->GetNumPixels() << endl;
+        *fLog << " exceeds number of pixels " << fData->GetNumPixels() << endl;
         return kERROR;
     }
@@ -221,8 +220,8 @@
 
     // Digitize into a buffer
-    MArrayI buffer(nslices*npix);
+    MArrayI buffer(nslices*fData->GetNumPixels());
 
     // Loop over all channels/pixels
-    for (UInt_t i=0; i<npix; i++)
+    for (UInt_t i=0; i<fCamera->GetNumChannels(); i++)
     {
         // Get i-th canalog hannel
Index: trunk/MagicSoft/Mars/resmc/dwarf-pde-gapd.txt
===================================================================
--- trunk/MagicSoft/Mars/resmc/dwarf-pde-gapd.txt	(revision 9421)
+++ trunk/MagicSoft/Mars/resmc/dwarf-pde-gapd.txt	(revision 9422)
@@ -1,11 +1,48 @@
-250 0.05
-300 0.16
-350 0.30
-400 0.40
-450 0.35
-500 0.28
-550 0.20
-600 0.17
-650 0.18
-700 0.13
-750 0.04
+280 0
+320 0.14
+360 0.2483
+369.655 0.272855
+380.359 0.30322
+392.682 0.328166
+400 0.3427
+410 0.36
+420 0.3791
+429.652 0.394688
+440 0.4056
+450 0.4111
+460 0.4132
+469.397 0.413991
+480 0.4125
+487.328 0.409247
+500 0.4052
+509.192 0.397064
+520 0.3869
+530 0.3736
+540 0.3634
+550 0.35
+560 0.3368
+570 0.325
+580 0.3114
+590 0.2987
+600 0.2847
+610 0.2726
+616.74 0.261643
+626.822 0.250952
+636.905 0.241449
+646.987 0.22957
+660 0.2192
+670 0.2099
+680 0.2028
+690 0.1933
+700 0.1847
+710 0.1778
+720 0.1699
+730 0.1616
+740 0.1526
+750 0.1464
+760 0.138
+770 0.1308
+780 0.1232
+790 0.1158
+846.399 0.0751422
+950 0
Index: trunk/MagicSoft/Mars/resmc/dwarf-reflectivity.txt
===================================================================
--- trunk/MagicSoft/Mars/resmc/dwarf-reflectivity.txt	(revision 9421)
+++ trunk/MagicSoft/Mars/resmc/dwarf-reflectivity.txt	(revision 9422)
@@ -8,2 +8,6 @@
 530 0.873
 620 0.811
+710 0.749
+800 0.687
+890 0.625
+980 0.563
Index: trunk/MagicSoft/Mars/resmc/magic-pde.txt
===================================================================
--- trunk/MagicSoft/Mars/resmc/magic-pde.txt	(revision 9421)
+++ trunk/MagicSoft/Mars/resmc/magic-pde.txt	(revision 9422)
@@ -44,2 +44,3 @@
 690  0.00494685
 700  0.00310554
+900  0
Index: trunk/MagicSoft/Mars/resmc/magic-reflectivity.txt
===================================================================
--- trunk/MagicSoft/Mars/resmc/magic-reflectivity.txt	(revision 9421)
+++ trunk/MagicSoft/Mars/resmc/magic-reflectivity.txt	(revision 9422)
@@ -47,3 +47,3 @@
 750 0.81
 800 0.77
-850 0.75
+900 0.69
