Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 8928)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 8929)
@@ -22,6 +22,56 @@
  2008/06/06 Thomas Bretz
 
+   * datacenter/macros/plotdb.C:
+     - added average temperature and wind speed 
+     - reviewed some ranges
+
+   * mhbase/MH3.cc:
+     - in the 2D case with labels and boxes use blue line color
+
+   * mhflux/MHEffectiveOnTime.[h,cc]:
+     - added a new data member fTotalTime counting the total run-time
+       from the run-headers
+     - added the new data member to the display
+     - increased class version number accordingly
+
+   * mjobs/MJCalibrateSignal.cc:
+     - let sum-trigger events pass to get calibrated
+     - improved DefineLabel table for trigger patterns
+     - added MTriggerPattern to output
+
+   * mjobs/MJStar.cc:
+     - added a new tab "Rate" showing the remaining rates per run and
+       trigger pattern after image cleaning
+     - let only event with Lvl1 trigger pass to effective on-time
+       calculation
+     - changed title in plot of avg dc currents and pedestal rms
+
+   * mtrigger/MFTriggerPattern.[h,cc]:
+     - added a counter counting the trigger decision
+     - print the result in the PostProcess
+
+
+
+ 2008/06/06 Thomas Bretz
+
    * datacenter/macros/fillstar.C:
      - added windspeed and temperature
+
+   * datacenter/macros/fillcalib.C, datacenter/macros/fillsignal.C,
+     datacenter/macros/fillstar.C:
+     - use MSQLMagic instead of MSQLServer
+
+   * datacenter/macros/plotdb.C:
+     - added wind speed and temperature
+
+   * datacenter/macros/plotstat.C:
+     - added a plot showing the observation time per exposure (based on
+       the source key)
+
+   * mbase/MStatusDisplay.cc:
+     - fixed the SaveAs. A wrong version was comitted
+
+   * mextralgo/MExtralgoSpline.h:
+     - added the missing inclusion of TMath (root 5.18)
 
 
@@ -44,5 +94,5 @@
    * mcalib/MCalibrationChargeCam.cc, 
      mcalib/MCalibrationChargePINDiode.cc:
-     - added the missing inclusion of TMath
+     - added the missing inclusion of TMath (root 5.18)
 
    * mgeom/MGeomCam.[h,cc]:
Index: /trunk/MagicSoft/Mars/datacenter/macros/plotdb.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/plotdb.C	(revision 8928)
+++ /trunk/MagicSoft/Mars/datacenter/macros/plotdb.C	(revision 8929)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.38 2007-12-20 11:54:22 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.39 2008-06-08 12:55:22 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -534,5 +534,5 @@
     plot.Plot("Calibration.fArrTimeMeanInner", 0, 40.0, 0.1);
     plot.SetDescription("RMS Arrival Time inner Camera;\\sigma_{T,I} [sl]", "RmsArrTmI");
-    plot.Plot("Calibration.fArrTimeRmsInner",  0, 3.0, 0.01);
+    plot.Plot("Calibration.fArrTimeRmsInner",  0, 4.5, 0.01);
     plot.SetDescription("Number of unsuitable pixels inner Camera;N{I}", "UnsuitI");
     plot.Plot("Calibration.fUnsuitableInner",  0, 75, 1);
@@ -550,5 +550,5 @@
     plot.Plot("Calibration.fPulsePosCheckMean", 1, 50.0, 0.1);
     plot.SetDescription("Rms PulsePosCheck (falling edge) inner camera;T [sl]", "ChkRms");
-    plot.Plot("Calibration.fPulsePosCheckRms", 0, 10.0, 0.1);
+    plot.Plot("Calibration.fPulsePosCheckRms", 0, 12.0, 0.1);
     plot.SetDescription("Mean calibrated PulsePos;T", "PulPos");
     plot.Plot("Calibration.fPulsePosMean", 1, 40.0, 0.1);
@@ -559,5 +559,5 @@
     plot.Plot("Calibration.fPulsePosOffMed", -0.33, 0.5, 0.01);
     plot.SetDescription("Hi-/Lo-Gain ratio;", "HiLoRatio");
-    plot.Plot("Calibration.fHiLoGainRatioMed", 10, 12.5, 0.05);
+    plot.Plot("Calibration.fHiLoGainRatioMed", 10, 15, 0.05);
 
     //plot.SetDescription("Pulse Variance;", "PulVar");
@@ -588,4 +588,8 @@
     plot.SetDescription("Maximum Humidity [%]", "Hum");
     plot.Plot("Star.fMaxHumidity",             0, 100, 1);
+    plot.SetDescription("Average Temperature [\\circ C];T [\\circ C]", "Temp");
+    plot.Plot("Star.fAvgTemperature",        -5, 25, 1);
+    plot.SetDescription("Average Wind Speed [km/h];v [km/h]", "Wind");
+    plot.Plot("Star.fAvgWindSpeed",        0, 50, 1);
 
     //muon
@@ -616,5 +620,5 @@
     plot.Plot("Calibration.fArrTimeMeanOuter", 0, 45, 0.1);
     plot.SetDescription("RMS Arrival Time outer Camera;\\sigma_{T,O} [sl]", "RmsArrTmO");
-    plot.Plot("Calibration.fArrTimeRmsOuter",  0, 3.0, 0.01);
+    plot.Plot("Calibration.fArrTimeRmsOuter",  0, 4.5, 0.01);
     plot.SetDescription("Number of unsuitable pixels outer Camera;N{O}", "UnsuitO");
     plot.Plot("Calibration.fUnsuitableOuter",  0, 25, 1);
Index: /trunk/MagicSoft/Mars/mhbase/MH3.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 8928)
+++ /trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 8929)
@@ -932,6 +932,12 @@
     str.ToLower();
 
-    if (str.IsNull() && GetLabels() && fDimension==2)
-        str = "colz";
+    if (GetLabels())
+    {
+        if (str.IsNull() && fDimension==2)
+            str = "colz";
+
+        if (str.Contains("box", TString::kIgnoreCase) && fDimension==2)
+            fHist->SetLineColor(kBlue);
+    }
 
     const Bool_t only  = str.Contains("only")  && TMath::Abs(fDimension)==2;
Index: /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc	(revision 8928)
+++ /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc	(revision 8929)
@@ -19,5 +19,5 @@
 !   Author(s): Wolfgang Wittek, 1/2002 <mailto:wittek@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -70,4 +70,6 @@
 //  Input Container:
 //    MPointingPos
+//    MRawRunHeader
+//    MTime
 //
 //  Output Container:
@@ -81,4 +83,8 @@
 //   +  UInt_t fNumEvents;
 //   -  Int_t fNumEvents;
+//
+//  Class version 3:
+//  ----------------
+//   +  Double_t fTotalTime;
 //
 //
@@ -276,4 +282,5 @@
 #include "MParameters.h"
 #include "MPointingPos.h"
+#include "MRawRunHeader.h"
 
 #include "MBinning.h"
@@ -293,5 +300,5 @@
 MHEffectiveOnTime::MHEffectiveOnTime(const char *name, const char *title)
     : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE), 
-    fNumEvents(200*60), fFirstBin(3)
+    fNumEvents(200*60), fFirstBin(3), fTotalTime(-1)
     //fNumEvents(2*60), fFirstBin(1)
 {
@@ -469,5 +476,21 @@
        SetBinning(&fH2DeltaT, binsdtime, binstheta);
 
+   fTotalTime = 0;
+
    return kTRUE;
+}
+
+Bool_t MHEffectiveOnTime::ReInit(MParList *pList)
+{
+    MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (header)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fTotalTime += header->GetRunLength();
+
+    return kTRUE;
 }
 
@@ -771,11 +794,11 @@
     text.SetTextSize(0.04);
 
-    text.SetText(0.45, 0.94, Form("T_{eff} = %.1fs \\pm %.1fs", val, error));
-    text.Paint();
-
-    if (range<0)
-        return;
-
-    text.SetText(0.66, 0.94, Form("T_{axe} = %.1fs", range));
+    TString txt = Form("T_{eff} = %.1fs \\pm %.1fs", val, error);
+    if (range>0)
+        txt += Form("     T_{axe} = %.1fs", range);
+    if (fTotalTime>0)
+        txt += Form("     T_{max} = %.1fs", fTotalTime);
+
+    text.SetText(0.35, 0.94, txt);
     text.Paint();
 }
Index: /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.h
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.h	(revision 8928)
+++ /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.h	(revision 8929)
@@ -50,4 +50,7 @@
     UInt_t fFirstBin;    // For bin for fit
 
+    Double_t fTotalTime; //[s] Total time accumulated from run-header
+
+    // MHEffectiveOnTime
     Bool_t FitH(TH1D *h, Double_t *res, Bool_t paint=kFALSE) const;
     void FitThetaBins();
@@ -60,8 +63,11 @@
     void PrintStatistics();
 
+    // MH
     Bool_t SetupFill(const MParList *pList);
+    Bool_t ReInit(MParList *pList);
     Bool_t Fill(const MParContainer *par, const Stat_t w=1);
     Bool_t Finalize();
 
+    // MParContainer
     Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
@@ -69,6 +75,10 @@
     MHEffectiveOnTime(const char *name=NULL, const char *title=NULL);
 
+    // Setter
     void SetNumEvents(Int_t i) { fNumEvents=i; }
     void SetFirstBin(Int_t i)  { fFirstBin=i;  }
+
+    // Getter
+    Double_t GetTotalTime() const { return fTotalTime; }
 
     const TH1D &GetHEffOnTheta() const { return fHThetaEffOn; }
@@ -77,8 +87,9 @@
     const TH2D &GetH2DeltaT() const { return fH2DeltaT; }
 
+    // TObject
     void Draw(Option_t *option="");
     void Paint(Option_t *opt="");
 
-    ClassDef(MHEffectiveOnTime, 2) // Histogram to determin effective On-Time vs Time and Zenith Angle
+    ClassDef(MHEffectiveOnTime, 3) // Histogram to determin effective On-Time vs Time and Zenith Angle
 };
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8928)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8929)
@@ -410,18 +410,24 @@
     //hpat.DefineLabelsY("1=Lvl1;2=Cal;3=Cal;4=Lvl2;5=Cal;7=Cal;8=Ped;9=Ped+Trig;13=Ped+Trig;16=Pin;32=Sum");
     hpat.DefaultLabelY("UNKNOWN");
-    hpat.DefineLabelY( 0, "0");        // 0: No pattern
-    hpat.DefineLabelY( 1, "Trig");     // Lvl1
-    hpat.DefineLabelY( 2, "Cal");      // Cal
-    hpat.DefineLabelY( 3, "Cal");      // Cal+Lvl1
-    hpat.DefineLabelY( 4, "Trig");     // Lvl2
-    hpat.DefineLabelY( 5, "Trig");     // Lvl1+Lvl2
-    hpat.DefineLabelY( 7, "Cal");      // Cal+Lvl1+Lvl2
-    hpat.DefineLabelY( 8, "Ped");      // Ped
-    hpat.DefineLabelY( 9, "Ped+Trig"); // Ped+Lvl1
-    hpat.DefineLabelY(13, "Ped+Trig"); // Ped+Lvl2
-    hpat.DefineLabelY(16, "Pin");
-    hpat.DefineLabelY(32, "Sum");      // Sum
-    hpat.DefineLabelY(33, "Sum");      // Sum+Lvl1
-    hpat.DefineLabelY(37, "Sum");      // Sum+Lvl1+Lvl2
+    hpat.DefineLabelY( 0, "0");        //  0: No pattern
+    hpat.DefineLabelY( 1, "Trig");     //  1: Lvl1
+    hpat.DefineLabelY( 2, "Cal");      //  2: Cal
+    hpat.DefineLabelY( 3, "Cal");      //     Cal+Lvl1
+    hpat.DefineLabelY( 4, "Trig");     //  4: Lvl2
+    hpat.DefineLabelY( 5, "Trig");     //     Lvl2+Lvl1
+    hpat.DefineLabelY( 7, "Cal");      //     Lvl2+Cal+Lvl
+    hpat.DefineLabelY( 8, "Ped");      //  8: Ped
+    hpat.DefineLabelY( 9, "Ped+Trig"); //     Ped+Lvl1
+    hpat.DefineLabelY(10, "Ped+Cal");  //     Ped+Cal
+    hpat.DefineLabelY(12, "Ped+Trig"); //     Ped+Lvl2
+    hpat.DefineLabelY(13, "Ped+Trig"); //     Ped+Lvl2+Lvl1
+    hpat.DefineLabelY(16, "Pin");      // 16: Pin
+    hpat.DefineLabelY(32, "Sum");      // 32: Sum
+    hpat.DefineLabelY(33, "Trig");     //     Sum+Lvl1
+    hpat.DefineLabelY(34, "Cal");      //     Sum+Cal
+    hpat.DefineLabelY(35, "Cal");      //     Sum+Cal+Lvl1
+    hpat.DefineLabelY(36, "Trig");     //     Sum+Lvl2
+    hpat.DefineLabelY(37, "Trig");     //     Sum+Lvl1+Lvl2
+    hpat.DefineLabelY(39, "Cal");      //     Sum+Lvl2+Cal+Lvl1
 
     MFillH fillpat(&hpat, "", "FillPattern");
@@ -439,5 +445,5 @@
     fcalped.AllowTriggerLvl1();
     fcalped.AllowTriggerLvl2();
-    //fcalped.AllowSumTrigger();
+    fcalped.AllowSumTrigger();
 
     // This will skip interleaved events with a cal- or ped-trigger
@@ -699,4 +705,5 @@
     write.AddContainer("MTime",                     "Events",     kFALSE);
     write.AddContainer("MRawEvtHeader",             "Events");
+    write.AddContainer("MTriggerPattern",           "Events");
 
     // Slow-Control: Current-tree
Index: /trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 8928)
+++ /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 8929)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2007
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -35,4 +35,5 @@
 #include <TFile.h>
 
+// Core
 #include "MLog.h"
 #include "MLogManip.h"
@@ -45,4 +46,5 @@
 #include "MStatusDisplay.h"
 
+// Histograms
 #include "MHSectorVsTime.h"
 #include "MHEffectiveOnTime.h"
@@ -50,11 +52,10 @@
 #include "MBinning.h"
 
+///NEEWWWW
+#include "MH3.h"
+
+// Tasks
 #include "MReadReports.h"
 #include "MReadMarsFile.h"
-#include "MFDataPhrase.h"
-#include "MFilterList.h"
-#include "MFDataMember.h"
-#include "MFDeltaT.h"
-#include "MFSoftwareTrigger.h"
 #include "MContinue.h"
 #include "MGeomApply.h"
@@ -69,6 +70,16 @@
 #include "MWriteRootFile.h"
 
+// Filter
+#include "MFDataPhrase.h"
+#include "MFTriggerPattern.h"
+#include "MFilterList.h"
+#include "MFDataMember.h"
+#include "MFDeltaT.h"
+#include "MFSoftwareTrigger.h"
+
+// Parameter container
 #include "MMuonSetup.h"
 #include "MObservatory.h"
+//#include "MTriggerPattern.h"
 #include "MPointingPosCalc.h"
 
@@ -242,4 +253,34 @@
     fill0d.SetNameTab("Sparks");
 
+    // FIXME: This should be replaced by a cut working for all triggers!
+    MTriggerPattern par;   // An empty trigger pattern for older files
+    plist.AddToList(&par); // without MTriggerPattern stored in the file
+
+    // For the effective on-time calculation we don't want SUM-only events
+    MFTriggerPattern fsum;
+    fsum.SetDefault(kTRUE);
+    fsum.DenySumTrigger();
+    fsum.AllowTriggerLvl1();
+    fill9.SetFilter(&fsum);
+
+    // Plot the trigger pattern rates vs. run-number
+    MH3 hrate("MRawRunHeader.fRunNumber", "MTriggerPattern.GetUnprescaled");
+    hrate.SetWeight("1./MRawRunHeader.GetRunLength");
+    hrate.SetName("Rate");
+    hrate.SetTitle("Event rate after cleaning [Hz];Run Number;Trigger Type;");
+    hrate.InitLabels(MH3::kLabelsX);
+    hrate.DefaultLabelY("ERROR");
+    hrate.DefineLabelY( 0, "0");        //  0: No pattern
+    hrate.DefineLabelY( 1, "Trig");     //  1: Lvl1
+    hrate.DefineLabelY( 4, "Trig");     //  4: Lvl2
+    hrate.DefineLabelY( 5, "Trig");     //     Lvl2+Lvl1
+    hrate.DefineLabelY(32, "Sum");      // 32: Sum
+    hrate.DefineLabelY(33, "Trig");     //     Sum+Lvl1
+    hrate.DefineLabelY(36, "Trig");     //     Sum+Lvl2
+    hrate.DefineLabelY(37, "Trig");     //     Sum+Lvl1+Lvl2
+
+    MFillH frate(&hrate, "", "FillRate");
+    frate.SetDrawOption("box");
+
     // ------------------ Setup write task ----------------
 
@@ -260,4 +301,5 @@
     write.AddContainer("MRawEvtHeader",             "Events");
     write.AddContainer("MPointingPos",              "Events");
+    write.AddContainer("MTriggerPattern",           "Events");
 
     // Run Header
@@ -333,4 +375,5 @@
         tlist2.AddToList(&rate);
         tlist2.AddToList(&fillvs);
+        tlist2.AddToList(&fsum);
         tlist2.AddToList(&fill9);
         tlist2.AddToList(&writet);
@@ -358,4 +401,5 @@
     tlist2.AddToList(&fill0d);
     tlist2.AddToList(&fill0b);
+    tlist2.AddToList(&frate);
     tlist2.AddToList(&fill1);
     tlist2.AddToList(&fill2);
@@ -409,9 +453,9 @@
     MHSectorVsTime histdc, histrms;
     histdc.SetNameTime("MTimeCurrents");
-    histdc.SetTitle("Mean of all DC Currents;;<I> [nA]");
+    histdc.SetTitle("Average DC currents of all pixels vs time;;<I> [nA]");
     histdc.SetMinimum(0);
     histdc.SetMaximum(10);
     histrms.SetNameTime("MTimeCurrents");
-    histrms.SetTitle("Mean pedestal rms of all pixels;;<\\sigma_{p}> [phe]");
+    histrms.SetTitle("Average pedestal rms of all pixels vs time;;<\\sigma_{p}> [phe]");
     histrms.SetType(5);
     histrms.SetMinimum(0);
Index: /trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.cc	(revision 8928)
+++ /trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.cc	(revision 8929)
@@ -93,4 +93,6 @@
     }
 
+    memset(fCounter, 0, sizeof(fCounter));
+
     return kTRUE;
 }
@@ -103,5 +105,5 @@
 // If any bit matches the fMasDenied* mask fResult is forced to be false.
 //
-Int_t MFTriggerPattern::Process()
+Int_t MFTriggerPattern::Eval() const
 {
     const Byte_t p = fPattern->GetPrescaled();
@@ -109,18 +111,56 @@
     if (p==0 && u==0)
     {
-        fResult = fDefault;
-        return kTRUE;
+        return fDefault;
     }
 
-    fResult = kFALSE;
+    Bool_t rc = kFALSE;
 
     // Check whether all the bits required are ON
     if ( ((p & fMaskRequiredPrescaled)   == fMaskRequiredPrescaled) &&
          ((u & fMaskRequiredUnprescaled) == fMaskRequiredUnprescaled))
-      fResult = kTRUE;
+      rc = kTRUE;
 
     // Now overwrite the result if one of the bits is denied
     if ( (p & fMaskDeniedPrescaled) || (u & fMaskDeniedUnprescaled) )
-      fResult = kFALSE;
+        return kFALSE;
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// If Prescaled and Unprescaled pattern is 0 return default.
+// If all bits of the fMaskRequired* mask are found in the pattern set
+// fResult to true.
+// If any bit matches the fMasDenied* mask fResult is forced to be false.
+//
+Int_t MFTriggerPattern::Process()
+{
+    fResult = Eval();
+    fCounter[fResult ? 0 : 1]++;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFTriggerPattern::PostProcess()
+{
+    const UInt_t n = GetNumExecutions();
+    if (n==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    *fLog << " " << setw(7) << fCounter[0] << " (" << setw(3) ;
+    *fLog << (int)(fCounter[0]*100/n);
+    *fLog << "%) Accepted trigger pattern." << endl;
+
+    *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3) ;
+    *fLog << (int)(fCounter[1]*100/n);
+    *fLog << "%) Rejected trigger pattern!" << endl;
+    *fLog << endl;
 
     return kTRUE;
Index: /trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.h
===================================================================
--- /trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.h	(revision 8928)
+++ /trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.h	(revision 8929)
@@ -29,5 +29,7 @@
 
   Bool_t fDefault;                  // Default which is used if trigger pattern has default value (p==0&&u==0)
+
   Bool_t fResult;                   //! Calculated result to be returned by IsExpressionTrue
+  Int_t  fCounter[2];               //! Counter for results
 
   // MFTriggerPattern
@@ -36,7 +38,10 @@
   void Allow(const Byte_t mask, Prescale_t prescaled=kUnPrescaled);
 
+  Int_t Eval() const;
+
   // MTask
   Int_t PreProcess(MParList *pList);
   Int_t Process();
+  Int_t PostProcess();
 
   // MFilter
