Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1714)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1715)
@@ -46,4 +46,7 @@
    * mhist/MHStarMap.cc:
      - added a warning output
+
+   * mmontecarlo/MMcCollectionAreaCalc.cc:
+     - added a check for impact=NaN (some MC Files have this)
 
 
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 1715)
@@ -16,7 +16,8 @@
 !
 !
-!   Author(s): Abelardo Moralejo 7/2002  (moralejo@pd.infn.it)
-!
-!   Copyright: MAGIC Software Development, 2002
+!   Author(s): Abelardo Moralejo 7/2002  <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz 2002  <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002-2003
 !
 !
@@ -24,19 +25,18 @@
 
 //////////////////////////////////////////////////////////////////////////////
-//                                                                          //
-//   MCerPhotCalc                                                          //
-//                                                                          //
-//   This is a task which calculates the number of photons from the FADC    //
-//   time slices. It weights the each slice according to the numbers in     //
-//   the array fWeight (default: all slices added up with weight 1). 
-//                                                                          //
-//  Input Containers:                                                       //
-//   MRawRunHeader, MRawEvtData, MPedestalCam                               //
-//                                                                          //
-//  Output Containers:                                                      //
-//   MCerPhotEvt                                                            //
-//                                                                          //
+//
+//   MCerPhotCalc
+//
+//   This is a task which calculates the number of photons from the FADC
+//   time slices. It weights the each slice according to the numbers in
+//   the array fWeight (default: all slices added up with weight 1).
+//
+//  Input Containers:
+//   MRawRunHeader, MRawEvtData, MPedestalCam
+//
+//  Output Containers:
+//   MCerPhotEvt
+//
 //////////////////////////////////////////////////////////////////////////////
-
 #include "MCerPhotCalc.h"
 
@@ -103,8 +103,5 @@
     fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
     if (!fPedestals)
-    {
-        *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
-        return kFALSE;
-    }
+        return kFALSE;
 
     fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
@@ -115,5 +112,5 @@
     fSumQuadWeights = 0.;
     for (Int_t i = 0; i < fWeight.GetSize(); i++)
-      fSumQuadWeights += fWeight[i]*fWeight[i];
+        fSumQuadWeights += fWeight[i]*fWeight[i];
 
     fSumQuadWeights = sqrt(fSumQuadWeights);
@@ -171,9 +168,9 @@
     MRawEvtPixelIter pixel(fRawEvt);
 
-    TArrayF BinSignal(fWeight.GetSize());
+    TArrayF binsignal(fWeight.GetSize());
 
     while (pixel.Next())
-      {
-	const UInt_t pixid = pixel.GetPixelId();
+    {
+        const UInt_t pixid = pixel.GetPixelId();
         const MPedestalPix &ped = (*fPedestals)[pixid];
 
@@ -187,28 +184,31 @@
 	}
 
-	// Mean pedestal:
-        Double_t mean = fEnableFix ? ped.GetMean()-0.5 : ped.GetMean();
-
-	Byte_t *ptr = pixel.GetHiGainSamples();
-
-	Float_t nphot = 0.;
-	Float_t nphoterr = 0.;
-
-	// Calculate pixel signal unless it has all FADC slices empty:
-
-	if (pixel.GetSumHiGainSamples()>0)
-	  {
-	    for(Int_t i = 0; i<fWeight.GetSize(); i++)
-	      {
-		BinSignal[i] =  (Float_t) ptr[i] - mean;
-		nphot       +=  BinSignal[i] * fWeight[i];
-	      }
-	    nphoterr = ped.GetSigma()* fSumQuadWeights;
-	  }
+        //
+        // Mean pedestal:
+        //
+        const Double_t mean = fEnableFix ? ped.GetMean()-0.5 : ped.GetMean();
+
+        //
+        // Calculate pixel signal unless it has all FADC slices empty:
+        //
+        const Byte_t *ptr = pixel.GetHiGainSamples();
+
+	Float_t nphot = 0;
+        Float_t nphoterr = 0;
+
+        if (pixel.GetSumHiGainSamples()>0)
+        {
+            for (Int_t i=0; i<fWeight.GetSize(); i++)
+            {
+                binsignal[i] =  ptr[i] - mean;
+                nphot       +=  binsignal[i] * fWeight[i];
+            }
+            nphoterr = ped.GetSigma() * fSumQuadWeights;
+        }
 
         fCerPhotEvt->AddPixel(pixid, nphot, nphoterr);
 
         // FIXME! Handling of Lo Gains is missing!
-      }
+    }
 
     fCerPhotEvt->SetReadyToSave();
