Index: /trunk/MagicSoft/Mars/mtemp/mifae/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 4117)
@@ -19,4 +19,25 @@
                                                  -*-*- END OF LINE -*-*-
 	
+ 2004/05/21  Javier Rico
+   * library/MDCA.[cc.h]
+     - removed
+
+   * library/MDisplay.[h,cc], library/MHillasDisplay.[h,cc]
+     - added
+
+   * library/Makefile, library/IFAELinkDef.h
+     - remove MDCA
+     - add MDisplay and MHillasDisplay
+
+   * library/MSrcPlace.[h,cc], library/MSrcRotate.[h,cc],
+     library/MSrcTranslate.[h,cc], library/MSrcPosFromFile.cc
+     - remove MDCA dependences
+
+   * programs/makeHillas.cc, programs/makehillas.datacard
+     - include display and selection cuts options
+	
+   * programs/Makefile
+     - include mfbase in the list of includes directory
+
  2004/05/18  Javier Rico
    * macros/plotOptimal.C
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/IFAELinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/IFAELinkDef.h	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/IFAELinkDef.h	(revision 4117)
@@ -5,5 +5,6 @@
 #pragma link off all functions;
 
-#pragma link C++ class MDCA+;
+#pragma link C++ class MDisplay+;
+#pragma link C++ class MHillasDisplay+;
 #pragma link C++ class MPSFFit+;
 #pragma link C++ class MPSFFitCalc+;
