Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7004)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7005)
@@ -21,4 +21,134 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2005/05/10 Thomas Bretz
+
+   * mreport/MReportStarguider.cc:
+     - introduced the correct version which marked the fix of the
+       units of the nominal position
+
+   * callisto.rc:
+     - introduced a new line for new option in MCalibColorFromPast
+
+   * ganymed.cc:
+     - removed option "--full-display" -> now default
+
+   * manalysis/MEnergyEstimate.cc:
+     - print the rule a bit earlier in PreProcess
+
+   * mfilter/MFDeltaT.cc:
+     - fixed a typo in the output
+
+   * mhflux/MAlphaFitter.cc:
+     - some improvements to output
+
+   * mjobs/MJCut.cc:
+     - added ThetaSquared to output
+
+   * mjobs/MJStar.cc:
+     - fixed bug in copying of OriginalMC tree
+
+   * mmuon/MMuonCalibParCalc.cc:
+     - removed obsolete setting of ReadyToSave
+
+
+
+ 2005/05/10 Markus Gaug (2005/05/09)
+
+   * mjobs/hilocalib_sp1.root
+   * mjobs/hilocalib_sp1_mc.root
+     - new hi-lo intercalibration files with the fixed spline extractor.
+
+   * mjobs/hilocalib_df46_mc.root
+     - new hi-lo intercalibration files from MC with the left out -O5 
+       option. (The real data files had already the correct executable).
+
+
+
+ 2005/05/10 Hendrik Bartko (2005/05/09)
+
+   * msignal/MC_weights46.dat
+     - NEW weights file for digital filter with dedicated MC weights
+       with 4 slices for the high gain and 6 slices for the low gain
+
+
+
+ 2005/05/10 Markus Gaug (2005/05/08)
+
+   * mhcalib/MHCalibrationCam.[h,cc]
+     - introduce parameters fLowerFitLimit and fHigherFitLimit to 
+       tell explicitly from outside to fit functions in a certain 
+       range. If both are 0. (default), the histogram limits define 
+       the fit limits (as before).
+
+
+
+ 2005/05/10 Abelardo Moralejo (2005/05/07)
+
+   * mcalib/MMcCalibrationCalc.cc
+     - in Process, fixed wrong estimate of true number of "equivalent 
+       photoelectrons" (correctedphotel). This worked roughly OK as long
+       as the file used for calibration was a (noiselesss) gamma file,
+       because most light is contained in the inner camera and the
+       problem was related to the light going into the outer pixels. So
+       results are not much affected, unless one uses for calibration 
+       a file with events having a lot of light in the outer camera.
+       Thomas Hengstebeck noticed this problem when he used a file of MC 
+       calibration pulses in mccalibrate.C
+
+   * manalysis/MMcCalibrationUpdate.[h,cc]
+     - Added possibility to set the hi to lo gain conversion factor. 
+       Until now the factor was simply the ratio of pulse areas as read
+       from MMcFadcHeader. This of course is not the factor to be applied 
+       to the extracted signals unless the extractor integrates the full 
+       pulse in both high and low gain. The factor depends then on the
+       extractor, and the user has to find out what its value is.
+       Set as default calibration type kPhe.
+
+   * macros/mccalibrate.C, starmc.C
+     - Added the setting of the hi to lo gain conversion factor (see 
+       above). For now it has to be calculated by the user. However, it
+       is strongly recommended from now on to use always callisto for the
+       calibration of real data, and not these macros. These are kept 
+       just for checking purposes, mostly by "experts".
+
+
+
+ 2005/05/10 Robert Wagner (2005/05/06)
+
+   * mreport/MReportStarguider.[h,cc]:
+     - Bugfix: Sequence of extracting fDevZd and fDevAz (switched)
+
+
+
+ 2005/05/10 Markus Gaug (2005/05/05)
+
+   * mcalib/MCalibCalcFromPast.[h,cc]
+     - introduce flag "fUpdateWithFFactorMethod" which allows to use the
+       entire results obtained with the F-Factor method (including a new 
+       number of mean photo-electrons). This possibility is switched on 
+       (only) if somewhere in the callisto.rc file the following line is 
+       written:
+         MJCalibrateSignal.MCalibCalcFromPast.UpdateWithFFactorMethod: yes
+       (Default is still the old way of adjusting the relative extracted 
+       charges w.r.t. the mean charge over the inner camera).
+
+
+
+ 2005/05/10 Markus Gaug (2005/05/02)
+
+   * mcalib/MCalibrationChargeCam.[h,cc]
+     - added new function MergeHiLoConversionFactors
+
+   * mcalib/MCalibColorSteer.[h,cc]
+     - introduce copying of hi-lo calibration factors from one cam to 
+       the next in intensity calibration.
+     - added storage of averageing histograms of flag fHistStorage is
+       set
+
+   * mcalib/MCalibrationIntensityCam.[h,cc]
+     - introduce place for storage of averageing histograms (if wanted).
+
+
+
  2005/05/09 Markus Meyer
 
@@ -27,4 +157,5 @@
      - changed the start parameter for the gaussian fit for the
        calculation of ArcWidth
+
 
 
Index: trunk/MagicSoft/Mars/Makefile.conf.darwin
===================================================================
--- trunk/MagicSoft/Mars/Makefile.conf.darwin	(revision 7004)
+++ trunk/MagicSoft/Mars/Makefile.conf.darwin	(revision 7005)
@@ -20,5 +20,5 @@
 #  ----->>>   settings for compilation
 #
-OPTIM    = -O5 -Wall -fno-exceptions -fPIC -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Woverloaded-virtual
+OPTIM    = -O -Wall -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Woverloaded-virtual
 # ggc 3.2: removed -fnonnull-objects -Wtraditional -Wnested-externs
 DEBUG    = 
Index: trunk/MagicSoft/Mars/macros/mccalibrate.C
===================================================================
--- trunk/MagicSoft/Mars/macros/mccalibrate.C	(revision 7004)
+++ trunk/MagicSoft/Mars/macros/mccalibrate.C	(revision 7005)
@@ -63,15 +63,25 @@
 
   //
-  //  Set signal extractor
+  //  USER CHANGE: Set signal extractor
   //
   //    MExtractFixedWindowPeakSearch sigextract;
   //    sigextract.SetWindows(6, 6, 4);
   //
-  MExtractTimeAndChargeDigitalFilter sigextract;
-  sigextract.SetNameWeightsFile("/users/emc/moralejo/Mars/msignal/MC_weights.dat");
-  sigextract.SetRange(1, 14, 3, 14);
-
+
+  //    MExtractTimeAndChargeDigitalFilter sigextract;
+  //    sigextract.SetNameWeightsFile("/users/emc/moralejo/Mars/msignal/MC_weights.dat");
+  //    sigextract.SetRange(1, 14, 3, 14);
+
+  MExtractTimeAndChargeSpline sigextract;
+  sigextract.SetRiseTimeHiGain(0.5);
+  sigextract.SetFallTimeHiGain(0.5);
+
+
+  // USER CHANGE: high to low gain ratio. DEPENDS on EXTRACTOR!!
+  // One should calculate somewhere else what this factor is for each extractor!
+  Float_t hi2low = 12.; // tentative value for spline with risetime 0.5, fall time 0.5
 
   MMcCalibrationUpdate  mccalibupdate;
