Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/mmcCleaning.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/mmcCleaning.C	(revision 5063)
+++ trunk/MagicSoft/Mars/mtemp/mifae/macros/mmcCleaning.C	(revision 5277)
@@ -1,30 +1,5 @@
-/* ======================================================================== *\
-   !
-   ! *
-   ! * 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):
-   !
-   !   Copyright: MAGIC Software Development, 2000-2004
-   !
-   !
-   \* ======================================================================== */
-
 /////////////////////////////////////////////////////////////////////////////
 //
-//  mmcCleaning - study different cleaning levels with mc
-//
+//  mmcCleaning - calibrate/clean mc events
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -40,19 +15,19 @@
 
   // ------------- user change -----------------
-  Char_t*  NonoiseFilename = "/local_disk/jrico/mc/Gamma_zbin12_0_7_1250to1259_w0_nonoise.root";  // File to be used for the calibration (must be a camera file without added noise)
-  Char_t*  NoiseFilename   = "/local_disk/jrico/mc/Gamma_zbin12_0_7_1250to1259_w0.root";  // File to be analyzed
+  Char_t*  NonoiseFilename = "/local_disk/jrico/mc/Gammas/Gamma_zbin0_0_7_1000to1009_w0_nonoise.root";  // File to be used for the calibration (must be a camera file without added noise)
+  Char_t*  NoiseFilename   = "/local_disk/jrico/mc/Gammas/Gamma_zbin0_0_7_1000to1009_w0.root"; // File to be analyzed
 
-  Char_t* NonoiseOutFilename = "/local_disk/jrico/mc/Gamma_zbin12_0_7_1250to1259_w0_cleaned_nonoise.root";  // Output file name
-  Char_t* NoiseOutFilename   = "/local_disk/jrico/mc/Gamma_zbin12_0_7_1250to1259_w0_cleaned_6045.root";     // Output file name
+  Char_t* NoiseOutFilename   = "/local_disk/jrico/mc/Gammas/prueba.root";   // Output file name
 
-
-  MExtractSignal    sigextract;  
+  // Signal extractor
   // (other extraction methods can be used)
-
-  sigextract.SetSaturationLimit(240);
-  // Defines when to switch to low gain
+  MExtractFixedWindowPeakSearch sigextract;
 
   // Define FADC slices to be integrated in high and low gain:
-  sigextract.SetRange(1, 14, 3, 14);
+  sigextract.SetRange(1, 14, 2, 14);
+  sigextract.SetWindows(6,6,4);
+
+  // Defines when to switch to low gain
+  sigextract.SetSaturationLimit(240);
 
   // ---------------------------------------------------------------------
@@ -107,6 +82,7 @@
   calib.SetCalibrationMode(MCalibrate::kFfactor);
 
-  MImgCleanStd clean(6.0,4.5);
-  clean.SetRemoveSingle(kFALSE);
+  MImgCleanStd clean(6.5,2.0);
+  clean.SetCleanRings(1);
+  //  clean.SetRemoveSingle(kFALSE);
   //
   // Applies tail cuts to image. Since the calibration is performed on 
@@ -122,12 +98,4 @@
   // Calculates calibration constants to convert from ADC counts to photons.
   
-  MWriteRootFile write(NonoiseOutFilename); // Writes output
-  write.AddContainer("MRawRunHeader", "Events");
-  write.AddContainer("MMcEvt",        "Events");
-  write.AddContainer("MRawEvtHeader", "Events");
-  write.AddContainer("MCerPhotEvt",   "Events");
-  write.AddContainer("MHillas",       "Events");
-  write.AddContainer("MHillasSrc",    "Events");
-
   tlist.AddToList(&read);
   tlist.AddToList(&geom);
@@ -139,13 +107,11 @@
   tlist.AddToList(&clean);
   tlist.AddToList(&hcalc);
-  tlist.AddToList(&hsrccalc);
-  //  tlist.AddToList(&display2);
+  tlist.AddToList(&hsrccalc); 
   tlist.AddToList(&mccalibcalc);
-  tlist.AddToList(&write);
+  //tlist.AddToList(&display2);
 
   //
   // First loop: No noise
   //
-
   MProgressBar bar;
   bar.SetWindowName("No noise...");
@@ -164,5 +130,18 @@
   //
   // Second loop: process file with noise
-  //
+  //  
+  MIslands      isl;
+  MArrivalTimeCam timecam;      
+  plist.AddToList(&isl);
+  plist.AddToList(&timecam);
+
+  MArrivalTimeCalc2 timecalc;
+  MIslandsCalc      islandcalc;
+  islandcalc.SetOutputName("MIslands");
+  islandcalc.SetAlgorithm(1);
+  MIslandsClean     islclean(40);
+  islclean.SetInputName("MIslands");
+  islclean.SetMethod(1);
+
   MReadMarsFile read2("Events");
   read2.AddFile(NoiseFilename);
@@ -171,24 +150,25 @@
   tlist.RemoveFromList(&read);
 
-  MWriteRootFile write2(NoiseOutFilename); // Writes output
-  write2.AddContainer("MRawRunHeader", "Events");
-  write2.AddContainer("MMcEvt",        "Events");
-  write2.AddContainer("MRawEvtHeader", "Events");
-  write2.AddContainer("MCerPhotEvt",   "Events");
-  write2.AddContainer("MHillas",       "Events");
-  write2.AddContainer("MHillasSrc",    "Events");
+  tlist.AddToListBefore(&timecalc,&mccalibupdate,"All");
+  tlist.AddToListBefore(&islandcalc,&hcalc,"All");
+  tlist.AddToListBefore(&islclean,&hcalc,"All");
 
-  //  tlist.AddToListBefore(&display2,&clean, "All");
-  tlist.AddToListBefore(&write2, &write, "All");
-  tlist.RemoveFromList(&write);
+  MWriteRootFile write(NoiseOutFilename); // Writes output
+  write.AddContainer("MRawRunHeader", "Events");
+  write.AddContainer("MMcEvt",        "Events");
+  write.AddContainer("MRawEvtHeader", "Events");
+  write.AddContainer("MHillas",       "Events");
+  write.AddContainer("MHillasSrc",    "Events");
+  write.AddContainer("MImagePar",     "Events");
+  write.AddContainer("MNewImagePar",  "Events");
+  write.AddContainer("MIslands",      "Events");
 
+  tlist.RemoveFromList(&mccalibcalc);
+  tlist.AddToList(&write);
+  //  tlist.AddToListBefore(&display2,&write, "All");
 
-
-  bar.SetWindowName("Cleaning 3015...");
-  clean.SetRemoveSingle();
-
-  //  tlist.RemoveFromList(&clean);
-  //  tlist.RemoveFromList(&hcalc);
-  tlist.RemoveFromList(&mccalibcalc);
+  bar.SetWindowName("Calibrating/Cleaning...");
+  //  clean.SetRemoveSingle();
+  //  clean.SetMethod(MImgCleanStd::kDemocratic);
 
   if (!evtloop.Eventloop())