Index: unk/MagicSoft/Mars/mtemp/mifae/library/MDCA.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MDCA.cc	(revision 4116)
+++ 	(revision )
@@ -1,261 +1,0 @@
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MDCA.cc                                                                 //
-// Container to store Hillas parameters and DCA stuff                      //
-//                                                                         //
-// Author(s): S.C. Commichau, L.S. Stark, 7/2003                           //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-
-#include "MDCA.h"
-
-using namespace std;
-
-ClassImp(MDCA); 
-
-// Default constructor
-MDCA::MDCA(const char *name, const char *title)
-{
-    fName = name ? name : "MDCA";
-    fTitle = title ? title : "Storage container for Hillas parameters and DCA of one event";
- 
-    Reset();
-   
-    fEllipse = new TEllipse;
-    fRefCircle = new TEllipse;
-    
-    fLineL = new TLine;
-    fLineW = new TLine;
-    fLineX = new TLine;
-    fLineY = new TLine;
-    fLineDCA = new TLine;
-    fLineMean = new TLine;
-  
-}
-
-// Destructor: Deletes ellipse and lines if they do exist
-
-MDCA::~MDCA()
-{
-    Clear();
-}
-
-// Initialize parameters with default values
-
-void MDCA::Reset()
-{
-
-    fLength = -1;
-    fWidth  = -1;
-    fDelta0 =  0;
-    fMeanX  =  0;
-    fMeanY  =  0;
-    fDelta1 =  0;
-    fDCA    = -1000;
-    fX1W    =  0;
-    fY1W    =  0;
-    fX2W    =  0;
-    fY2W    =  0;
-    fX1L    =  0;
-    fY1L    =  0;
-    fX2L    =  0;
-    fY2L    =  0;
-    fXDCA   =  0;
-    fYDCA   =  0;
-  
-}
-
-
-// Print parameters to *fLog
-
-void MDCA::Print(Option_t *) const
-{
-    Double_t atg = atan2(fMeanY, fMeanX)*kRad2Deg;
-
-    if (atg<0)
-        atg += 180;
-
-    *fLog << all;
-    *fLog << "Basic Image Parameters (" << GetName() << ")" << endl;
-    *fLog << " - Length      [mm]  = " << fLength << endl;
-    *fLog << " - Width       [mm]  = " << fWidth  << endl;
-    *fLog << " - Delta0      [deg] = " << fDelta0*kRad2Deg << endl;
-    *fLog << " - Meanx       [mm]  = " << fMeanX  << endl;
-    *fLog << " - Meany       [mm]  = " << fMeanY  << endl;
-    *fLog << " - atg(y/x)    [deg] = " << atg     << endl;
-    *fLog << " - DCA         [mm]  = " << fDCA << endl;
-    *fLog << " - Delta1      [deg] = " << fDelta1*kRad2Deg << endl;
-
-    
-}
-
-void MDCA::Paint(Option_t *opt)
-{
-    Clear();
-
-    if (fLength<=0 || fWidth<=0) //fLength<0 || fWidth<0 doesn't look nice...
-        return;                  //We get a circle!
-
-    // Length line
-    fLineL = new TLine(fX1L, fY1L, fX2L, fY2L);
-    fLineL->SetLineWidth(2);
-    fLineL->SetLineColor(2);
-    fLineL->Draw();
-
-    // Width line
-    fLineW = new TLine(fX1W, fY1W, fX2W, fY2W);
-    fLineW->SetLineWidth(2);
-    fLineW->SetLineColor(2);
-    fLineW->Draw();
-
-    // Coordinate system
-    fLineX = new TLine(-600,fYRef,600,fYRef);
-    fLineY = new TLine(fXRef,-600,fXRef,600);
-    fLineX->SetLineWidth(1);
-    fLineX->SetLineColor(108);
-    fLineY->SetLineWidth(1);
-    fLineY->SetLineColor(108);
-    fLineX->Draw();
-    fLineY->Draw();
-    
-    // DCA line
-    fLineDCA = new TLine(fXRef,fYRef,fXDCA+fXRef,fYDCA+fYRef);
-    fLineDCA->SetLineWidth(2);
-    fLineDCA->SetLineColor(2);
-    fLineDCA->Draw();
-
-    // COG line
-    fLineMean = new TLine(fXRef,fYRef,fMeanX,fMeanY);
-    fLineMean->SetLineWidth(2);
-    fLineMean->SetLineColor(2);
-    fLineMean->Draw();
-
-    // Reference point marker
-    fRefCircle = new TEllipse(fXRef, fYRef, 10, 10, 0, 360, 0);
-    fRefCircle->SetLineColor(108);
-    fRefCircle->SetFillColor(108);
-    fRefCircle->Draw();
-
-    // Hillas ellipse
-    fEllipse = new TEllipse(fMeanX, fMeanY, fLength, fWidth, 0, 360, fDelta0*kRad2Deg+180);
-    fEllipse->SetLineWidth(2);
-    fEllipse->SetLineColor(2);
-    fEllipse->Draw();
-
-}
-
-
-// If an ellipse and lines exist they will be deleted 
-
-void MDCA::Clear(Option_t *)
-{
-    if (!fEllipse && !fRefCircle && !fLineL && !fLineW && !fLineX && !fLineY && !fLineDCA && !fLineMean) 
-        return;
- 
-    delete fEllipse;
-    delete fRefCircle;
-    delete fLineL;
-    delete fLineW;
-    delete fLineX;
-    delete fLineY;
-    delete fLineDCA;
-    delete fLineMean;
-     
-    fLineL = NULL;
-    fLineX = NULL;
-    fLineY = NULL;
-    fLineW = NULL;
-    fLineDCA = NULL;
-    fLineMean = NULL;
-    fEllipse = NULL;
-    fRefCircle = NULL;
-}
-
-
-Int_t MDCA::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hil)
-{
-    // Get basic Hillas parameters from MHillas
-    fDelta0 = hil.GetDelta();
-    fMeanX  = hil.GetMeanX();
-    fMeanY  = hil.GetMeanY();
-    fLength = hil.GetLength();
-    fWidth  = hil.GetWidth();
-
-    // The Length Line - rotation and shift
-    fX1L = - (fLength+OffsetL)*cos(fDelta0) + fMeanX; // [mm]    
-    fY1L = - (fLength+OffsetL)*sin(fDelta0) + fMeanY; // [mm]    
-    fX2L =   (fLength+OffsetL)*cos(fDelta0) + fMeanX; // [mm]    
-    fY2L =   (fLength+OffsetL)*sin(fDelta0) + fMeanY; // [mm]
-
-    // The Width Line - rotation and shift
-    fX1W =   (fWidth+OffsetW)*sin(fDelta0) + fMeanX;  // [mm]   
-    fY1W = - (fWidth+OffsetW)*cos(fDelta0) + fMeanY;  // [mm]   
-    fX2W = - (fWidth+OffsetW)*sin(fDelta0) + fMeanX;  // [mm]   
-    fY2W =   (fWidth+OffsetW)*cos(fDelta0) + fMeanY;  // [mm]  
-
-    // Vector of orientation of the shower axis
-    fr1 = fX2L-fX1L;  
-    fr2 = fY2L-fY1L;  
-       
-    // Determine parameters to calculate coordinates of the DCA vector
-    flambda = (fr1*(fXRef-fMeanX) + fr2*(fYRef-fMeanY))/(fr1*fr1 + fr2*fr2);
-    fmu = (fMeanY-fYRef)/fr1 + flambda*fr2/fr1;
-
-    // Components of the DCA vector
-    fXDCA = -fmu*fr2;
-    fYDCA =  fmu*fr1;
-  
-    // Components of vector going from intersection point of the DCA vector
-    // with the shower axis to the COG
-    fd1 = fMeanX + fmu*fr2 - fXRef;
-    fd2 = fMeanY - fmu*fr1 - fYRef;
-
-    // Calculate DCA value 
-    fDCA = sqrt(fXDCA*fXDCA + fYDCA*fYDCA);
-
-    // Calculate angle of the shower axis with respect to the x-axis
-    fDelta1 = acos(fd1/sqrt(fd1*fd1 + fd2*fd2)); //botch
-
-    // Calculate angle of the shower axis with respect to the y-axis
-    //fDelta1 = acos(fd2/sqrt(fd1*fd1 + fd2*fd2)); 
-
-    // Determine the correct sign of the DCA (cross product of DCA vector and 
-    // vector going from the intersection point of the DCA vector with the shower axis
-    // to the COG)
-    if((fmu*(-fr2*(fMeanY-fYRef)-fr1*(fMeanX-fXRef)))<0)
-       fDCA = -fDCA;    
-
-    gRandom->Rannor(gx,gy);
-    gx = fabs(gx);
-  
-    // This is nice but does not remove the systematics in the profile plot...
-    //if(((1-0.6*gx)*(180-kRad2Deg*fDelta1)>120) || ((1-0.6*gx)*kRad2Deg*fDelta1>120))
-      // fDCA = -1;
-
-    // Enlarge the interval of Delta correctly...
-    if((fMeanY-fYRef-fmu*fr1)<0)
-       fDelta1 = TwoPi-fDelta1;
-
-    // Enlarge the interval of Delta correctly... (Delta with respect to the y-axis)
-    // if(-(fMeanX-fXRef+fmu*fr2)<0)
-     //  fDelta1 = TwoPi-fDelta1;
-
-    // This has to be improved...
-    if(fr1 == 0 || fr2 == 0 || (fr1*fr1+fr2*fr2) == 0 || sqrt(fd1*fd1+fd2*fd2) == 0)
-       fDCA = -fDCA;
-
-    SetReadyToSave();
-   
-    return 0;
-}
-
-void MDCA::SetRefPoint(const Float_t fXRef0, const Float_t fYRef0)
-{
-    fXRef = fXRef0;
-    fYRef = fYRef0;
-}
-
-
-
-
Index: unk/MagicSoft/Mars/mtemp/mifae/library/MDCA.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MDCA.h	(revision 4116)
+++ 	(revision )
@@ -1,118 +1,0 @@
-#ifndef MARS_MDCA 
-#define MARS_MDCA
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MDCA.cc                                                                 //
-// Container to store the DCA stuff                                        //
-//                                                                         //
-// Author(s): S.C. Commichau, L.S. Stark, 7/2003                           //
-//                                                                         //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-
-#include <TArrayF.h>
-#include <TEllipse.h>
-#include <TLine.h>
-#include <TCanvas.h>
-#include <TROOT.h>
-#include <TStyle.h> 
-#include <TMath.h>
-#include <math.h>
-#include <TPad.h>
-#include <TRandom.h>
-#include <TRandom2.h>
-#include <fstream>
-#include <iostream>
-
-#include "MLog.h"
-#include "MLogManip.h"
-#include "MGeomCam.h"
-#include "MGeomPix.h"
-#include "MCerPhotPix.h"
-#include "MCerPhotEvt.h"
-#include "MHillas.h"
-
-// Add offsets to the Width and Length to draw nice lines
-#define OffsetW 20.0
-#define OffsetL 440.0
-
-#define kmm2Deg 0.00317460317
-#define TwoPi 6.28318530717958623 
-
-class TArrayF;
-class TEllipse;
-class MGeoCam;
-class MCerPhotEvt;
-class MHillas;
-
-class MDCA : public MParContainer
-{
- private:
-    
-    Float_t fLength;  // [mm]   major axis of ellipse
-    Float_t fWidth;   // [mm]   minor axis of ellipse
-    Float_t fDelta0;  // [rad]  angle of major axis with x-axis (-Pi/2 .. Pi/2)
-    Float_t fDelta1;  // [rad]  my angle of major axis with x-axis (0 .. 2*Pi)
-    Float_t fMeanX;   // [mm]   x-coordinate of center of ellipse
-    Float_t fMeanY;   // [mm]   y-coordinate of center of ellipse
-    Float_t fX1W;     // [mm]   x-coordinate of 1st point of Lline
-    Float_t fY1W;     // [mm]   y-coordinate of 1st point of Lline
-    Float_t fX2W;     // [mm]   x-coordinate of 2nd point of Lline
-    Float_t fY2W;     // [mm]   y-coordinate of 2nd point of Lline
-    Float_t fX1L;     // [mm]   x-coordinate of 1st point of Wline
-    Float_t fY1L;     // [mm]   y-coordinate of 1st point of Wline
-    Float_t fX2L;     // [mm]   x-coordinate of 2nd point of Wline
-    Float_t fY2L;     // [mm]   y-coordinate of 2nd point of Wline
-    Double_t fDCA;    // [mm]   Distance of Cloasest Approach 
-    Float_t fXDCA;    // [mm]   x-coordinate of 2nd point of the DCA-line 
-    Float_t fYDCA;    // [mm]   y-coordinate of 2nd point of the DCA-line  
-    Float_t fXRef;    // [mm]   x-coordinate of reference point
-    Float_t fYRef;    // [mm]   y-coordinate of reference point
-    Float_t fmu;
-    Float_t flambda;  
-    Float_t fr1, fr2; // [mm] Coordinates of the orientation vector of the shower axis
-    Float_t fd1, fd2; // [mm] Coordinates of the DCA vector
-    Float_t gx, gy;
-   
-    TEllipse *fEllipse;   // Graphical object to draw the ellipse, ROOT!
-    TEllipse *fRefCircle; // To draw reference point
-
-    TLine *fLineL;        // Shower axis
-    TLine *fLineW;        // Line perpendicular to the shower axis
-    TLine *fLineX;        // x-axis of the coordinate system 
-    TLine *fLineY;        // y-axis of the coordinate system  
-    TLine *fLineDCA;      // DCA line
-    TLine *fLineMean;     // Line to COG of the shower 
-
- public:
-    MDCA(const char *name=NULL, const char *title=NULL);
-
-    ~MDCA();
-
-    void Reset();
-
-    Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix, const MHillas &hil);
-
-    void Print(Option_t *opt=NULL) const;
-
-    void Paint(Option_t *opt=NULL);
-
-    void Clear(Option_t *opt=NULL);
-
-    void SetRefPoint(const Float_t fXRef0, const Float_t fYRef0);
-    
-    Float_t GetDCA() const { return fDCA; }
- 
-    Float_t GetDelta() const { return fDelta1; }
-
-    ClassDef(MDCA, 1) 
-
-};
-
-#endif
-
-
-
-
-
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc	(revision 4117)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc	(revision 4117)
@@ -0,0 +1,119 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Javier Rico     05/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MDisplay
+//
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <math.h>
+
+#include "MParList.h"
+#include "MDisplay.h"
+#include "MCamEvent.h"
+#include "MGeomCam.h"
+#include "MHCamera.h"
+
+#include "TCanvas.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDisplay);
+
+using namespace std;
+
+static const TString gsDefName  = "MDisplay";
+static const TString gsDefTitle = "Camera display task";
+
+// -------------------------------------------------------------------------
+//
+// Constructor.
+//
+MDisplay::MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type, const char* name, const char* title) 
+  :  fGeomCam(geom), fCamEvent(event),  fCanvas(NULL), fDisplayType(type)
+{
+  fName  = name  ? name  : gsDefName.Data();
+  fTitle = title ? title : gsDefTitle.Data();
+
+  fDisplay = new MHCamera(*geom);
+  fDisplay->SetPrettyPalette();
+}
+// -------------------------------------------------------------------------
+//
+// Destructor
+//
+MDisplay::~MDisplay()
+{
+  delete fDisplay;
+  if(fCanvas)
+    delete fCanvas;
+}
+
+// -------------------------------------------------------------------------
+//
+// Look for needed containers.
+//
+Int_t MDisplay::PreProcess(MParList* pList)
+{ 
+  fCanvas = new TCanvas("myCanvas","Event Display",600,600);
+  fCanvas->cd(1);
+  fDisplay->Draw();
+
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Call to compute a new position and then save it in the histogram (fMode==kOn) 
+// of to read the new position from the histogram (fMode==kOff)
+//
+Int_t MDisplay::Process()
+{  
+  fDisplay->SetCamContent(*fCamEvent);
+  fCanvas->GetPad(1)->Modified();
+  fCanvas->GetPad(1)->Update();
+
+  // pause execution
+  cout << "Type 'q' to exit, <return> to go on: ";      
+  TString input;
+  input =cin.get(); 
+  
+  if (input=='q')
+    return kFALSE;
+  else
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Dump 2D histo statistics
+//
+Int_t MDisplay::PostProcess()
+{
+  return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h	(revision 4117)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h	(revision 4117)
@@ -0,0 +1,40 @@
+#ifndef MARS_MDisplay
+#define MARS_MDisplay
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHCamera;
+class MCamEvent;
+class MGeomCam;
+class TCanvas;
+
+class MDisplay : public MTask
+{
+ private:
+  MHCamera*  fDisplay;     // pointer to the camera display
+  MGeomCam*  fGeomCam;     // pointer to the camera geometry
+  MCamEvent* fCamEvent;    // pointer to camera event
+  TCanvas*   fCanvas;      // pointer to the canvas
+  Int_t      fDisplayType; 
+  
+  virtual Int_t PostProcess();
+
+ protected:
+  virtual Int_t PreProcess(MParList *plist);  
+  virtual Int_t Process();
+
+ public:
+  MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type=0, const char* name=NULL, const char* title=NULL);
+  virtual ~MDisplay();
+
+  MGeomCam*    GetGeomCam()               {return fGeomCam;}
+  void         SetDisplayType(Int_t type) {fDisplayType=type;}
+  virtual void Paint(Option_t* option)    {};
+
+  ClassDef(MDisplay, 0) // Task to display camera containers
+};
+
+#endif
+
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc	(revision 4117)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc	(revision 4117)
@@ -0,0 +1,172 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Javier Rico     05/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MDisplayHillas
+//
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+#include <fstream>
+#include <math.h>
+
+#include "TVirtualPad.h"
+#include "TLine.h"
+#include "TEllipse.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MHillasDisplay.h"
+#include "MCerPhotEvt.h"
+#include "MGeomCam.h"
+#include "MHillas.h"
+#include "MSrcPosCam.h"
+
+
+ClassImp(MHillasDisplay);
+
+using namespace std;
+
+static const TString gsDefName  = "MHillasDisplay";
+static const TString gsDefTitle = "Hillas Camera display task";
+
+// -------------------------------------------------------------------------
+//
+// Constructor.
+//
+MHillasDisplay::MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type, const char* name, const char* title) 
+  :  MDisplay(event,geom,type), fHillas(NULL), fSrcPos(NULL)
+{
+  fName  = name  ? name  : gsDefName.Data();
+  fTitle = title ? title : gsDefTitle.Data();
+}
+// -------------------------------------------------------------------------
+//
+// Look for needed containers.
+//
+Int_t MHillasDisplay::PreProcess(MParList* pList)
+{  
+  if(!MDisplay::PreProcess(pList))
+    return kFALSE;
+
+  // Look for the MHillas container  
+  if(!fHillas)
+    fHillas = (MHillas*)pList->FindObject(AddSerialNumber("MHillas"), "MHillas");
+  if(!fHillas)
+    *fLog << warn << "MHillasDisplay::PreProcess Warning: MHillas object not found" << endl;
+  else
+    {
+      gPad->cd(1);
+      Draw();
+    }
+
+  // Look for the MHillas container  
+  if(!fSrcPos)
+    fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber("MSrcPosCam"), "MSrcPosCam");
+  if(!fSrcPos)
+    *fLog << warn << "MHillasDisplay::PreProcess Warning: MSrcPosCam object not found" << endl;
+
+  return kTRUE;
+}
+// -------------------------------------------------------------------------
+//
+// Display event AND hillas parameters
+//
+Int_t MHillasDisplay::Process()
+{
+   // draw the hillas parameters
+  if(fHillas)
+    fHillas->Print();
+   
+  // draw the event
+  if(!MDisplay::Process())
+    return kFALSE;
+  return kTRUE;
+}
+// -------------------------------------------------------------------------
+//
+// Paint
+//
+void MHillasDisplay::Paint(Option_t* option)
+{
+  const Float_t OffsetW=20.0;
+  const Float_t OffsetL=300.0;
+
+  Float_t meanX  = fHillas->GetMeanX();
+  Float_t meanY  = fHillas->GetMeanY();
+  Float_t length = fHillas->GetLength();
+  Float_t width  = fHillas->GetWidth();
+  Float_t delta  = fHillas->GetDelta();
+
+
+  if (length<=0 || width<=0)
+    return;
+  
+  // Length line
+  TLine lineL(-(length+OffsetL)*cos(delta) + meanX,
+              -(length+OffsetL)*sin(delta) + meanY,
+	      (length+OffsetL)*cos(delta)  + meanX,
+	      (length+OffsetL)*sin(delta)  + meanY);
+
+  lineL.SetLineWidth(1);
+  lineL.SetLineColor(2);
+  lineL.Paint();
+
+  // Width line
+  TLine lineW(-(width+OffsetW)*sin(delta) + meanX,
+              -(width+OffsetW)*cos(delta) + meanY,
+	      (width+OffsetW)*sin(delta)  + meanX,
+	      (width+OffsetW)*cos(delta)  + meanY);
+
+  lineW.SetLineWidth(1);
+  lineW.SetLineColor(2);
+  lineW.Paint();
+
+  // Coordinate system
+  Float_t xSrc   = fSrcPos? fSrcPos->GetX() : 0.;
+  Float_t ySrc   = fSrcPos? fSrcPos->GetY() : 0.;
+  Float_t radius = GetGeomCam()->GetMaxRadius();
+  TLine lineX(-radius,ySrc,radius,ySrc);
+  TLine lineY(xSrc,-radius,xSrc,radius);
+  lineX.SetLineWidth(1);
+  lineX.SetLineColor(108);
+  lineY.SetLineWidth(1);
+  lineY.SetLineColor(108);
+  lineX.Paint();
+  lineY.Paint();
+  
+  // COG line
+  TLine lineMean(xSrc,ySrc,meanX,meanY);
+  lineMean.SetLineWidth(2);
+  lineMean.SetLineColor(2);
+  lineMean.Paint();
+  
+  // Hillas ellipse
+  TEllipse ellipse(meanX,meanY,length,width,0,360,delta*kRad2Deg+180);
+  ellipse.SetLineWidth(2);
+  ellipse.SetLineColor(2);
+  ellipse.Paint(); 
+}
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.h	(revision 4117)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.h	(revision 4117)
@@ -0,0 +1,37 @@
+#ifndef MARS_MHillasDisplay
+#define MARS_MHillasDisplay
+
+#ifndef MARS_MDisplay
+#include "MDisplay.h"
+#endif
+
+class MCerPhotEvt;
+class MSrcPosCam;
+class MGeomCam;
+class MHillas;
+
+class MHillasDisplay : public MDisplay
+{
+ private:
+  MHillas* fHillas;    // pointer to container with the hillas parameters
+  MSrcPosCam* fSrcPos; // pointer to the source position in camera
+
+  virtual Int_t PreProcess(MParList *plist);
+  virtual Int_t Process();
+
+ public:
+  MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type=0,
+		 const char* name=NULL, const char* title=NULL);
+
+  virtual ~MHillasDisplay(){};
+
+  void SetHillas(MHillas* hillas) {fHillas=hillas;}
+  void SetSrcPos(MSrcPosCam* srcpos) {fSrcPos=srcpos;}
+
+  virtual void Paint(Option_t* option);
+
+  ClassDef(MHillasDisplay, 0) // task to display cleaned events with hillas parameters
+};
+
+#endif
+
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.cc	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.cc	(revision 4117)
@@ -39,5 +39,4 @@
 //  Output Containers:
 //    MSrcPosCam