+  mccalibupdate.SetUserLow2HiGainFactor(hi2low);
   ///// User change: calibrate in photons or phe- :
   mccalibupdate.SetSignalType(MCalibrateData::kPhe);
Index: trunk/MagicSoft/Mars/macros/starmc.C
===================================================================
--- trunk/MagicSoft/Mars/macros/starmc.C	(revision 7004)
+++ trunk/MagicSoft/Mars/macros/starmc.C	(revision 7005)
@@ -52,9 +52,9 @@
   // differences in gain of outer pixels)
   //
-  CalibrationFilename = new TString("/users/emc/moralejo/mcdata/Period021_0.73_mirror/gammas_nonoise/Gamma_zbin0_*.root");
+  CalibrationFilename = new TString("/data1/magic/mc_data/root/Period025/gammas_nonoise/Gamma_zbin0_*.root");
   // File to be used in the calibration (must be a camera file without added noise)
 
 
-  Char_t* AnalysisFilename = "Gamma_*w0.root";  // File to be analyzed
+  Char_t* AnalysisFilename = "Gamma_zbin1_0_*.root";  // File to be analyzed
 
 
@@ -74,23 +74,34 @@
   Float_t accepted_fraction = 1.;
 
-  Float_t CleanLev[2] = {5., 4.}; 
-  // User change: tail cuts for image analysis
-
+  // USER CHANGE: tail cuts for image analysis
+
+  Float_t CleanLev[2] = {7., 5.}; 
   MImgCleanStd  clean(CleanLev[0], CleanLev[1]); // Applies tail cuts to image.
-
-
-  //  User change: signal extraction
+  clean.SetMethod(MImgCleanStd::kAbsolute);      // In absolute units (phot or phe- as chosen below)
+
+
+  //  USER CHANGE: signal extraction
   //
   //  MExtractFixedWindowPeakSearch sigextract;
   //  sigextract.SetWindows(6, 6, 4);
 
-  MExtractTimeAndChargeDigitalFilter sigextract;
-  sigextract.SetNameWeightsFile("/users/emc/moralejo/Mars/msignal/MC_weights.dat");
-  sigextract.SetRange(1, 14, 3, 14);
+  //  MExtractTimeAndChargeDigitalFilter sigextract;
+  //  sigextract.SetNameWeightsFile("/users/emc/moralejo/Mars/msignal/MC_weights.dat");
+  //  sigextract.SetRange(1, 14, 3, 14);
+
+  MExtractTimeAndChargeSpline sigextract;
+  sigextract.SetRiseTimeHiGain(0.5);
+  sigextract.SetFallTimeHiGain(0.5);
+
+  // USER CHANGE: high to low gain ratio. DEPENDS on EXTRACTOR!!
+  // One should calculate somewhere else what this factor is for each extractor!
+  Float_t hi2low = 12.; // tentative value for spline with risetime 0.5, fall time 0.5
+
 
   ////////// Calibration //////////
-
   MMcCalibrationUpdate  mccalibupdate;
-  ///// User change: calibrate in photons or phe- :
+  mccalibupdate.SetUserLow2HiGainFactor(hi2low);
+
+  ///// USER CHANGE: calibrate in photons or phe- :
   mccalibupdate.SetSignalType(MCalibrateData::kPhe);
   //  mccalibupdate.SetSignalType(MCalibrateData::kPhot);
@@ -233,9 +244,9 @@
   //
 
-  //  MProgressBar bar;
-  //  bar.SetWindowName("Calibrating...");
+  MProgressBar bar;
+  bar.SetWindowName("Calibrating...");
 
   MEvtLoop evtloop;
-  //  evtloop.SetProgressBar(&bar);
+  evtloop.SetProgressBar(&bar);
   evtloop.SetParList(&plist);
 
@@ -271,5 +282,5 @@
   tlist.AddToListBefore(&skip, &sigextract);
 
-  //  bar.SetWindowName("Analyzing...");
+  bar.SetWindowName("Analyzing...");
 
   tlist.RemoveFromList(&mccalibcalc); // Removes calibration task from list.
Index: trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 7005)
@@ -79,17 +79,10 @@
 
 MMcCalibrationUpdate::MMcCalibrationUpdate(const char *name, const char *title)
+  :  fFillCalibrationCam(kTRUE), fOuterPixelsGainScaling(kTRUE), fAmplitude(-1.), 
+     fAmplitudeOuter(-1.), fConversionHiLo(-1.), fUserLow2HiGainFactor(-1.), 
+     fSignalType(MCalibrateData::kPhe)
 {
     fName  = name  ? name  : "MMcCalibrationUpdate";
     fTitle = title ? title : "Write MC pedestals and conversion factors into MCalibration Container";
-
-
-    fAmplitude = -1.;
-    fAmplitudeOuter = -1.;
-    fConversionHiLo = -1.;
-
-    fSignalType = MCalibrateData::kPhot;
-
-    fFillCalibrationCam = kTRUE;
-    fOuterPixelsGainScaling = kTRUE;
 }
 
@@ -194,5 +187,22 @@
 	  {
 	    fAmplitudeOuter = fHeaderFadc->GetAmplitudOuter();
-	    fConversionHiLo = fHeaderFadc->GetLow2HighGain();
+
+	    fHeaderLow2HiGainFactor = fHeaderFadc->GetLow2HighGain();
+
+	    // The high to low gain ratio is stored in MMcFadcHeader.Low2HighGain. 
+	    // However, this is just the ratio of total pulse integrals. Since the 
+	    // shape of the low gain pulse is different from that of the high gain,
+	    // the factor to be applied to signals extracted from low gain depends
+	    // on the type of signal extractor (for instance if we extract the pulse 
+	    // height, the factor is larger than Low2HighGain, because the low gain
+	    // pulse shape is wider and hence lower than the high gain pulse. So the 
+	    // user can set manually the value of the factor to be applied. If such 
+	    // value has not been set by the user, then we takes as default Low2HighGain.
+
+	    if (fUserLow2HiGainFactor < 0.)
+	      fConversionHiLo = fHeaderLow2HiGainFactor;
+	    else
+	      fConversionHiLo = fUserLow2HiGainFactor;
+
 	  }
 	else // old MC files, camera  < v0.7
@@ -203,5 +213,5 @@
 
     }
-    else   // Check that following files have all the same FADC parameters
+    else   // Check that the following files have all the same FADC parameters as the first
     {
       if ( fabs(fHeaderFadc->GetAmplitud()-fAmplitude) > 1.e-6 )
@@ -211,8 +221,8 @@
 	}
 
