Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 7032)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 7033)
@@ -51,4 +51,75 @@
      - integration ranges were shifted by 0.2 FADC slices to the right. 
        Fixed in the new algorithm according to Markus' change.
+
+   * mcalib/MCalibrationChargeCalc.h:
+     - Incremented ClassVersion number by 1
+   
+   * mhcalib/MHCalibrationPulseTimeCam.cc:
+     - removed a commented debug output
+
+   * mjobs/MJCalibration.cc
+     - new undocumented adjust of "Unsuitable"- and "Unreliable"-displays 
+       for new exclusion criteria taken from bcn
+
+   * manalysis/MEventRateCalc.cc:
+     - some fixes. In some cases the event rate wasn't calculated
+       anymore
+
+   * mbadpixels/MBadPixelsCalc.cc:
+     - fixed a bug when checking whether the check should be done
+       or not (>0 was missing)
+
+   * mhist/Makefile:
+     - added MHWeather
+
+   * mhvstime/MHVsTime.[h,cc]:
+     - implemented new function the set minimum
+
+   * mjobs/MJStar.cc:
+     - read weather data (CC tree)
+     - set minimum of rate-display to 0
+     - display weather data for non-MC files
+
+   * mmuon/MHSingleMuon.cc:
+     - slight change to a comment
+
+
+
+ 2005/05/13 Markus Gaug (2005/05/12)
+
+   * msignal/MExtractTimeAndChargeDigitalFilter.cc
+     - set default extraction range in the high gain to 4.
+     - set default weights file to cosmics_weights46.dat
+
+   * mhcalib/MHCalibrationHiLoCam.cc
+     - set Oscillations to kFALSE
+
+   * mhcalib/MHCalibrationChargeCam.cc
+     - set default for fNumHiGainSaturationLimit to 0.15
+
+   * mjobs/MJCalibrateSignal.[h,cc]
+     - put MHCalibrationHiLoCam and MHCalibrationPulseTimeCam directly 
+       into tasklist if needed. Otherwise, it does not read the 
+       resources from the config. file.
+
+
+ 2005/05/11 Markus Gaug (2005/05/11)
+
+   * mjobs/MJPedestal.cc
+     - adjust the fit ranges for the histogramming with moon data slightly.
+
+   * mcalib/MCalibrationChargeCam.cc, mcalib/MCalibrationChargeCalc.cc
+     - make a distinction between newly excluded pixels (by calibration)
+       and previously excluded pixels in the displays and print-functions
+
+   * mcalib/MCalibrationChargeCalc.cc
+     - introduce the check for fluctuating arrival times.
+     - set charge limit to from 2.5 to 4.5
+     - introduce asymmetric exclusion due to "deviating number of phes":
+       Default: -9.0 +4.5
+     - make deviating number of phes unsuitable (see David's findings).
+   
+   * mbadpixels/MBadPixelsPix.h 
+     - add kDeviatingNumPhes to function GetUnsuitableCalLevel()
 
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 7032)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 7033)
@@ -108,4 +108,6 @@
        Default: -9.0 +4.5
      + make deviating number of phes unsuitable (see David's findings).
+
+   - The weather data is now displayed in star
 
 
Index: /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc	(revision 7032)
+++ /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc	(revision 7033)
@@ -172,11 +172,4 @@
     const UInt_t cnt = n1<n2 ? n : n1-n2;
 
-    if (cnt<n/10)
-        return kTRUE;
-
-
-    // Calculate the rate
-    const Double_t rate = (Double_t)cnt/(fTimes[n1%n]-fTimes[n2%n]);
-
     // Store the time difference between two consecutive events
     fTimeDiff->SetVal(exec==0 ? -1 : fTimes[n1%n] - fTimes[(n1+n-1)%n]);
@@ -185,9 +178,9 @@
     // Make sure, that the beginning of data-takeing (open
     // a new file) doesn't effect the rate too much
-    if (exec<fNumFirstEvent+n)
-    {
-        fRate->SetRate(-1, 0);
+    if (cnt<n/10)
         return kTRUE;
-    }
+
+    // Calculate the rate
+    const Double_t rate = (Double_t)cnt/(fTimes[n1%n]-fTimes[n2%n]);
 
     // Store the rate
@@ -195,12 +188,12 @@
     fRate->SetReadyToSave();
 
-    Double_t diff = fTimes[n1%n]- fTimes[n2%n];
-    Double_t time = fTimes[n2%n]+ (cnt-n/10.)/(n-n/10.)*diff/2;
+    // Calculate and store the corresponding time
+    const Double_t diff = fTimes[n1%n] - fTimes[n2%n];
+    const Double_t time = fTimes[n2%n] + (cnt-n/10.)/(n-n/10.)*diff/2;
 
     fTimeRate->SetMean(time, time);
-
-    //if (cnt>1000)
-    //*fLog << all << *fTimeRate << " " << *fTime << " " << diff << " " << cnt << " " << n << " " << (float)(cnt-n/2)/n << endl;
-
+    fTimeRate->SetReadyToSave();
+
+   /*
     // Store the corresponding time
     if (exec==fNumFirstEvent+n)
@@ -208,4 +201,5 @@
     else
         fTimeRate->SetMean(fTimes[n1%n], fTimes[n2%n]);
+        */
 
     return kTRUE;
Index: /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc	(revision 7032)
+++ /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc	(revision 7033)
@@ -208,5 +208,4 @@
 
         //Calculate the corrected means:
-
         if (rms<=0.5*meanrms[aidx] || rms>=1.5*meanrms[aidx])
             continue;
@@ -254,6 +253,6 @@
         const Byte_t  aidx = (*fGeomCam)[i].GetAidx();
 
-        if ((fPedestalLevel<0         || (rms>lolim1[aidx] && rms<=uplim1[aidx])) &&
-            (fPedestalLevelVariance<0 || (rms>lolim2[aidx] && rms<=uplim2[aidx])))
+        if ((fPedestalLevel<=0         || (rms>lolim1[aidx] && rms<=uplim1[aidx])) &&
+            (fPedestalLevelVariance<=0 || (rms>lolim2[aidx] && rms<=uplim2[aidx])))
             continue;
 
@@ -261,5 +260,4 @@
         bads++;
     }