@@ -217,17 +217,11 @@
 }
 
+// --------------------------------------------------------------------------
 //
 // Set default values for the number of slices and weights:
 //
-
 void MCerPhotCalc::SetDefaultWeights()
 {
-  const Float_t dummy[15] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,};
-
-  fWeight.Set(15,dummy);
-  return;
-}
-
-
-
-
+    const Float_t dummy[15] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+    fWeight.Set(15, dummy);
+}
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.h	(revision 1714)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.h	(revision 1715)
@@ -10,4 +10,7 @@
 //                                                                         //
 /////////////////////////////////////////////////////////////////////////////
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
 
 #ifndef MARS_MTask
@@ -15,11 +18,8 @@
 #endif
 
-#include <TArrayF.h>
-
 class MRawEvtData;
 class MPedestalCam;
 class MCerPhotEvt;
 class MRawRunHeader;
-class TArrayF;
 
 class MCerPhotCalc : public MTask
@@ -44,5 +44,6 @@
     Bool_t ReInit(MParList *pList);
 
-    void   SetWeights(TArrayF w) {fWeight.Set(w.GetSize(),w.GetArray());}
+    // FIXME: The array size should be checked!
+    void   SetWeights(const TArrayF &w) { fWeight = w; }
 
     ClassDef(MCerPhotCalc, 0)   // Task to calculate cerenkov photons from raw data
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 1715)
@@ -158,4 +158,6 @@
         return -5.;
 
+    const UInt_t n = geom->GetNumPixels();
+
     Float_t minval = (*this)[0].GetNumPhotons();
 
@@ -164,8 +166,12 @@
         const MCerPhotPix &pix = (*this)[i];
 
+        const UInt_t id = pix.GetPixId();
+        if (id>=n)
+            continue;
+
         Float_t testval = pix.GetNumPhotons();
 
         if (geom)
-            testval *= geom->GetPixRatio(pix.GetPixId());
+            testval *= geom->GetPixRatio(id);
 
         if (testval < minval)
@@ -187,4 +193,6 @@
         return 50.;
 
+    const UInt_t n = geom->GetNumPixels();
+
     Float_t maxval = (*this)[0].GetNumPhotons();
 
@@ -193,8 +201,11 @@
         const MCerPhotPix &pix = (*this)[i];
 
+        const UInt_t id = pix.GetPixId();
+        if (id>=n)
+            continue;
+
         Float_t testval = pix.GetNumPhotons();
-
         if (geom)
-            testval *= geom->GetPixRatio(pix.GetPixId());
+            testval *= geom->GetPixRatio(id);
 
         if (testval > maxval)
@@ -322,2 +333,37 @@
     return NULL;
 }
+
+/*
+// --------------------------------------------------------------------------
+//
+// Use this function to sum photons in events together.
+//
+Bool_t MCerPhotEvt::AddEvent(const MCerPhotEvt &evt)
+{
+    if (evt.fNumPixels<=0)
+    {
+        *fLog << "Warning - Event to be added has no pixels." << endl;
+        return kFALSE;
+    }
+    if (fNumPixels<=0)
+    {
+        *fLog << "Warning - Event to add pixels to has no pixels." << endl;
+        return kFALSE;
+    }
+
+    for (UInt_t i=0; i<evt.fNumPixels; i++)
+    {
+        const UInt_t id = evt[i].GetPixId();
+
+        MCerPhotPix *pix2 = GetPixById(id);
+        if (!pix2)
+        {
+            *fLog << "Error - Pixel#" << dec << id << " does not exist in this event!" << endl;
+            return kFALSE;
+        }
+
+        pix2->AddNumPhotons(evt[i].GetNumPhotons());
+    }
+    return kTRUE;
+}
+*/
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 1714)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 1715)
@@ -30,4 +30,5 @@
     }
 
