Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4825)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4826)
@@ -19,8 +19,49 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2004/09/1: Thomas Bretz
+
+   * mfileio/MWriteRootFile.[h,cc]:
+     - do not add a container which is already in the list
+     - replaced fNameCont by fTitle in MRootFileBranch
+
+   * mgeom/MGeomPix.[h,cc]:
+     - declared tan(30)
+     - added GetL member function
+
+   * mhist/MHAlpha.cc:
+     - added a logging output
+
+   * mhist/MHFalseSource.[h,cc]:
+     - shift by MSrcPosCam introduced
+     - fixed on-off plot
+     - fixed changed return value MHillasSrc::Calc
+     - as a workaround for some crashes removed SetBit(kCanDelete)
+       of catalog
+
+   * mimage/MHHillasSrc.cc, mimage/MHillasSrc.cc:
+     - some small fixes to new plots
+     - some cosmetics to the code
+
+   * mimage/MHillas.cc, mimage/MHillasExt.cc, 
+     mimage/MImagePar.cc, mimage/MImgCleanStd.cc,
+     mimage/MNewImagePar.cc:
+     - removed obsolete include of fstream
+
+   * mpointing/Makefile, mpointing/PointingLinkDef.h:
+     - added new class MPointingPosFromModel
+     
+   * mpointing/MPointingPosFromModel.[h,cc]:
+     - added
+
+
+
  2004/08/31: Daniel Mazin
 
    * manalysis/MSigmabarCalc.h:
-     - added function SetNamePedPhotCam to set the name of the MPedPhotCam container
+     - added function SetNamePedPhotCam to set the name of the 
+       MPedPhotCam container
+
+
 
  2004/08/31: Thomas Bretz
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 4825)
+++ trunk/MagicSoft/Mars/NEWS	(revision 4826)
@@ -54,4 +54,8 @@
    - The the mars-executable Camera Display can now also read
      calibrated data files written by callisto/MJCalibrateSignal
+
+   - Added a new class which can calculate the source position in
+     the camera from a pointing model known to be correct and
+     the pointing model used for observations (MSrcPosFromModel)
 
 
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 4826)
@@ -233,5 +233,5 @@
         name += branch->GetName();
 
-        *fLog << " " << name.Strip(TString::kTrailing, '.') << ": \t" << branch->GetEntries() << " entries." << endl;
+        *fLog << " " << name.Strip(TString::kTrailing, '.') << ": \t" << (ULong_t)branch->GetEntries() << " entries." << endl;
     }
 
@@ -240,5 +240,5 @@
     while ((t=(TTree*)NextTree()))
         if (t->TestBit(kIsNewTree))
-            *fLog << " " << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
+            *fLog << " " << t->GetName() << ": \t" << (ULong_t)t->GetEntries() << " entries." << endl;
     *fLog << endl;
 }
@@ -257,4 +257,13 @@
 void MWriteRootFile::AddContainer(const char *cname, const char *tname, Bool_t must)
 {
+    TIter Next(&fBranches);
+    TObject *o=0;
+    while ((o=Next()))
+        if (TString(o->GetName())==TString(tname) && TString(o->GetTitle())==TString(cname))
+        {
+            *fLog << "WARNING - Container '" << cname << "' in Tree '" << tname << "' already scheduled... ignored." << endl;
+            return;
+        }
+
     //
     // create a new entry in the list of branches to write and
@@ -281,4 +290,14 @@
                                   Bool_t must)
 {
+    TIter Next(&fBranches);
+    TObject *o=0;
+    while ((o=Next()))
+        if (TString(o->GetName())==TString(tname) &&
+            static_cast<MRootFileBranch*>(o)->GetContainer()==cont)
+        {
+            *fLog << "WARNING - Container " << cont << " in Tree '" << tname << "' already scheduled... ignored." << endl;
+            return;
+        }
+
     //
     // create a new entry in the list of branches to write and
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 4825)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 4826)
@@ -23,5 +23,4 @@
 
     MParContainer *fContainer;
-    TString        fContName;
 
     Bool_t         fMust;
@@ -37,5 +36,5 @@
     {
         Init(NULL, kFALSE);
-        fContName = "";
+        fTitle = "";
     }
 
@@ -44,11 +43,12 @@
     {
         Init(tname, must);
-        fContName = cname;
+        fTitle = cname;
     }
 
     MRootFileBranch(MParContainer *cont, const char *tname=NULL, Bool_t must=kFALSE)