-
 
     // Check if the number of pixels to blind is > 60% of total number of pixels
@@ -280,9 +278,6 @@
 Int_t MBadPixelsCalc::Process()
 {
-    if (fPedestalLevel>0 || fPedestalLevelVariance)
-    {
+    if (fPedestalLevel>0 || fPedestalLevelVariance>0)
         CheckPedestalRms();
-        //fPedPhotCam->ReCalc(*fGeomCam, fBadPixels);
-    }
 
     return kTRUE;
Index: /trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 7032)
+++ /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 7033)
@@ -10,4 +10,5 @@
 #pragma link C++ class MHEvent+;
 #pragma link C++ class MHCamEvent+;
+#pragma link C++ class MHCamEventRot+;
 #pragma link C++ class MHTriggerLvl0+;
 
@@ -19,5 +20,5 @@
 #pragma link C++ class MHCamera+;
 
-#pragma link C++ class MHCamEventRot+;
+#pragma link C++ class MHWeather+;
 
 #endif
Index: /trunk/MagicSoft/Mars/mhist/MHWeather.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHWeather.cc	(revision 7033)
+++ /trunk/MagicSoft/Mars/mhist/MHWeather.cc	(revision 7033)
@@ -0,0 +1,277 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 05/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHWeather
+//
+// Display weather data and the corresponding event rate
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHWeather.h"
+
+#include <TPad.h>
+#include <TCanvas.h>
+#include <TGaxis.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MTime.h"
+#include "MReportCC.h"
+#include "MEventRate.h"
+
+ClassImp(MHWeather);
+
+using namespace std;
+
+void MHWeather::ResetGraph(TGraph &g) const
+{
+    g.Set(1);
+    g.SetPoint(0, 0, 0); // Dummy Point
+    g.SetEditable();     // Used as flag: First point? yes/no
+}
+
+void MHWeather::InitGraph(TGraph &g) const
+{
+    ResetGraph(g);
+    g.SetMarkerStyle(kFullDotMedium);
+}
+
+void MHWeather::AddPoint(TGraph &g, Double_t x, Double_t y) const
+{
+    if (g.IsEditable())
+    {
+        g.RemovePoint(0);
+        g.SetEditable(kFALSE);
+    }
+
+    g.SetPoint(g.GetN(), x, y);
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms 
+//
+MHWeather::MHWeather(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHWeather";
+    fTitle = title ? title : "Graphs for weather data";
+
+    // Init Graphs
+
+    fHumidity.SetNameTitle("Humidity", "Humidity");
+    fTemperature.SetNameTitle("Temperature", "Temperature");
+    fSolarRadiation.SetNameTitle("SolarRadiation", "Solar Radiation");
+    fWindSpeed.SetNameTitle("WindSpeed", "Wind Speed");
+    fEventRate.SetNameTitle("EventRate", "Event Rate at CC-REPORT time");
+
+    InitGraph(fHumidity);
+    InitGraph(fTemperature);
+    InitGraph(fSolarRadiation);
+    InitGraph(fWindSpeed);
+    InitGraph(fEventRate);
+
+    fHumidity.SetMinimum(0);
+    fHumidity.SetMaximum(100);
+    fTemperature.SetMinimum(-25);
+    fTemperature.SetMaximum(45);
+    fWindSpeed.SetMinimum(0);
+    fSolarRadiation.SetMinimum(0);
+    fEventRate.SetMinimum(0);
+
+    fHumidity.SetMarkerColor(kBlue);
+    fTemperature.SetMarkerColor(kRed);
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning
+//
+Bool_t MHWeather::SetupFill(const MParList *plist)
+{
+    fReport = (MReportCC*)plist->FindObject("MReportCC");
+    if (!fReport)
+    {
+        *fLog << warn << "MReportCC not found... abort." << endl;
+        return kFALSE;
+    }
+    fRate = (MEventRate*)plist->FindObject("MEventRate");
+    if (!fRate)
+    {
+        *fLog << warn << "MEventRate not found... abort." << endl;
+        return kFALSE;
+    }
+
+    // Reset Graphs
+    ResetGraph(fHumidity);
+    ResetGraph(fTemperature);
+    ResetGraph(fSolarRadiation);
+    ResetGraph(fWindSpeed);
+    ResetGraph(fEventRate);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MMuonCalibPar and
+// MMuonSearchPar container.
+//
+Bool_t MHWeather::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MTime *t = dynamic_cast<const MTime*>(par);
+    if (!t)
+    {
+        *fLog << err <<"MHWeather::Fill - ERROR: MTime not given as argument... abort." << endl;
+        return kERROR;
+    }
+
+    const Double_t tm = t->GetAxisTime();
+
+    AddPoint(fTemperature,    tm, fReport->GetTemperature());
+    AddPoint(fHumidity,       tm, fReport->GetHumidity());
+    AddPoint(fSolarRadiation, tm, fReport->GetSolarRadiation());
+    AddPoint(fWindSpeed,      tm, fReport->GetWindSpeed());
+    AddPoint(fEventRate,      tm, fRate->GetRate());
+
+    return kTRUE;
+}
+
+void MHWeather::DrawGraph(TGraph &g, const char *y) const
+{
+    TH1 *h = g.GetHistogram();
+    if (h)
+    {
+        TAxis *axe = h->GetXaxis();
+        axe->SetLabelSize(0.033);
+        axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT");
+        axe->SetTimeDisplay(1);
+        axe->SetTitle("Time");
+        if (y)
+            h->SetYTitle(y);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Update position of an axis on the right side of the histogram
+//
+void MHWeather::UpdateRightAxis(TGraph &g) const
+{
+    TH1 &h = *g.GetHistogram();
+
+    const Double_t max = h.GetMaximum();
+    if (max==0)
+        return;
+
+    TGaxis *axis = (TGaxis*)gPad->FindObject("RightAxis");
+    if (!axis)
+        return;
+
+    axis->SetX1(g.GetXaxis()->GetXmax());
+    axis->SetX2(g.GetXaxis()->GetXmax());
+    axis->SetY1(gPad->GetUymin());
+    axis->SetY2(gPad->GetUymax());
+    axis->SetWmax(max);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw an axis on the right side of the histogram
+//
+void MHWeather::DrawRightAxis(const char *title) const
+{
+    TGaxis *axis = new TGaxis(gPad->GetUxmax(), gPad->GetUymin(),
+                              gPad->GetUxmax(), gPad->GetUymax(),
+                              0, 1, 510, "+L");
+    axis->SetName("RightAxis");
+    axis->SetTitle(title);
+    axis->SetTitleOffset(0.9);
+    axis->SetTextColor(kRed);
+    axis->SetBit(kCanDelete);
+    axis->Draw();
+}
+
+// --------------------------------------------------------------------------
+//
+// This displays the TGraph like you expect it to be (eg. time on the axis)
+// It should also make sure, that the displayed time always is UTC and
+// not local time...
+//
+void MHWeather::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad();
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fHumidity.Draw("AP");
+    fTemperature.Draw("P");
+    DrawRightAxis("T [\\circ C]");
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fSolarRadiation.Draw("AP");
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fEventRate.Draw("AP");
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fWindSpeed.Draw("AP");
+}
+
+void MHWeather::Paint(Option_t *o)
+{
+    DrawGraph(fHumidity,       "H [%]");
+    DrawGraph(fSolarRadiation, "R [W/m^{2}]");
+    DrawGraph(fTemperature,    "T [\\circ C]");
+    DrawGraph(fWindSpeed,      "km/h");
+    DrawGraph(fEventRate,      "f [Hz]");
+
+    gPad->cd(1);
+
+    if (gPad)
+    {
+        fHumidity.GetHistogram()->GetYaxis()->SetTitleColor(kBlue);
+        UpdateRightAxis(fTemperature);
+    }
+}
Index: /trunk/MagicSoft/Mars/mhist/MHWeather.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHWeather.h	(revision 7033)
+++ /trunk/MagicSoft/Mars/mhist/MHWeather.h	(revision 7033)
@@ -0,0 +1,47 @@
+#ifndef MARS_MHWeather
+#define MARS_MHWeather
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TGraph
+#include <TGraph.h>
+#endif
+
+class MReportCC;
+class MEventRate;
+
+class MHWeather : public MH
+{
+private:
+    TGraph fHumidity;        // 
+    TGraph fTemperature;     //
+    TGraph fWindSpeed;       //
+    TGraph fSolarRadiation;  //
+    TGraph fEventRate;       //!
+
+    MReportCC  *fReport;     //!
+    MEventRate *fRate;       //!
+
+    void ResetGraph(TGraph &g) const;
+    void InitGraph(TGraph &g) const;
+    void AddPoint(TGraph &g, Double_t x, Double_t y) const;
+    void DrawGraph(TGraph &g, const char *y=0) const;
+    void UpdateRightAxis(TGraph &g) const;
+    void DrawRightAxis(const char *title) const;
+
+public:
+    MHWeather(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    void Draw(Option_t *opt="");
+    void Paint(Option_t *opt="");
+
+    ClassDef(MHWeather, 1) // Histogram to display weather data
+};
+
+#endif
+
+
Index: /trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mhist/Makefile	(revision 7032)
+++ /trunk/MagicSoft/Mars/mhist/Makefile	(revision 7033)
@@ -21,7 +21,6 @@
 INCLUDES = -I. -I../mbase -I../mhbase -I../mraw -I../manalysis      \
 	   -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage \
-           -I../mmain -I../mmc -I../mreflector -I../mpointing       \
-           -I../mastro -I../mpedestal -I../msignal -I../mbadpixels  \
-	   -I../mcalib
+           -I../mpointing -I../mmc  -I../mastro -I../msignal        \
+           -I../mbadpixels -I../mcalib -I../mreport
 
 SRCFILES = MHEvent.cc \
@@ -34,5 +33,6 @@
            MHHadronness.cc \
 	   MHTriggerLvl0.cc \
-           MHCamera.cc
+           MHCamera.cc \
+           MHWeather.cc
 
 ############################################################
Index: /trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc	(revision 7032)
+++ /trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc	(revision 7033)
@@ -121,4 +121,14 @@
 // --------------------------------------------------------------------------
 //
+// Call SetMinimum of fGraph
+//
+void MHVsTime::SetMinimum(Double_t min)
+{
+    if (fGraph)
+        fGraph->SetMinimum(0);
+}
+
+// --------------------------------------------------------------------------
+//
 // Return the data members used by the data chain to be used in
 // MTask::AddBranchToList
@@ -151,5 +161,4 @@
     fGraph->SetPoint(0, 0, 0); // Dummy point!
     fGraph->SetEditable();     // Used as flag: First point? yes/no
-
 
     TString title(fData ? GetRule() : (TString)"Graph");
Index: /trunk/MagicSoft/Mars/mhvstime/MHVsTime.h
===================================================================
--- /trunk/MagicSoft/Mars/mhvstime/MHVsTime.h	(revision 7032)
+++ /trunk/MagicSoft/Mars/mhvstime/MHVsTime.h	(revision 7033)
@@ -45,4 +45,5 @@
 
     void SetScale(Double_t scale) { fScale = scale; }
+    void SetMinimum(Double_t min=-1111);
 
     Int_t GetNbins() const;
Index: /trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 7032)
+++ /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 7033)
@@ -193,7 +193,7 @@
     readreal.AddTree("Events", "MTime.", kTRUE);
     readreal.AddTree("Drive");
+    readreal.AddTree("CC");
     //read.AddTree("Trigger");
     //read.AddTree("Camera");
-    //read.AddTree("CC");
     //read.AddTree("Currents");
     readreal.AddFiles(iter);
@@ -260,4 +260,5 @@
     hvs.SetTitle("Rate per 500 events;;R [Hz]");
     hvs.SetNumEvents(500);
+    hvs.SetMinimum(0);
 
     //MContinue cont1("MEventRate2.fRate/MEventRate.fRate>1.1");
@@ -423,4 +424,5 @@
     // ------------------------------------------------------------
 
+    MFillH fillw("MHWeather", "MTimeCC", "FillWeather");
     //tlist2.AddToList(&fill6);
     //tlist2.AddToList(&fill7);
@@ -432,4 +434,6 @@
     tlist.AddToList(&pcalc,  ismc ? "Events" : "Drive");
     tlist.AddToList(&tlist2, "Events");
+    if (!ismc)
+        tlist.AddToList(&fillw,  "CC");
     tlist.AddToList(&write);
 
Index: /trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc	(revision 7032)
+++ /trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc	(revision 7033)
@@ -204,6 +204,5 @@
             fHistPhi.Fill(TMath::ATan2(dx, dy)*TMath::RadToDeg(), pix.GetNumPhotons());
 
-        // use only the inner pixles. This is geometry dependent. This has to
-        // be fixed!
+        // use only the inner pixles. FIXME: This is geometry dependent
         if(i>397)
             continue;
