Index: trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 5295)
+++ trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 5657)
@@ -25,4 +25,5 @@
 #include "MExtractFixedWindowPeakSearch.h"
 #include "MExtractSlidingWindow.h"
+#include "MExtractTimeAndChargeSpline.h"
 #include "MPedCalcFromLoGain.h"
 #include "MExtractSignal.h"
@@ -78,5 +79,4 @@
 MRunIter pedcaliter;
 MRunIter caliter;
-MRunIter pediter;
 MRunIter datiter;
 UInt_t   display   = 0;
@@ -156,4 +156,11 @@
       ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(wsize,wsize,4);
       break;
+    case 3:
+      extractor = new MExtractTimeAndChargeSpline();
+      ((MExtractTimeAndChargeSpline*)extractor)->SetChargeType(MExtractTimeAndChargeSpline::kIntegral);      
+      ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTime((Float_t)wsize*0.25); 
+      ((MExtractTimeAndChargeSpline*)extractor)->SetFallTime((Float_t)wsize*0.75);
+      ((MExtractTimeAndChargeSpline*)extractor)->SetTimeType(MExtractTimeAndChargeSpline::kHalfMaximum);
+      break;
     default:
       extractor = new MExtractFixedWindow();
@@ -172,13 +179,39 @@
   //badcam.AsciiRead("badpixels.dat");
 
-  MJPedestal pedcalloop;
-  pedcalloop.SetInput(&pedcaliter);
-  pedcalloop.SetExtractor(extractor);
-  //  pedloop.SetBadPixels(badcam);
-  //pedcalloop.SetOutputPath(outpath.Data());
-
-
-  if (!pedcalloop.Process())
-    return;
+  MJPedestal pedloop1;
+  MJPedestal pedloop2;
+  MJCalibration calloop;
+
+  if(calflag>0)
+    {
+      pedloop1.SetInput(&pedcaliter);
+      pedloop1.SetExtractor(extractor);
+      pedloop1.SetNoStorage();
+      if (!pedloop1.Process())
+	return;
+
+      if (extractor->InheritsFrom("MExtractTimeAndCharge"))
+        {
+          
+          /***********************************************************/
+          /* NEEDED FOR SECOND LOOP: EXTRACTOR RESOLUTION COMPUTATION */
+          /***********************************************************/
+          pedloop2.SetNoStorage();
+          pedloop2.SetExtractor(extractor);
+          pedloop2.SetExtractorResolution();
+          pedloop2.SetPedestals(pedloop1.GetPedestalCam());  
+          pedloop2.SetInput(&pedcaliter);
+          
+          if (!pedloop2.Process())
+            return;
+          
+          calloop.SetExtractorCam(pedloop2.GetPedestalCam());
+        }
+    }
+
+  MPedestalCam pedcammean = pedloop1.GetPedestalCam();      
+  extractor->SetPedestals(&pedcammean);
+
+  MPedestalCam pedcamrms;
 
   /*****************************/
@@ -186,485 +219,288 @@
   /*****************************/        
 
-  MJCalibration calloop;
-
   calloop.SetRelTimeCalibration(caltimeflag);
   calloop.SetExtractor(extractor);
   calloop.SetInput(&caliter);
-  calloop.SetBadPixels(pedcalloop.GetBadPixels());
+  calloop.SetBadPixels(pedloop1.GetBadPixels());
   if(calflag==2)
     calloop.SetUseBlindPixel();
   if(calflag>0)
-    if (!calloop.Process(pedcalloop.GetPedestalCam()))
+    if (!calloop.Process(pedcammean))
       return;
 