-//    MDCA
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -51,5 +50,4 @@
 #include "MSrcPlace.h"
 #include "MSrcPosCam.h"
-#include "MDCA.h"
 
 #include "MLog.h"
@@ -67,9 +65,8 @@
 // Default constructor. The first argument is the name of the internal histo, 
 // the second (third) argument is the name of the input (output) container
-// containing the source position in the camera plain. Fourth argument is the
-// name of the output MDCA container.
-//
-MSrcPlace::MSrcPlace(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title)
-  : fSrcPosIn(NULL), fSrcPosOut(NULL), fDCA(NULL), fHistoName("SrcPosHist"), 
+// containing the source position in the camera plain. 
+//
+MSrcPlace::MSrcPlace(const char* srcPosIn, const char* srcPosOut,  const char *name, const char *title)
+  : fSrcPosIn(NULL), fSrcPosOut(NULL), fHistoName("SrcPosHist"), 
     fHistoBinPrec(1.), fHistPos(NULL)
 {
@@ -79,5 +76,4 @@
     fSrcPosInName   = srcPosIn;
     fSrcPosOutName  = srcPosOut;
-    fDCAName        = dca;
 
     fMode=kOn;
@@ -116,5 +112,4 @@
       fHistPos->GetRandom2(x,y);
       fSrcPosOut->SetXY(x,y);
-      fDCA->SetRefPoint(x,y);
     }
 }
