Index: trunk/MagicSoft/Mars/mtemp/mifae/Changelog
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 4310)
+++ trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 4316)
@@ -18,4 +18,8 @@
 
                                                  -*-*- END OF LINE -*-*-
+  2004/06/21  Eva Domingo, Pepe Flix
+    * library/MDisp.[h,cc]
+    * library/MDispCalc.[h,cc]
+      - Included first version of DISP method evaluation classes.
 
   2004/06/15  Javier Lopez
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MDisp.cc	(revision 4316)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MDisp.cc	(revision 4316)
@@ -0,0 +1,111 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Eva Domingo  02/2004 <mailto:domingo@ifae.es>
+!   Author(s): Josep Flix   02/2004 <mailto:jflix@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MDisp
+//
+// Storage Container for image parameters
+//
+//    Disp method for extended sources analysis related image parameters
+//
+//
+// Version 1:
+// ----------
+//  fDisp          Distance along the major axis from the centroid to the suspected position of the source
+//  fPosDisp1      Position of Disp evaluated point 1 in the camera in [mm]
+//  fPosDisp2      Position of Disp evaluated point 2 in the camera in [mm]
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MDisp.h"
+
+#include <iostream.h>
+//#include <TArrayF.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDisp);
+
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MDisp::MDisp(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MDisp";
+    fTitle = title ? title : "Parameter related to Disp method for extended sources analysis";
+
+}
+
+void MDisp::SetPosDisp(char *var, Float_t value)
+{
+
+    if ( !strcmp(var,"X1") )
+	fX1 = value;
+    else if ( !strcmp(var,"Y1") )
+	fY1 = value;
+    else if ( !strcmp(var,"X2") )
+	fX2 = value;
+    else if ( !strcmp(var,"Y2") )
+	fY2 = value;  
+    else
+	cout << "SetPosDisp:: Coordinate argument WRONG!" << endl;
+
+};
+
+
+Float_t MDisp::GetPosDisp(char *var)
+{
+
+    if ( !strcmp(var,"X1") )
+	return fX1;
+    else if ( !strcmp(var,"Y1") )
+	return fY1;
+    else if ( !strcmp(var,"X2") )
+	return fX2;
+    else if ( !strcmp(var,"Y2") )
+	return fY2;  
+    else
+    {
+	cout << "GetPosDisp:: Coordinate argument WRONG!" << endl;
+	return -9999.;
+    }
+};
+
+
+void MDisp::Print(Option_t *opt) const
+{
+      *fLog << all << GetDescriptor() << ":" << endl;
+      *fLog << "Disp [mm] = " << fDisp << ": ";
+      *fLog << "DX1 [mm] = " << fX1 << ": ";
+      *fLog << "DY1 [mm] = " << fY1 << ": ";
+      *fLog << "DX2 [mm] = " << fX2 << ": ";
+      *fLog << "DY2 [mm] = " << fY2 << ": ";
+      *fLog << "PsiEvent[mm] =" << fPsiEvent << ": " << endl;  
+};
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MDisp.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MDisp.h	(revision 4316)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MDisp.h	(revision 4316)
@@ -0,0 +1,47 @@
+#ifndef MARS_MDisp
+#define MARS_MDisp
+
+#ifndef MARS_MSrcPosCam
+#include "MSrcPosCam.h"
+#endif
+
+class MSrcPosCam;
+
+class MDisp : public MParContainer
+{
+private:
+
+    Float_t fX1; // Position of Disp evaluated point 1 in the camera in [mm]
+    Float_t fY1;
+
+    Float_t fX2; // Position of Disp evaluated point 2 in the camera in [mm]
+    Float_t fY2;
+
+    Float_t fDisp;                // [mm]  distance along the major axis from the centroid
+                                  //       to the suspected position of the source 
+    Float_t fPsi;                 // [mm]  Psi Disp parameter (has to fixed before Disp calculations,
+                                  //                      used for fPosDisp1, fPosDisp2, fDisp determination)
+
+    Float_t fPsiEvent;            // [mm]  Psi Disp parameter evaluated for every event (uses fSrcPos as Disp)
+
+
+public:
+
+    MDisp(const char *name=NULL, const char *title=NULL);
+
+    Float_t GetPosDisp(char *var);
+    Float_t GetDisp()               { return fDisp; } 
+    Float_t GetPsi()                { return fPsi; } 
+    Float_t GetPsiEvent()           { return fPsiEvent; } 
+
+    void SetPosDisp(char *var, Float_t value);
+    void SetDisp(Float_t disp)                { fDisp=disp; } 
+    void SetPsi(Float_t psi)                  { fPsi=psi; } 
+    void SetPsiEvent(Float_t psievent)        { fPsiEvent=psievent; } 
+
+    void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MDisp, 1) // Container to hold disp related parameters
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MDispCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MDispCalc.cc	(revision 4316)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MDispCalc.cc	(revision 4316)
@@ -0,0 +1,129 @@
+#include "MDispCalc.h"
+
+#include "MParList.h"
+
+#include "MDisp.h"
+#include "MHillas.h"
+#include "MHillasSrc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDispCalc);
+
+using namespace std;
+
+static const TString gsDefName  = "MDispCalc";
+static const TString gsDefTitle = "Calculate Disp related parameters";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MDispCalc::MDispCalc(const char *name, const char *title)
+    : fHillas(NULL), fHillasSrc(NULL), fSrcPos(NULL), fDisp(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MDispCalc::PreProcess(MParList *pList)
+{
+
+    fHillas = (MHillas*)pList->FindObject("MHillas");
+    if (!fHillas)
+    {
+        *fLog << err << dbginf << "MHillas not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHillasSrc = (MHillasSrc*)pList->FindObject("MHillasSrc");
+    if (!fHillasSrc)
+    {
+        *fLog << err << dbginf << "MHillasSrc not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSrcPos = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
+    if (!fSrcPos)
+    {
+        *fLog << err << dbginf << "SrcPosCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fDisp = (MDisp*)pList->FindCreateObj("MDisp");
+    if (!fDisp)
+        return kFALSE;
+ 
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MDispCalc::Process()
+{
+
+    fDisp->SetPsi(fPsi);
+
+    if ( fHillas->GetWidth()==-1 || fHillas->GetLength()==-1 )
+      {
+	fErrors++;
+	return kTRUE;
+      }
+
+    Float_t xshift = 0.;
+    Float_t yshift = 0.;
+
+    if ( fSrcPos )
+      {
+	xshift = fSrcPos->GetX();
+	yshift = fSrcPos->GetY();
+      }
+
+    fDisp->SetDisp(fPsi*(1-(fHillas->GetWidth()/fHillas->GetLength())));
+    fDisp->SetPosDisp("X1", fHillas->GetMeanX() - (fDisp->GetDisp()*fHillas->GetCosDelta()) - xshift);
+    fDisp->SetPosDisp("Y1", fHillas->GetMeanY() - (fDisp->GetDisp()*fHillas->GetSinDelta()) - yshift);
+    fDisp->SetPosDisp("X2", fHillas->GetMeanX() + (fDisp->GetDisp()*fHillas->GetCosDelta()) - xshift);
+    fDisp->SetPosDisp("Y2", fHillas->GetMeanY() + (fDisp->GetDisp()*fHillas->GetSinDelta()) - yshift);
+
+    if ( (1-fHillas->GetWidth()/fHillas->GetLength()) == 0. )
+      {
+	fErrors++;
+	return kTRUE;
+      }
+
+    fDisp->SetPsiEvent(fHillasSrc->GetDist()/(1-fHillas->GetWidth()/fHillas->GetLength()));
+
+    fDisp->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the disp calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+Int_t MDispCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: (1-w/l)==0 or (Width or Length == -1)" << endl;
+    *fLog << endl;
+
+    /*
+    delete fHillas;
+    delete fHillasSrc;
+    delete fSrcPos;
+    delete fDisp;
+    */
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MDispCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MDispCalc.h	(revision 4316)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MDispCalc.h	(revision 4316)
@@ -0,0 +1,45 @@
+#ifndef MARS_MDispCalc
+#define MARS_MDispCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MSrcPosCam
+#include "MSrcPosCam.h"
+#endif
+
+class MHillas;
+class MHillasSrc;
+class MDisp;
+class MSrcPosCam;
+
+class MDispCalc : public MTask
+{
+private:
+
+    MHillas    *fHillas;     //! Pointer to the source independent hillas parameters
+    MHillasSrc *fHillasSrc;  //! Pointer to the source dependent hillas parameters
+    MSrcPosCam *fSrcPos;     //! Pointer to the source position
+    MDisp *fDisp; 
+
+    Float_t fPsi;                 // [mm]  Psi Disp parameter (has to fixed before Disp calculations,
+                                  //                      used for fPosDisp1, fPosDisp2, fDisp determination)
+    
+    Int_t       fErrors;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+
+    MDispCalc(const char *name=NULL, const char *title=NULL);
+    
+    void SetSrcPos(Float_t xpos, Float_t ypos) {fSrcPos->SetXY(xpos,ypos);}
+    void SetPsi(Float_t psi) {fPsi = psi;}
+
+    ClassDef(MDispCalc, 0) // task to calculate the Disp parameter and related positions
+};
+
+#endif