-      if (mcrunh->GetCamVersion() > 60) // old MC files, camera < v0.7
+      if (mcrunh->GetCamVersion() > 60) // files from camera 0.7 or newer
 	{
 	  if( fabs(fHeaderFadc->GetAmplitudOuter()-fAmplitudeOuter) > 1.e-6  ||
-	      fabs(fConversionHiLo-fHeaderFadc->GetLow2HighGain())  > 1.e-6 )
+	      fabs(fHeaderLow2HiGainFactor-fHeaderFadc->GetLow2HighGain()) > 1.e-6 )
 	    {
 	      *fLog << err << "Parameters of MMcFadcHeader are not the same for all files... aborting." << endl;
Index: trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.h	(revision 7004)
+++ trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.h	(revision 7005)
@@ -42,5 +42,9 @@
     Float_t fAmplitude;      // FADC parameters from camera simulation (see camera manual)
     Float_t fAmplitudeOuter; // to be read from the MMcFadcHeader.
-    Float_t fConversionHiLo; // Ratio of high to low gain.
+    Float_t fConversionHiLo; // Ratio of high to low gain to be used for low gain signal calibration.
+
+    Float_t fHeaderLow2HiGainFactor; // Ratio of high to low gain, as read from the MMcFadcHeader
+    Float_t fUserLow2HiGainFactor;   // Ratio of high to low gain, as set manually by the user
+
 
     Float_t fOuterPixelsLightCollection; 
@@ -58,4 +62,6 @@
       { fOuterPixelsGainScaling = tf; }
 
+    void SetUserLow2HiGainFactor(Float_t x) { fUserLow2HiGainFactor = x; }
+
     void SetSignalType (MCalibrateData::SignalType_t x) { fSignalType = x; }
     MCalibrateData::SignalType_t GetSignalType () const { return fSignalType; }
Index: trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc	(revision 7005)
@@ -79,5 +79,5 @@
       fIntensCharge(NULL), fIntensBlind(NULL), fIntensRelTime(NULL), fIntensBad(NULL),
       fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
-      fNumEvents(0), fNumCam(0)
+      fNumEvents(0), fNumCam(0), fUpdateWithFFactorMethod(kFALSE)
 {
 
@@ -249,5 +249,6 @@
     fRelTimeCalc->Finalize();
   if (fCalibrate)
-    fCalibrate->UpdateConversionFactors((MCalibrationChargeCam*)fIntensCharge->GetCam());
+      fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL :
+                                          (MCalibrationChargeCam*)fIntensCharge->GetCam());
 
   ReInitialize();
@@ -324,7 +325,23 @@
 Int_t MCalibCalcFromPast::PostProcess()
 {
-  *fLog << "Number of Calibration Cams: " << fNumCam << endl;
+  *fLog << inf << "Number of Calibration Cams: " << fNumCam << endl;
   return kTRUE;
   
 }
 
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv, eg:
+//   MCalibCalcFromPast.UpdateWithFFactorMethod: Off, On
+//
+Int_t MCalibCalcFromPast::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kFALSE;
+    if (IsEnvDefined(env, prefix, "UpdateWithFFactorMethod", print))
+    {
+        rc = kTRUE;
+        SetUpdateWithFFactorMethod(GetEnvValue(env, prefix, "UpdateWithFFactorMethod", fUpdateWithFFactorMethod));
+    }
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h	(revision 7005)
@@ -41,5 +41,7 @@
   UInt_t fNumEvents;           //! Event counter only for calibration events
   UInt_t fNumCam;              //! Number of currently used Calibration Cam
-  
+
+  Bool_t fUpdateWithFFactorMethod; // Update the interlaced calib events with the full F-Factor method
+
   Int_t  PreProcess(MParList *pList);
   Int_t  Process();
@@ -48,4 +50,6 @@
   Bool_t ReInitialize();
   Bool_t Finalize(const char* name);
+
+  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
 public:
@@ -61,4 +65,6 @@
   void SetChargeCalc   ( MCalibrationChargeCalc  *c )  { fChargeCalc  = c; }
   void SetRelTimeCalc  ( MCalibrationRelTimeCalc *c )  { fRelTimeCalc = c; }
+
+  void SetUpdateWithFFactorMethod(const Bool_t b=kTRUE){ fUpdateWithFFactorMethod = b; }
   
   ClassDef(MCalibCalcFromPast, 1) // Task to steer the processing of interlace calibration events
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc	(revision 7005)
@@ -22,4 +22,5 @@
 !
 \* ======================================================================== */
+
 //////////////////////////////////////////////////////////////////////////////
 //
@@ -81,5 +82,5 @@
     : fCalibPattern(NULL), fGeom(NULL), fParList(NULL), 
       fIntensCharge(NULL), fIntensRelTime(NULL), fIntensBad(NULL),
-      fBad(NULL), fChargeCalc(NULL), fRelTimeCalc(NULL)
+      fBad(NULL), fChargeCalc(NULL), fRelTimeCalc(NULL), fHistCopy(kFALSE)
 {
 
@@ -285,4 +286,25 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Reads the pattern from MCalibrationPattern and initializes new containers in the 
+// Intensity Cams, if the pattern has changed. Executes Finalize of the 
+// MCalibration*Calc classes in that case.
+//
+Int_t MCalibColorSteer::PostProcess()
+{
+    //
+    // Finalize Possible calibration histogram classes...
+    //
+    *fLog << inf << "Finalize calibration histograms..." << flush;
+    if (Finalize("MHCalibrationChargeCam"))      *fLog << inf << "MHCalibrationChargeCam..." << flush;
+    if (Finalize("MHCalibrationChargeBlindCam")) *fLog << inf << "MHCalibrationChargeBlindCam..." << flush;
+    if (Finalize("MHCalibrationRelTimeCam"))     *fLog << inf << "MHCalibrationRelTimeCam..." << flush;
+    if (Finalize("MHCalibrationTestCam"))        *fLog << inf << "MHCalibrationChargeCam..." << flush;
+    if (Finalize("MHCalibrationTestTimeCam"))    *fLog << inf << "MHCalibrationChargeCam..." << flush;
+    *fLog << inf << "done." << endl;
+
+    return kTRUE;
+}
 
 // --------------------------------------------------------------------------
@@ -300,4 +322,5 @@
 
   hist->Finalize();
+  CopyHist(name);
   hist->ResetHists();
   hist->SetColor( fCalibPattern->GetPulserColor());
@@ -331,6 +354,6 @@
       MCalibrationChargeCam *cam    = (MCalibrationChargeCam*)fIntensCharge->GetCam();
       cam->SetPulserColor(fCalibPattern->GetPulserColor());
-      if (!cam->CopyHiLoConversionFactors(*oldcam))
-        return kFALSE;
+      if (!cam->MergeHiLoConversionFactors(*oldcam))
+          return kFALSE;
       *fLog << inf << "New MCalibrationChargeCam with name: " << cam->GetName() << endl;
     }
@@ -388,2 +411,26 @@
   return result;
 }