@@ -153,14 +148,4 @@
       fSrcPosOut = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosOutName));
       if(!fSrcPosOut)
-	return kFALSE;
-    }
-
-  // look for/create MDCA
-  fDCA = (MDCA*)pList->FindObject(AddSerialNumber(fDCAName), "MDCA");
-  if (!fDCA)
-    {
-      *fLog << warn << AddSerialNumber(fDCAName) << " [MDCA] not found... creating default container." << endl;
-      fDCA = (MDCA*)pList->FindCreateObj("MDCA", AddSerialNumber(fDCAName));
-      if(!fDCA)
 	return kFALSE;
     }
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.h	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.h	(revision 4117)
@@ -6,5 +6,4 @@
 #endif
 
-class MDCA;
 class MSrcPosCam;
 class TH2F;
@@ -18,9 +17,7 @@
   MSrcPosCam*  fSrcPosIn;       //  Pointer to the input source position container
   MSrcPosCam*  fSrcPosOut;      //  Pointer to the output source position container
-  MDCA*        fDCA;            //  Pointer to the output MDCA container
   
   TString      fSrcPosInName;   //  Name of the input MSrcPosCam object
   TString      fSrcPosOutName;  //  Name of the output MSrcPosCam object
-  TString      fDCAName;        //  Name of the MDCA object
 
   TString      fHistoName;      //  Name of internal histogram
