Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7121)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7122)
@@ -33,4 +33,45 @@
      - added MJOptimizeCuts
      - added MJOptimizeEnergy
+
+   * showplot.cc:
+     - set window name to input file name
+
+   * mcalib/MCalibColorSet.cc:
+     - changed order of checks so that an explicit color is 
+       prior to any automatic detection.
+
+   * mcalib/MCalibrateData.[h,cc]:
+     - implemented setting a possible additional scale factor
+       (for MC it is always reset to 1)
+
+   * mfilter/MFCosmics.cc:
+     - don't count saturated hi-gain pixels at all. It should
+       not be necessary, because such pixels should have a value
+       high enough in the high-gains but it seems sometimes they don't
+
+   * mhflux/MHAlpha.[h,cc]:
+     - changed some orders in header
+     - made some private data members protected
+     - Call GetVal() if fMap[0]<0. This is necessary if the fill
+       value is calculated on-the-fly (like ThetaSq)
+     - made InitMapping virtual
+
+   * mhflux/MHDisp.cc:
+     - removed 'Get-Entries' workarund
+     - changed the function integartion for the significance
+
+   * mhflux/MHThetaSq.[h,cc]:
+     - overwrite InitMapping because ThetaSq should be read from
+       the parlist always
+
+   * mimage/MHHillas.cc:
+     - set histogram minimum of Delta to 0
+
+   * mpedestal/MPedPhotCam.cc:
+     - check for unsuitable pixels when calculating the means not
+       only for the UnsuitableRun ones
+
+   * msignal/MExtractor.cc:
+     - replaced wrong %2d by %2f
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 7121)
+++ trunk/MagicSoft/Mars/NEWS	(revision 7122)
@@ -15,4 +15,6 @@
      correctly.
 
+   - shoplot now displays the filename in the title bar of the window
+
    - merpp: new options: --auto-time-start --auto-time-stop which
      allow to cut updating with slow-control at the start- or 
@@ -32,4 +34,20 @@
      Wrongly the calibration_UV weights were used instead
      of the cosmics weights set in callisto.rc.
+
+   - callisto: should allow ct1 pulser data when the color is
+     explicitly set also for pretty new runs
+
+   - callisto: a new option (MCalibrateData.ScaleFactor) allows
+     to introduce an additional scale factor (should be around 1)
+     to adapt for slight deviations in different extractors from
+     the MC calibration. For MC calibrations the scale factor
+     is fixed to 1
+
+   - callisto: MFCosmics should handle very high signals a bit
+     more accurate now
+
+   - callisto: when calculating the mean pedestal rms for different
+     pixel sizes or sectors also kUnsuitableEvt is now taken into
+     account - not only kUnsuitableRun
 
    - star: fixed a bug which caused the first bin of the histograms
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc	(revision 7122)
@@ -157,10 +157,4 @@
     }
   
-  if (header->IsMonteCarloRun())
-    return kTRUE;
-
-  if (header->GetRunNumber() > gkFirstRunWithFinalBits)
-    return kTRUE;
-
   //
   // Consider the case that a pedestal run is interleaved in the calibration run sequence ... prepare
@@ -176,4 +170,7 @@
     }
  
+  //
+  // Check if the color was set explicitly from outside
+  //
   if (fIsExplicitColor)
     {
@@ -182,4 +179,11 @@
       return kTRUE;
     }
+
+  //
+  // 1) Do nothing if this is a MC run. Correct settings of all flags is assumed
+  // 2) Skip the rest if the run already contains the correct color information
+  //
+  if (header->IsMonteCarloRun() || header->GetRunNumber()>gkFirstRunWithFinalBits)
+      return kTRUE;
 
   const Int_t num = header->GetRunNumber();
Index: trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 7122)
@@ -107,4 +107,5 @@
 
 #include "MGeomCam.h"
+#include "MRawRunHeader.h"
 
 #include "MPedestalCam.h"
@@ -153,5 +154,5 @@
     : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL), 
       fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
-      fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.)
+      fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1.)
 {
 
@@ -318,4 +319,11 @@
 Bool_t MCalibrateData::ReInit(MParList *pList)
 {
+    MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!header)
+    {
+        *fLog << err << "MRawRunHeader not found... abort." << endl;
+        return kFALSE;
+    }
+
     fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     if (!fGeomCam)
@@ -399,5 +407,13 @@
       break;
     }
-    
+
+    if (header->IsMonteCarloRun())
+    {
+        *fLog << "Additional scale factor: 1 (MonteCarloRun)" << endl;
+        fScaleFactor = 1;
+    }
+    else
+        *fLog << "Additional scale factor: " << fScaleFactor << endl;
+
     const Int_t npixels = fGeomCam->GetNumPixels();
 
@@ -603,6 +619,6 @@
           }
 
-	calibConv    *= fRenormFactor * calibUpdate;
-	calibFFactor *= TMath::Sqrt(fRenormFactor);
+	calibConv    *= fRenormFactor*fScaleFactor * calibUpdate;
+	calibFFactor *= TMath::Sqrt(fRenormFactor*fScaleFactor);
 
         fHiLoConv     [pixidx] = hiloconv;
