Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 8581)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 8582)
@@ -18,4 +18,45 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2007/06/19 Thomas Bretz
+
+   * callisto.rc, callisto_Dec04Jan05.rc:
+     - changed the default values (commented out anyhow) to the real
+       values.
+       
+   * mbase/MEnv.h:
+     - allow printing contents from the context menu
+
+   * mcalib/MCalibrationRelTimeCalc.cc:
+     - replaced kDeviatingTimeResolution by new kDeviatingRelTimeResolution
+
+   * mhcalib/MHCalibrationPulseTimeCam.cc:
+     - automatically scale the saturation limit to the fadc range
+
+   * mjobs/MJCalibrateSignal.cc:
+     - save resource file into signal*.root file
+     - added some code (still commented) for saving the calibration
+       results
+     - do not fill the bad-pixel plots with MCs
+
+   * mjobs/MJCalibration.cc:
+     - save resource file into signal*.root file
+
+   * mjobs/MJPedestal.cc:
+     - clarified output for "mean pulse time" further
+
+   * mpedestal/MExtractPedestal.cc:
+     - automatically scale the maximum variation and the 
+       maximum value to fit the FADC range
+
+   * mraw/MRawRunHeader.h:
+     - added a function returnung the maximum value of the FADC
+     - changed the GetScale from a calculation to a switch 
+       (faster and easier to understand)
+
+   * msignal/MExtractor.cc:
+     - get the maximum in case of no lo-gains from the run-header
+
+
 
  2007/06/18 Thomas Bretz
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 8581)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 8582)
@@ -7,4 +7,8 @@
      Also the old values seemed not exactly the PulsePos used for 
      teh check.
+
+   - general: Now the output files (calib*.root, etc) also contain the
+     resource file (to check it open it in the TBrowser and choose Print()
+     from the context menu)
 
    - callisto: improved calculation of spline coefficients a lot. This
Index: /trunk/MagicSoft/Mars/callisto.rc
===================================================================
--- /trunk/MagicSoft/Mars/callisto.rc	(revision 8581)
+++ /trunk/MagicSoft/Mars/callisto.rc	(revision 8582)
@@ -311,7 +311,7 @@
 # Define the Pulse Position check parameters:
 # -------------------------------------------------------------------------
-#MJPedestalY2.MHCalibrationPulseTimeCam.SaturationLimit:  255
-#MJPedestalY2.MHCalibrationPulseTimeCam.LowerSignalLimit: 100
-#MJPedestalY2.MHCalibrationPulseTimeCam.NumPixelsRequired: 2
+#MJPedestalY2.MHCalibrationPulseTimeCam.SaturationLimit:  245
+#MJPedestalY2.MHCalibrationPulseTimeCam.LowerSignalLimit:  85
+#MJPedestalY2.MHCalibrationPulseTimeCam.NumPixelsRequired:  2
 #MJPedestalY2.PixelCheck: no
 
Index: /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc
===================================================================
--- /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 8581)
+++ /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 8582)
@@ -339,7 +339,7 @@
 # Define the Pulse Position check parameters:
 # -------------------------------------------------------------------------
-#MJPedestalY2.MHCalibrationPulseTimeCam.SaturationLimit:  255
-#MJPedestalY2.MHCalibrationPulseTimeCam.LowerSignalLimit: 100
-#MJPedestalY2.MHCalibrationPulseTimeCam.NumPixelsRequired: 2
+#MJPedestalY2.MHCalibrationPulseTimeCam.SaturationLimit:  245
+#MJPedestalY2.MHCalibrationPulseTimeCam.LowerSignalLimit:  85
+#MJPedestalY2.MHCalibrationPulseTimeCam.NumPixelsRequired:  2
 #MJPedestalY2.PixelCheck: no
 
Index: /trunk/MagicSoft/Mars/mbase/MEnv.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MEnv.h	(revision 8581)
+++ /trunk/MagicSoft/Mars/mbase/MEnv.h	(revision 8582)
@@ -67,4 +67,7 @@
     void        AddEnv(const TEnv &env, Bool_t overwrite=kTRUE);
 
