Index: trunk/MagicSoft/Mars/mtemp/mifae/programs/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/programs/Makefile	(revision 4100)
+++ 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 4100)
+++ 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 4100)
+++ 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 4100)
+++ 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 4100)
+++ 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 4100)
+++ 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
 
 