-  // Next loops are different if we take pedestals from data or from pedestal files
-  if(pediter.GetNumRuns()==0)
+
+  /************************************************************************/
+  /*                 THIRD (SMALL) LOOP TO GET INITIAl PEDESTALS          */
+  /************************************************************************/      
+  MParList  plist3;
+  MTaskList tlist3;
+  
+  // containers
+  MGeomCamMagic geomcam;
+  MGeomApply      geomapl;
+  
+  plist3.AddToList(&tlist3);
+  plist3.AddToList(&geomcam);
+  plist3.AddToList(&pedcammean);
+  
+  //tasks
+  MReadMarsFile read3("Events");
+  static_cast<MRead&>(read3).AddFiles(datiter); 
+  read3.DisableAutoScheme();
+  
+  MPedCalcFromLoGain pedlo1;
+  pedlo1.SetPedestalUpdate(kFALSE);
+  const Float_t win = extractor->GetNumHiGainSamples();
+  pedlo1.SetExtractWindow(15, (UShort_t)TMath::Nint(win));
+  pedlo1.SetNumEventsDump(500);
+  pedlo1.SetMaxSignalVar(40);
+  pedlo1.SetPedestalsOut(&pedcammean);
+  
+  tlist3.AddToList(&read3);
+  tlist3.AddToList(&geomapl);
+  tlist3.AddToList(&pedlo1);
+  
+  // Create and setup the eventloop
+  MEvtLoop evtloop3;
+  evtloop3.SetParList(&plist3);
+  if (!evtloop3.Eventloop(500))
+    return;
+  
+  tlist3.PrintStatistics();
+  
+  /************************************************************************/
+  /*       FIFTH LOOP: PEDESTAL+DATA CALIBRATION INTO PHOTONS             */
+  /************************************************************************/
+  
+  MParList  plist5;
+  MTaskList tlist5;
+  plist5.AddToList(&tlist5);
+  
+  //tasks
+  //      MReadMarsFile read5("Events");
+  MReadReports read5;
+  read5.AddTree("Drive");
+  read5.AddTree("Events","MTime.",kTRUE);
+  
+  read5.AddFiles(datiter);
+  read5.AddToBranchList("MReportDrive.*");
+  read5.AddToBranchList("MRawEvtData.*");
+  read5.AddToBranchList("MRawEvtHeader.*");
+  
+  //      read5.DisableAutoScheme();
+  //      static_cast<MRead&>(read5).AddFiles(datiter); 
+  tlist5.AddToList(&read5);
+  tlist5.AddToList(&geomapl);
+  tlist5.AddToList(&pedlo1);
+  pedlo1.SetPedestalUpdate(kTRUE);
+  
+  MCalibrateData::CalibrationMode_t calMode=MCalibrateData::kDefault;  
+  if(calflag==0)
+    calMode=MCalibrateData::kNone;
+  if(calflag==-1)
+    calMode=MCalibrateData::kDummy;
+  MCalibrateData  photcalc;
+  photcalc.SetCalibrationMode(calMode);
+  photcalc.EnablePedestalType(MCalibrateData::kRun);
+  photcalc.EnablePedestalType(MCalibrateData::kEvent);
+  photcalc.SetPedestalCamMean(&pedcammean);
+  
+  if (extractor->InheritsFrom("MExtractTimeAndCharge"))
     {
       /************************************************************************/
-      /*                 THIRD (SMALL) LOOP TO GET INITIAl PEDESTALS          */
+      /*                 FOURTH (SMALL) LOOP TO GET INITIAl PEDESTALS RMS     */
       /************************************************************************/      
-      MParList  plist3;
-      MTaskList tlist3;
-      
-      // containers
-      MPedestalCam  pedcamdata;      
-      MGeomCamMagic geomcam;
-      
-      plist3.AddToList(&tlist3);
-      plist3.AddToList(&geomcam);
-      plist3.AddToList(&pedcamdata);
-            
-      //tasks
-      MReadMarsFile read3("Events");
-      static_cast<MRead&>(read3).AddFiles(datiter); 
-      read3.DisableAutoScheme();
-
-      MGeomApply      geomapl;
-
-      MPedCalcFromLoGain peddatacalc;
-      peddatacalc.SetPedestalUpdate(kFALSE);
-      peddatacalc.SetRange(hifirst,hilast,lofirst,lolast);
-      peddatacalc.SetWindowSize(wsize,wsize);
-      peddatacalc.SetNumEventsDump(500);
-      peddatacalc.SetMaxHiGainVar(40);
-      
-      tlist3.AddToList(&read3);
-      tlist3.AddToList(&geomapl);
-      tlist3.AddToList(&peddatacalc);
-      
-      // Create and setup the eventloop
-      MEvtLoop evtloop3;
-      evtloop3.SetParList(&plist3);
-      if (!evtloop3.Eventloop(500))
-	return;
-      
-      tlist3.PrintStatistics();
-      
-      /************************************************************************/
-      /*       FOURTH LOOP: PEDESTAL+DATA CALIBRATION INTO PHOTONS            */
-      /************************************************************************/
-      
       MParList  plist4;
       MTaskList tlist4;
+      
       plist4.AddToList(&tlist4);
-      
-      // containers 
-      MCerPhotEvt     nphot;
-      MPedPhotCam     nphotrms;
-      MHillas         hillas;
-      MNewImagePar    newimagepar;
-      MSrcPosCam      source;
-      MRawRunHeader   runhead;      
-      MArrivalTimeCam timecam;      
-      MReportDrive    reportdrive;
-      // islands
-      MIslands      isl;
-      MIslands      isl2;
-      MIslands      isl3;
-      
-      isl.SetName("MIslands");  
-      isl2.SetName("MIslands2");
-      isl3.SetName("MIslands3");
-      
-      plist4.AddToList(&timecam);
-      plist4.AddToList(&isl);
-      
-      if (islflag == 2)
-	plist4.AddToList(&isl2);
-      if (islflag == 3)
-	plist4.AddToList(&isl3);
-      
       plist4.AddToList(&geomcam);
-      plist4.AddToList(&pedcamdata);
-      plist4.AddToList(&calloop.GetCalibrationCam());
-      plist4.AddToList(&calloop.GetQECam());
-      plist4.AddToList(&calloop.GetRelTimeCam());
-      plist4.AddToList(&calloop.GetBadPixels());
-      plist4.AddToList(&nphot);
-      plist4.AddToList(&nphotrms);
-      plist4.AddToList(&source);
-      plist4.AddToList(&hillas);
-      plist4.AddToList(&newimagepar);
-      plist4.AddToList(&runhead);
-      plist4.AddToList(&reportdrive);
-      
-      // cuts
-      MF cut(filter);
       
       //tasks
-      //      MReadMarsFile read4("Events");
-      MReadReports read4;
-      read4.AddTree("Events","MTime.",kTRUE);
-      read4.AddTree("Drive");
-		    //      read4.DisableAutoScheme();
+      MReadMarsFile read4("Events");
       static_cast<MRead&>(read4).AddFiles(datiter); 
-            
-      peddatacalc.SetPedestalUpdate(kTRUE);
-
-      MCalibrateData::CalibrationMode_t calMode=MCalibrateData::kDefault;  
-      if(calflag==0)
-	calMode=MCalibrateData::kNone;
-      if(calflag==-1)
-	calMode=MCalibrateData::kDummy;
-      MCalibrateData  photcalc;
-      photcalc.SetCalibrationMode(calMode);
-      photcalc.EnablePedestalType(MCalibrateData::kRun);
-      photcalc.EnablePedestalType(MCalibrateData::kEvent);
-
-      MImgCleanStd      clean(lcore,ltail);
-      clean.SetCleanRings(lrings);
-      MImgCleanStd::CleaningMethod_t cleanMeth= MImgCleanStd::kStandard;  
-      if(cleanflag==2)
-	cleanMeth=MImgCleanStd::kDemocratic;
-      clean.SetMethod(cleanMeth);
-      
-      MArrivalTimeCalc2 timecalc;
-      MIslandsCalc       island;
-      island.SetOutputName("MIslands");
-      island.SetAlgorithm(kalgorithm);
-      
-      MBadPixelsTreat   interpolatebadpixels;
-      interpolatebadpixels.SetUseInterpolation();
-      interpolatebadpixels.SetProcessPedestal();
-      
-      MIslandsClean      islclean(lnew);
-      islclean.SetInputName("MIslands");
-      islclean.SetMethod(kmethod);
-      
-      MIslandsCalc       island2;
-      island2.SetOutputName("MIslands2");  
-      island2.SetAlgorithm(kalgorithm);
-      
-      MIslandsCalc       island3;
-      island3.SetOutputName("MIslands3");  
-      
-      
-      MHillasCalc       hcalc;
-      MHillasSrcCalc    csrc1;
-      
-      MContinue applycut(&cut);
-      applycut.SetInverted(kTRUE);
-      MWriteRootFile write(outname,"RECREATE");
-      
-      MHillasDisplay*  disphillas=NULL;
-      
-      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("MTime"          , "Parameters");
-      write.AddContainer("MConcentration" , "Parameters");
-      write.AddContainer("MSrcPosCam"     , "Parameters");
-      write.AddContainer("MIslands"       , "Parameters");
-      write.AddContainer("MReportDrive"   , "Parameters");
-
-      if (islflag == 2) 
-	write.AddContainer("MIslands2" , "Parameters");
-      if (islflag == 3) 
-	write.AddContainer("MIslands3" , "Parameters");
-      
-      
-      if(display)
-	{
-	  disphillas = new MHillasDisplay(&nphot,&geomcam);
-	  disphillas->SetIslandsName("MIslands");
-	  if (islflag == 2)
-	    disphillas->SetIslandsName("MIslands2");
-	  if (islflag == 3)
-	    disphillas->SetIslandsName("MIslands3");
-	}      
+      read4.DisableAutoScheme();
+      
+      MPedCalcFromLoGain pedlo2;
+      pedlo2.SetPedestalUpdate(kFALSE);
+      pedlo2.SetExtractor((MExtractTimeAndCharge*)extractor);
+      pedlo2.SetNumEventsDump(500);
+      pedlo2.SetMaxSignalVar(40);
+      pedlo2.SetPedestalsIn(&pedcammean);
+      pedlo2.SetPedestalsOut(&pedcamrms);
       
       tlist4.AddToList(&read4);
       tlist4.AddToList(&geomapl);
-      tlist4.AddToList(&peddatacalc);
-      tlist4.AddToList(extractor);
-      tlist4.AddToList(&timecalc);
-      tlist4.AddToList(&photcalc);
-      if(calflag==11 || calflag==21)
-      	tlist4.AddToList(&interpolatebadpixels);
-      tlist4.AddToList(&clean);
-      tlist4.AddToList(&island);
-      
+      tlist4.AddToList(&pedlo2);
+      
+      // Create and setup the eventloop
+      MEvtLoop evtloop4;
+      evtloop4.SetParList(&plist4);
+      if (!evtloop4.Eventloop(500))
+	return;
+      
+      tlist4.PrintStatistics();
+      
+      tlist5.AddToList(&pedlo2);
+      pedlo2.SetPedestalUpdate(kTRUE);
+      
+      photcalc.SetPedestalCamRms(&pedcamrms);
+    }
+  
+  // containers 
+  MCerPhotEvt     nphot;
+  MPedPhotCam     nphotrms;
+  MHillas         hillas;
+  MNewImagePar    newimagepar;
+  MSrcPosCam      source;
+  MRawRunHeader   runhead;      
+  MArrivalTimeCam timecam;      
+  MReportDrive    reportdrive;
+  // islands
+  MIslands      isl;
+  MIslands      isl2;
+  MIslands      isl3;
+  
+  isl.SetName("MIslands");  
+  isl2.SetName("MIslands2");
+  isl3.SetName("MIslands3");
+  
+  plist5.AddToList(&timecam);
+  plist5.AddToList(&isl);
+  
+  if (islflag == 2)
+    plist5.AddToList(&isl2);
+  if (islflag == 3)
+    plist5.AddToList(&isl3);
+  
+  plist5.AddToList(&geomcam);
+  plist5.AddToList(&pedcammean);
+  plist5.AddToList(&calloop.GetCalibrationCam());
+  plist5.AddToList(&calloop.GetQECam());
+  plist5.AddToList(&calloop.GetRelTimeCam());
+  plist5.AddToList(&calloop.GetBadPixels());
+  plist5.AddToList(&nphot);
+  plist5.AddToList(&nphotrms);
+  plist5.AddToList(&source);
+  plist5.AddToList(&hillas);
+  plist5.AddToList(&newimagepar);
+  plist5.AddToList(&runhead);
+  plist5.AddToList(&reportdrive);
+  
+  // cuts
+  MF cut(filter);
+  
+  MImgCleanStd      clean(lcore,ltail);
+  clean.SetCleanRings(lrings);
+  MImgCleanStd::CleaningMethod_t cleanMeth= MImgCleanStd::kStandard;  
+  if(cleanflag==2)
+    cleanMeth=MImgCleanStd::kDemocratic;
+  clean.SetMethod(cleanMeth);
+  
+  MArrivalTimeCalc2 timecalc;
+  MIslandsCalc       island;
+  island.SetOutputName("MIslands");
+  island.SetAlgorithm(kalgorithm);
+  
+  MBadPixelsTreat   interpolatebadpixels;
+  interpolatebadpixels.SetUseInterpolation();
+  interpolatebadpixels.SetProcessPedestal();
+  
+  MIslandsClean      islclean(lnew);
+  islclean.SetInputName("MIslands");
+  islclean.SetMethod(kmethod);
+  
+  MIslandsCalc       island2;
+  island2.SetOutputName("MIslands2");  
+  island2.SetAlgorithm(kalgorithm);
+  
+  MIslandsCalc       island3;
+  island3.SetOutputName("MIslands3");  
+  
+  
+  MHillasCalc       hcalc;
+  MHillasSrcCalc    csrc1;
+  
+  MContinue applycut(&cut);
+  applycut.SetInverted(kTRUE);
+  MWriteRootFile write(outname,"RECREATE");
+  
+  MHillasDisplay*  disphillas=NULL;
+  
+  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("MTime"          , "Parameters");
+  write.AddContainer("MConcentration" , "Parameters");
+  write.AddContainer("MSrcPosCam"     , "Parameters");
+  write.AddContainer("MIslands"       , "Parameters");
+  write.AddContainer("MReportDrive"   , "Parameters");
+  
+  if (islflag == 2) 
+    write.AddContainer("MIslands2" , "Parameters");
+  if (islflag == 3) 
+    write.AddContainer("MIslands3" , "Parameters");
+  
+      
+  if(display)
+    {
+      disphillas = new MHillasDisplay(&nphot,&geomcam);
+      disphillas->SetIslandsName("MIslands");
       if (islflag == 2)
-	{
-	  tlist4.AddToList(&islclean);
-	  tlist4.AddToList(&island2);
-	}
-      
+	disphillas->SetIslandsName("MIslands2");
       if (islflag == 3)
-	{
-	  tlist4.AddToList(&islclean);
-	  tlist4.AddToList(&island3);
-	}
-      
-      tlist4.AddToList(&hcalc);
-      tlist4.AddToList(&csrc1);
-      if(filter.Length())
-	tlist4.AddToList(&applycut);
-      tlist4.AddToList(&write);
-      if(display)
-	{
-	  disphillas->SetPSFile();
-	  disphillas->SetPSFileName(psfilename);
-	  if(display==2) 
-	    disphillas->SetPause(kFALSE);	
-	  tlist4.AddToList(disphillas);
-	}
-      
-      // Create and setup the eventloop
-      MEvtLoop datloop;
-      datloop.SetParList(&plist4);
-      
-      cout << "*************************************************************" << endl;
-      cout << "***   COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS)  ***" << endl;
-      cout << "*************************************************************" << endl;
-      
-      if (!datloop.Eventloop(nmaxevents))
-	return;
-      
-      tlist4.PrintStatistics();    
-      delete extractor;
-    }
-  else
-    {      
-      /************************************************************************/
-      /*                THIRD LOOP: PEDESTAL CALIBRATION INTO PHOTONS         */
-      /************************************************************************/
-      
-      // First Compute the pedestals
-      MJPedestal pedloop;
-      pedloop.SetInput(&pediter);
-      
-      if (!pedloop.Process())
-	return;
-      
-      MParList  plist3;
-      MTaskList tlist3;
-      plist3.AddToList(&tlist3);
-      
-      // containers
-      MGeomCamMagic       geomcam;
-      MCerPhotEvt         nphot;
-      MPedPhotCam         nphotrms;
-      MExtractedSignalCam sigcam;
-      
-      plist3.AddToList(&geomcam);
-      plist3.AddToList(&pedloop.GetPedestalCam());
-      plist3.AddToList(&calloop.GetCalibrationCam());
-      plist3.AddToList(&calloop.GetQECam());
-      plist3.AddToList(&calloop.GetRelTimeCam());
-      plist3.AddToList(&calloop.GetBadPixels());
-      plist3.AddToList(&sigcam);
-      plist3.AddToList(&nphot);
-      plist3.AddToList(&nphotrms);
-      
-      
-      MCalibrateData::CalibrationMode_t calMode=MCalibrateData::kDefault;  
-      if(calflag==0)
-	calMode=MCalibrateData::kNone;
-      if(calflag==-1)
-	calMode=MCalibrateData::kDummy;
-      
-      //tasks
-      MReadMarsFile read3("Events");
-      static_cast<MRead&>(read3).AddFiles(pediter); 
-      read3.DisableAutoScheme();
-      
-      MGeomApply      geomapl;
-      MPedPhotCalc    photrmscalc; 
-      MCalibrateData  photcalc;
-      photcalc.SetCalibrationMode(calMode);
-      
-      tlist3.AddToList(&read3);
-      tlist3.AddToList(&geomapl);
-      tlist3.AddToList(extractor);
-      tlist3.AddToList(&photcalc);
-      tlist3.AddToList(&photrmscalc);
-      
-      // Create and setup the eventloop
-      MEvtLoop evtloop3;
-      evtloop3.SetParList(&plist3);
-      if (!evtloop3.Eventloop())
-	return;
-      
-      tlist3.PrintStatistics();
-      
-      /************************************************************************/
-      /*                FOURTH LOOP: DATA CALIBRATION INTO PHOTONS            */
-      /************************************************************************/
-      
-      MParList  plist4;
-      MTaskList tlist4;
-      plist4.AddToList(&tlist4);
-      
-      // containers 
-      MHillas       hillas;
-      MNewImagePar  newimagepar;
-      MSrcPosCam    source;
-      MRawRunHeader runhead;
-      
-      MArrivalTimeCam   timecam;
-      
-      
-      // islands
-      MIslands      isl;
-      MIslands      isl2;
-      MIslands      isl3;
-      
-      isl.SetName("MIslands");  
-      isl2.SetName("MIslands2");
-      isl3.SetName("MIslands3");
-      
-      plist4.AddToList(&timecam);
-      plist4.AddToList(&isl);
-      
-      if (islflag == 2)
-	plist4.AddToList(&isl2);
-      if (islflag == 3)
-	plist4.AddToList(&isl3);
-      
-      plist4.AddToList(&geomcam);
-      plist4.AddToList(&pedloop.GetPedestalCam());
-      plist4.AddToList(&calloop.GetCalibrationCam());
-      plist4.AddToList(&calloop.GetQECam());
-      plist4.AddToList(&calloop.GetRelTimeCam());
-      plist4.AddToList(&calloop.GetBadPixels());
-      plist4.AddToList(&nphot);
-      plist4.AddToList(&nphotrms);
-      plist4.AddToList(&source);
-      plist4.AddToList(&hillas);
-      plist4.AddToList(&newimagepar);
-      plist4.AddToList(&runhead);
-      
-      // cuts
-      MF cut(filter);
-      
-      //tasks
-      //      MReadMarsFile read4("Events");
-      MReadReports read4;
-      read4.AddTree("Events","MTime.",kTRUE);
-      read4.AddTree("Drive");
-		    //      read4.DisableAutoScheme();
-      static_cast<MRead&>(read4).AddFiles(datiter); 
-            
-      
-
-      MImgCleanStd      clean(lcore,ltail);
-      clean.SetCleanRings(lrings);
-      MImgCleanStd::CleaningMethod_t cleanMeth= MImgCleanStd::kStandard;  
-      if(cleanflag==2)
-	cleanMeth=MImgCleanStd::kDemocratic;
-      clean.SetMethod(cleanMeth);
-      
-      MArrivalTimeCalc2 timecalc;
-      MIslandsCalc       island;
-      island.SetOutputName("MIslands");
-      island.SetAlgorithm(kalgorithm);
-      
-      MBadPixelsTreat   interpolatebadpixels;
-      interpolatebadpixels.SetUseInterpolation();
-      interpolatebadpixels.SetProcessPedestal();
-      //  interpolatebadpixels.SetSloppyTreatment();
-      
-      MIslandsClean      islclean(lnew);
-      islclean.SetInputName("MIslands");
-      islclean.SetMethod(kmethod);
-      
-      MIslandsCalc       island2;
-      island2.SetOutputName("MIslands2");  
-      island2.SetAlgorithm(kalgorithm);
-      
-      MIslandsCalc       island3;
-      island3.SetOutputName("MIslands3");  
-      
-      
-      MHillasCalc       hcalc;
-      MHillasSrcCalc    csrc1;
-      
-      MContinue applycut(&cut);
-      applycut.SetInverted(kTRUE);
-      MWriteRootFile write(outname,"RECREATE");
-      
-      MHillasDisplay*  disphillas=NULL;
-      
-      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("MTime"          , "Parameters");
-      write.AddContainer("MConcentration" , "Parameters");
-      write.AddContainer("MSrcPosCam"     , "Parameters");
-      write.AddContainer("MIslands"       , "Parameters");
-      
-      if (islflag == 2) 
-	write.AddContainer("MIslands2" , "Parameters");
-      if (islflag == 3) 
-	write.AddContainer("MIslands3" , "Parameters");
-      
-      
-      if(display)
-	{
-	  disphillas = new MHillasDisplay(&nphot,&geomcam);
-	  disphillas->SetIslandsName("MIslands");
-	  if (islflag == 2)
-	    disphillas->SetIslandsName("MIslands2");
-	  if (islflag == 3)
-	    disphillas->SetIslandsName("MIslands3");
-	}      
-      
-      tlist4.AddToList(&read4);
-      tlist4.AddToList(&geomapl);
-      tlist4.AddToList(extractor);
-      tlist4.AddToList(&photcalc);
-      if(calflag==11 || calflag==21)
-	tlist4.AddToList(&interpolatebadpixels);
-      tlist4.AddToList(&clean);
-      tlist4.AddToList(&timecalc);
-      tlist4.AddToList(&island);
-      
-      if (islflag == 2)
-	{
-	  tlist4.AddToList(&islclean);
-	  tlist4.AddToList(&island2);
-	}
-      
-      if (islflag == 3)
-	{
-	  tlist4.AddToList(&islclean);
-	  tlist4.AddToList(&island3);
-	}
-      
-      tlist4.AddToList(&hcalc);
-      tlist4.AddToList(&csrc1);
-      if(filter.Length())
-	tlist4.AddToList(&applycut);
-      tlist4.AddToList(&write);
-      if(display)
-	{
-	  disphillas->SetPSFile();
-	  disphillas->SetPSFileName(psfilename);
-	  if(display==2) 
-	    disphillas->SetPause(kFALSE);	
-	  tlist4.AddToList(disphillas);
-	}
-      
-      // Create and setup the eventloop
-      MEvtLoop datloop;
-      datloop.SetParList(&plist4);
-      
-      cout << "*************************************************************" << endl;
-      cout << "***   COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS)  ***" << endl;
-      cout << "*************************************************************" << endl;
-      
-      if (!datloop.Eventloop(nmaxevents))
-	return;
-      
-      tlist4.PrintStatistics();    
-      delete extractor;
-    }
+	disphillas->SetIslandsName("MIslands3");
+    }      
+  
+  tlist5.AddToList(extractor);
+  tlist5.AddToList(&timecalc);
+  tlist5.AddToList(&photcalc);
+  if(calflag==11 || calflag==21)
+    tlist5.AddToList(&interpolatebadpixels);
+  tlist5.AddToList(&clean);
+  tlist5.AddToList(&island);
+  
+  if (islflag == 2)
+    {
+      tlist5.AddToList(&islclean);
+      tlist5.AddToList(&island2);
+    }
+  
+  if (islflag == 3)
+    {
+      tlist5.AddToList(&islclean);
+      tlist5.AddToList(&island3);
+    }
+  
+  tlist5.AddToList(&hcalc);
+  tlist5.AddToList(&csrc1);
+  if(filter.Length())
+    tlist5.AddToList(&applycut);
+  tlist5.AddToList(&write);
+  if(display)
+    {
+      disphillas->SetPSFile();
+      disphillas->SetPSFileName(psfilename);
+      if(display==2) 
+	disphillas->SetPause(kFALSE);	
+      tlist5.AddToList(disphillas);
+    }
+  
+  // Create and setup the eventloop
+  MEvtLoop datloop;
+  datloop.SetParList(&plist5);
+  
+  cout << "*************************************************************" << endl;
+  cout << "***   COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS)  ***" << endl;
+  cout << "*************************************************************" << endl;
+  
+  if (!datloop.Eventloop(nmaxevents))
+    return;
+  
+  tlist5.PrintStatistics();    
+  delete extractor;
 }
   //-------------------------------------------------------------------------------