@@ -42,5 +39,4 @@
  public:
   MSrcPlace(const char* srcin="MSrcPosCam",const char* srcout="MSrcPosCam", 
-	    const char* dcaout="MDCA",
 	    const char* name=NULL, const char* title=NULL);
 
@@ -50,5 +46,4 @@
   void SetInputSrcPosName(TString name)     {fSrcPosInName=name;}
   void SetOutputSrcPosName(TString name)    {fSrcPosOutName=name;}
-  void SetDCAName(TString name)             {fDCAName=name;}
   void SetInternalHistoName(TString name)   {fHistoName=name;}
   void SetInternalHistoBinSize(Float_t size){fHistoBinPrec=size;}
@@ -59,5 +54,4 @@
   MSrcPosCam*   GetInputSrcPosCam()    {return fSrcPosIn;}
   MSrcPosCam*   GetOutputSrcPosCam()   {return fSrcPosOut;}
-  MDCA*         GetDCA()               {return fDCA;}
   TString       GetInternalHistoName() {return fHistoName;}
   
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.cc	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.cc	(revision 4117)
@@ -42,5 +42,4 @@
 #include "MRawRunHeader.h"
 #include "MSrcPosCam.h"
-#include "MDCA.h"
 
 #include "MLog.h"
@@ -156,5 +155,4 @@
 
   GetOutputSrcPosCam()->SetXY(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY());