+    void        Print(Option_t *option) const { TEnv::Print(option); }
+    void        Print() const { TEnv::PrintEnv(kEnvLocal); } //*MENU*
+
     void PrintUntouched() const;
     Int_t GetNumUntouched() const;
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 8582)
@@ -227,5 +227,5 @@
   *fLog << GetDescriptor() << ": Errors statistics:" << endl;  
 
-  PrintUncalibrated(MBadPixelsPix::kDeviatingTimeResolution,    
+  PrintUncalibrated(MBadPixelsPix::kDeviatingRelTimeResolution,
                     Form("%s%2.1f%s","Rel.time rms more than ", fRelTimeResolutionLimit, " dev from median:"));
   PrintUncalibrated(MBadPixelsPix::kRelTimeOscillating,   
@@ -309,5 +309,5 @@
             {
                 *fLog << warn << "Pixel  " << setw(4) << i << ": Rel-time rms could not be calculated." << endl;
-                (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution);
+                (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingRelTimeResolution);
                 continue;
             }
@@ -320,5 +320,5 @@
                     << Form("[%4.2f,%4.2f]", lolim, hilim) << endl;
 
-                (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution);
+                (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingRelTimeResolution);
             }
         }
@@ -342,5 +342,5 @@
 
       if (IsCheckDeviatingBehavior())
-          if (bad.IsUncalibrated(MBadPixelsPix::kDeviatingTimeResolution))
+          if (bad.IsUncalibrated(MBadPixelsPix::kDeviatingRelTimeResolution))
               bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
 
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc	(revision 8582)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCalibrationPulseTimeCam.cc,v 1.40 2007-06-12 20:49:55 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCalibrationPulseTimeCam.cc,v 1.41 2007-06-19 09:25:38 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -394,5 +394,5 @@
 
         // Check for saturation
-        if (evt->GetSaturation(idx, fSaturationLimit)>0)
+        if (evt->GetSaturation(idx, fSaturationLimit*fRunHeader->GetScale())>0)
             continue;
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8582)
@@ -151,6 +151,12 @@
     // file always. Which might make the usage outside of
     // callisto difficult.
+    TObjArray cont;
+    cont.Add(const_cast<TEnv*>(GetEnv()));
+
+    if (fDisplay)
+        cont.Add(fDisplay);
+
     const TString name(Form("signal%08d.root", fSequence.GetSequence()));
-    return WriteDisplay(name, "UPDATE");
+    return WriteContainer(cont, name, "UPDATE");
 }
 
@@ -675,4 +681,13 @@
     writemc.AddContainer("MMcEvtBasic", "OriginalMC");
 
+    // Write the special calib tree
+    /*
+    MWriteRootFile writecal(2, fname, fOverwrite?"RECREATE":"NEW");
+    writecal.SetName("WriteCalib");
+    writecal.AddContainer("MBadPixelsCam",          "Calib");
+    writecal.AddContainer("MCalibrationChargeCam",  "Calib");
+    writecal.AddContainer("MCalibrationRelTimeCam", "Calib");
+    */
+
     // Now setup tasklist for events
     MTaskList tlist2;
@@ -722,5 +737,7 @@
 	if (fIsRelTimesUpdate)
             tlist3.AddToList(&recalc); // MCalibrationRelTimeCam
-    }  
+
+        //tlist3.AddToList(&writecal);   // MWriteRootFile
+    }
 
     // Continue for all non-cosmic events
@@ -761,6 +778,9 @@
     //    tlist2.AddToList(&fill7);
     tlist2.AddToList(&fill9);
-    tlist2.AddToList(&fillB);
-    tlist2.AddToList(&fillD);
+    if (!fSequence.IsMonteCarlo())
+    {
+        tlist2.AddToList(&fillB);
+        tlist2.AddToList(&fillD);
+    }
     if (extractor1->HasLoGain())
     {
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 8582)
@@ -2027,4 +2027,6 @@
         cont.Add(fDisplay);
 
+    cont.Add(const_cast<TEnv*>(GetEnv()));
+
     return WriteContainer(cont, GetOutputFileName(), "UPDATE");
 }
Index: /trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 8582)
@@ -319,4 +319,6 @@
     if (fDisplay)
         arr.Add(fDisplay);