+
+// --------------------------------------------------------------------------
+//
+// Copies the histogram classes into the intensity cams
+//
+void MCalibColorSteer::CopyHist(const char* name)
+{
+  MHCalibrationCam *hcam = (MHCalibrationCam*)fParList->FindObject(name);
+  TString n(name);
+  if (n.Contains("ChargeCam"))
+    {
+      if (fIntensCharge)
+	  fIntensCharge->AddHist((MHCalibrationCam*)hcam->Clone());
+    }
+  if (n.Contains("Blind"))
+    if (fIntensBlind)
+	  fIntensBlind->AddHist((MHCalibrationCam*)hcam->Clone());
+
+  if (n.Contains("RelTime"))
+    if (fIntensRelTime)
+	  fIntensRelTime->AddHist((MHCalibrationCam*)hcam->Clone());
+}
+
+// --------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.h	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.h	(revision 7005)
@@ -27,6 +27,4 @@
 {
 private:
-
-
   MCalibrationPattern             *fCalibPattern;    //!
   MRawRunHeader                   *fRunHeader;       //!
@@ -45,16 +43,21 @@
   MCalibrationCam::PulserColor_t   fColor;
   Float_t                          fStrength;
+
+  Bool_t                           fHistCopy;        // Decide whether MHCalibrationCams will get copied
   
   Int_t  PreProcess(MParList *pList);
   Int_t  Process();
+  Int_t  PostProcess();
   
   Bool_t ReInitialize();
   Bool_t Finalize(const char* name);
+
+  void    CopyHist(const char* name);
   TString GetNamePattern();
   
 public:
+    MCalibColorSteer(const char *name=NULL, const char *title=NULL);
 
-    MCalibColorSteer(const char *name=NULL, const char *title=NULL);
-    ~MCalibColorSteer() {}
+    void SetHistCopy(const Bool_t b=kTRUE) { fHistCopy = b; }
 
     ClassDef(MCalibColorSteer, 1) // Task to steer the processing of multiple calibration colours
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 7005)
@@ -252,5 +252,5 @@
 // Copy High-gain vs. low-gain conversion factors from cam to this.
 //
-Bool_t MCalibrationChargeCam::CopyHiLoConversionFactors(const MCalibrationChargeCam &cam) const
+Bool_t MCalibrationChargeCam::MergeHiLoConversionFactors(const MCalibrationChargeCam &cam) const
 {
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h	(revision 7005)
@@ -59,5 +59,5 @@
                                               const UInt_t sec=0, MBadPixelsCam *bad=NULL);
 
-  Bool_t CopyHiLoConversionFactors(const MCalibrationChargeCam &cam) const;
+  Bool_t MergeHiLoConversionFactors(const MCalibrationChargeCam &cam) const;
   
   // Prints
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc	(revision 7005)
@@ -30,5 +30,7 @@
 // Contains TOrdCollections for the following objects:
 // - fCams:  Array of classes derived from MCalibrationCam, one entry 
-//           per calibration camera result. Has to be created
+//           per calibration camera result.
+// - fHists: Array of classes derived from MHCalibrationPix, one entry
+//           per calibration camera result and area index
 //
 // See also: MCalibrationIntensityChargeCam, MCalibrationIntensityQECam,
@@ -39,4 +41,6 @@
 //           MCalibrationChargeBlindPix, MCalibrationChargePINDiode
 //
+// ClassVersion 2:
+//  + fHists
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -45,5 +49,9 @@
 #include <TOrdCollection.h>
 
+#include "MLog.h"
+#include "MLogManip.h"
+
 #include "MGeomCam.h"
+#include "MHCalibrationCam.h"
 
 ClassImp(MCalibrationIntensityCam);
@@ -57,4 +65,5 @@
 // Set the following pointer to NULL:
 // - fCams
+// - fHists
 //
 MCalibrationIntensityCam::MCalibrationIntensityCam(const char *name, const char *title)
@@ -66,5 +75,7 @@
   fCams = new TOrdCollection;
   fCams->SetOwner();
-  
+
+  fHists = new TOrdCollection;
+  fHists->SetOwner();
 }
 
@@ -76,6 +87,19 @@
 MCalibrationIntensityCam::~MCalibrationIntensityCam()
 {
-  if (fCams)
     delete fCams;
+    delete fHists;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new MHCalibrationCam to fHists
+//
+void MCalibrationIntensityCam::AddHist( const MHCalibrationCam *cam)
+{
+    const Int_t size = fHists->GetSize();
+    fHists->AddAt((TObject*)cam,size);
+
+    if (size != GetSize()-1)
+        *fLog << warn << "Histogram Cams and Calibration Cams size mismatch! " << endl;
 }
 
@@ -100,20 +124,21 @@
 void MCalibrationIntensityCam::Copy(TObject& object) const
 {
-  
-  MCalibrationIntensityCam &calib = (MCalibrationIntensityCam&)object;
-  
-  MParContainer::Copy(calib);
-  
-  calib.fOffsets = fOffsets;
-  calib.fSlopes  = fSlopes;
-  
-  const UInt_t n = GetSize();
-  if (n != 0)
+    MCalibrationIntensityCam &calib = (MCalibrationIntensityCam&)object;
+
+    MParContainer::Copy(calib);
+
+    calib.fOffsets = fOffsets;
+    calib.fSlopes  = fSlopes;
+
+    const UInt_t n = GetSize();
+    if (n != 0)
     {
-      calib.InitSize(n);
-      for (UInt_t i=0; i<n; i++)
-        GetCam(i)->Copy(*(calib.GetCam(i)));
+        calib.InitSize(n);
+        for (UInt_t i=0; i<n; i++)
+        {
+            GetCam(i)->Copy(*(calib.GetCam(i)));
+            GetHist(i)->Copy(*(calib.GetHist(i)));
+        }
     }
-  
 }
 
@@ -124,8 +149,6 @@
 void MCalibrationIntensityCam::Clear(Option_t *o)
 {
-
-  fCams->ForEach(MCalibrationCam, Clear)(); 
-
-  return;
+    fCams->ForEach(MCalibrationCam, Clear)();
+    fHists->ForEach(MHCalibrationCam, Clear)();
 }
 
@@ -136,5 +159,6 @@
 void MCalibrationIntensityCam::Print(Option_t *o) const
 {
-  fCams->ForEach(MCalibrationCam, Print)(o); 
+    fCams->ForEach(MCalibrationCam, Print)(o);
+    fHists->ForEach(MHCalibrationCam, Print)(o);
 }
 
@@ -424,2 +448,38 @@
   return size;
 }
+
+// --------------------------------------------------------------------------
+//
+// Get i-th histogram class 
+//
+MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i)
+{
+    return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th histogram class
+//
+const MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i) const
+{
+    return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get histogram class with name 'name'
+//
+MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name )
+{
+    return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get histogram class with name 'name'
+//
+const MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name ) const
+{
+    return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
+}
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h	(revision 7005)
@@ -18,14 +18,15 @@
 class MBadPixelsPix;
 class MGeomCam;
+class MHCalibrationCam;
+
 class MCalibrationIntensityCam : public MParContainer, public MCamEvent
 {
 private:
-  
-  MArrayD fOffsets;           //! Arrays of Higain-vs-LoGain fit result Offsets
-  MArrayD fSlopes;            //! Arrays of Higain-vs-LoGain fit result Slopes
+  MArrayD fOffsets;        //! Arrays of Higain-vs-LoGain fit result Offsets
+  MArrayD fSlopes;         //! Arrays of Higain-vs-LoGain fit result Slopes
 
 protected:  
-
-  TOrdCollection *fCams;        // Array of MCalibrationCams, one per pulse colour and intensity
+  TOrdCollection *fCams;   // Array of MCalibrationCams, one per pulse colour and intensity
+  TOrdCollection *fHists;  // Array of MHCalibrationCam's, containing the mean charges per area histograms
 
   virtual void Add(const UInt_t from, const UInt_t to);
@@ -33,5 +34,4 @@
   
 public:
-
   MCalibrationIntensityCam(const char *name=NULL, const char *title=NULL);
   ~MCalibrationIntensityCam();
@@ -40,5 +40,6 @@
   void  Copy(TObject& object) const;  
   
-  void AddToList( const char* name, const MGeomCam &geom );
+  void AddToList(const char* name, const MGeomCam &geom);
+  void AddHist(const MHCalibrationCam *cam);
 
   Int_t CountNumEntries(const MCalibrationCam::PulserColor_t col) const;  
@@ -69,4 +70,10 @@
   const MCalibrationCam *GetCam              ( const char *name ) const;
 
+        MHCalibrationCam *GetHist            ( Int_t i=-1);
+  const MHCalibrationCam *GetHist            ( Int_t i=-1) const;
+
+        MHCalibrationCam *GetHist            ( const char *name );
+  const MHCalibrationCam *GetHist            ( const char *name ) const;
+
         MCalibrationPix &operator[]          ( UInt_t i );
   const MCalibrationPix &operator[]          ( UInt_t i )  const;
@@ -91,5 +98,5 @@
                                                                 GetCam()->SetPulserColor(col);            }
 
