Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 8483)
+++ trunk/MagicSoft/Mars/Changelog	(revision 8484)
@@ -18,4 +18,35 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2007/05/10 Thomas Bretz
+
+   * callisto.rc, callisto_Dec04Jan05.rc, callisto_MarApr05.rc:
+     - cleanup of some comments
+
+   * mbase/MMath.cc:
+     - removed the usage of a storage space for the index in
+       GetMedianDev because the index is reacalculated anyhow
+
+   * mbase/MStatusArray.cc:
+     - if several objects of the same name (but different class 
+       types) are in a pad we don't stop searching if an object
+       with the right name has been found
+
+   * mcalib/MCalibrateData.cc, mcalib/MCalibrationChargeCalc.cc,
+     mcalib/MCalibrationRelTimeCalc.cc:
+     - updated output
+
+   * mhist/MHCamera.[h,cc]
+     - added two new member functions to count the number of bins
+       above or below a threshold
+
+   * mjobs/MJCalibrateSignal.cc:
+     - added a new Tab to show the time development of the unsuitable
+       pixels
+
+   * mjobs/MJCalibration.cc:
+     - updated texts in bad pixel display
+
+
 
  2007/05/09 Daniela Dorner
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 8483)
+++ trunk/MagicSoft/Mars/NEWS	(revision 8484)
@@ -13,4 +13,8 @@
      properly because the callisto output was currupted
 
+   - general: a script called scripts/makemovie has been added which
+     simplified the process of producing several movies from a single
+     sequence with different setup.
+
    - callisto: the ArrTimeRmsLimit is now is a check of the deviation from
      the median rms of the absolute arrival time and expressed in significance
@@ -19,4 +23,9 @@
      all arrival times are shifted at the same time (in fact it might be
      a shift of the artificial trigger w.r.t. to the light flash).
+
+   - callisto: Added a new tab "BadPixTm" which shows the time evolution
+     of the number of unsuitable pixels over the whole sequence. This
+     is usefull mainly to judge if an intermediate calibration had
+     problems.
 
    - callisto: It is now possible to use the position of the maximum
Index: trunk/MagicSoft/Mars/callisto.rc
===================================================================
--- trunk/MagicSoft/Mars/callisto.rc	(revision 8483)
+++ trunk/MagicSoft/Mars/callisto.rc	(revision 8484)
@@ -384,6 +384,5 @@
 #MJCalibrateSignal.MCalibrateData.CalibConvMaxLimit: 5.
 #MJCalibrateSignal.Interlaced: yes
-#MJCalibrateSignal.RelTimesUpdate: no
-#MJCalibrateSignal.PulsePosCheck: yes
+#MJCalibrateSignal.RelTimesUpdate: yes
 
 # -------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc
===================================================================
--- trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 8483)
+++ trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 8484)
@@ -409,6 +409,5 @@
 #MJCalibrateSignal.MCalibrateData.CalibConvMaxLimit: 5.
 #MJCalibrateSignal.Interlaced: yes
-#MJCalibrateSignal.RelTimesUpdate: no
-#MJCalibrateSignal.PulsePosCheck: yes
+#MJCalibrateSignal.RelTimesUpdate: yes
 
 # -------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/callisto_MarApr05.rc
===================================================================
--- trunk/MagicSoft/Mars/callisto_MarApr05.rc	(revision 8483)
+++ trunk/MagicSoft/Mars/callisto_MarApr05.rc	(revision 8484)
@@ -323,6 +323,6 @@
 # -------------------------------------------------------------------------
 #MJPedestalY2.PulsePosCheck: yes
-MJPedestalY2.ExtractWinLeft:  4.0
-MJPedestalY2.ExtractWinRight: 4.5
+#MJPedestalY2.ExtractWinLeft:  0.0
+#MJPedestalY2.ExtractWinRight: 0.5
 
 # -------------------------------------------------------------------------
@@ -403,7 +403,5 @@
 #MJCalibrateSignal.MCalibrateData.CalibConvMaxLimit: 5.
 #MJCalibrateSignal.Interlaced: yes
-#MJCalibrateSignal.RelTimesUpdate: no
-#MJCalibrateSignal.HiLoCalibration: no
-#MJCalibrateSignal.PulsePosCheck: yes
+#MJCalibrateSignal.RelTimesUpdate: yes
 
 # -------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mbase/MMath.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 8483)
+++ trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 8484)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.30 2006-10-30 12:46:12 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.31 2007-05-10 12:14:54 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -196,19 +196,12 @@
         arr[i] = TMath::Abs(a[i]-med);
 
-    // FIXME: GausProb() is a workaround. It should be taken into account in Median!
-    //return TMath::Median(n, arr);
-    
-    // Sort distribution
-    Long64_t idx[n];
-    TMath::SortImp(n, arr, idx, kTRUE);
-
-    // Define where to divide
-    const Int_t div = TMath::Nint(n*prob);
+    // Define where to divide (floor because the highest possible is n-1)
+    const Int_t div = TMath::FloorNint(n*prob);
 
     // Calculate result