@@ -703,13 +539,4 @@
 	}
 
-      // pedestal runs
-      if(strcmp(word.Data(),"PRUNS")==0)
-	{
-	  if(pediter.GetNumRuns())
-	    cout << "readDataCards Warning: adding pedestal runs to the existing list" << endl;
-	  ifun >> word;
-	  if(strcmp(word.Data(),"0")!=0)
-	    pediter.AddRuns(word.Data(),idirname.Data());
-	}
 
       // pedestal runs for calibration
@@ -812,5 +639,4 @@
     }
 
-  pediter.Reset();
   pedcaliter.Reset();
   caliter.Reset();
@@ -828,12 +654,5 @@
   while(!(pfile=caliter.Next()).IsNull())
     cout << pfile << endl;
-  if(pediter.GetNumRuns()>0)
-    {
-      cout << "Pedestal file (s): "  << endl;
-      while(!(pfile=pediter.Next()).IsNull())
-	cout << pfile << endl;
-    }
-  else 
-    cout << "Warning: Pedestals for data will be computed from data themselves" << endl;
+  cout << "Warning: Pedestals for data will be computed from data themselves" << endl;
   cout << "Data file (s): "  << endl;
   while(!(pfile=datiter.Next()).IsNull())
@@ -865,5 +684,5 @@
   cout << "***********" << endl << endl;
   