-  ClassDef(MCalibrationIntensityCam, 1) // Base Container Intensity Calibration Results
+  ClassDef(MCalibrationIntensityCam, 2) // Base Container Intensity Calibration Results
 };
 
Index: trunk/MagicSoft/Mars/mcalib/MMcCalibrationCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MMcCalibrationCalc.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mcalib/MMcCalibrationCalc.cc	(revision 7005)
@@ -242,5 +242,5 @@
 {
     //
-    // Exclude events with some saturated pixel
+    // Exclude events with some high-gain saturated pixel
     //
     if (fPar->GetNumSatPixelsHG()>0)
@@ -266,11 +266,6 @@
     //
  
-    const Float_t inner_photel = (Float_t) fMcEvt->GetPhotElfromShower() * innersize / size;
-    const Float_t outer_photel = (Float_t) fMcEvt->GetPhotElfromShower() - inner_photel;
-
-    const Float_t corrected_photel = inner_photel + outer_photel / fOuterPixelsLightCollection;
-
-
-    //    fHistADC2PhotEl->Fill(TMath::Log10(fMcEvt->GetPhotElfromShower()/size));
+    const Float_t corrected_photel = (Float_t) fMcEvt->GetPhotElfromShower() /
+      (fOuterPixelsLightCollection + innersize / size * (1. - fOuterPixelsLightCollection));
 
     fHistADC2PhotEl->Fill(TMath::Log10(corrected_photel/size));
Index: trunk/MagicSoft/Mars/mfilter/MFDeltaT.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDeltaT.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mfilter/MFDeltaT.cc	(revision 7005)
@@ -110,5 +110,5 @@
 // --------------------------------------------------------------------------
 //
-// Calculate the consition. The consition is true if the time difference
+// Calculate the condition. The condition is true if the time difference
 // between two consecutive events are >0 or <= upper limit.
 //
@@ -158,5 +158,5 @@
     PrintSkipped(fErrors[5], "MTime not initialized");
     *fLog << " " << (int)fErrors[0] << " (";
-    *fLog << Form("5.1f", 100.*fErrors[0]/GetNumExecutions());
+    *fLog << Form("%5.1f", 100.*fErrors[0]/GetNumExecutions());
     *fLog << "%) Evts fullfilled filter condition!" << endl;
     *fLog << endl;
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc	(revision 7005)
@@ -52,4 +52,13 @@
 // The flag kAverageing steers if the event-by-event averages are treated at all.
 //
+// Class Version 5:
+//  + Double_t fLowerFitLimitHiGain;          // Lower limit for the fit range for the hi-gain hist
+//  + Double_t fUpperFitLimitHiGain;          // Upper limit for the fit range for the hi-gain hist
+//  + Double_t fLowerFitLimitLoGain;          // Lower limit for the fit range for the lo-gain hist
+//  + Double_t fUpperFitLimitLoGain;          // Upper limit for the fit range for the lo-gain hist
+//  + Bool_t   fIsHiGainFitRanges;            // Are high-gain fit ranges defined?
+//  + Bool_t   fIsLoGainFitRanges;            // Are low-gain fit ranges defined?
+//
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MHCalibrationCam.h"
@@ -86,11 +95,18 @@
 using namespace std;
 
+const Double_t MHCalibrationCam::fgLowerFitLimitHiGain = 0;
+const Double_t MHCalibrationCam::fgUpperFitLimitHiGain = 0;
+const Double_t MHCalibrationCam::fgLowerFitLimitLoGain = 0;
+const Double_t MHCalibrationCam::fgUpperFitLimitLoGain = 0;
+
 const Int_t   MHCalibrationCam::fgPulserFrequency  = 500;
 const Float_t MHCalibrationCam::fgProbLimit        = 0.0001;
 const Float_t MHCalibrationCam::fgOverflowLimit    = 0.005;
+
 const TString MHCalibrationCam::gsHistName   = "Hist";
 const TString MHCalibrationCam::gsHistTitle  = "";
 const TString MHCalibrationCam::gsHistXTitle = "";
 const TString MHCalibrationCam::gsHistYTitle = "Nr. events";
+
 // --------------------------------------------------------------------------
 //
@@ -116,11 +132,16 @@
 //-  SetSizeCheck   (kTRUE);
 //-  SetInterlaced  (kFALSE);
+//-  SetLowerFitLimitHiGain();
+//-  SetUpperFitLimitHiGain();
+//-  SetLowerFitLimitLoGain();
+//-  SetUpperFitLimitLoGain();
 //
 MHCalibrationCam::MHCalibrationCam(const char *name, const char *title)
-    :  fHistName(gsHistName),fHistTitle(gsHistTitle),
-       fHistXTitle(gsHistXTitle),fHistYTitle(gsHistYTitle), 
-       fColor(MCalibrationCam::kNONE), fIntensBad(NULL),
-       fBadPixels(NULL), fIntensCam(NULL), fCam(NULL), fGeom(NULL), 
-       fRunHeader(NULL)
+    :  fIsHiGainFitRanges(kFALSE), fIsLoGainFitRanges(kFALSE),
+    fHistName(gsHistName),fHistTitle(gsHistTitle),
+    fHistXTitle(gsHistXTitle),fHistYTitle(gsHistYTitle),
+    fColor(MCalibrationCam::kNONE), fIntensBad(NULL),
+    fBadPixels(NULL), fIntensCam(NULL), fCam(NULL), fGeom(NULL),
+    fRunHeader(NULL)
 {
 
@@ -152,4 +173,9 @@
     SetOscillations(kTRUE);
     SetSizeCheck   (kTRUE);
+
+    SetLowerFitLimitHiGain();
+    SetUpperFitLimitHiGain();
+    SetLowerFitLimitLoGain();
+    SetUpperFitLimitLoGain();
 }
 
@@ -1048,5 +1074,6 @@
                                        MBadPixelsPix::UncalibratedType_t osctyp)
 {
-  
+  fIsHiGainFitRanges = TMath::Abs(fUpperFitLimitHiGain - fLowerFitLimitHiGain) > 1E-5;
+
   for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
     {
@@ -1097,5 +1124,6 @@
                                             MBadPixelsPix::UncalibratedType_t osctyp)
 {
-  
+  fIsLoGainFitRanges = TMath::Abs(fUpperFitLimitLoGain - fLowerFitLimitLoGain) > 1E-5;
+
   if (!IsLoGain())
     return;
@@ -1207,13 +1235,20 @@
   // 2) Fit the Hi Gain histograms with a Gaussian
   //
-  if (!hist.FitGaus())
-    //
-    // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
-    //
-    if (!hist.RepeatFit())
-      {
-        hist.BypassFit();
-        bad.SetUncalibrated( fittyp );
-      }
+  if (fIsHiGainFitRanges)
+  {
+      if (!hist.FitGaus("R",fLowerFitLimitHiGain,fUpperFitLimitHiGain))
+          bad.SetUncalibrated( fittyp );
+  }
+  else
+      if (!hist.FitGaus())
+          //
+          // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
+          //
+          if (!hist.RepeatFit())
+          {
+              hist.BypassFit();
+              bad.SetUncalibrated( fittyp );
+          }
+
  
   //
@@ -1291,15 +1326,21 @@
   // 2) Fit the Hi Gain histograms with a Gaussian
   //
-  if (!hist.FitGaus())
-    //
-    // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
-    //
-    if (!hist.RepeatFit())
-      {
-        hist.BypassFit();
-        if (pix.IsHiGainSaturation())
+  if (fIsLoGainFitRanges)
+  {
+      if (!hist.FitGaus("R",fLowerFitLimitLoGain,fUpperFitLimitLoGain))
           bad.SetUncalibrated( fittyp );
-      }
-  
+  }
+  else
+      if (!hist.FitGaus())
+          //
+          // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
+          //
+          if (!hist.RepeatFit())
+          {
+              hist.BypassFit();
+              if (pix.IsHiGainSaturation())
+                  bad.SetUncalibrated( fittyp );
+          }
+
   //
   // 4) Check for oscillations
@@ -1429,4 +1470,23 @@
 }
 
+// -----------------------------------------------------------------------------
+// 
+// Available options
+//  Debug
+//  LoGain
+//  Oscillations
+//  SizeCheck
+//  Averageing
+//  Nbins
+//  First
+//  Last
+//  ProbLimit
+//  OverflowLimit
+//  PulserFrequency
+//  LowerFitLimitHiGain
+//  UpperFitLimitHiGain
+//  LowerFitLimitLoGain
+//  UpperFitLimitLoGain
+//
 Int_t MHCalibrationCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
@@ -1493,4 +1553,29 @@
       rc = kTRUE;
     }