-    Double_t dev = TMath::KOrdStat(n, arr, div, idx);
+    Double_t dev = TMath::KOrdStat(n, arr, div);
     if (n%2 == 0)
     {
-        dev += TMath::KOrdStat(n, arr, div-1, idx);
+        dev += TMath::KOrdStat(n, arr, div-1);
         dev /= 2;
     }
Index: trunk/MagicSoft/Mars/mbase/MStatusArray.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusArray.cc	(revision 8483)
+++ trunk/MagicSoft/Mars/mbase/MStatusArray.cc	(revision 8484)
@@ -93,17 +93,21 @@
 TObject *MStatusArray::FindObjectInPad(TVirtualPad *pad, const char *object, TClass *cls) const
 {
-    TObject *o = pad->FindObject(object);
-    if (o && o->InheritsFrom(cls))
-        return o;
+    TObject *o = NULL;//pad->FindObject(object);
+//    if (o && o->InheritsFrom(cls))
+//        return o;
 
     TIter Next(pad->GetListOfPrimitives());
     while ((o=Next()))
     {
+        if (o->GetName()==(TString)object && o->InheritsFrom(cls))
+            return o;
+
         if (o==pad || !o->InheritsFrom(TVirtualPad::Class()))
             continue;
 
         if ((o = FindObjectInPad((TVirtualPad*)o, object, cls)))
-            if (o->InheritsFrom(cls))
-                return o;
+            return o;
+//            if (o->InheritsFrom(cls))
+//                return o;
     }
     return 0;
Index: trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 8483)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 8484)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.68 2007-04-27 10:04:46 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.69 2007-05-10 12:14:54 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -666,6 +666,6 @@
 	    calibConv    = -1.;
 	    calibFFactor = -1.;
-            *fLog << warn << GetDescriptor() << ": WARNING - ";
-            *fLog << "Conversion factor " << calibConv << " of Pixel " << pixidx << " out of range ]";
+            *fLog << warn << GetDescriptor() << ": ";
+            *fLog << "Conv.factor " << calibConv << " of Pixel " << pixidx << " out of range ]";
             *fLog << fCalibConvMinLimit << "," << fCalibConvMaxLimit << "[... set to 0. " << endl;
 	  }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 8483)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 8484)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.178 2007-05-09 12:15:52 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.179 2007-05-10 12:14:54 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -745,5 +745,5 @@
             if (res<0) //FIXME!!! How does this happen?
             {
-                *fLog << warn << "Pixel  " << setw(4) << i << ": Abs-time resolution could not be calculated." << endl;
+                *fLog << warn << "Pixel  " << setw(4) << i << ": Abs-time rms could not be calculated." << endl;
                 (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution);
                 continue;
@@ -753,5 +753,5 @@
             if (res<=lolim || res>=hilim)
             {
-                *fLog << warn << "Pixel  " << setw(4) << i << ": Deviating abs-time resolution: "
+                *fLog << warn << "Pixel  " << setw(4) << i << ": Deviation from abs-time rms: "
                     << Form("%5.2f", res) << " out of range "
                     << Form("[%4.2f,%4.2f]", lolim, hilim) << endl;
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 8483)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 8484)
@@ -228,5 +228,5 @@
 
   PrintUncalibrated(MBadPixelsPix::kDeviatingTimeResolution,    
-                    Form("%s%2.1f%s","Time resol. less than ", fRelTimeResolutionLimit, " med-dev from median:"));
+                    Form("%s%2.1f%s","Rel.time rms more than ", fRelTimeResolutionLimit, " dev from median:"));
   PrintUncalibrated(MBadPixelsPix::kRelTimeOscillating,   
                     "Pixels with changing Rel. Times over time:");
@@ -308,5 +308,5 @@
             if (res<0) //FIXME!!! How does this happen?
             {
-                *fLog << warn << "Pixel  " << setw(4) << i << ": Rel-time resolution could not be calculated." << endl;
+                *fLog << warn << "Pixel  " << setw(4) << i << ": Rel-time rms could not be calculated." << endl;
                 (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution);
                 continue;
@@ -316,5 +316,5 @@
             if (res<=lolim || res>=hilim)
             {
-                *fLog << warn << "Pixel  " << setw(4) << i << ": Deviating rel-time resolution: "
+                *fLog << warn << "Pixel  " << setw(4) << i << ": Deviation from rel-time rms: "
                     << Form("%5.2f", res) << " out of range "
                     << Form("[%4.2f,%4.2f]", lolim, hilim) << endl;
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 8483)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 8484)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.103 2007-04-20 08:55:19 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.104 2007-05-10 12:14:54 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -514,4 +514,34 @@
 // ------------------------------------------------------------------------
 //