-        : fTree(NULL), fBranch(NULL), fContName(""), fMust(0)
+        : fTree(NULL), fBranch(NULL), fMust(0)
     {
         Init(tname, must);
+        fTitle = "";
         fContainer = cont;
     }
@@ -58,5 +58,5 @@
     void          *GetAddress()         { return &fContainer; }
     TBranch       *GetBranch() const    { return fBranch; }
-    const char    *GetContName() const  { return fContName; }
+    const char    *GetContName() const  { return fTitle; }
     Bool_t         MustHave() const     { return fMust; }
 
Index: trunk/MagicSoft/Mars/mgeom/MGeomPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 4826)
@@ -65,4 +65,5 @@
 using namespace std;
 
+const Float_t MGeomPix::gsTan30 = tan(30/kRad2Deg);
 const Float_t MGeomPix::gsTan60 = tan(60/kRad2Deg);
 
Index: trunk/MagicSoft/Mars/mgeom/MGeomPix.h
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 4825)
+++ trunk/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 4826)
@@ -12,4 +12,5 @@
 private:
     static const Float_t gsTan60; // tan(60/kRad2Deg);
+    static const Float_t gsTan30; // tan(30/kRad2Deg);
 
     enum {
@@ -45,4 +46,5 @@
     Float_t GetY() const  { return fY; }
     Float_t GetD() const  { return fD; }
+    Float_t GetL() const  { return fD*gsTan30; } // Length of one of the parallel sides
     UInt_t  GetSector() const { return fSector; }
 
Index: trunk/MagicSoft/Mars/mhist/MHAlpha.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHAlpha.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mhist/MHAlpha.cc	(revision 4826)
@@ -138,5 +138,8 @@
         const MHillasSrc *hil = dynamic_cast<const MHillasSrc*>(par);
         if (!par)
+        {
+            *fLog << err << dbginf << "MHillasSrc not found... abort." << endl;
             return kFALSE;
+        }
 
         alpha = hil->GetAlpha();
Index: trunk/MagicSoft/Mars/mhist/MHFalseSource.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFalseSource.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mhist/MHFalseSource.cc	(revision 4826)
@@ -276,4 +276,8 @@
         *fLog << warn << "MTime not found... no derotation." << endl;
 
+    fSrcPos = (MSrcPosCam*)plist->FindObject(AddSerialNumber("MSrcPosCam"));
+    if (!fSrcPos)
+        *fLog << warn << "MSrcPosCam not found... no translation." << endl;
+
     fObservatory = (MObservatory*)plist->FindObject(AddSerialNumber("MObservatory"));
     if (!fObservatory)
@@ -341,8 +345,12 @@
             // convert degrees to millimeters
             v *= 1./fMm2Deg;
+
+            if (fSrcPos)
+                v += fSrcPos->GetXY();
+
             src.SetXY(v);
 
             // Source dependant hillas parameters
-            if (!hsrc.Calc(*hil))
+            if (hsrc.Calc(*hil)>0)
             {
                 *fLog << warn << "Calculation of MHillasSrc failed for x=" << cx[ix] << " y=" << cy[iy] << endl;
@@ -498,5 +506,5 @@
     if ((h5 = (TH2D*)gPad->FindObject("Alpha_yx_diff")))
     {
-        h5->Add(h3, h2, -1);
+        h5->Add(h2, h3, -1);
         MakeSymmetric(h5);
     }
@@ -575,5 +583,5 @@
     *fLog << err << "FIXME - The catalog will never be deleted, because this crashes!" << endl;
 
-    stars->SetBit(kCanDelete);
+//    stars->SetBit(kCanDelete);
 
     return stars;
Index: trunk/MagicSoft/Mars/mhist/MHFalseSource.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFalseSource.h	(revision 4825)
+++ trunk/MagicSoft/Mars/mhist/MHFalseSource.h	(revision 4826)
@@ -14,4 +14,5 @@
 class MParList;
 class MTime;
+class MSrcPosCam;
 class MPointingPos;
 class MObservatory;
@@ -22,4 +23,5 @@
     MTime         *fTime;        //! container to take the event time from
     MPointingPos  *fPointPos;    //! container to take pointing position from
+    MSrcPosCam    *fSrcPos;      //! container for sopurce position in camera
     MObservatory  *fObservatory; //! conteiner to take observatory location from
 
Index: trunk/MagicSoft/Mars/mimage/MHHillasSrc.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHHillasSrc.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mimage/MHHillasSrc.cc	(revision 4826)
@@ -73,6 +73,6 @@
     fDist  = new TH1F("Dist",  "Dist of Ellipse",                 100,   0, 445);
     fCosDA = new TH1F("CosDA", "cos(Delta,Alpha) of Ellipse",     101,  -1,   1);
-    fDCA   = new TH1F("DCA",   "Distance of closest aproach",     101,  -1,   1);
-    fDCADelta  = new TH1F("DCADelta",  "Angle between shower and x-axis", 101,   0, 360);
+    fDCA   = new TH1F("DCA",   "Distance of closest aproach",     101,  -500,   500);
+    fDCADelta = new TH1F("DCADelta", "Angle between shower and x-axis", 101,   0, 360);
 
     fAlpha->SetDirectory(NULL);
@@ -132,5 +132,5 @@
     ApplyBinning(*plist, "Dist",     fDist);
     ApplyBinning(*plist, "DCA",      fDCA);
-    ApplyBinning(*plist, "DCADelta",     fDCADelta);
+    ApplyBinning(*plist, "DCADelta", fDCADelta);
 
     return kTRUE;
@@ -203,5 +203,5 @@
 
     fDist->SetXTitle(mmscale ? "Dist [mm]" : "Dist [\\circ]");
-    fDCA->SetXTitle(mmscale ? "DCA [mm]" : "DCA [\\circ]");
+    fDCA ->SetXTitle(mmscale ? "DCA [mm]"  : "DCA [\\circ]");
 
     fUseMmScale = mmscale;
Index: trunk/MagicSoft/Mars/mimage/MHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillas.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mimage/MHillas.cc	(revision 4826)
@@ -60,6 +60,4 @@
 #include "MHillas.h"
 
-#include <fstream>
-
 #include <TArrayF.h>
 #include <TEllipse.h>
Index: trunk/MagicSoft/Mars/mimage/MHillasExt.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasExt.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mimage/MHillasExt.cc	(revision 4826)
@@ -63,5 +63,4 @@
 #include "MHillasExt.h"
 
-#include <fstream>
 #include <TArrayF.h>
 
Index: trunk/MagicSoft/Mars/mimage/MHillasSrc.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasSrc.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mimage/MHillasSrc.cc	(revision 4826)
@@ -69,5 +69,4 @@
 #include "MHillasSrc.h"
 
-#include <fstream>
 #include <TArrayF.h>
 
@@ -99,5 +98,5 @@
 
     fDCA           = -1;
-    fDCADelta          =  0;
+    fDCADelta      =  0;
 }
 
Index: trunk/MagicSoft/Mars/mimage/MImagePar.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImagePar.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mimage/MImagePar.cc	(revision 4826)
@@ -36,6 +36,4 @@
 /////////////////////////////////////////////////////////////////////////////
 #include "MImagePar.h"
-
-#include <fstream>
 
 #include "MLog.h"
Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 4826)
@@ -605,5 +605,5 @@
 
 #ifdef DEBUG