@@ -861,4 +877,10 @@
     }
 
+    if (IsEnvDefined(env, prefix, "ScaleFactor", print))
+    {
+        fScaleFactor = GetEnvValue(env, prefix, "ScaleFactor", fScaleFactor);
+        rc = kTRUE;
+    }
+
     return rc;
 }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrateData.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrateData.h	(revision 7121)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrateData.h	(revision 7122)
@@ -71,4 +71,5 @@
   
   Float_t  fRenormFactor;                // Possible renormalization factor for signals (-> phes)
+  Float_t  fScaleFactor;                 // Possible scale factor for signals
   
   TList   fNamesPedestal;                // Names of input and output pedestal conatainer
@@ -110,5 +111,7 @@
   void   SetCalibConvMinLimit( const Float_t f=gkCalibConvMinLimit ) { fCalibConvMinLimit = f; }
   void   SetCalibConvMaxLimit( const Float_t f=gkCalibConvMaxLimit ) { fCalibConvMaxLimit = f; }
-    
+
+  void   SetScaleFactor(const Float_t f=1) { fScaleFactor=1; }
+
   Bool_t UpdateConversionFactors( const MCalibrationChargeCam *updatecam=NULL);
 
Index: trunk/MagicSoft/Mars/mfilter/MFCosmics.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFCosmics.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/mfilter/MFCosmics.cc	(revision 7122)
@@ -185,6 +185,14 @@
             continue;
 
-        const MExtractedSignalPix &sig =  (*fSignals)[idx];
-        const MPedestalPix        &ped =  (*fPedestals)[idx];
+        const MExtractedSignalPix &sig = (*fSignals)[idx];
+
+        //
+        // Check whether the pixel has a saturating hi-gain. In
+        // this case the extracted hi-gain might be empty.
+        //
+        if (sig.GetNumHiGainSaturated()>0)
+            continue;
+
+        const MPedestalPix  &ped = (*fPedestals)[idx];
 
         const Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples;
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 7122)
@@ -83,8 +83,7 @@
     : fNameParameter("MHillasSrc"), fParameter(0),
     fOffData(0), fResult(0), /*fExcess(0),*/ fEnergy(0), fHillas(0),
-    fPointPos(0), fTimeEffOn(0), fTime(0),
-    fSkipHistTime(kFALSE), fSkipHistTheta(kFALSE), fSkipHistEnergy(kFALSE),
-    fForceUsingSize(kFALSE), fNumTimeBins(10), fMatrix(0)
-
+    fPointPos(0), fTimeEffOn(0), fTime(0), fNumTimeBins(10),
+    fMatrix(0), fSkipHistTime(kFALSE), fSkipHistTheta(kFALSE),
+    fSkipHistEnergy(kFALSE), fForceUsingSize(kFALSE)
 {
     //
@@ -449,5 +448,5 @@
     if (fMatrix)
     {
-        alpha  = (*fMatrix)[fMap[0]];
+        alpha  = fMap[0]<0 ? GetVal() : (*fMatrix)[fMap[0]];
         energy = fMap[1]<0 ? -1 : (*fMatrix)[fMap[1]];
         size   = fMap[2]<0 ? -1 : (*fMatrix)[fMap[2]];
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 7121)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 7122)
@@ -52,4 +52,12 @@
     MTime    fLastTime;         //! Last fTimeEffOn
 
+    UShort_t fNumTimeBins;      // Number of time bins to fill together
+    UShort_t fNumRebin;         //!
+
+    //const TString fNameProjAlpha;  //! This should make sure, that gROOT doen't confuse the projection with something else
+protected:
+    MHMatrix *fMatrix;          //!
+    Int_t fMap[5];              //!
+
     Bool_t fSkipHistTime;
     Bool_t fSkipHistTheta;
@@ -57,13 +65,6 @@
     Bool_t fForceUsingSize;
 
-    UShort_t fNumTimeBins;      // Number of time bins to fill together
-    UShort_t fNumRebin;         //!
-
-    //const TString fNameProjAlpha;  //! This should make sure, that gROOT doen't confuse the projection with something else
-
-    MHMatrix *fMatrix;          //!
-    Int_t fMap[5];              //!
-
-    Float_t FitEnergyBins(Bool_t paint=kFALSE);
+private:
+     Float_t FitEnergyBins(Bool_t paint=kFALSE);
     void FitThetaBins(Bool_t paint=kFALSE);
 
@@ -127,5 +128,5 @@
     void DrawAll(); //*MENU*
 
-    void InitMapping(MHMatrix *mat, Int_t type=0);
+    virtual void InitMapping(MHMatrix *mat, Int_t type=0);
     void StopMapping();
 
Index: trunk/MagicSoft/Mars/mhflux/MHDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHDisp.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/mhflux/MHDisp.cc	(revision 7122)
@@ -197,5 +197,5 @@
             return kFALSE;
         }