+    //Bool_t  AddEvent(const MCerPhotEvt &evt);
 
     Bool_t  IsPixelExisting(Int_t id) const;
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 1714)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 1715)
@@ -41,4 +41,6 @@
     void    Set(Float_t np, Float_t ep) { fPhot = np; fErrPhot = ep; }
 
+    void    AddNumPhotons(Float_t f)    { fPhot += f; }
+
     void    Print(Option_t *opt = NULL) const;
 
Index: /trunk/MagicSoft/Mars/mbase/MContinue.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 1715)
@@ -24,21 +24,53 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MContinue                                                               //
-//                                                                         //
-// Does nothing than return kCONTINUE in the Process-function              //
-// (use with filters)                                                      //
-//                                                                         //
+//
+// MContinue
+//
+// Does nothing than return kCONTINUE in the Process-function
+// (use with filters). For more details see the description of the
+// constructors.
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MContinue.h"
 
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MF.h"
+#include "MParList.h"
+#include "MTaskList.h"
+
 ClassImp(MContinue);
 
-MContinue::MContinue(const char *name, const char *title)
+// --------------------------------------------------------------------------
+//
+// Use this constructor if a rule (see MF for more details) shell be used.
+// MContinue will create a MF object and use it as a filter for the
+// instance. The MF-Task is added to the tasklist in front of the MContinue
+// instance and also automatically deleted, eg.
+//   MContinue cont("MHillas.fSize<20");
+//   tasklist.AddToList(&cont);
+// would skip all events which fullfill "MHillas.fSize<20" from this point
+// in the tasklist.
+//
+MContinue::MContinue(const TString rule, const char *name, const char *title)
 {
     fName  = name  ? name  : "MContinue";
     fTitle = title ? title : "Task returning kCONTINUE";
+
+    if (rule.IsNull())
+        return;
+
+    SetBit(kIsOwner);
+
+    MTask::SetFilter(new MF(rule, TString("MF(")+fName+")"));
 }
 
+// --------------------------------------------------------------------------
+//
+// Use this if you have a filter. Would be the same as if you would call:
+//   MContinue cont;
+//   cont.SetFilter(f);
+//
 MContinue::MContinue(MFilter *f, const char *name, const char *title)
 {
@@ -48,2 +80,46 @@
     SetFilter(f);
 }
+
+// --------------------------------------------------------------------------
+//
+//  Delete the filter if it was created automatically
+//
+MContinue::~MContinue()
+{
+    if (TestBit(kIsOwner))
+        delete GetFilter();
+}
+
+// --------------------------------------------------------------------------
+//
+//  In case the filter was created automatically, PreProcess tries to find
+//  the tasklist MTaskList, adds the filter before this instance to the
+//  tasklist and preprocesses the filter.
+//
+Bool_t MContinue::PreProcess(MParList *list)
+{
+    if (!TestBit(kIsOwner))
+        return kTRUE;
+
+    MTaskList *tlist = (MTaskList*)list->FindObject("MTaskList");
+    if (!tlist)
+    {
+        *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
+        return kFALSE;
+    }
+
+    if (!GetFilter())
+    {
+        *fLog << err << dbginf << "Unknown fatal Error! (fFilter=NULL?!?)" << endl;
+        return kFALSE;
+    }
+
+    if (!tlist->AddToListBefore(GetFilter(), this))
+    {
+        *fLog << err << dbginf << "ERROR - Adding filter before MContinue... abort." << endl;
+        return kFALSE;
+    }
+
+    return GetFilter()->CallPreProcess(list);
+}
+
Index: /trunk/MagicSoft/Mars/mbase/MContinue.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 1714)
+++ /trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 1715)
@@ -20,9 +20,15 @@
 {
 private:
+    Bool_t PreProcess(MParList *list);
     Bool_t Process() { return kCONTINUE; }
 
+    enum { kIsOwner = BIT(14) };
+
 public:
-    MContinue(const char *name=NULL, const char *title=NULL);
+    MContinue(const TString rule="", const char *name=NULL, const char *title=NULL);
     MContinue(MFilter *f, const char *name=NULL, const char *title=NULL);
+    ~MContinue();
+
+    void SetFilter(MFilter *filter) { if (!TestBit(kIsOwner)) MTask::SetFilter(filter); }
 
     ClassDef(MContinue, 1) //Task returning kCONTINUE
Index: /trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mbase/Makefile	(revision 1714)
+++ /trunk/MagicSoft/Mars/mbase/Makefile	(revision 1715)
@@ -20,5 +20,5 @@
 # @endcode 
 
-INCLUDES = -I. -I../mraw -I../MRawFormat -I../mmc -I../mfileio -I../mmain
+INCLUDES = -I. -I../mraw -I../MRawFormat -I../mmc -I../mfileio -I../mmain -I../mfilter
 
 # @code 
Index: /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1715)
@@ -701,4 +701,5 @@
 
     fNumFilterEvts = 0;
+    fNumEvents     = 0;
     fNumRuns       = 0;
 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 1715)
@@ -117,5 +117,5 @@
 Float_t MGeomCam::GetPixRatio(Int_t i) const
 {
-    return (*this)[0].GetA()/(*this)[i].GetA();
+    return i<fNumPixels ? (*this)[0].GetA()/(*this)[i].GetA() : 0;
 }
 
Index: /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1715)
@@ -42,5 +42,5 @@
 #include <TStyle.h>
 #include <TCanvas.h>
-#include <TButton.h>
+//#include <TButton.h>
 #include <TClonesArray.h>
 
@@ -167,6 +167,9 @@
 }
 
-inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max)
-{
+inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const UInt_t i, Float_t min, Float_t max)
+{
+    if (i>=fNumPixels)
+        return;
+
     //
     // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
@@ -178,6 +181,9 @@
 }
 
-inline void MCamDisplay::SetPixColorPedestal(const MPedestalPix &pix, const Int_t i, Float_t min, Float_t max)
-{
+inline void MCamDisplay::SetPixColorPedestal(const MPedestalPix &pix, const UInt_t i, Float_t min, Float_t max)
+{
+    if (i>=fNumPixels)
+        return;
+
     //
     // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
@@ -189,6 +195,9 @@
 }
 
-inline void MCamDisplay::SetPixColorError(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max)
-{
+inline void MCamDisplay::SetPixColorError(const MCerPhotPix &pix, const UInt_t i, Float_t min, Float_t max)
+{
+    if (i>=fNumPixels)
+        return;
+
     //
     // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
@@ -378,4 +387,19 @@
 }
 
+void MCamDisplay::SetPrettyPalette()
+{
+    SetPalette(1, 0);
+}
+
+void MCamDisplay::SetDeepBlueSeaPalette()
+{
+    SetPalette(51, 0);
+}
+
+void MCamDisplay::SetInvDeepBlueSeaPalette()
+{
+    SetPalette(52, 0);
+}
+
 // ------------------------------------------------------------------------
 //
@@ -418,19 +442,21 @@
     Paint();
 
-    //
-    // Create and draw the buttons which allows changing the
-    // color palette of the display
-    //
-    TButton *but;
-    char txt[100];
-    sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(1,0);", this);
-    but = new TButton("Pretty", txt, 0.01, 0.95, 0.15, 0.99);
-    but->Draw();
-    sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(51,0);", this);
-    but = new TButton("Deap Sea", txt, 0.16, 0.95, 0.30, 0.99);
-    but->Draw();
-    sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(52,0);", this);
-    but = new TButton("Blue Inv", txt, 0.31, 0.95, 0.45, 0.99);
-    but->Draw();
+    /*
+     //
+     // Create and draw the buttons which allows changing the
+     // color palette of the display
+     //
+     TButton *but;
+     char txt[100];
+     sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(1,0);", this);
+     but = new TButton("Pretty", txt, 0.01, 0.95, 0.15, 0.99);
+     but->Draw();
+     sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(51,0);", this);
+     but = new TButton("Deap Sea", txt, 0.16, 0.95, 0.30, 0.99);
+     but->Draw();
+     sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(52,0);", this);
+     but = new TButton("Blue Inv", txt, 0.31, 0.95, 0.45, 0.99);
+     but->Draw();
+     */
 
     //
@@ -441,5 +467,5 @@
     {
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        (*this)[i].SetBit(kNoContextMenu|kCannotPick);
+        (*this)[i].SetBit(/*kNoContextMenu|*/kCannotPick);
 #endif
         (*this)[i].SetFillColor(22);
@@ -470,5 +496,5 @@
         box->SetFillColor(22);
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        box->SetBit(kNoContextMenu|kCannotPick);
+        box->SetBit(/*kNoContextMenu|*/kCannotPick);
 #endif
         box->Draw();
@@ -478,5 +504,5 @@
         txt->SetY(H*((i+0.5)*h - 1.));
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        txt->SetBit(kNoContextMenu|kCannotPick);
+        txt->SetBit(/*kNoContextMenu|*/kCannotPick);
 #endif
         txt->Draw();
Index: /trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1714)
+++ /trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1715)
@@ -54,9 +54,9 @@
     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
 
-    void  SetPixColor(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max);
+    void  SetPixColor(const MCerPhotPix &pix, const UInt_t i, Float_t min, Float_t max);
     void  SetPixColorRatio(const MCerPhotPix &pix, Float_t min, Float_t max);
     void  SetPixColorLevel(const MCerPhotPix &pix, Float_t lvl1, Float_t lvl2);
-    void  SetPixColorError(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max);
-    void  SetPixColorPedestal(const MPedestalPix &pix, const Int_t i, Float_t min, Float_t max);
+    void  SetPixColorError(const MCerPhotPix &pix, const UInt_t i, Float_t min, Float_t max);
+    void  SetPixColorPedestal(const MPedestalPix &pix, const UInt_t i, Float_t min, Float_t max);
     Int_t GetColor(Float_t val, Float_t min, Float_t max);
 
@@ -86,4 +86,8 @@
     void SetPalette(Int_t ncolors, Int_t *colors);
 
+    void SetPrettyPalette(); // *MENU*
+    void SetDeepBlueSeaPalette(); // *MENU*
+    void SetInvDeepBlueSeaPalette(); // *MENU*
+
     ClassDef(MCamDisplay, 0) // Displays the magic camera
 };
