Index: trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc	(revision 3029)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc	(revision 3057)
@@ -29,6 +29,5 @@
 //   Task to calculate the calibration conversion factors from the FADC
 //   time slices. The integrated time slices have to be delivered by an 
-//   MExtractedSignalCam. The pedestals by an MPedestalCam and possibly 
-//   arrival times from MArrivalTime
+//   MExtractedSignalCam. The pedestals by an MPedestalCam.
 //
 //   The output container MCalibrationCam holds one entry of type MCalibrationPix 
@@ -37,5 +36,4 @@
 //   ProProcess: Search for MPedestalCam, MExtractedSignalCam
 //               Initialize MCalibrationCam
-//               Initialize MArrivalTime if exists
 //               Initialize pulser light wavelength
 //               
@@ -62,5 +60,4 @@
 //
 //                Fits can be excluded via the commands:
-//                MalibrationCam::SkipTimeFits()   (skip all time fits)
 //                MalibrationCam::SkipBlindPixelFits()  (skip all blind
 //                pixel fits)
@@ -112,12 +109,10 @@
 #include "MCalibrationPINDiode.h"
 
-#include "MArrivalTime.h"
-
 ClassImp(MCalibrationCalc);
 
 using namespace std;
 
-const Int_t MCalibrationCalc::fBlindPixelId = 559;
-const Int_t MCalibrationCalc::fPINDiodeId   = 9999;
+const UInt_t MCalibrationCalc::fBlindPixelId = 559;
+const UInt_t MCalibrationCalc::fPINDiodeId   = 9999;
 const Byte_t MCalibrationCalc::fgSaturationLimit = 254;
 const Byte_t MCalibrationCalc::fgBlindPixelFirst = 3;
@@ -130,5 +125,5 @@
 MCalibrationCalc::MCalibrationCalc(const char *name, const char *title)
     : fPedestals(NULL), fCalibrations(NULL), fSignals(NULL),
-      fRawEvt(NULL), fRunHeader(NULL), fArrivalTime(NULL), fEvtTime(NULL)
+      fRawEvt(NULL), fRunHeader(NULL), fEvtTime(NULL)
 {
 
@@ -147,5 +142,4 @@
 {
   
-    SETBIT(fFlags, kUseTimes);
     SETBIT(fFlags, kUseBlindPixelFit);
     SETBIT(fFlags, kUseCosmicsRejection);
@@ -153,6 +147,4 @@
     SETBIT(fFlags, kHiLoGainCalibration);
 
-    CLRBIT(fFlags, kBlindPixelOverFlow);
-    CLRBIT(fFlags, kPINDiodeOverFlow);
     CLRBIT(fFlags, kHiGainOverFlow);
     CLRBIT(fFlags, kLoGainOverFlow);
@@ -198,5 +190,4 @@
 // The following output containers are only searched, but not created
 //
-//  - MArrivaltime
 //  - MTime
 //
@@ -226,6 +217,4 @@
         return kFALSE;
       }
-
-    fArrivalTime  = (MArrivalTime*)pList->FindObject("MArrivalTime");
 
     fEvtTime      = (MTime*)pList->FindObject("MTime");
@@ -310,4 +299,11 @@
         if (!TESTBIT(fFlags,kUseQualityChecks))
           pix.SetExcludeQualityCheck();
+
+        // Exclude the blind pixel and the PIN Diode from normal pixel calibration:
+        if (i == fBlindPixelId)
+          pix.SetExcluded();
+
+        if (i == fPINDiodeId)
+          pix.SetExcluded();
 
      }
@@ -450,5 +446,4 @@
   // Create a (second) loop to do fill the calibration histograms
   // Search for: a signal in MExtractedSignalCam 
-  //             a time in MArrivalTime. 
   // Fill histograms with:
   //             charge
@@ -463,7 +458,4 @@
       MCalibrationPix &pix = (*fCalibrations)[pixid];
       
-      if (pix.IsExcluded())
-        continue;
-      
       MExtractedSignalPix &sig =  (*fSignals)[pixid];
       
@@ -474,4 +466,5 @@
       Float_t reltime = 0.;
 
+#if 0
       if (TESTBIT(fFlags,kUseTimes))
         {
@@ -492,18 +485,18 @@
               if (pixid == 1)
                 referencetime = (Float_t)pixel.GetIdxMaxHiGainSample();
-
+#endif
               if (sig.IsLoGainUsed())
                 {
                   abstime = (Float_t)pixel.GetIdxMaxLoGainSample();
-                  reltime = abstime - referencetime;
+                  //            reltime = abstime - referencetime;
                 }
               else
                 {
                   abstime = (Float_t)pixel.GetIdxMaxHiGainSample();
-                  reltime = abstime - referencetime;
+                  //                  reltime = abstime - referencetime;
                 }
-            }
-        }  /* if Use Times */
-      
+              //            }
+              //        }  /* if Use Times */
+
       switch(pixid)
         {
@@ -526,18 +519,7 @@
                   "Overflow or Underflow occurred filling Blind Pixel sum = " << blindpixelsum << endl;
               
-              if (TESTBIT(fFlags,kUseTimes))
-                {
-                  if (!blindpixel.FillTime(reltime))
-                    *fLog << warn << 
-                      "Overflow or Underflow occurred filling Blind Pixel time = " << reltime << endl;
-                }
-              
-              if (!TESTBIT(fFlags,kBlindPixelOverFlow))
-                if (!blindpixel.FillRChargevsTime(blindpixelsum,fEvents))
-                  {
-                    *fLog << warn << 
-                      "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
-                    SETBIT(fFlags,kBlindPixelOverFlow);
-                  }
+              //              if (!blindpixel.FillRChargevsTime(blindpixelsum,fEvents))
+                  //                  *fLog << warn << 
+                  //                    "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
             } /* if use blind pixel */
           