+// Return the number of bins (excluding under- and overflow) for which
+// GetBinContent returns a value > t
+//
+Int_t MHCamera::GetNumBinsAboveThreshold(Double_t t) const
+{
+    Int_t n = 0;
+    for (Int_t i=0; i<fNcells-2; i++)
+        if (GetBinContent(i+1)>t)
+            n++;
+
+    return n;
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the number of bins (excluding under- and overflow) for which
+// GetBinContent returns a value < t
+//
+Int_t MHCamera::GetNumBinsBelowThreshold(Double_t t) const
+{
+    Int_t n = 0;
+    for (Int_t i=0; i<fNcells-2; i++)
+        if (GetBinContent(i+1)>t)
+            n++;
+
+    return n;
+}
+
+// ------------------------------------------------------------------------
+//
 // Call this function to draw the camera layout into your canvas.
 // Setup a drawing canvas. Add this object and all child objects
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 8483)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 8484)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-!  $Name: not supported by cvs2svn $:$Id: MHCamera.h,v 1.63 2007-02-01 14:42:02 tbretz Exp $
+!  $Name: not supported by cvs2svn $:$Id: MHCamera.h,v 1.64 2007-05-10 12:14:54 tbretz Exp $
 \* ======================================================================== */
 #ifndef MARS_MHCamera
@@ -40,4 +40,6 @@
 public:
     enum {
+        // DO NOT USE BIT(14) (MStatusArray WORKAROUND!)
+        // BIT(15)/BIT(16)/BIT(17) used by TH1
         kProfile            = BIT(18), // FIXME: When changing change max/min!
         kFreezed            = BIT(19),
@@ -45,5 +47,5 @@
         kNoScale            = BIT(21),
         kNoUnused           = BIT(22),
-        kErrorMean          = BIT(23)/*,
+        kErrorMean          = BIT(23)/*,  // NO MORE BITS ALLOWED!
         kSqrtVariance       = BIT(21),
         kSinglePixelProfile = BIT(22)*/
@@ -197,4 +199,7 @@
     Double_t GetMinimumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t ball=kFALSE) const;
     Double_t GetMaximumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t ball=kFALSE) const;
+
+    Int_t    GetNumBinsAboveThreshold(Double_t t=0) const;
+    Int_t    GetNumBinsBelowThreshold(Double_t t=0) const;
 
     void     SetLevels(const TArrayF &arr);
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8483)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8484)
@@ -75,4 +75,5 @@
 #include "MHCalibrationRelTimeCam.h"
 #include "MHCalibrationPulseTimeCam.h"
+#include "MHVsTime.h"
 #include "MHCamera.h"
 
@@ -121,5 +122,4 @@
 // - fIsRelTimesUpdate to kFALSE
 // - fIsHiLoCalibration to kFALSE
-// - fPulsePosCheck to kTRUE
 //
 MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title)
@@ -128,7 +128,4 @@
     fName  = name  ? name  : "MJCalibrateSignal";
     fTitle = title ? title : "Tool to calibrate data";
-
-    SetPulsePosCheck();
-    //fCruns = NULL;
 }
 
@@ -600,4 +597,13 @@
     MFillH fillR(&evtR, "MExtractedSignalCam",           "FillHiLoCal");
     MFillH fillO(&evtO, "MArrivalTimeCam",               "FillHiLoOff");
+
+    MHVsTime histbp("MBadPixelsCam.GetNumUnsuitable");
+    histbp.SetName("BadPixTm");
+    histbp.SetTitle("Number of unsuitable pixels;;N");
+    histbp.SetMinimum(0);
+
+    // Task to fill the histogram
+    MFillH fillB(&histbp, "MTime", "FillBadTime");
+    fillB.SetNameTab("BadPixTm");
 
     /*
@@ -758,4 +764,5 @@
     //    tlist2.AddToList(&fill7);
     tlist2.AddToList(&fill9);
+    tlist2.AddToList(&fillB);
     if (extractor1->HasLoGain())
     {
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 8483)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 8484)
@@ -854,6 +854,6 @@
       DrawBadPixel(*pave, disp24,  5, f, "Presumably dead from Ped. Rms:              ");
       DrawBadPixel(*pave, disp24,  6, f, "Deviating Number of Photo-electrons:       ");
-      DrawBadPixel(*pave, disp24,  7, f, "Fluctuating Pulse Arrival Times:                 ");
-      DrawBadPixel(*pave, disp24,  8, f, "Deviating Rel. Arrival Time RMS:                ");
+      DrawBadPixel(*pave, disp24,  7, f, "Deviation from median abs.arr-time rms:   ");
+      DrawBadPixel(*pave, disp24,  8, f, "Deviation from median rel.arr-time rms:     ");
       DrawBadPixel(*pave, disp24,  9, f, "Too many Low-Gain Blackout Events:       ");
       DrawBadPixel(*pave, disp24, 10, f, "Previously Excluded:                                   ");