-        *fLog << all << "Calc Islands" << endl;
+    *fLog << all << "Calc Islands" << endl;
 #endif
     // Takes roughly 10% of the time
Index: trunk/MagicSoft/Mars/mimage/MNewImagePar.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MNewImagePar.cc	(revision 4825)
+++ trunk/MagicSoft/Mars/mimage/MNewImagePar.cc	(revision 4826)
@@ -69,6 +69,4 @@
 #include "MNewImagePar.h"
 
-#include <fstream>
-
 #include "MLog.h"
 #include "MLogManip.h"
Index: trunk/MagicSoft/Mars/mpointing/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mpointing/Makefile	(revision 4825)
+++ trunk/MagicSoft/Mars/mpointing/Makefile	(revision 4826)
@@ -26,5 +26,6 @@
 	   MPointingPosCalc.cc \
            MSrcPosCam.cc \
-           MSrcPosCalc.cc
+           MSrcPosCalc.cc \
+           MSrcPosFromModel.cc
 
 ############################################################
Index: trunk/MagicSoft/Mars/mpointing/PointingLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mpointing/PointingLinkDef.h	(revision 4825)
+++ trunk/MagicSoft/Mars/mpointing/PointingLinkDef.h	(revision 4826)
@@ -10,6 +10,7 @@
 #pragma link C++ class MPointingPosCalc+;
 
+#pragma link C++ class MSrcPosCam+;
 #pragma link C++ class MSrcPosCalc+;
-#pragma link C++ class MSrcPosCam+;
+#pragma link C++ class MSrcPosFromModel+;
 
 #endif
