Index: trunk/MagicSoft/Mars/macros/calibration.C
===================================================================
--- trunk/MagicSoft/Mars/macros/calibration.C	(revision 5342)
+++ trunk/MagicSoft/Mars/macros/calibration.C	(revision 5343)
@@ -54,5 +54,5 @@
 //  "calibrate" it and test the resulting outcome.
 //
-/////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////
 #include "MJPedestal.h"
 #include "MJCalibration.h"
@@ -66,9 +66,11 @@
 #include "MExtractTimeHighestIntegral.h"
 #include "MExtractTimeFastSpline.h"
+#include "MExtractTimeAndChargeDigitalFilter.h"
+#include "MExtractTimeAndChargeSlidingWindow.h"
+#include "MExtractTimeAndChargeSpline.h"
 #include "MRunIter.h"
 #include "MStatusDisplay.h"
+#include "MCalibrationQECamMagic.h"
 #include "MCalibrationQECam.h"
-#include "MHCalibrationTestCam.h"
-#include "MHCalibrationTestPix.h"
 #include "MBadPixelsCam.h"
 #include "MArgs.h"
@@ -87,6 +89,9 @@
 
 static TString outpath = "./";
-static TString inpath  = "/home/rootdata/Calib/2004_07_06/";
+static TString inpath  = "/home/rootdata/Calib/2004_07_06";
 static TString badfile = "";
+//static TString badfile = "badpixels_only0_559_560.dat";
+static TString weightfile = "msignal/calibration_weights_UV.dat";
+//static TString weightfile = "msignal/cosmics_weights.dat";
 //
 // the default pedestal run for the calibration
@@ -101,4 +106,5 @@
 // between calrun1 and calrun2)
 //
+//static  const Int_t calrun2 = 31754;
 static  const Int_t calrun2 = 0;
 //
@@ -110,11 +116,16 @@
 //
 static Bool_t blindpix = kTRUE;
+//
 // A switch to use the PIN Diode 
 //
-static Bool_t pindiode = kFALSE;
+static Bool_t pindiode = kTRUE;
 //
 // Tell if you want to calibrate times:
 //
-static Bool_t useTimes = kFALSE;
+static Bool_t useTimes = kTRUE;
+//
+// Tell if you want to use a combined extractor:
+//
+static Bool_t useTimeAndCharge = kTRUE;
 //
 // Tell if you want to use the display:
@@ -124,5 +135,17 @@
 // Tell if you want to test the result afterwards
 //