+
+  if (IsEnvDefined(env, prefix, "LowerFitLimitHiGain", print))
+    {
+      SetLowerFitLimitHiGain(GetEnvValue(env, prefix, "LowerFitLimitHiGain", fLowerFitLimitHiGain));
+      rc = kTRUE;
+    }
+
+  if (IsEnvDefined(env, prefix, "UpperFitLimitHiGain", print))
+    {
+      SetUpperFitLimitHiGain(GetEnvValue(env, prefix, "UpperFitLimitHiGain", fUpperFitLimitHiGain));
+      rc = kTRUE;
+    }
+
+  if (IsEnvDefined(env, prefix, "LowerFitLimitLoGain", print))
+    {
+      SetLowerFitLimitLoGain(GetEnvValue(env, prefix, "LowerFitLimitLoGain", fLowerFitLimitLoGain));
+      rc = kTRUE;
+    }
+
+  if (IsEnvDefined(env, prefix, "UpperFitLimitLoGain", print))
+    {
+      SetUpperFitLimitLoGain(GetEnvValue(env, prefix, "UpperFitLimitLoGain", fUpperFitLimitLoGain));
+      rc = kTRUE;
+    }
+
   
   return rc;
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h	(revision 7004)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h	(revision 7005)
@@ -40,4 +40,8 @@
   
 private:
+  static const Double_t fgLowerFitLimitHiGain; //! The default for fLowerFitLimitHiGain (now at: 0)
+  static const Double_t fgUpperFitLimitHiGain; //! The default for fUpperFitLimitHiGain (now at: 0)
+  static const Double_t fgLowerFitLimitLoGain; //! The default for fLowerFitLimitLoGain (now at: 0)
+  static const Double_t fgUpperFitLimitLoGain; //! The default for fUpperFitLimitLoGain (now at: 0)
 
   static const Int_t   fgPulserFrequency;  //! The default for fPulserFrequency (now set to: 500)
@@ -58,4 +62,12 @@
   Float_t fProbLimit;                     // Limit for acceptance of probability of Gauss-Fit
   Float_t fOverflowLimit;                 // Part of maximum allowed overflow events
+
+  Double_t fLowerFitLimitHiGain;          // Lower limit for the fit range for the hi-gain hist
+  Double_t fUpperFitLimitHiGain;          // Upper limit for the fit range for the hi-gain hist
+  Double_t fLowerFitLimitLoGain;          // Lower limit for the fit range for the lo-gain hist
+  Double_t fUpperFitLimitLoGain;          // Upper limit for the fit range for the lo-gain hist
+
+  Bool_t   fIsHiGainFitRanges;            // Are high-gain fit ranges defined?
+  Bool_t   fIsLoGainFitRanges;            // Are low-gain fit ranges defined?
   
   TString fHistName;                      //! Histogram names
@@ -211,4 +223,9 @@
   void SetHistXTitle( const char *name )  { fHistXTitle = name; }
   void SetHistYTitle( const char *name )  { fHistYTitle = name; }
+
+  void SetLowerFitLimitHiGain( const Double_t d=fgLowerFitLimitHiGain)  {  fLowerFitLimitHiGain = d;  }
+  void SetUpperFitLimitHiGain( const Double_t d=fgUpperFitLimitHiGain)  {  fUpperFitLimitHiGain = d;  }
+  void SetLowerFitLimitLoGain( const Double_t d=fgLowerFitLimitLoGain)  {  fLowerFitLimitLoGain = d;  }
+  void SetUpperFitLimitLoGain( const Double_t d=fgUpperFitLimitLoGain)  {  fUpperFitLimitLoGain = d;  }
    
   void SetNbins                   ( const Int_t  i )       { fNbins   = i; }
@@ -223,5 +240,5 @@
   void SetPulserFrequency      ( const Int_t   i=fgPulserFrequency )   { fPulserFrequency  = i; }
   
-  ClassDef(MHCalibrationCam, 4)	// Base Histogram class for Calibration Camera
+  ClassDef(MHCalibrationCam, 5)	// Base Histogram class for Calibration Camera
 };
 
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 7005)
@@ -292,8 +292,12 @@
 void MAlphaFitter::PaintResult(Float_t x, Float_t y, Float_t size) const
 {
-    TLatex text(x, y, Form("\\sigma_{Li/Ma}=%.1f  \\omega=%.1f\\circ  E=%d  (\\alpha<%.1f\\circ)  (\\chi_{b}^{2}/ndf=%.1f  \\chi_{s}^{2}/ndf=%.1f  c_{0}=%.1f)",
-                           fSignificance, GetGausSigma(),
-                           (int)fEventsExcess, fIntegralMax,
-                           fChiSqBg, fChiSqSignal, fCoefficients[3]));
+    const Double_t w  = GetGausSigma();
+    const Int_t    l  = w<=0 ? 0 : (Int_t)TMath::Ceil(-TMath::Log10(w));
+    const TString fmt = Form("\\sigma_{Li/Ma}=%%.1f  \\omega=%%.%df\\circ  E=%%d  (\\alpha<%%.1f\\circ)  (\\chi_{b}^{2}/ndf=%%.1f  \\chi_{s}^{2}/ndf=%%.1f  c_{0}=%%.1f)",
+                             l<1?1:l);
+
+    TLatex text(x, y, Form(fmt.Data(), fSignificance, w, (int)fEventsExcess,
+                           fIntegralMax, fChiSqBg, fChiSqSignal,
+                           fCoefficients[3]));
 
     text.SetBit(TLatex::kTextNDC);
Index: trunk/MagicSoft/Mars/mjobs/MJCalibTest.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibTest.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibTest.cc	(revision 7005)
@@ -390,7 +390,13 @@
 
   // Check for interleaved events
+  // This will make that for data with version less than 5, where trigger
+  // patterns were not yet correct, all the events in the file will be
+  // processed. For those data there are no interleaved calibration events,
+  // so it makes no sense to run this test on a _D_ file. So we assume it
+  // will be a _C_ file, and accept all events.
   MTriggerPatternDecode decode;
   MFTriggerPattern      fcalib;
   fcalib.DenyCalibration();
+  fcalib.SetDefault(kFALSE);
   MContinue conttp(&fcalib, "ContTrigPattern");
 
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 7005)
@@ -460,4 +460,8 @@
     MTriggerPatternDecode     decode;
 