+
+    arr.Add(const_cast<TEnv*>(GetEnv()));
 
     return WriteContainer(arr, fname, "UPDATE");
Index: /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 8582)
@@ -895,5 +895,5 @@
         return kFALSE;
 
-    *fLog << all << "Mean pulse time (" << (fSequence.IsMonteCarlo()?"MC":"cosmics") << "): ";
+    *fLog << all << "Mean pulse time/Avg pos.of maximum (" << (fSequence.IsMonteCarlo()?"MC":"cosmics") << "): ";
     *fLog << meanpulsetime << "+-" << rmspulsetime << endl;
 
Index: /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 8582)
@@ -1322,7 +1322,14 @@
 
     // check if output should be written
-    if (!fPathOut.IsNull())
-        fDisplay->SaveAsRoot(fPathOut);
-
-    return kTRUE;
-}
+    if (fPathOut.IsNull())
+        return kTRUE;
+
+    // Write the output
+    TObjArray cont;
+    cont.Add((TObject*)GetEnv());
+
+    if (fDisplay)
+        cont.Add(fDisplay);
+
+    return WriteContainer(cont, fPathOut, "RECREATE");
+}
Index: /trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 8582)
@@ -103,19 +103,12 @@
     }
 
+    TObjArray cont;
+    cont.Add(const_cast<TEnv*>(GetEnv()));
+
+    if (fDisplay)
+        cont.Add(fDisplay);
+
     const TString oname = Form("%s/star%08d.root", (const char*)fPathOut, fSequence.GetSequence());
-
-    *fLog << inf << "Writing to file: " << oname << endl;
-
-    TFile file(oname, "RECREATE");
-
-    *fLog << inf << " - MStatusDisplay..." << flush;
-    if (fDisplay && fDisplay->Write()<=0)
-    {
-        *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
-        return kFALSE;
-    }
-    *fLog << inf << "ok." << endl;
-
-    return kTRUE;
+    return WriteContainer(cont, oname, "UPDATE");
 }
 
@@ -345,4 +338,5 @@
     // Spark cut
     MFDataPhrase fsparks("log10(MNewImagePar.fConc1) < (-0.371)*log10(MHillas.fSize) + 0.596", "SparkCut");
+    //fill0b.SetFilter(&fsparks);
     fill0c.SetFilter(&fsparks);
 
Index: /trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc	(revision 8582)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.32 2007-06-16 21:59:19 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.33 2007-06-19 09:25:39 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -620,6 +620,8 @@
     }
 
+    max /= fRunHeader->GetScale();
+    min /= fRunHeader->GetScale();
+
     // If the maximum in the high gain window is smaller than
-    // FIXME: Precompiled value!
     return max-min<fMaxSignalVar && max<fMaxSignalAbs;
 }
Index: /trunk/MagicSoft/Mars/mraw/MRawRunHeader.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawRunHeader.h	(revision 8581)
+++ /trunk/MagicSoft/Mars/mraw/MRawRunHeader.h	(revision 8582)
@@ -115,5 +115,6 @@
     UShort_t GetNumNormalPixels() const;
     UShort_t GetNumSpecialPixels() const;
-    UInt_t   GetScale() const { return 1<<((fNumBytesPerSample-1)*8); }
+    UInt_t   GetScale() const { switch (fNumBytesPerSample) { case 1: return 0x1; case 2: return 0x100; case 4: return 0x1000000; } return 0; }
+    UInt_t   GetMax() const { switch (fNumBytesPerSample) { case 1: return 0xff; case 2: return 0xffff; case 4: return 0xffffffff; } return 0; }
 
     UInt_t GetNumSamplesPerCrate() const
Index: /trunk/MagicSoft/Mars/msignal/MExtractor.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 8581)
+++ /trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 8582)
@@ -251,8 +251,8 @@
         fLoGainFirst=0;
         fLoGainLast =0;
-        if (fSaturationLimit>0xff)
+        if (fSaturationLimit>fRunHeader->GetMax())
         {
-            *fLog << " and saturation limit";
-            fSaturationLimit=0xff;
+            *fLog << " and saturation limit to " << fRunHeader->GetMax();
+            fSaturationLimit=fRunHeader->GetMax();
         }
         *fLog << "." << endl;
