Index: trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 4391)
+++ trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 4392)
@@ -73,7 +73,9 @@
 // declaration of variables read from datacards
 TString  outname;
+const TString outpath = "./";
 TString  idirname;
 TString  filter;
 TString  psfilename("makehillas.ps");
+MRunIter pedcaliter;
 MRunIter caliter;
 MRunIter pediter;
@@ -82,4 +84,6 @@
 ULong_t  nmaxevents= 999999999;
 Short_t  calflag   = 1;
+Short_t  cleanflag   = 1;
+UShort_t  lrings     = 1;
 Float_t  lcore     = 3.0;
 Float_t  ltail     = 1.5;
@@ -131,10 +135,10 @@
 {
   // Set the general tasks/containers
-  MExtractFixedWindow    extractor;
+  //MExtractFixedWindow    extractor;
+  //extractor.SetRange(hifirst,hilast,lofirst,lolast);
+ 
+  MExtractSlidingWindow    extractor;
   extractor.SetRange(hifirst,hilast,lofirst,lolast);
- 
-  //  MExtractSlidingWindow    extractor;
-  // extractor.SetRange(hifirst,hilast,lofirst,lolast);
-  // extractor.SetWindowSize(2,2);
+  extractor.SetWindowSize(4,4);
   
   MGeomCamMagic       geomcam;
@@ -149,10 +153,12 @@
   //badcam.AsciiRead("badpixels.dat");
 
-  MJPedestal pedloop;
-  pedloop.SetInput(&pediter);
-  pedloop.SetExtractor(&extractor);
+  MJPedestal pedcalloop;
+  pedcalloop.SetInput(&pediter);
+  pedcalloop.SetExtractor(&extractor);
   //  pedloop.SetBadPixels(badcam);
-
-  if (!pedloop.Process())
+  //pedcalloop.SetOutputPath(outpath.Data());
+
+
+  if (!pedcalloop.Process())
     return;
 
@@ -165,8 +171,9 @@
   calloop.SetExtractor(&extractor);
   calloop.SetInput(&caliter);
-  calloop.SetBadPixels(pedloop.GetBadPixels());
-
+  calloop.SetBadPixels(pedcalloop.GetBadPixels());
+  if(calflag==2)
+    calloop.SetUseBlindPixel();
   if(calflag>0)
-    if (!calloop.Process(pedloop.GetPedestalCam()))
+    if (!calloop.Process(pedcalloop.GetPedestalCam()))
       return;
 
@@ -175,4 +182,11 @@
   /*                THIRD LOOP: PEDESTAL CALIBRATION INTO PHOTONS         */
   /************************************************************************/
+  // First Compute the pedestals
+  MJPedestal pedloop;
+  pedloop.SetInput(&pediter);
+
+  if (!pedloop.Process())
+    return;
+
   MParList  plist3;
   MTaskList tlist3;
@@ -279,4 +293,10 @@
   
   MImgCleanStd      clean(lcore,ltail);
+  clean.SetCleanRings(lrings);
+  MImgCleanStd::CleaningMethod_t cleanMeth= MImgCleanStd::kStandard;  
+  if(cleanflag==2)
+    cleanMeth=MImgCleanStd::kDemocratic;
+  clean.SetMethod(cleanMeth);
+
   MArrivalTimeCalc2 timecalc;
   MIslandCalc       island;
@@ -338,5 +358,5 @@
   tlist4.AddToList(&extractor);
   tlist4.AddToList(&photcalc);
-  if(calflag==11)
+  if(calflag==11 || calflag==21)
     tlist4.AddToList(&interpolatebadpixels);
   tlist4.AddToList(&clean);
@@ -428,4 +448,13 @@
 	}
 
+      // pedestal runs for calibration
+      if(strcmp(word.Data(),"PCRUNS")==0)
+	{
+	  if(pedcaliter.GetNumRuns())
+	    cout << "readDataCards Warning: adding pedestal runs for calibration to the existing list" << endl;
+	  ifun >> word;
+	  pedcaliter.AddRuns(word.Data(),idirname.Data());
+	}
+
       // calibration runs
       if(strcmp(word.Data(),"CRUNS")==0)
@@ -483,4 +512,6 @@
 	  ifun >> lcore;
 	  ifun >> ltail;
+	  ifun >> lrings;
+	  ifun >> cleanflag;
 	}
 
@@ -536,5 +567,6 @@
   else if(calflag==11)
     cout << "Default calibration + bad pixels interpolation" << endl;
-  cout << "Cleaning level: ("<<lcore<<","<<ltail<<")" << endl;
+  cout << "Cleaning level: ("<<lcore<<","<<ltail<<") - " << lrings << "ring" << endl;
+  cout << "Cleaning methode: "<< cleanflag << endl;
   if (islflag == 1 || islflag == 2)
     cout << "Island calcultation..." << "using algorithm #" << kalgorithm <<endl;