-  GetDCA()->SetRefPoint(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY());
 
   return kTRUE;
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc	(revision 4117)
@@ -33,5 +33,4 @@
 //  Output Containers:
 //    MSrcPosCam
-//    MDCA
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -48,5 +47,4 @@
 #include "MObservatory.h"
 #include "MSrcPosCam.h"
-#include "MDCA.h"
 
 #include "MLog.h"
@@ -66,5 +64,5 @@
 // camera plain
 //
-MSrcRotate::MSrcRotate(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title)
+MSrcRotate::MSrcRotate(const char* srcPosIn, const char* srcPosOut, const char *name, const char *title)
   : fRA(0), fDEC(0), fRefMJD(0), fRunNumber(0)
 {
@@ -74,5 +72,4 @@
     SetInputSrcPosName(srcPosIn);
     SetOutputSrcPosName(srcPosOut);
-    SetDCAName(dca);
 
     SetInternalHistoName(TString(fName)+"Hist");
@@ -181,5 +178,4 @@
   MSrcPosCam* srcposIn  = GetInputSrcPosCam();
   MSrcPosCam* srcposOut = GetOutputSrcPosCam();
-  MDCA* dca = GetDCA();
   
   Float_t c = TMath::Cos(rotationAngle);
@@ -196,5 +192,4 @@
   
   srcposOut->SetXY(newX,newY);
-  dca->SetRefPoint(newX,newY);
 
   return kTRUE;
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.h	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.h	(revision 4117)
@@ -32,5 +32,4 @@
  public:
   MSrcRotate(const char* srcIn="MSrcPosCam",const char* srcOut="MSrcPosCam",
-	     const char* dca="MDCA",
 	     const char* name=NULL, const char* title=NULL);
   
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.cc	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.cc	(revision 4117)
@@ -36,5 +36,4 @@
 //  Output Containers:
 //    MSrcPosCam
-//    MDCA
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -47,5 +46,4 @@
 #include "MSrcTranslate.h"
 #include "MSrcPosCam.h"
-#include "MDCA.h"
 
 #include "MLog.h"
@@ -65,5 +63,5 @@
 // camera plain
 //
-MSrcTranslate::MSrcTranslate(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title)
+MSrcTranslate::MSrcTranslate(const char* srcPosIn, const char* srcPosOut, const char *name, const char *title)
   : fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE)
 {
@@ -73,5 +71,4 @@
     SetInputSrcPosName(srcPosIn);
     SetOutputSrcPosName(srcPosOut);
-    SetDCAName(dca);
 
     SetInternalHistoName(TString(fName)+"Hist");
@@ -84,5 +81,5 @@
 Int_t MSrcTranslate::PreProcess(MParList *pList)
 {
-  // look for/create MSrcPosCam and DCA
+  // look for/create MSrcPosCam 
   if(!MSrcPlace::PreProcess(pList))
     return kFALSE;
@@ -103,5 +100,4 @@
 
   MSrcPosCam* srcPosOut = GetOutputSrcPosCam();
-  MDCA*       dca       = GetDCA();
   
   if(fTranslationIsRelative)
@@ -118,5 +114,4 @@
 
   srcPosOut->SetXY(newX,newY);
-  dca->SetRefPoint(newX,newY);
 
   return kTRUE;
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.h	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.h	(revision 4117)
@@ -18,5 +18,4 @@
  public:
   MSrcTranslate(const char* srcIn="MSrcPosCam", const char* srcOut="MSrcPosCam", 
-		const char* dca="MDCA",
 		const char* name=NULL, const char* title=NULL);
   
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/Makefile	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/Makefile	(revision 4117)
@@ -48,5 +48,6 @@
 
 SRCFILES = \
-	MDCA.cc \
+	MDisplay.cc \
+	MHillasDisplay.cc \
         MPSFFit.cc \
         MPSFFitCalc.cc \
Index: /trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha.C
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha.C	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha.C	(revision 4117)
@@ -13,5 +13,5 @@
 {    
     // constants
-    const Int_t nbins = 18;
+    const Int_t nbins = 9;
     TString psname("alphaMrk.gif");
     // general settings
@@ -36,10 +36,10 @@
     
     // ON data
-    ton->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/programs/srcPosPrueba.root");
+    ton->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/crab20040215OnRotateCalA-D.root");
 
     TChain* toff= new TChain("Parameters");
 
     // OFF data
-    toff->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/programs/srcPosOffPrueba.root");
+    toff->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/crab20040215OffRotateCalA-H.root");
     
     TCanvas *c1 = new TCanvas("c1","c1",800,500);
@@ -54,4 +54,5 @@
     ton->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
     ton->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
+    ton->SetAlias("leakage","MNewImagePar.fInnerLeakage1");
     
     toff->SetAlias("length","MHillas.fLength*0.6/189");
@@ -62,11 +63,12 @@
     toff->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
     toff->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
-	
+    toff->SetAlias("leakage","MNewImagePar.fInnerLeakage1");
+
     // define  cut(s)
-//    const char* eventcut="event%3==0 &&";
+//    const char* eventcut="event%4==0 &&";
     const char* eventcut="";
     const char varcut[512];
     //    sprintf(varcut,"size>%f && size<%f && length>%f  &&length<%f && width>%f &&  width<%f",cutsize,upcutsize,lengthlowcut,lengthcut,widthlowcut,widthcut);
-    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<1.1 && length>%f  &&length<%f && width>%f &&  width<%f",cutsize,upcutsize,lengthlowcut,lengthcut,widthlowcut,widthcut);
+    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<1.1 && leakage==0 && length>%f  &&length<%f && width>%f &&  width<%f",cutsize,upcutsize,lengthlowcut,lengthcut,widthlowcut,widthcut);
 //    sprintf(varcut,"size>%f && dist>0.2 && dist<0.8 && length<0.21 && width<0.125",cutsize,upcutsize,lengthcut,widthcut);
 //    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<0.8 && length<0.21 && width<0.125",cutsize,upcutsize);
Index: /trunk/MagicSoft/Mars/mtemp/mifae/programs/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/programs/Makefile	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/programs/Makefile	(revision 4117)
@@ -26,4 +26,5 @@
 	   -I../library \
 	   -I../../../mbase \
+	   -I../../../mfbase \
 	   -I../../../mjobs \
 	   -I../../../mpedestal \
Index: /trunk/MagicSoft/Mars/mtemp/mifae/programs/falsesource.datacard
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/programs/falsesource.datacard	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/programs/falsesource.datacard	(revision 4117)
@@ -39,5 +39,5 @@
 
 // Size cut (lower and upper) in # of photons
-SIZECUT   1200   9999999
+SIZECUT   2000   9999999
 
 // Dist cut (lower and upper) in degrees
Index: /trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 4117)
@@ -25,5 +25,4 @@
 #include "MFCosmics.h"
 #include "MContinue.h"
-#include "MFillH.h"
 #include "MLog.h"
 #include "MCerPhotEvt.h"
@@ -44,9 +43,13 @@
 #include "MIslandClean.h"
 #include "MWriteRootFile.h"
-#include "MProgressBar.h"
 #include "MArgs.h"
 #include "MRunIter.h"
 #include "MJPedestal.h"
 #include "MJCalibration.h"
+#include "MHillasDisplay.h"
+#include "MF.h"
+#include "MContinue.h"
+
+#include "TApplication.h"
 
 #include <iostream>
@@ -68,17 +71,19 @@
 TString  outname;
 TString  idirname;
+TString  filter;
 MRunIter caliter;
 MRunIter pediter;
 MRunIter datiter;
-ULong_t  nmaxevents=999999999;
-Short_t  calflag=1;
-Float_t  lcore = 3.0;
-Float_t  ltail = 1.5;
-Int_t islflag = 0;
-Float_t  lnew  = 40;
-Int_t  kmethod = 1;
-Int_t    nfiles = 0;
-
-const TString defaultcard="input.datacard";
+Bool_t   display   = kFALSE;
+ULong_t  nmaxevents= 999999999;
+Short_t  calflag   = 1;
+Float_t  lcore     = 3.0;
+Float_t  ltail     = 1.5;
+Int_t    islflag   = 0;
+Float_t  lnew      = 40;
+Int_t    kmethod   = 1;
+Int_t    nfiles    = 0;
+
+const TString defaultcard="makehillas.datacard";
 /*************************************************************/
 static void Usage()
@@ -93,4 +98,7 @@
 int main(int argc, char **argv)
 {
+  // create a TApplication to be able to 
+  TApplication app("Application",0,0);
+
   // evaluate arguments
   MArgs arg(argc, argv);
@@ -250,4 +258,7 @@
   plist4.AddToList(&hillas);
   plist4.AddToList(&runhead);
+
+  // cuts
+  MF cut(filter);
   
   //tasks
@@ -285,19 +296,31 @@
   MHillasSrcCalc    csrc1;
   
-  MWriteRootFile write(outname,"RECREATE");
-  
-  write.AddContainer("MHillas"        , "Parameters");
-  write.AddContainer("MHillasSrc"     , "Parameters");
-  write.AddContainer("MHillasExt"     , "Parameters");
-  write.AddContainer("MNewImagePar"   , "Parameters");
-  write.AddContainer("MRawEvtHeader"  , "Parameters");
-  write.AddContainer("MRawRunHeader"  , "Parameters");
-  write.AddContainer("MConcentration" , "Parameters");
-  write.AddContainer("MSrcPosCam"     , "Parameters");
-
-  if (islflag == 1 || islflag == 2)
-    write.AddContainer("MIslands1" , "Parameters");
-  if (islflag == 2) 
-    write.AddContainer("MIslands2" , "Parameters");
+  MContinue applycut(&cut);
+  applycut.SetInverted(kTRUE);
+  MWriteRootFile* write=NULL;
+  MDisplay*  disphillas=NULL;
+
+  if(!display)
+    {
+      write = new MWriteRootFile(outname,"RECREATE");
+      
+      write->AddContainer("MHillas"        , "Parameters");
+      write->AddContainer("MHillasSrc"     , "Parameters");
+      write->AddContainer("MHillasExt"     , "Parameters");
+      write->AddContainer("MNewImagePar"   , "Parameters");
+      write->AddContainer("MRawEvtHeader"  , "Parameters");
+      write->AddContainer("MRawRunHeader"  , "Parameters");
+      write->AddContainer("MConcentration" , "Parameters");
+      write->AddContainer("MSrcPosCam"     , "Parameters");
+      
+      if (islflag == 1 || islflag == 2)
+	write->AddContainer("MIslands1" , "Parameters");
+      if (islflag == 2) 
+	write->AddContainer("MIslands2" , "Parameters");
+    }
+  else
+    {
+      disphillas = new MHillasDisplay(&nphot,&geomcam);
+    }
 
   tlist4.AddToList(&read4);
@@ -322,7 +345,10 @@
   //tlist4.AddToList(&blind2);
   tlist4.AddToList(&hcalc);
-  //  tlist4.AddToList(&srcposcalc);
   tlist4.AddToList(&csrc1);
-  tlist4.AddToList(&write);
+  tlist4.AddToList(&applycut);
+  if(!display)
+    tlist4.AddToList(write);
+  else
+    tlist4.AddToList(disphillas);
 
   // Create and setup the eventloop
@@ -409,7 +435,23 @@
 	}
 
+      // exclusion cut
+      if(strcmp(word.Data(),"FILTER")==0)
+	{
+	  if(filter.Length())
+	    cout << "readDataCards Warning: overriding existing cut" << endl;
+	  
+	  char ch;
+	  while((ch=ifun.get())!='\n')
+	    filter.Append(ch);	  
+	}
+
+      // display flag
+      if(strcmp(word.Data(),"DISPLAY")==0)
+	ifun >> display;
+
       // calibration flag
       if(strcmp(word.Data(),"CALFLAG")==0)
 	ifun >> calflag;
+
 
       // cleaning level
@@ -454,5 +496,8 @@
     cout << pfile << endl;
   cout << "Maximum number of events: " << nmaxevents << endl;
-  cout << "Output file name: " << outname << endl;
+  if(filter.Length())
+    cout << "Applying rejection cut: " << filter << endl;
+  if(!display)
+    cout << "Output file name: " << outname << endl;
   cout << "Calibration flag: " << calflag << endl;
   cout << "Cleaning level: ("<<lcore<<","<<ltail<<")" << endl;
@@ -489,2 +534,3 @@
   return kTRUE;
 }
+
Index: /trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard	(revision 4117)
@@ -14,4 +14,13 @@
 // OUTFILE ~/magic/mars/mars/hillasCrab/crab20040215OnA.root
 OUTFILE ./prueba.root
+
+// Selection cut. 
+// Condition "==" not supported.
+// Enclose all conditions between brakets, like: "(x<y) && (z<5)"
+// (see MF description class for more details)
+FILTER (MHillas.fLength<100) && (MHillas.fLength>50)
+
+// Display flag (DISPLAY=1 will show event display and skip saving into output file)
+DISPLAY 1
 
 // calibration flag:
@@ -34,2 +43,3 @@
 // 1: no timing method  val: 40, 50, 60...
 ISLANDCLEAN 1 40
+
Index: /trunk/MagicSoft/Mars/mtemp/mifae/programs/optimizecuts.datacard
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/programs/optimizecuts.datacard	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/programs/optimizecuts.datacard	(revision 4117)
@@ -4,14 +4,14 @@
 
 // On data acceptance rate (e.g 4 for taking 1/4 of whole data sample)
-ONRATE 1
+ONRATE 2
 
 // Input file name pattern (On data)
-ONFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OnRotateNoCalB.root
+ONFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OnRotateCalA-D.root
 
 // Input file name pattern (Off data)
-OFFFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OffRotateNoCalA-C.root
+OFFFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OffRotateCalA-H.root
 
 // output file name
-OUTFILE  ./optimize_fine.out
+OUTFILE  ./optimizeCrab_cal_fine.out
 
 // Preliminar cuts (size in size units, distance in deg)
@@ -20,8 +20,8 @@
 
 // Length initial, final and step values
-LENGTHCUTS 0.1 0.4 0.005 
+LENGTHCUTS 0.15 0.35 0.005 
 
 // Width initial, final and step values
-WIDTHCUTS 0.0 0.3 0.005 
+WIDTHCUTS 0.05 0.15 0.005 
 
 
Index: /trunk/MagicSoft/Mars/mtemp/mifae/programs/srcpos.datacard
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/programs/srcpos.datacard	(revision 4116)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/programs/srcpos.datacard	(revision 4117)
@@ -4,17 +4,17 @@
 
 // Input file name pattern (wildcards allowed)
-INPUTFILES /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OnNoCalB.root
+INPUTFILES /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OnCal*.root
 
 // Specify optionally the name of OFF-data files you want to apply the same source position distribution to
-OFFFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OffNoCal*.root
+OFFFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OffCal*.root
 
 // output file name (on data)
-OUTFILE  ./srcPosPrueba.root
+OUTFILE  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OnRotateCalA-D.root
 
 // output file name (off data)
-OFFOUTFILE ./srcPosOffPrueba.root
+OFFOUTFILE /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OffRotateCalA-H.root
 
 // X and Y position of the source (degrees) for a MJ date (days) -important only in case of rotation
-SRCPOS  0.21  0.176   53050.0773
+SRCPOS  0.3  0.1   53049.89
 
 // Flag to determine whether source position is absolute (0) or relative to previous position (1)
@@ -27,10 +27,10 @@
 
 // source coordinates (RA DEC in rads)
-// SRCCOORDS 1.46 0.384 // (Crab)
-SRCCOORDS 2.899 0.667   // (Mrk 421)
+SRCCOORDS 1.46 0.384 // (Crab)
+// SRCCOORDS 2.899 0.667   // (Mrk 421)
 
 
 // File containing source position as a function of run number (invalidates SRCPOS, SRCABS, ROTFLAG and SRCCOORDS values)
-SRCFILE /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/programs/20040215_Mrk421.B.pos
+// SRCFILE /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/programs/20040215_Mrk421.B.pos
 
 
