Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4517)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4518)
@@ -22,5 +22,5 @@
  2004/08/05: Robert Wagner
 
-   * mtemp/mmpi/MAstroCatalog.[h,cc]
+   * mastro/MAstroCatalog.[h,cc]
      - Added MAstroCatalog::AddObject, functionality to insert single
        objects manually; needed for mtemp/mmpi/MSourceDirections
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 4517)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 4518)
@@ -60,5 +60,5 @@
     void ReadBinary(istream &in);
 
-    ClassDef(MVector3, 1) // A specialized TVector3 storeing a star-name
+    ClassDef(MVector3, 1) // A specialized TVector3 storing a star-name
 };
 
@@ -175,4 +175,5 @@
     Int_t ReadHeasarcPPM(TString catalog = "heasarc_ppm.tdat", TString fout="");
     Int_t ReadCompressed(TString catalog);
+    Int_t AddObject(Float_t ra, Float_t dec, Float_t mag, TString name="");
 
     void Print(Option_t *o="") const { fList.Print(); } // Print all stars
Index: trunk/MagicSoft/Mars/mtemp/Changelog
===================================================================
--- trunk/MagicSoft/Mars/mtemp/Changelog	(revision 4517)
+++ trunk/MagicSoft/Mars/mtemp/Changelog	(revision 4518)
@@ -18,6 +18,14 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/08/05: Robert Wagner
+
+   * mtemp/mmpi/MSourceDirections.[h,cc]
+     - Converts objects given by their sky coordinates into 
+       camera coordinates by using MAstroCamera the same way
+       as MFindStars does.
+
 
  2004/08/02: Robert Wagner
+
    * mtemp/mmpi/MFindStars.[h,cc]
      - Functionality for finding stars by using stars from star catalog
Index: trunk/MagicSoft/Mars/mtemp/mmpi/MSourceDirections.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/MSourceDirections.cc	(revision 4518)
+++ trunk/MagicSoft/Mars/mtemp/mmpi/MSourceDirections.cc	(revision 4518)
@@ -0,0 +1,149 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 expressed
+! * or implied warranty.
+! *
+!
+!   Author(s): Robert Wagner, 8/2004 <mailto:rwagner@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MSourceDirections
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MSourceDirections.h"
+
+#include <TTimer.h>
+#include <TString.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TCanvas.h>
+#include <TH1F.h>
+#include <TF1.h>
+#include <TEllipse.h>
+
+
+#include "MObservatory.h"
+#include "MAstroCamera.h"
+#include "MMcConfigRunHeader.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHCamera.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MCameraDC.h"
+#include "MTime.h"
+#include "MReportDrive.h"
+#include "MStarLocalCam.h"
+#include "MStarLocalPos.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+ClassImp(MSourceDirections);
+using namespace std;
+
+MSourceDirections::MSourceDirections(const char *name, const char *title): 
+  fGeomCam(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL)
+{
+  fName  = name  ? name  : "MSourceDirections";
+  fTitle = title ? title : "Convert Ra-Dec source positions into camera coordinates";
+  fGeometryFile="";
+}
+
+Int_t MSourceDirections::PreProcess(MParList *pList)
+{
+  fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+  if (!fGeomCam) {
+    *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
+    return kFALSE;
+  }
+  
+  fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
+  if (!fTimeCurr) {
+    *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
+    return kFALSE;
+  }
+
+  fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
+  if (!fDrive) {
+    *fLog << warn << AddSerialNumber("MReportDrive") << " not found ... aborting" << endl;
+    return kFALSE;
+  } 
+
+  fStars = (MStarLocalCam*)pList->FindCreateObj(AddSerialNumber("MStarLocalCam"),"MSourceLocalCam");
+  if (!fStars) {
+    *fLog << err << AddSerialNumber("MStarLocalCam") << " cannot be created ... aborting" << endl;
+    return kFALSE;
+  }
+  
+  MObservatory magic1;
+  
+  MMcConfigRunHeader *config=0;
+  MGeomCam           *geom=0;
+  
+  TFile file(fGeometryFile);
+  TTree *tree = (TTree*)file.Get("RunHeaders");
+  tree->SetBranchAddress("MMcConfigRunHeader", &config);
+  if (tree->GetBranch("MGeomCam")) tree->SetBranchAddress("MGeomCam", &geom);
+  tree->GetEntry(0);
+  
+  fAstro.SetMirrors(*config->GetMirrors());
+  fAstro.SetGeom(*geom);	
+  fAstro.SetObservatory(magic1);  
+    
+  return kTRUE;
+}
+
+Int_t MSourceDirections::AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name) 
+{
+  return fAstro.AddObject(ra,dec,1,name);
+}
+
+Int_t MSourceDirections::Process()
+{
+  //Fist delete the previous directions in the list
+  fStars->GetList()->Delete();
+
+  fAstro.SetTime(*fTimeCurr);
+  fAstro.SetGuiActive();
+  fAstro.FillStarList(fStars->GetList());      
+      
+  MStarLocalPos* starpos;
+  TIter Next(fStars->GetList());
+  while ((starpos=(MStarLocalPos*)Next())) {
+    starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),0.,0.);
+    starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),0.,0.,0.,1);
+  }
+    
+  if (fStars->GetList()->GetSize() == 0) {
+    *fLog << err << GetName() << "No directions inside the chosen FOV." << endl;
+  } else {
+    *fLog << inf << GetName() << " found " << fStars->GetList()->GetSize() 
+	  << " directions inside the chosen FOV." << endl;          
+  }
+  return kTRUE;
+}
+
+Int_t MSourceDirections::PostProcess()
+{
+  return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mtemp/mmpi/MSourceDirections.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/MSourceDirections.h	(revision 4518)
+++ trunk/MagicSoft/Mars/mtemp/mmpi/MSourceDirections.h	(revision 4518)
@@ -0,0 +1,49 @@
+#ifndef MARS_MSourceDirections
+#define MARS_MSourceDirections
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MAstroCamera
+#include "MAstroCamera.h"
+#endif
+
+class MTime;
+class MReportDrive;
+class MStarLocalCam;
+class MStarLocalPos;
+
+class MSourceDirections : public MTask
+{
+
+private:
+
+    MGeomCam      *fGeomCam;
+    MTime         *fTimeCurr;
+    MReportDrive  *fDrive;
+    MStarLocalCam *fStars;
+
+    MAstroCamera fAstro;
+  
+    TString fGeometryFile;
+
+  public:
+    
+    MSourceDirections(const char *name=NULL, const char *title=NULL);
+    
+    Int_t AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name="");
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    // setters
+    void SetGeometryFile(TString f) {fGeometryFile=f;}
+    void SetRaDec(Double_t ra, Double_t dec) {fAstro.SetRaDec(ra,dec);}
+    void SetRaDec(TVector3 &v) { fAstro.SetRaDec(v); }
+    void SetRadiusFOV(Double_t deg) { fAstro.SetRadiusFOV(deg); }
+    
+  ClassDef(MSourceDirections, 0) // Tool to translate RaDec Source Directions into camera coordinates
+};
+
+#endif