-        const Double_t m3l = fHilExt->GetM3Long()*TMath::Sign(1.0f, hsrc.GetCosDeltaAlpha())*fMm2Deg;
+        const Double_t m3l = fHilExt->GetM3Long()*TMath::Sign(fMm2Deg, hsrc.GetCosDeltaAlpha());
 
         gweight = m3l>fM3lCut ? 1 : 0;
@@ -217,9 +217,6 @@
     }
 
-    // Workaround: Number-of-entries
-    if (gweight>0.25)
-        fHist.Fill(pos1.X(), pos1.Y(), 0.0, w*gweight);
-    if (gweight<0.75)
-        fHist.Fill(pos2.X(), pos2.Y(), 0.0, w*(1-gweight));
+    fHist.Fill(pos1.X(), pos1.Y(), 0.0, w*gweight);
+    fHist.Fill(pos2.X(), pos2.Y(), 0.0, w*(1-gweight));
 
     return kTRUE;
@@ -273,4 +270,5 @@
         const Double_t x0 = h1->GetXaxis()->GetBinCenter(ix);
         const Double_t y0 = h1->GetYaxis()->GetBinCenter(iy);
+        const Double_t w0 = h1->GetXaxis()->GetBinWidth(1);
 
         for (int x=0; x<h1->GetNbinsX(); x++)
@@ -294,8 +292,14 @@
         h2->Fit(&func, "IMQ", "", 0, 1.0);
 
-        const Double_t r0 = 2*func.GetParameter(2);
-        const Double_t e  = func.Integral(0, r0)/h1->GetBinWidth(1);
-        func.SetParameter(0, 0);
-        const Double_t b  = func.Integral(0, r0)/h1->GetBinWidth(1);
+        // No wintegrate the function f(x) per Delta Area
+        // which is f(x)/(pi*delta r*(2*r+delta r))
+        TF1 func2("fcn2", Form("(gaus + [3]*x*x + [4])/(2*x+%.5f)", w0));
+        for (int i=0; i<5; i++)
+            func2.SetParameter(i, func.GetParameter(i));
+
+        const Double_t r0 = 2*func2.GetParameter(2);
+        const Double_t e  = func2.Integral(0, r0)/(w0*TMath::Pi());
+        func2.SetParameter(0, 0);
+        const Double_t b  = func2.Integral(0, r0)/(w0*TMath::Pi());
         const Double_t s  = MMath::SignificanceLiMa(e, b);
 
Index: trunk/MagicSoft/Mars/mimage/MHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHHillas.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/mimage/MHHillas.cc	(revision 7122)
@@ -90,4 +90,6 @@
     fDistC->SetYTitle("Counts");
     fDelta->SetYTitle("Counts");
+
+    fDistC->SetMinimum(0);
 
     MBinning bins;
Index: trunk/MagicSoft/Mars/mjobs/MJOptimizeCuts.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJOptimizeCuts.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/mjobs/MJOptimizeCuts.cc	(revision 7122)
@@ -315,6 +315,6 @@
 Bool_t MJOptimizeCuts::RunOnOff(const char *fname, MFilter *filter, MAlphaFitter *fit, const char *tree)
 {
-    MHAlpha *histon = CreateNewHist();
-    MHAlpha *histof = CreateNewHist("MHAlphaOff");
+    MHAlpha *histon = CreateNewHist("Hist");
+    MHAlpha *histof = CreateNewHist("HistOff");
 
     const Bool_t rc = RunOnOffCore(*histon, *histof, fname, filter, fit, tree);
Index: trunk/MagicSoft/Mars/mpedestal/MPedPhotCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedPhotCam.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/mpedestal/MPedPhotCam.cc	(revision 7122)
@@ -273,6 +273,6 @@
     for (int i=0; i<np; i++)
     {
-        if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
-            continue; //was: .IsBad()
+        if (bad && (*bad)[i].IsUnsuitable())
+            continue;
 
         // Create sums for areas and sectors
Index: trunk/MagicSoft/Mars/msignal/MExtractor.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 7122)
@@ -433,5 +433,5 @@
     *fLog << " Gain Overlap to Lo: " << Form("%2d", fHiLoLast)        << endl;
     *fLog << " Saturation Lim:     " << Form("%3d", fSaturationLimit) << endl;
-    *fLog << " Num Samples Hi/Lo:  " << Form("%2d %2d", fNumHiGainSamples, fNumLoGainSamples) << endl;
+    *fLog << " Num Samples Hi/Lo:  " << Form("%2.1f %2.1f", fNumHiGainSamples, fNumLoGainSamples) << endl;
     if (fPedestals)
         *fLog << " Pedestals:          " << fPedestals->GetName() << ", " << fPedestals << endl;
Index: trunk/MagicSoft/Mars/showplot.cc
===================================================================
--- trunk/MagicSoft/Mars/showplot.cc	(revision 7121)
+++ trunk/MagicSoft/Mars/showplot.cc	(revision 7122)
@@ -177,4 +177,6 @@
     // From now on each 'Exit' means: Terminate the application
     d->SetTitle(kInput);
+    d->SetWindowName(kInput);
+
     d->Open(kInput);
 