+    // This will make that for data with version less than 5, where
+    // trigger patterns were not yet correct, all the events in the real
+    // data file will be processed. In any case there are no interleaved
+    // calibration events in such data, so this is fine.
     MFTriggerPattern ftp;
     ftp.SetDefault(kTRUE);
@@ -467,6 +471,8 @@
     //    ftp.DenyPinDiode();
     ftp.SetInverted();
+
+    // This will skip interleaved calibration events and pedestal events (if any)
+    // --> tlist2
     MContinue conttp(&ftp, "ContTrigPattern");
-    // --> tlist2
 
     // Do signal and pedestal calculation
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 7005)
@@ -1799,4 +1799,10 @@
     // Other Tasks
     //
+
+    // Set the default for data version earlier than 5, where no valid
+    // trigger pattern exists. There should not be pin diode or other
+    // types of events inside the calibration files which should be skipped,
+    // anyway. So we set the default such that the MContinue ccalib
+    // will never be executed.
     MTriggerPatternDecode     trgpat;
     MFTriggerPattern          fcalib("CalibFilter");
Index: trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7005)
@@ -77,5 +77,5 @@
 MJCut::MJCut(const char *name, const char *title)
     : fStoreSummary(kFALSE), fStoreResult(kTRUE), fWriteOnly(kFALSE),
-    fIsWobble(kFALSE), fIsMonteCarlo(kFALSE),  fFullDisplay(kFALSE),
+    fIsWobble(kFALSE), fIsMonteCarlo(kFALSE),  fFullDisplay(kTRUE),
     fNameHist("MHThetaSq"), fCalcHadronness(0)
 {
@@ -334,4 +334,5 @@
     write->AddContainer("MHadronness",    "Events", kFALSE);
     write->AddContainer("MEnergyEst",     "Events", kFALSE);
+    write->AddContainer("ThetaSquared",   "Events", kFALSE);
     write->AddContainer("MMcEvt",         "Events", kFALSE);
     write->AddContainer("DataType",       "Events");
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7005)
@@ -940,5 +940,10 @@
     }
 
+    // This will make that for data with version less than 5, where
+    // trigger patterns were not yet correct, all the events in the real
+    // data file will be processed. In any case there are no interleaved
+    // calibration events in such data, so this is fine.
     MFTriggerPattern fcalib("CalibFilter");
+    fcalib.SetDefault(kFALSE);
     fcalib.RequireCalibration();
     fcalib.SetInverted();
Index: trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 7005)
@@ -178,10 +178,4 @@
         return -1;
 
-    TObject *hist = arr.FindObjectInCanvas("Hist", "MHAlpha", "Hist");
-    cout << "HIST: " << hist << endl;
-    if (hist)
-        cout << "TYPE: " << hist->ClassName() << endl;
-    arr.Print();
-
     vstime->Copy(h1);
     size->Copy(h2);
@@ -335,4 +329,24 @@
 Bool_t MJSpectrum::Refill(MParList &plist, TH1D &h2) const
 {
+    // Try to find the class used to determin the signal!
+    TString cls("MHAlpha");
+    if (fDisplay)
+    {
+        TCanvas *c = fDisplay->GetCanvas("Hist");
+        if (c)
+        {
+            TIter Next(c->GetListOfPrimitives());
+            TObject *obj=0;
+            while ((obj=Next()))
+                if (obj->InheritsFrom(MHAlpha::Class()))
+                    break;
+            if (obj)
+                cls = obj->ClassName();
+        }
+    }
+
+    cout << "FOUND: "<< cls << endl;
+
+    // Now fill the histogram
     *fLog << endl;
     fLog->Separator("Refill Excess");
@@ -350,6 +364,6 @@
     taskenv1.SetDefault(fEstimateEnergy ? fEstimateEnergy : &est);
 
-    MFillH fill1("HistEOff [MHAlpha]", "MHillasSrc", "FillHistEOff");
-    MFillH fill2("HistE    [MHAlpha]", "MHillasSrc", "FillHistE");
+    MFillH fill1(Form("HistEOff [%s]", cls.Data()), "", "FillHistEOff");
+    MFillH fill2(Form("HistE    [%s]", cls.Data()), "", "FillHistE");
 
     MFDataMember f0("DataType.fVal", '<', 0.5, "FilterOffData");
Index: trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 7005)
@@ -325,5 +325,4 @@
         write.AddContainer("MMcConfigRunHeader",   "RunHeaders");
         write.AddContainer("MMcCorsikaRunHeader",  "RunHeaders");
-        write.AddCopySource("OriginalMC");
     }
     else
@@ -354,4 +353,10 @@
         writem.AddContainer("MMcTrig",    "Muons");
     }
+
+    if (ismc)
+        if (fMuonAnalysis)
+            writem.AddCopySource("OriginalMC");
+        else
+            write.AddCopySource("OriginalMC");
 
     MTaskList tlist2("Events");
Index: trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.cc	(revision 7005)
@@ -213,9 +213,4 @@
     fMuonCalibPar->SetArcWidth(width);
 
-    // Check if this is a 'Write-Out' candidate
-    if (fMuonCalibPar->GetArcPhi()>160    && fMuonSearchPar->GetRadius()<400 &&
-        fMuonSearchPar->GetDeviation()<50 && fMuonSearchPar->GetRadius()>170)
-        fMuonCalibPar->SetReadyToSave();
-
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 7005)
@@ -220,5 +220,5 @@
   fTrigPattern = (MTriggerPattern*)pList->FindObject("MTriggerPattern");
   if (!fTrigPattern)
-    *fLog << warn << "MTriggerPattern not found... Cannot use interlaced pedestal events." << endl;
+    *fLog << inf << "MTriggerPattern not found... Cannot use interlaced pedestal events." << endl;
 
   return MExtractPedestal::PreProcess(pList);