@@ -550,25 +532,17 @@
           
               if (!pindiode.FillCharge(sumhi)) 
-                *fLog << warn << 
-                  "Overflow or Underflow occurred filling PINDiode: sum = " << sumhi << endl;
+                *fLog << warn 
+                      << "Overflow or Underflow occurred filling PINDiode: sum = " 
+                      << sumhi << endl;
               
-              if (TESTBIT(fFlags,kUseTimes))
-                {
-                  if (!pindiode.FillAbsTime(abstime))
-                    *fLog << warn << 
-                      "Overflow or Underflow occurred filling PINDiode abs. time = " << abstime << endl;
-                  if (!pindiode.FillRelTime(reltime))
-                    *fLog << warn << 
-                      "Overflow or Underflow occurred filling PINDiode rel. time = " << reltime << endl;
-                }
-              
-              if (!TESTBIT(fFlags,kPINDiodeOverFlow))
-                if (!pindiode.FillRChargevsTime(sumhi,fEvents))
-                  {
-                    *fLog << warn 
-                          << "Overflow or Underflow occurred filling PINDiode: eventnr = " 
-                          << fEvents << endl;
-                    SETBIT(fFlags,kPINDiodeOverFlow);
-                  }
+              if (!pindiode.FillAbsTime(abstime))
+                 *fLog << warn 
+                       << "Overflow or Underflow occurred filling PINDiode abs. time = " 
+                       << abstime << endl;
+
+              if (!pindiode.FillGraphs(sumhi,sumlo))
+                *fLog << warn 
+                      << "Overflow or Underflow occurred filling PINDiode: eventnr = " 
+                      << fEvents << endl;
               
             } /* if use PIN Diode */
@@ -578,27 +552,8 @@
         default:
               
-          if (!TESTBIT(fFlags,kLoGainOverFlow))
-            if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents))
-              {
-                *fLog << warn 
-                      << "Overflow filling Histogram ChargevsNLoGain eventnr = " 
-                      << fEvents << endl;
-                SETBIT(fFlags,kLoGainOverFlow);
-                SkipHiLoGainCalibration();
-              }
-          
-          if (!TESTBIT(fFlags,kHiGainOverFlow))
-            if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents))
-              {
-                *fLog << warn 
-                      << "Overflow filling Histogram ChargevsNHiGain eventnr = " 
-                      << fEvents << endl;
-                SETBIT(fFlags,kHiGainOverFlow);
-                SkipHiLoGainCalibration();
-              }
-
-
-          if (TESTBIT(fFlags,kHiLoGainCalibration))
-            pix.FillChargesInGraph(sumhi,sumlo);
+          if (pix.IsExcluded())
+            continue;
+
+          pix.FillGraphs(sumhi,sumlo);
 
           if (sig.IsLoGainUsed())
@@ -608,14 +563,13 @@
                 *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid 
                       << " signal = " << sumlo << endl;
-              
-              if (TESTBIT(fFlags,kUseTimes))
-                {
-                  if (!pix.FillAbsTimeLoGain(abstime)) 
-                    *fLog << warn << "Could not fill Lo Gain Abs. Time of pixel: " 
-                          << pixid << " time = " << abstime << endl;
-                  if (!pix.FillRelTimeLoGain(reltime)) 
-                    *fLog << warn << "Could not fill Lo Gain Rel. Time of pixel: " 
-                          << pixid << " time = " << reltime << endl;
-                }
+
+              if (!pix.FillAbsTimeLoGain(abstime)) 
+                *fLog << warn << "Could not fill Lo Gain Abs. Time of pixel: " 
+                      << pixid << " time = " << abstime << endl;
+              /*
+                if (!pix.FillRelTimeLoGain(reltime)) 
+                *fLog << warn << "Could not fill Lo Gain Rel. Time of pixel: " 
+                    << pixid << " time = " << reltime << endl;
+              */
             } /* if (sig.IsLoGainUsed()) */
           else
@@ -625,13 +579,12 @@
                       << " signal = " << sumhi << endl;
               
-              if (TESTBIT(fFlags,kUseTimes))
-                {
-                  if (!pix.FillAbsTimeHiGain(abstime))
-                    *fLog << warn << "Could not fill Hi Gain Abs. Time of pixel: " 
-                          << pixid << " time = " << abstime << endl;
-                  if (!pix.FillRelTimeHiGain(reltime))
+              if (!pix.FillAbsTimeHiGain(abstime))
+                *fLog << warn << "Could not fill Hi Gain Abs. Time of pixel: " 
+                      << pixid << " time = " << abstime << endl;
+              /*
+              if (!pix.FillRelTimeHiGain(reltime))
                     *fLog << warn << "Could not fill Hi Gain Rel. Time of pixel: " 
                           << pixid << " time = " << reltime << endl;
-                }
+              */
             } /* else (sig.IsLoGainUsed()) */
           break;
@@ -771,8 +724,7 @@
 
       //
-      // Perform the Gauss fits to the arrival times
-      //
-      if (TESTBIT(fFlags,kUseTimes))
-        pix.FitTime();
+      // check also for oscillations
+      // 
+      pix.CheckOscillations();
       
     }
