Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 4347)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 4348)
@@ -25,4 +25,6 @@
     - added calibration of pedestal files and creation of F2-files.
 
+  * macros/bootcampstandardanalysis.C
+    - updated to use MJExtractSignal
 
  2004/06/18: Markus Gaug
Index: /trunk/MagicSoft/Mars/macros/bootcampstandardanalysis.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/bootcampstandardanalysis.C	(revision 4347)
+++ /trunk/MagicSoft/Mars/macros/bootcampstandardanalysis.C	(revision 4348)
@@ -46,4 +46,5 @@
 //////////////////////////////////////////////////////////////////////////////////
 const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_02_10/";
+const TString outpath = "./";
 const Int_t dpedrun  = 14607;
 const Int_t dcalrun1 = 14608;
@@ -52,5 +53,13 @@
 const Int_t ddatrun2 = 14614;
 const Bool_t usedisplay = kTRUE;
-
+//
+// A switch to use the Blind Pixel
+//
+const Bool_t blindpix = kTRUE;
+//
+// A switch to use the PIN Diode 
+//
+const Bool_t pindiode = kFALSE;
+//
 void bootcampstandardanalysis(const Int_t prun=dpedrun, // pedestal file
                               const Int_t crun1=dcalrun1, const Int_t crun2=dcalrun2, // calibration file(s)
@@ -120,4 +129,5 @@
   MJPedestal pedloop;
   pedloop.SetInput(&pruns);
+  pedloop.SetOutputPath(outpath.Data());
   if (usedisplay)
     {
@@ -144,4 +154,5 @@
   MJCalibration     calloop;
   calloop.SetInput(&cruns);
+  calloop.SetOutputPath(outpath.Data());
   calloop.SetExtractor(&extractor);
   //
@@ -155,4 +166,9 @@
   calloop.SetQECam(qecam);
   calloop.SetBadPixels(pedloop.GetBadPixels());
+  //
+  // Choose if you want to use the blind pixel and/or the pin diode
+  //
+  calloop.SetUseBlindPixel(blindpix);
+  calloop.SetUsePINDiode(pindiode);
   //
   // The next two commands are for the display:
@@ -172,61 +188,17 @@
   /*************************************/
 
-  //
-  // Create a empty Parameter List and an empty Task List
-  //
-  MParList  plist3;
-  MTaskList tlist3;
-  plist3.AddToList(&tlist3);
-  
-  //
-  // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
-  // -----------------------------------------------------------------------------------
-  //
-  
-  MCerPhotEvt    nphot;
-  MPedPhotCam    nphotrms;
-  
-  plist3.AddToList(&geomcam);
-
-  //
-  // Retrieve the cameras from the previous runs:
-  //
-  plist3.AddToList(&pedloop.GetPedestalCam());
-  plist3.AddToList(&calloop.GetCalibrationCam());
-  plist3.AddToList(&calloop.GetQECam());
-  plist3.AddToList(&calloop.GetRelTimeCam());
-  plist3.AddToList(&calloop.GetBadPixels());
-  plist3.AddToList(&nphot);
-  plist3.AddToList(&nphotrms);
-  
-  //tasks
-  MReadMarsFile read3("Events");
-  read3.DisableAutoScheme();
-  static_cast<MRead&>(read3).AddFiles(pruns);  
-
-  MCalibrate       photcalc;
-  photcalc.SetCalibrationMode(MCalibrate::kFfactor);
-  //    MPedPhotCalc  photrmscalc;  //It doesn't exist yet
-  
-  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);
-  
-  //
-  // Execute first analysis
-  //
-  if (!evtloop3.Eventloop())
+  MJExtractSignal pedphotloop;
+
+  pedphotloop.SetExtractor(&extractor);
+  pedphotloop.SetTimeExtractor(&timeext);
+  pedphotloop.SetInput(&pruns);
+  pedphotloop.SetOutputPath(outpath);
+  if (useDisplay)
+    pedphotloop.SetDisplay(display);
+  pedphotloop.SetBadPixels(calloop.GetBadPixels());
+  
+  if (!pedphotloop.ProcessP(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
     return;
-  
-  tlist3.PrintStatistics();
-  
+
   /*************************************/
   /* FOURTH LOOP: DATA CALIBRATION     */
@@ -244,5 +216,4 @@
   // -----------------------------------------------------
   //
-  
   plist4.AddToList(&geomcam);
   //
@@ -254,6 +225,8 @@
   plist4.AddToList(&calloop.GetRelTimeCam());
   plist4.AddToList(&calloop.GetBadPixels());
+  plist4.AddToList(&pedphotloop.GetPedPhotCam());
+
+  MCerPhotEvt nphot;
   plist4.AddToList(&nphot);
-  plist4.AddToList(&nphotrms);
 
   MArrivalTime times;
@@ -265,4 +238,6 @@
   static_cast<MRead&>(read4).AddFiles(druns);  
   
+  MCalibrate       photcalc;
+  photcalc.SetCalibrationMode(MCalibrate::kFfactor);
   MCalibrateRelTimes  timecal;
 
Index: /trunk/MagicSoft/Mars/macros/calibration.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/calibration.C	(revision 4347)
+++ /trunk/MagicSoft/Mars/macros/calibration.C	(revision 4348)
@@ -57,15 +57,15 @@
 #include "MJPedestal.h"
 #include "MJCalibration.h"
+#include "MJExtractSignal.h"
 #include "MJExtractCalibTest.h"
-#include "TObject.h"
-#include "TObjectTable.h"
 #include "MExtractFixedWindowPeakSearch.h"
 #include "MExtractSlidingWindow.h"
 #include "MExtractFixedWindow.h"
+#include "MExtractFixedWindowSpline.h"
+#include "MExtractAmplitudeSpline.h"
 #include "MExtractTimeHighestIntegral.h"
 #include "MExtractTimeFastSpline.h"
 #include "MRunIter.h"
 #include "MStatusDisplay.h"
-#include "TStyle.h"
 #include "MCalibrationQECam.h"
 #include "MHCalibrationTestCam.h"
@@ -77,16 +77,24 @@
 #include "MParContainer.h"
 
+#include "TStyle.h"
+#include "TObject.h"
+#include "TObjectTable.h"
+#include "TSystem.h"
+
+#include <fstream>
+
 using namespace std;
 
 static TString outpath = "./";
-static TString inpath = "./";
+static TString inpath  = "/home/rootdata/Calib/2004_05_24/";
+static TString badfile = "";
 //
 // the default pedestal run for the calibration
 //
-static const Int_t   pedrun  = 26851;
+static const Int_t   pedrun  = 26569;
 //
 // the default start calibration run 
 //
-static const Int_t   calrun1 = 26849;
+static const Int_t   calrun1 = 26568;
 //
 // the default last calibration run (if 0, only one run is taken, otherwise consecutive runs 
@@ -109,9 +117,13 @@
 // Tell if you want to calibrate times:
 //
-static Bool_t useTimes = kFALSE;
+static Bool_t useTimes = kTRUE;
 //
 // Tell if you want to use the display:
 //
 static Bool_t useDisplay = kTRUE;
+//
+// Tell if you want to test the result afterwards
+//
+static Bool_t useTest = kTRUE;
 //
 Int_t calibration(const Int_t prun=pedrun, 
@@ -127,11 +139,11 @@
   //  MExtractFixedWindowPeakSearch extractor;
   //  MExtractSlidingWindow  extractor;   
-  MExtractFixedWindow extractor;   
-
+  MExtractFixedWindowSpline extractor;
+  //  MExtractAmplitudeSpline extractor;
+  //  MExtractTimeAndChargeSpline extractor;
   //
   // Set Ranges or Windows
   //
-  extractor.SetRange(0,15,3,14);
-   // extractor.SetRange(5,9 ,5,9 );
+  extractor.SetRange(1,14,2,13);
   //  extractor.SetWindows(8,8);
 
@@ -144,5 +156,5 @@
   // Set Ranges or Windows
   //
-  timeext.SetRange(1,14,3,14);
+  timeext.SetRange(0,7,3,8);
 
   MRunIter pruns;
@@ -156,6 +168,8 @@
     cruns.AddRuns(crun1,crun2,inpath);
 
-  gStyle->SetOptStat(111111);
+  gStyle->SetOptStat(1111);
   gStyle->SetOptFit();
+  gStyle->SetTitleSize(0.1,"u");
+  gStyle->SetLineWidth(1);
 
   MStatusDisplay *display = NULL;
@@ -178,5 +192,10 @@
   // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
   //
-  //  badcam.AsciiRead("badpixels.dat");
+  if (!badfile.IsNull())
+    {
+      ifstream f(badfile.Data());
+      badcam.AsciiRead(f);  
+      f.close();
+    }
 
   MJPedestal pedloop;
@@ -197,10 +216,12 @@
   MJCalibration calloop;
 
+  if (debug)
+    calloop.SetDebug();
   //
   // If you want to run the data-check on RAW DATA!!!, choose:
-  // calloop.SetDataCheck();
+  //  calloop.SetDataCheck();
   // 
   // If you want to see the data-check plots only, choose:
-  // calloop.SetDataCheckDisplay();
+  calloop.SetDataCheckDisplay();
   // 
   // For everything, you have ever dreamed of, choose:
@@ -249,37 +270,59 @@
   /********************************************************************/
 
-  MJExtractCalibTest testloop;
-
-  testloop.SetExtractor(&extractor);
-  testloop.SetTimeExtractor(&timeext);
-  testloop.SetInput(&cruns);
-  testloop.SetOutputPath(outpath);
+  if (useTest)
+    {
+      
+      MJExtractCalibTest testloop;
+      
+      testloop.SetExtractor(&extractor);
+      testloop.SetTimeExtractor(&timeext);
+      testloop.SetInput(&cruns);
+      testloop.SetOutputPath(outpath);
+      if (useDisplay)
+        testloop.SetDisplay(display);
+      testloop.SetBadPixels(calloop.GetBadPixels());
+      
+      if (!testloop.ProcessD(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
+        return 3;
+      
+      if (useTimes)
+        if (!testloop.ProcessT(pedloop.GetPedestalCam(),calloop.GetRelTimeCam()))
+      return 4;
+      
+      gLog << endl;
+      gLog << "Mean equiv. number of photons from cascades per mm^2 Inner pixels: " 
+       << testloop.GetTestCam().GetMeanMeanPhotPerArea(0) 
+           << " +- " << testloop.GetTestCam().GetRmsMeanPhotPerArea(0) << endl;
+      gLog << "Sigma equiv. number of photons from cascades per mm^2 Inner pixels: " 
+           << testloop.GetTestCam().GetMeanSigmaPhotPerArea(0) 
+           << " +- " << testloop.GetTestCam().GetRmsSigmaPhotPerArea(0) << endl;
+      
+      gLog << endl;
+      gLog << "Mean equiv. number of photons from cascades per mm^2 Outer pixels: " 
+           << testloop.GetTestCam().GetMeanMeanPhotPerArea(1) 
+           << " +- " << testloop.GetTestCam().GetRmsMeanPhotPerArea(1) << endl;
+      gLog << "Sigma equiv. number of photons from cascades per mm^2 Outer pixels: " 
+           << testloop.GetTestCam().GetMeanSigmaPhotPerArea(1) 
+           << " +- " << testloop.GetTestCam().GetRmsSigmaPhotPerArea(1) << endl;
+      gLog << endl;  
+      
+    }
+  
+  /********************************************************************/
+  /* FOURTH LOOP: APPLY CALIBRATION TO THE PEDESTAL FILES             */
+  /********************************************************************/
+
+  MJExtractSignal pedphotloop;
+
+  pedphotloop.SetExtractor(&extractor);
+  pedphotloop.SetTimeExtractor(&timeext);
+  pedphotloop.SetInput(&pruns);
+  pedphotloop.SetOutputPath(outpath);
   if (useDisplay)
-    testloop.SetDisplay(display);
-  testloop.SetBadPixels(calloop.GetBadPixels());
-  
-  if (!testloop.ProcessD(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
-    return 3;
-
-  if (useTimes)
-    if (!testloop.ProcessT(pedloop.GetPedestalCam(),calloop.GetRelTimeCam()))
-      return 4;
-
-  gLog << endl;
-  gLog << "Mean equiv. number of photons from cascades per mm^2 Inner pixels: " 
-       << testloop.GetTestCam().GetMeanMeanPhotPerArea(0) 
-       << " +- " << testloop.GetTestCam().GetRmsMeanPhotPerArea(0) << endl;
-  gLog << "Sigma equiv. number of photons from cascades per mm^2 Inner pixels: " 
-       << testloop.GetTestCam().GetMeanSigmaPhotPerArea(0) 
-       << " +- " << testloop.GetTestCam().GetRmsSigmaPhotPerArea(0) << endl;
-
-  gLog << endl;
-  gLog << "Mean equiv. number of photons from cascades per mm^2 Outer pixels: " 
-       << testloop.GetTestCam().GetMeanMeanPhotPerArea(1) 
-       << " +- " << testloop.GetTestCam().GetRmsMeanPhotPerArea(1) << endl;
-  gLog << "Sigma equiv. number of photons from cascades per mm^2 Outer pixels: " 
-       << testloop.GetTestCam().GetMeanSigmaPhotPerArea(1) 
-       << " +- " << testloop.GetTestCam().GetRmsSigmaPhotPerArea(1) << endl;
-  gLog << endl;  
+    pedphotloop.SetDisplay(display);
+  pedphotloop.SetBadPixels(calloop.GetBadPixels());
+  
+  if (!pedphotloop.ProcessP(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
+    return 5;
 
 
@@ -296,7 +339,4 @@
   // List of useful containers:
   // 
-  MHCalibrationTestCam  &testcam     = testloop.GetTestCam();
-  testcam[100].DrawClone("events");
-
 /*
   MPedestalCam          &pedcam      = pedloop.GetPedestalCam();
@@ -312,4 +352,5 @@
   // 
 /*
+  testcam[200].DrawClone("fourierevents");
   testcam.GetAverageHiGainArea(0).DrawClone();
   testcam.GetAverageLoGainArea(0).DrawClone();
@@ -330,4 +371,5 @@
   testcam.GetAverageLoGainSector(6).DrawClone();
 */
+
   return 0;
 
@@ -351,7 +393,9 @@
     gLog << "     --inpath=#          Find the data in inpath"                      << endl;
     gLog << "     --outpath=#         Write the output containers to outpath"       << endl;
+    gLog << "     --badfile=#         Use the file # to exclude pixels from the beginning" << endl;
     gLog << "     --debug             Use the TObjectTable for debugging    "       << endl;
     gLog << "                             and write out the pixels as ascii tables" << endl;
     gLog << "     --useTimes          Calibrate the relative arrival times"         << endl;
+    gLog << "     --useTest           Use the class MJExtractCalibTest to test the calibration on itself" << endl;
     gLog << "     --skipBlindPix      Skip the blind pixel calibration"             << endl;
     gLog << "     --skipPINDiode      Skip the PIN Diode   calibration"             << endl;
@@ -374,4 +418,5 @@
   debug    = arg.HasOnlyAndRemove("--debug")    || arg.HasOnlyAndRemove("-d");
   useTimes = arg.HasOnlyAndRemove("--useTimes") || arg.HasOnlyAndRemove("-t");
+  useTest  = arg.HasOnlyAndRemove("--useTest")  || arg.HasOnlyAndRemove("-e");
   blindpix = !(arg.HasOnlyAndRemove("--skipBlindPix"));
   pindiode = !(arg.HasOnlyAndRemove("--skipPINDiode"));
@@ -383,5 +428,13 @@
     outpath = arg.GetStringAndRemove("--outpath=");
 
-  //
+  if (arg.HasOption("--badfile="))
+    badfile = arg.GetStringAndRemove("--badfile=");
+
+  if (gSystem->AccessPathName(badfile,kFileExists))
+  {
+    gLog << "WARNING: the bad pixels file '" << badfile.Data() << "' doesn't exist." << endl;
+    badfile = "";
+  }
+
   // check for the right usage of the program
   //
Index: /trunk/MagicSoft/Mars/mjobs/MJExtractCalibTest.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJExtractCalibTest.cc	(revision 4347)
+++ /trunk/MagicSoft/Mars/mjobs/MJExtractCalibTest.cc	(revision 4348)
@@ -179,5 +179,5 @@
 
   TCanvas &c = fDisplay->AddTab("TestTimes");
-  c.Divide(4,2);
+  c.Divide(2,4);
 
   disp1.CamDraw(c, 1, 2,  5, 1);