Index: trunk/MagicSoft/Mars/mreport/MReportStarguider.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportStarguider.cc	(revision 7004)
+++ trunk/MagicSoft/Mars/mreport/MReportStarguider.cc	(revision 7005)
@@ -84,5 +84,5 @@
 {
     Int_t len;
-    Int_t n=sscanf(str.Data(), "%lf %lf %n", &fDevAz, &fDevZd, &len);
+    Int_t n=sscanf(str.Data(), "%lf %lf %n", &fDevZd, &fDevAz, &len);
     if (n!=2)
     {
@@ -105,5 +105,5 @@
     MAstro::String2Angle(str, fNominalAz);   // Nom Az
 
-    if (ver < 999999999)
+    if (ver < 200503220)
     {
         // Until a fix in the software the written position was nonsense
Index: trunk/MagicSoft/Mars/msignal/MC_weights.dat
===================================================================
--- trunk/MagicSoft/Mars/msignal/MC_weights.dat	(revision 7004)
+++ trunk/MagicSoft/Mars/msignal/MC_weights.dat	(revision 7005)
@@ -63,62 +63,62 @@
 # Low Gain Weights: 6 10
 # (Amplitude)  (Time)
-0.0138311 -0.0165919
-0.0117372 -0.0354005
-0.00232654 -0.0581018
--0.00791094 -0.0631271
--0.0131845 -0.0558022
--0.0154786 -0.0480772
--0.0171358 -0.0420274
--0.0199068 -0.0340744
--0.02688 -0.0117278
--0.0404328 0.0754397
--0.0357035 0.342673
-0.00409834 0.849274
-0.248584 1.52181
-0.528673 1.67974
-0.67261 1.47068
-0.735023 1.24965
-0.778865 1.10395
-0.832049 1.02856
-0.907609 1.00924
-1.07304 1.09208
-1.25051 1.14906
-1.37475 1.0253
-1.52056 0.653112
-1.53175 0.163076
-1.49683 -0.15273
-1.47188 -0.344252
-1.45258 -0.50129
-1.42348 -0.670218
-1.3673 -0.87756
-1.19832 -1.20557
-0.99973 -1.53248
-0.808836 -1.68211
-0.533208 -1.45238
-0.446023 -0.900265
-0.459037 -0.529769
-0.470945 -0.368053
-0.465845 -0.313525
-0.446981 -0.311926
-0.415815 -0.342317
-0.348688 -0.425439
-0.271752 -0.495437
-0.211195 -0.503879
-0.131582 -0.413276
-0.109187 -0.245156
-0.114005 -0.139006
-0.117671 -0.0939116
-0.116527 -0.078572
-0.11177 -0.0772896
-0.103901 -0.0840098
-0.0871027 -0.102357
-0.0758618 -0.119019
-0.0611863 -0.118991
-0.0430436 -0.0930814
-0.0390695 -0.0517162
-0.0409257 -0.027711
-0.0420581 -0.0186558
-0.0419035 -0.0164813
-0.0408279 -0.0174564
-0.0389147 -0.0202082
-0.0345678 -0.025232
+0.0446612 -0.385273
+0.038191 -0.00418687
+0.0386966 0.0212324
+0.0402881 0.0744799
+0.0415794 0.229615
+0.0598731 0.44332
+0.0758477 0.661518
+0.101509 1.10641
+0.159323 1.64997
+0.497256 2.83685
+0.245087 3.27499
+0.140546 2.46177
+0.58086 2.2849
+0.632721 2.45587
+0.72819 2.52835
+0.889583 2.48099
+0.980812 2.50031
+1.09885 2.55892
+1.21374 2.78769
+1.61928 3.08069
+1.38544 1.95583
+1.31998 1.1792
+1.50633 0.591226
+1.50916 0.0793899
+1.5008 -0.33188
+1.47339 -0.575386
+1.45362 -0.915309
+1.40214 -1.31593
+1.34175 -1.77904
+1.0661 -2.05471
+1.31087 -1.49798
+1.33793 -1.34758
+1.10172 -1.21719
+1.08133 -1.09356
+1.04007 -0.981455
+0.976745 -1.08299
+0.930979 -1.14774
+0.874203 -1.18348
+0.816708 -1.20126
+0.587354 -1.92869
+0.783078 -1.89621
+0.792771 -1.03439
+0.622278 -0.781807
+0.61184 -0.745831
+0.578792 -0.683741
+0.537336 -0.596328
+0.51443 -0.592858
+0.482294 -0.560586
+0.462351 -0.827587
+0.317989 -1.05649
+0.459672 -0.775035
+0.468287 -0.619961
+0.374182 -0.31635
+0.376946 -0.225242
+0.367075 -0.347444
+0.340737 -0.393231
+0.321054 -0.187384
+0.320654 -0.225558
+0.302148 -0.399499
+0.232954 -0.607578
Index: trunk/MagicSoft/Mars/msignal/MC_weights4.dat
===================================================================
--- trunk/MagicSoft/Mars/msignal/MC_weights4.dat	(revision 7004)
+++ trunk/MagicSoft/Mars/msignal/MC_weights4.dat	(revision 7005)
@@ -43,42 +43,42 @@
 # Low Gain Weights: 4 10
 # (Amplitude)  (Time)
--0.0150435 -0.0456535
--0.0167019 -0.0398625
--0.0194073 -0.032228
--0.0261603 -0.0107884
--0.0393003 0.072764
--0.0383678 0.323756
-0.000454566 0.807731
-0.23557 1.45054
-0.504239 1.60174
-0.641895 1.40233
-0.696427 1.19531
-0.740101 1.0546
-0.791986 0.981974
-0.86479 0.963146
-1.02308 1.04186
-1.19338 1.09617
-1.31232 0.977824
-1.45116 0.622149
-1.4609 0.154384
-1.42695 -0.14665
-1.4151 -0.336941
-1.39615 -0.485034
-1.36751 -0.645756
-1.31284 -0.843784
-1.14997 -1.15775
-0.956626 -1.4693
-0.772909 -1.61173
-0.5089 -1.39031
-0.426731 -0.860608
-0.440367 -0.505876
-0.459554 -0.35905
-0.453541 -0.305066
-0.434575 -0.303057
-0.403893 -0.332238
-0.338482 -0.412519
-0.268138 -0.482693
-0.208943 -0.491638
-0.131208 -0.403936
-0.109532 -0.240282
-0.114424 -0.136913
+0.178287 2.98244
+0.0799794 2.25048
+0.501997 2.04566
+0.559993 2.18952
+0.636334 2.28558
+0.784832 2.29757
+0.894393 2.36602
+1.01571 2.62578
+1.14191 3.14701
+1.70405 4.27635
+1.25503 1.69442
+1.19843 1.00804
+1.36974 0.493838
+1.37759 0.0452029
+1.37174 -0.336051
+1.34423 -0.563321
+1.31669 -0.852661
+1.26602 -1.28826
+1.20062 -1.85625
+0.874127 -2.44773
+1.2433 -1.47361
+1.27171 -1.3052
+1.03025 -1.1211
+1.00417 -0.992811
+0.968251 -0.911359
+0.907626 -1.02038
+0.852293 -1.06813
+0.797164 -1.16276
+0.739386 -1.25445
+0.447754 -2.34757
+0.777349 -1.83155
+0.779564 -1.01577
+0.600426 -0.733238
+0.5863 -0.688006
+0.557156 -0.650488
+0.514926 -0.584649
+0.485323 -0.569089
+0.454047 -0.573249
+0.429026 -0.907077
+0.245526 -1.35434