Index: /trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1714)
+++ /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1715)
@@ -17,4 +17,6 @@
 #pragma link C++ class MHFadcCam+;
 #pragma link C++ class MHFadcPix+;
+
+#pragma link C++ class MHCerPhotEvt+;
 
 #pragma link C++ class MHHillas+;
@@ -48,5 +50,5 @@
 #pragma link C++ class MHMcEnergyImpact+;
 #pragma link C++ class MHMcCollectionArea+;
-# pragma link C++ class MHMcEnergyMigration+;
+#pragma link C++ class MHMcEnergyMigration+;
 
 #endif
Index: /trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1715)
@@ -400,9 +400,10 @@
     if (fParContainerName.IsNull())
     {
-        fParContainer = pList;
+        fParContainer = NULL; 
         return kTRUE;
     }
 
     fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
+
     if (fParContainer)
         return kTRUE;
Index: /trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 1715)
+++ /trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 1715)
@@ -0,0 +1,101 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  12/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHCerPhotEvt
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCerPhotEvt.h"
+
+ClassImp(MHCerPhotEvt);
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Width, Length
+//
+MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
+    : fEvt(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCerPhotEvt";
+    fTitle = title ? title : "Sum up camera events";
+
+    fSum.InitSize(577);
+    for (int i=0; i<577; i++)
+        fSum.AddPixel(i, 0, 0);
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHCerPhotEvt::SetupFill(const MParList *plist)
+{
+    fEvt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
+    if (!fEvt)
+        *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MHillas-Container.
+// Be careful: Only call this with an object of type MHillas
+//
+Bool_t MHCerPhotEvt::Fill(const MParContainer *par)
+{
+    const MCerPhotEvt *evt = par ? (MCerPhotEvt*)par : fEvt;
+    if (!evt)
+    {
+        *fLog << err << dbginf << "No MCerPhotEvt found..." << endl;
+        return kFALSE;
+    }
+
+    const UInt_t n = evt->GetNumPixels();
+
+    for (UInt_t i=0; i<n; i++)
+    {
+        const MCerPhotPix &pix = (*evt)[i];
+
+        fSum[pix.GetPixId()].AddNumPhotons(pix.GetNumPhotons());
+    }
+    return kTRUE;
+}
+
Index: /trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h	(revision 1715)
+++ /trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h	(revision 1715)
@@ -0,0 +1,33 @@
+#ifndef MARS_MHCerPhotEvt
+#define MARS_MHCerPhotEvt
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef MARS_MCerPhotEvt
+#include "MCerPhotEvt.h"
+#endif
+
+class TH1D;
+
+class MHCerPhotEvt : public MH
+{
+private:
+    MCerPhotEvt  fSum;
+    MCerPhotEvt *fEvt; //!
+
+public:
+    MHCerPhotEvt(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+
+    TH1 *GetHistByName(const TString name) { return NULL; }
+
+    const MCerPhotEvt &GetSum() const { return fSum; }
+
+    ClassDef(MHCerPhotEvt, 1) // Container which holds histograms for the source independent image parameters
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mhist/MHHillasExt.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillasExt.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/mhist/MHHillasExt.cc	(revision 1715)
@@ -179,5 +179,5 @@
     const MHillasSrc *src = (MHillasSrc*)par;
 
-    const Double_t scale = src ? TMath::Sign(fUseMmScale?1:fMm2Deg, src->GetCosDeltaAlpha()) : 1;
+    const Double_t scale = TMath::Sign(fUseMmScale?1:fMm2Deg, src ? src->GetCosDeltaAlpha() : 1);
 
     fHConc.Fill(fHillasExt->GetConc());
Index: /trunk/MagicSoft/Mars/mhist/MHStarMap.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1715)
@@ -68,4 +68,6 @@
     fTitle = title ? title : "Container for a Star Map" ;
 
+    *fLog << warn << "WARNING - Using MHStarMap doesn't take care of the Source Position!" << endl;
+
     //
     //   loop over all Pixels and create two histograms
Index: /trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mhist/Makefile	(revision 1714)
+++ /trunk/MagicSoft/Mars/mhist/Makefile	(revision 1715)
@@ -34,4 +34,5 @@
            MHArray.cc \
            MH3.cc \
+           MHCerPhotEvt.cc \
            MHMatrix.cc \
            MHFadcPix.cc \
@@ -82,12 +83,2 @@
 
 # @endcode
-
-
-
-
-
-
-
-
-
-
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 1714)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 1715)
@@ -130,7 +130,15 @@
 Bool_t MMcCollectionAreaCalc::Process()
 {
-//    *fLog << all << fMcEvt << " " << (int)fAllEvtsTriggered << " " << fCollArea << endl;
-    const Float_t energy = fMcEvt->GetEnergy();
-    const Float_t impact = fMcEvt->GetImpact()/100.;
+    const Double_t energy = fMcEvt->GetEnergy();
+    const Double_t impact = fMcEvt->GetImpact()/100.;
+
+    //
+    // This happens for camera files created with Camera 0.5
+    //
+    if (TMath::IsNaN(impact))
+    {
+        *fLog << err << dbginf << "ERROR - Impact=NaN (Not a number)... abort." << endl;
+        return kERROR;
+    }
 
     if (!fAllEvtsTriggered)
