Index: trunk/MagicSoft/Mars/macros/calibration.C
===================================================================
--- trunk/MagicSoft/Mars/macros/calibration.C	(revision 3852)
+++ trunk/MagicSoft/Mars/macros/calibration.C	(revision 3855)
@@ -51,12 +51,16 @@
 //  uncommented as well. 
 // 
+//  Last, a third loop is performed over the calibration file again in order to 
+//  "calibrate" it and test the resulting outcome.
+//
 /////////////////////////////////////////////////////////////////////////////
-const TString inpath = "/home/rootdata/Calib/2004_04_16/";
-const Int_t pedrun  = 22265;
-const Int_t calrun1 = 22299;
-const Int_t calrun2 = 22300;
+static const TString inpath = "/home/rootdata/Calib/2004_04_16/";
+static const Int_t pedrun  = 22265;
+static const Int_t calrun1 = 22300;
+static const Int_t calrun2 = 0;
 
 void calibration(const Int_t prun=pedrun, const Int_t crun1=calrun1, const Int_t crun2=calrun2)
 {
+
   
   MRunIter pruns;
@@ -72,5 +76,6 @@
   MCalibrationQECam qecam;
   MBadPixelsCam     badcam;
-
+  MGeomCamMagic     geomcam;
+  MGeomApply        geomapl;
   //
   // If you want to exclude pixels from the beginning, read 
@@ -95,14 +100,16 @@
     return;
 
-  //
-  // Now setup the tasks and for the calibration:
-  // ---------------------------------------------------
-  //
+  /****************************************/
+  /* SECOND LOOP: CALIBRATION COMPUTATION */
+  /****************************************/
+
   MJCalibration calloop;
-  //  calloop.SetColor(color);
 
   //
   // If you want to run the data-check on RAW DATA!!!, choose:
   // calloop.SetDataCheck();
+  // 
+  // If you want to see the data-check plots only, choose:
+  // calloop.SetDataCheckDisplay();
   // 
   // For everything, you ever dreamed of, choose:
@@ -119,5 +126,19 @@
   if (!calloop.Process(pedloop.GetPedestalCam()))
     return;
-  
+
+
+  /********************************************************************/
+  /* THIRD LOOP: APPLY CALIBRATION TO THE CALIBRATION FILES FOR TESTS */
+  /********************************************************************/
+
+  MJExtractCalibTest testloop;
+
+  testloop.SetInput(&cruns);
+  testloop.SetDisplay(display);
+  testloop.SetBadPixels(calloop.GetBadPixels());
+  if (!testloop.ProcessD(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
+    return;
+
+
 }
 