-static Bool_t useTest = kTRUE;
+static Bool_t useTest = kFALSE;
+//
+// Tell if you want to test the intensity calibration
+//
+static Bool_t useIntensity = kFALSE;
+//
+// Tell if you want to use MPedCalcFromLogain for the pedestal calculation
+//
+static Bool_t usedata      = kTRUE;
+//
+// Tell if you want to store and read the F0 and F1- files
+//
+static Bool_t usestorage   = kFALSE;
 //
 Int_t calibration(const Int_t prun=pedrun, 
@@ -136,25 +159,42 @@
   // Choose the signal Extractor:
   //
-  //  MExtractFixedWindowPeakSearch extractor;
-  //  MExtractSlidingWindow  extractor;   
-  //  MExtractFixedWindowSpline extractor;
-  MExtractFixedWindow extractor;
-  //  MExtractAmplitudeSpline extractor;
-  //  MExtractTimeAndChargeSpline extractor;
-  //
-  // Set Ranges or Windows
-  //
-  extractor.SetRange(3,14,4,13);
-  //  extractor.SetWindows(8,8);
-
-  //
-  // Choose the arrival time Extractor:
+  // PURE CHARGE EXTRACTORS:
+  //  MExtractFixedWindowPeakSearch  extractor;
+  //  MExtractSlidingWindow         extractor;   
+  //  MExtractFixedWindow           extractor;
+  //  MExtractFixedWindowSpline     extractor;
+  //  MExtractAmplitudeSpline       extractor;
+  //
+  // PURE TIME EXTRACTORS:
+  // ATTENTION: If an extractor deriving from MExtractTimeAndCharge is
+  //            used, you may want to use the timing calculated directly
+  //            from there. Use the flag: "useTimeAndCharge" in this case
   //
   //  MExtractTimeHighestIntegral timeext;
-  MExtractTimeFastSpline timeext;
-  //
-  // Set Ranges or Windows
-  //
-  timeext.SetRange(0,7,3,8);
+  //  MExtractTimeFastSpline timeext;
+  //  MExtractTimeSpline timeext;
+  //
+  // COMBINED TIME AND CHARGE EXTRACTORS:
+  // (You have to set the variable "useTimeAndCharge" in order to use the 
+  //  time calculated by this extractor!)
+  MExtractTimeAndChargeDigitalFilter extractor;
+  //  MExtractTimeAndChargeSpline   extractor;
+  //  MExtractTimeAndChargeSlidingWindow extractor;
+  //
+  //  Set Ranges or Windows
+  //
+  //  extractor.SetRange(1,14,4,12);
+  //  extractor.SetWindowSize(6,6);
+  //  timeext.SetRange(1,14,4,12);
+  //  timeext.SetWindowSize(6,6);
+  //
+  // Set additional information for some extractors
+  //
+  // Digital Filter:
+  extractor.ReadWeightsFile(weightfile.Data());
+  //  extractor.ReadWeightsFile("");
+  // TimeAndChargeSpline:
+  //  extractor.SetChargeType(MExtractTimeAndChargeSpline::kIntegral);
+  //  extractor.SetTimeType(MExtractTimeAndChargeSpline::kHalfMaximum);
 
   MRunIter pruns;
@@ -186,6 +226,9 @@
   /************************************/
 
-  MCalibrationQECam qecam;
-  MBadPixelsCam     badcam;
+  //
+  // Hand over to the jobs a QE Cam with Cornings initialized
+  // 
+  MCalibrationQECamMagic qecam;
+  MBadPixelsCam          badcam;
   //
   // If you want to exclude pixels from the beginning, read 
@@ -195,9 +238,12 @@
     {
       ifstream f(badfile.Data());
-      badcam.AsciiRead(f);  
+      badcam.AsciiRead((istream&)f);  
       f.close();
     }
 
   MJPedestal pedloop;
+  pedloop.SetUseData(usedata);
+  pedloop.SetNoStorage(!usestorage);
+  pedloop.SetEnvDebug(debug);
   pedloop.SetExtractor(&extractor);
   pedloop.SetInput(&pruns);
@@ -221,4 +267,12 @@
   if (debug)
     calloop.SetDebug();
+  calloop.SetEnvDebug(debug);
+  if (useIntensity)
+    calloop.SetIntensity();
+  //  calloop.SetHistsStorage();
+  calloop.SetNoStorage(!usestorage);
+  //
+  // If you want to set a colour explicitely from outside (not recommanded!)
+  //  calloop.SetColor(MCalibrationCam::kUV);
   //
   // If you want to run the data-check on RAW DATA!!!, choose:
@@ -227,7 +281,8 @@
   // If you want to see the data-check plots only, choose:
   calloop.SetDataCheckDisplay();
+  //calloop.SetNormalDisplay();
   // 
   // For everything, you have ever dreamed of, choose:
-  // calloop.SetFullDisplay();
+  //  calloop.SetFullDisplay();
 
   //
@@ -236,4 +291,5 @@
   calloop.SetRelTimeCalibration(useTimes);
   calloop.SetExtractor(&extractor);
+  calloop.SetTimeAndCharge(useTimeAndCharge);
   calloop.SetTimeExtractor(&timeext);
   calloop.SetInput(&cruns);
@@ -262,10 +318,4 @@
       badbad.Print();
     }
-
-  gLog << endl;
-  gLog << "Mean number of photons from pulser Inner pixels (F-Factor Method): " 
-       << calloop.GetCalibrationCam().GetNumPhotonsFFactorMethod() 
-       << " +- " << calloop.GetCalibrationCam().GetNumPhotonsFFactorMethodErr() << endl;
-  gLog << endl;
 
   /********************************************************************/
@@ -297,9 +347,10 @@
       
     }
-  
+
   /********************************************************************/
   /* FOURTH LOOP: APPLY CALIBRATION TO THE PEDESTAL FILES             */
   /********************************************************************/
 
+  /*
   MJExtractSignal pedphotloop;
 
@@ -315,5 +366,5 @@
     return 5;
 
-
+  */
   if (debug)
     TObject::SetObjectStat(kFALSE);
@@ -324,16 +375,4 @@
   if (debug)
     gObjectTable->Print();
-
-  //
-  // List of useful containers:
-  // 
-/*
-  MPedestalCam          &pedcam      = pedloop.GetPedestalCam();
-  MCalibrationChargeCam &chargecam   = calloop.GetCalibrationCam();
-  MCalibrationQECam     &qecam       = calloop.GetCalibrationCam();
-  MBadPixelsCam         &badcam      = calloop.GetBadPixels();
-  MCalibrationTestCam   &testcam     = testloop.GetTestCam();
-  MHCalibrationTestTimeCam &testtime = testloop.GetTestTimeCam();
-*/
 
   return 0;