-  if(!pedcaliter.GetNumEntries())
+  if(!pedcaliter.GetNumEntries() && calflag>0)
     {
       cout << "No pedestal file for calibration specified" << endl;
Index: trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard	(revision 5295)
+++ trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard	(revision 5657)
@@ -20,5 +20,4 @@
 PCRUNS 39313
 CRUNS  39315
-PRUNS 0
 DRUNS 39261,39262,39264,39265,39269,39271,39273,39274,39276,39277,39279,39280,39282,39283,39285
 //,39286,39288,39290,39292-39294,39296-39299,39301,39302,39304-39306,39308,39309,39311,39318,39319,39321,39322,39324,39325,39327,39328,39330,39331,39333,39334,39336-39338,39340-39342,39344,39348-39350,39352-39355,39357,39358,39360-39362,39364-39366,39368-39370,39372,39373
@@ -45,6 +44,6 @@
 
 // Signal extractor, higain first, higainlast, logainfirst, logainlast, window size
-// signal extractors: 0 fixed window, 1 sliding window, 2 peak search
-EXTRACTOR 2 0 14 2 14 6
+// signal extractors: 0 fixed window, 1 sliding window, 2 peak search, 3 spline
+EXTRACTOR 3 1 11 2 12 2
 
 // calibration flag:
