Index: trunk/MagicSoft/Mars/datacenter/macros/plotdb.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/plotdb.C	(revision 8937)
+++ trunk/MagicSoft/Mars/datacenter/macros/plotdb.C	(revision 8938)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.39 2008-06-08 12:55:22 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.40 2008-06-12 13:00:44 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -21,5 +21,5 @@
 !   Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2006
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -547,12 +547,30 @@
     plot.SetDescription("Mean Signal inner Camera;S_{I} [phe]", "SignalI");
     plot.Plot("Calibration.fMeanSignalInner",  0, 7.0, 0.05);
-    plot.SetDescription("Mean PulsePosCheck (falling edge) inner camera;T [sl]", "ChkPos");
+
+    plot.SetDescription("Mean PulsePosCheck (maximum slice) inner camera;T [sl]", "ChkPos");
     plot.Plot("Calibration.fPulsePosCheckMean", 1, 50.0, 0.1);
-    plot.SetDescription("Rms PulsePosCheck (falling edge) inner camera;T [sl]", "ChkRms");
+    plot.SetDescription("Rms PulsePosCheck (maximum slice) inner camera;T [sl]", "ChkRms");
     plot.Plot("Calibration.fPulsePosCheckRms", 0, 12.0, 0.1);
-    plot.SetDescription("Mean calibrated PulsePos;T", "PulPos");
+    plot.SetDescription("Mean calibrated PulsePos (as extracted);T [ns]", "PulPos");
     plot.Plot("Calibration.fPulsePosMean", 1, 40.0, 0.1);
-    plot.SetDescription("Rms calibrated PulsePos;T", "PulRms");
+    plot.SetDescription("Rms calibrated PulsePos (as extracted);T [ns]", "PulRms");
     plot.Plot("Calibration.fPulsePosRms", 0, 3.0, 0.02);
+
+    plot.SetDescription("Average rate of events with lvl1 trigger;R [Hz]", "RateTrig");
+    plot.Plot("Calibration.fRateTrigEvts", 0, 500, 5);
+    plot.SetDescription("Average rate of events with only Sum trigger;R [Hz]", "RateSum");
+    plot.Plot("Calibration.fRateSumEvts", 0, 1500, 5);
+    //plot.SetDescription("Ratio of only Sum to Lvl1 triggers;R [Hz]", "RateRatio");
+    //plot.Plot("100*Calibration.fRateSumEvts/Calibration.fRateTrigEvts", 0, 500, 1);
+    plot.SetDescription("Average rate of events with calibration trigger;R [Hz]", "RateCal");
+    plot.Plot("Calibration.fRateCalEvts", 0, 50, 1);
+    plot.SetDescription("Average rate of events with pedestal trigger;R [Hz]", "RatePed");
+    plot.Plot("Calibration.fRatePedEvts", 0, 50, 1);
+    plot.SetDescription("Average rate of events with ped+cosmics trigger;R [Hz]", "RatePT");
+    plot.Plot("Calibration.fRatePedTrigEvts", 0, 3.5, 0.1);
+    plot.SetDescription("Average rate of events without trigger pattern;R [Hz]", "Rate0");
+    plot.Plot("Calibration.fRateNullEvts", 0, 3.5, 0.1);
+    plot.SetDescription("Average rate of unknown trigger pattern;R [Hz]", "RateUnknown");
+    plot.Plot("Calibration.fRateUnknownEvts", 0, 3.5, 0.1);
 
     plot.SetDescription("Hi-/Lo-Gain offset;", "PulOff");
@@ -586,6 +604,14 @@
     plot.SetDescription("Datarate [Hz]", "Rate");
     plot.Plot("Star.fDataRate",                0, 600, 10);
-    plot.SetDescription("Maximum Humidity [%]", "Hum");
+    plot.SetDescription("Average Cloudiness [%]", "AvgClouds");
+    plot.Plot("Star.fAvgCloudiness",           0, 100, 1);
+    plot.SetDescription("RMS Cloudiness [%]", "RmsClouds");
+    plot.Plot("Star.fRmsCloudiness",           0, 100, 1);
+    plot.SetDescription("Sky Temperature [K]", "SkyTemp");
+    plot.Plot("Star.fAvgTempSky",         200, 300, 1);
+    plot.SetDescription("Maximum Humidity [%]", "MaxHum");
     plot.Plot("Star.fMaxHumidity",             0, 100, 1);
+    plot.SetDescription("Average Humidity [%]", "AvgHum");
+    plot.Plot("Star.fAvgHumidity",             0, 100, 1);
     plot.SetDescription("Average Temperature [\\circ C];T [\\circ C]", "Temp");
     plot.Plot("Star.fAvgTemperature",        -5, 25, 1);
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 8937)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 8938)
@@ -1049,6 +1049,7 @@
 
         // Remove the canvas from the global list to make sure it is
-        // not found by gROOT->FindOBject
-        gROOT->GetListOfCanvases()->Remove(c);
+        // not found by gROOT->FindObject
+        //gROOT->GetListOfCanvases()->Remove(c);
+        //gROOT->GetListOfCleanups()->Add(c);
 
         return *c;
@@ -1081,6 +1082,7 @@
 
     // Remove the canvas from the global list to make sure it is
-    // not found by gROOT->FindOBject
-    gROOT->GetListOfCanvases()->Remove(&c);
+    // not found by gROOT->FindObject
+    //gROOT->GetListOfCanvases()->Remove(&c);
+    //gROOT->GetListOfCleanups()->Add(&c);
 
     TGComboBox *box = (TGComboBox*)fList->FindWidget(kTabs);
@@ -1332,4 +1334,12 @@
     if (!c)
         return;
+
+    // Repair the "Workaround" being in the RecursiveRemove list
+    // but not in a list checked by gROOT->FindObject
+    //gROOT->GetListOfCleanups()->Remove(c);
+    //gROOT->GetListOfCanvases()->Add(c);
+
+    // FIXME: Due to our workaround this is necessary for a successfull deletion
+    //c->cd();
 
     const TString name(c->GetName());
Index: trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc	(revision 8937)
+++ trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc	(revision 8938)
@@ -317,22 +317,25 @@
         {
             pad->GetPad(1)->GetPad(2)->cd(1);
-            if ((hx=(TH1D*)gPad->FindObject("EnergyEst_ez")))
+            if (gPad->FindObject("EnergyEst_ez"))
                 fHEnergy.Project3D("ez");
 
             pad->GetPad(1)->GetPad(2)->cd(2);
-            hx = (TH1D*)fHResolutionEst.ProjectionY("Resolution", -1, -1, "e");
-            TPaveStats *stats = dynamic_cast<TPaveStats*>(hx->FindObject("stats"));
-            if (stats)
+            if (gPad->FindObject("ResEnergyEst_py"))
             {
-                stats->SetBit(BIT(17)); // TStyle.cxx: kTakeStyle=BIT(17)
-                stats->SetX1NDC(0.63);
-                stats->SetY1NDC(0.68);
+                hx = (TH1D*)fHResolutionEst.ProjectionY("_py", -1, -1, "e");
+                TPaveStats *stats = dynamic_cast<TPaveStats*>(hx->FindObject("stats"));
+                if (stats)
+                {
+                    stats->SetBit(BIT(17)); // TStyle.cxx: kTakeStyle=BIT(17)
+                    stats->SetX1NDC(0.63);
+                    stats->SetY1NDC(0.68);
+                }
+
+                hx->Fit("gaus", "Q", "", -1.0, 0.25);
+                hx->GetFunction("gaus")->SetLineColor(kBlue);
+                hx->GetFunction("gaus")->SetLineWidth(2);
+                gPad=NULL;
+                gStyle->SetOptFit(101);
             }
-
-            hx->Fit("gaus", "Q", "", -1.0, 0.25);
-            hx->GetFunction("gaus")->SetLineColor(kBlue);
-            hx->GetFunction("gaus")->SetLineWidth(2);
-            gPad=NULL;
-            gStyle->SetOptFit(101);
         }
     }
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8937)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 8938)
@@ -635,4 +635,6 @@
     MHCamEvent evtR(  4, "HiLoCal",    "Hi-/Lo-Gain ratio;;Ratio");
     MHCamEvent evtO(  7, "HiLoOff",    "Lo-/Hi-Gain Offset;;Offset");
+    MHCamEvent evtC(  4, "CalPos",     "Extracted pulse position of calibration pulses;;T [sl]");
+    //MHCamEvent evt2(0, "Extra'd", "Extracted Calibration Signal;;S [cnts/sl]");
     evt2.SetErrorSpread(kFALSE);
     evt5.SetErrorSpread(kFALSE);
@@ -649,7 +651,9 @@
     // MFillH fill7(&evt7, "MSignalCam",                    "FillTimes");
     MFillH fill8(&evt8, "MCalibConstCam",                "FillConv");
-    MFillH fill9(&evt9, "MSignalCam",                    "FillPulse");
+    MFillH fill9(&evt9, "MSignalCam",                    "FillPulsePos");
     MFillH fillR(&evtR, "MExtractedSignalCam",           "FillHiLoCal");
     MFillH fillO(&evtO, "MArrivalTimeCam",               "FillHiLoOff");
+    MFillH fillC(&evtC, "MArrivalTimeCam",               "FillCalPos");
+    //MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtractedSignal");
 
     MHVsTime histbp("MBadPixelsCam.GetNumUnsuitable");
@@ -804,4 +808,6 @@
             tlist4.AddToList(&recalc); // MCalibrationRelTimeCam
 
+        tlist4.AddToList(&fillC);      // FillCalPos
+
         //tlist3.AddToList(&writecal);   // MWriteRootFile
     }
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 8937)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 8938)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2007
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -263,9 +263,7 @@
 
     if (str.BeginsWith("graph"))
-        if (str.Length()>5)
-            sscanf(&str[5], "%d", &id);
+        sscanf(str.Data()+5, "%d", &id);
     if (str.BeginsWith("hist"))
-        if (str.Length()>4)
-            sscanf(&str[4], "%d", &id);
+        sscanf(str.Data()+4, "%d", &id);
 
     MRawEvtPixelIter pix(this);
@@ -299,5 +297,5 @@
             graphhi->SetPoint(graphhi->GetN(), i+nh, GetSample(logains, i));
 
-        graphhi->SetMaximum(256);
+        graphhi->SetMaximum(GetMax()+0.5);
         graphhi->SetMinimum(0);
 
@@ -307,5 +305,5 @@
         TH1F *histhi = graphhi->GetHistogram();
         histhi->SetMinimum(0);
-        histhi->SetMaximum(255);
+        histhi->SetMaximum(GetMax()+0.5);
  
         histhi->SetXTitle("Time/FADC Slices");
@@ -320,7 +318,7 @@
         *fLog << inf << "Drawing Histogram of Pixel with Idx #" << dec << pix.GetPixelId() << " to " << gPad << endl;
 
-        TH1F *histh = new TH1F(name, "FADC Samples", nh, -0.5, nh-.5);
+        TH1F *histh = new TH1F(name, "FADC Samples", nh+nl, -0.5, nh+nl-.5);
         histh->SetMinimum(0);
-        histh->SetMaximum(255);
+        histh->SetMaximum(GetMax()+0.5);
         histh->SetXTitle("Time [FADC Slices]");
         histh->SetYTitle("Signal [FADC Units]");
@@ -329,5 +327,5 @@
             histh->Fill(i, GetSample(higains, i));
         for (int i=0; i<nl; i++)
-            histh->Fill(i, GetSample(logains, i));
+            histh->Fill(i+nl, GetSample(logains, i));
         histh->SetBit(kCanDelete);
         histh->Draw(same ? "same" : "");
@@ -613,3 +611,5 @@
 
     evt.fConnectedPixels = fConnectedPixels;
-}
+
+    evt.fNumBytesPerSample = fNumBytesPerSample;
+}
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 8937)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 8938)
@@ -47,9 +47,9 @@
     UInt_t GetSample(const void *ptr, Int_t n) // Helper for Draw
     {
-        switch (n)
+        switch (fNumBytesPerSample)
         {
-        case 1: return *(Byte_t*)ptr;
-        case 2: return *(UShort_t*)ptr;
-        case 3: return *(Int_t*)ptr;
+        case 1: return reinterpret_cast<const Byte_t*>(ptr)[n];
+        case 2: return reinterpret_cast<const UShort_t*>(ptr)[n];
+        case 3: return reinterpret_cast<const UInt_t*>(ptr)[n];
         }
         return 0;
@@ -83,4 +83,5 @@
     UShort_t GetNumBytesPerSample() const { return fNumBytesPerSample; }
     UInt_t   GetScale() const { return 1<<((fNumBytesPerSample-1)*8); }
+    UInt_t   GetMax() const   { return (UInt_t)(~1)>>((4-fNumBytesPerSample)*8); }
 
     void ReadPixel(istream &fin, Int_t npix);
