Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2243)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2244)
@@ -1,3 +1,28 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/06/27: Thomas Bretz
+ 
+   * macros/sumevents.C, macros/sumpedestals.C:
+     - some small changes
+     
+   * manalysis/MPedestalCam.cc:
+     - return pixel as used if the value is valid (>=0)
+     
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - MHPixVsTime added (Name is preliminary)
+
+   * mhist/MHCamEvent.cc:
+     - removed including MGeomPix
+     
+   * mhist/MHCamera.h:
+     - in SetCamContent copy also number of entries
+     
+   * mraw/MRawEvtData.cc:
+     - fixed to support correct pixel numbering
+     
+   * mhist/MHPixVsTime.[h,cc]:
+     - added
+
+
 
  2003/06/27: Abelardo Moralejo
@@ -10,4 +35,6 @@
   * macros/CT1collectionArea.C, CT1EgyEst.C
     - Changed theta binnings to adapt them to the new standard.
+
+
 
  2003/06/26: Abelardo Moralejo
@@ -20,6 +47,4 @@
       them to run on files with hadronness info.
 
- 2003/06/26: Abelardo Moralejo
-
   * mhistmc/MHMcEnergyMigration.cc
     - exchanged axes of E_est and E_MC in the 3-d histograms.
@@ -31,4 +56,6 @@
      - adapted to new function names in MPedestalPix (please Thomas
        check these, I had to do it to make Mars compile)
+
+
 
  2003/06/26: Thomas Bretz
@@ -109,7 +136,15 @@
    * mmontecarlo/MMcCollectionAreaCalc.cc:
      - minor change
-     
-
-  
+
+   * macros/sumevents.C, macros/sumpedestals.C:
+     - added
+
+   * mhist/MHCamEvent.cc:
+     - do not scale with 100
+
+   * mhist/MHCamera.cc:
+     - fixed displaying number of entries when used 
+       SetCamContent(MHCamera&)
+
 
 
Index: trunk/MagicSoft/Mars/macros/sumevents.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sumevents.C	(revision 2243)
+++ trunk/MagicSoft/Mars/macros/sumevents.C	(revision 2244)
@@ -76,6 +76,6 @@
     MHCamera *disp0 = h.GetHistByName();
     MHCamera *disp1 = new MHCamera(geom, "MCerPhotEvt;avg", "Cerenkov Photons Avarage");
-    MHCamera *disp2 = new MHCamera(geom, "MCerPhotEvt;rms", "Cerenkov Photons RMS");
-    MHCamera *disp3 = new MHCamera(geom, "MCerPhotEvt;rel", "Cerenkov Photons RMS/VAL");
+    MHCamera *disp2 = new MHCamera(geom, "MCerPhotEvt;err", "Cerenkov Photons Error");
+    MHCamera *disp3 = new MHCamera(geom, "MCerPhotEvt;rel", "Cerenkov Photons ERR/VAL");
     disp1->SetBit(kCanDelete);
     disp2->SetBit(kCanDelete);
@@ -88,4 +88,8 @@
     disp2->SetStats(kFALSE);
     disp3->SetStats(kFALSE);
+
+    disp1->SetYTitle("a.u.");
+    disp2->SetYTitle("err");
+    disp3->SetYTitle("rel.err [%]");
 
     c->cd(4);
Index: trunk/MagicSoft/Mars/macros/sumpedestals.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sumpedestals.C	(revision 2243)
+++ trunk/MagicSoft/Mars/macros/sumpedestals.C	(revision 2244)
@@ -76,6 +76,6 @@
     MHCamera *disp0 = h.GetHistByName();
     MHCamera *disp1 = new MHCamera(geom, "MPedestalCam;avg", "Pedestals Avarage");
-    MHCamera *disp2 = new MHCamera(geom, "MPedestalCam;rms", "Pedestals Avarage RMS");
-    MHCamera *disp3 = new MHCamera(geom, "MPedestalCam;rel", "Pedestals Avarage RMS/VAL");
+    MHCamera *disp2 = new MHCamera(geom, "MPedestalCam;rms", "Pedestals Avarage Error");
+    MHCamera *disp3 = new MHCamera(geom, "MPedestalCam;rel", "Pedestals Avarage ERR/VAL");
     disp1->SetBit(kCanDelete);
     disp2->SetBit(kCanDelete);
@@ -88,4 +88,8 @@
     disp2->SetStats(kFALSE);
     disp3->SetStats(kFALSE);
+
+    disp1->SetXTitle("a.u.");
+    disp2->SetXTitle("err");
+    disp3->SetXTitle("rel.err [%]");
 
     c->cd(4);
@@ -114,9 +118,7 @@
 
     c->cd(2);
-    gPad->SetLogy();
     disp2->Draw("hist");
 
     c->cd(3);
-    gPad->SetLogy();
     disp3->Draw("hist");
 
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2243)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2244)
@@ -192,4 +192,4 @@
         break;
     }
-    return kTRUE;
+    return val>=0;
 }
Index: trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 2243)
+++ trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 2244)
@@ -44,6 +44,5 @@
 
 #pragma link C++ class MHCamera+;
-//#pragma link C++ class MHCurrents+;
-//#pragma link C++ class MHOnSubtraction+;
+#pragma link C++ class MHPixVsTime+;
 
 #endif
Index: trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 2243)
+++ trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 2244)
@@ -43,5 +43,4 @@
 
 #include "MGeomCam.h"
-#include "MGeomPix.h"
 
 ClassImp(MHCamEvent);
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2243)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2244)
@@ -93,5 +93,5 @@
     virtual void     SetCamContent(const MCamEvent &evt, Int_t type=0) { Reset(); AddCamContent(evt, type); }
     virtual void     SetCamContent(const TArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); }
-    virtual void     SetCamContent(const MHCamera &d, Int_t type=0) { Reset(), AddCamContent(d, type); }
+    virtual void     SetCamContent(const MHCamera &d, Int_t type=0) { Reset(); fEntries=d.fEntries-1; AddCamContent(d, type); }
     virtual void     CntCamContent(const MCamEvent &evt, Double_t threshold, Int_t type=0);
     virtual void     CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE);
Index: trunk/MagicSoft/Mars/mhist/MHPixVsTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHPixVsTime.cc	(revision 2244)
+++ trunk/MagicSoft/Mars/mhist/MHPixVsTime.cc	(revision 2244)
@@ -0,0 +1,168 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 12/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHPixVsTime
+//
+// A histogram to store the sum of camera events. This can be photons,
+// currents or enything else derived from MPixVsTime
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHPixVsTime.h"
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCamEvent.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MHPixVsTime);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task.
+// Resets the sum histogram
+//
+MHPixVsTime::MHPixVsTime(Int_t idx, const char *name, const char *title)
+    : fIndex(idx), fEvt(NULL), fType(0)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHPixVsTime";
+    fTitle = title ? title : "Average of MPixVsTimes";
+
+    TString t("Pixel Index #");
+    t += idx;
+    t += " vs. time";
+
+    fGraph.SetName("MCamEvent");
+    fGraph.SetTitle(t);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the corresponding camera display if available
+//
+MHPixVsTime::~MHPixVsTime()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the event (MPixVsTime) the histogram might be filled with. If
+// it is not given, it is assumed, that it is filled with the argument
+// of the Fill function.
+// Looks for the camera geometry MGeomCam and resets the sum histogram.
+//
+Bool_t MHPixVsTime::SetupFill(const MParList *plist)
+{
+    fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
+    if (!fEvt)
+    {
+        if (!fNameEvt.IsNull())
+        {
+            *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
+            return kFALSE;
+        }
+        *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
+    }
+
+    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << err << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MPixVsTime-Container.
+//
+Bool_t MHPixVsTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
+    if (!evt)
+    {
+        *fLog << err << dbginf << "No MCamEvent found..." << endl;
+        return kFALSE;
+    }
+
+    Double_t val = 0;
+    evt->GetPixelContent(val, fIndex, *fCam, fType);
+    if (TMath::IsNaN(val))
+        return kCONTINUE;
+
+    fGraph.SetPoint(fGraph.GetN(), fGraph.GetN(), val);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scale the sum container with the number of entries
+//
+Bool_t MHPixVsTime::Finalize()
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return fSum.
+//
+TH1 *MHPixVsTime::GetHistByName(const TString name)
+{
+    return fGraph.GetHistogram();
+}
+
+void MHPixVsTime::Draw(Option_t *)
+{
+    /*
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    gPad->SetBorderMode(0);
+    fSum->Draw();
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fSum->Draw("EPhist");
+    */
+}
Index: trunk/MagicSoft/Mars/mhist/MHPixVsTime.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHPixVsTime.h	(revision 2244)
+++ trunk/MagicSoft/Mars/mhist/MHPixVsTime.h	(revision 2244)
@@ -0,0 +1,49 @@
+#ifndef MARS_MHPixVsTime
+#define MARS_MHPixVsTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TGraph
+#include <TGraph.h>
+#endif
+
+class MHCamera;
+class MCamEvent;
+class MGeomCam;
+
+class MHPixVsTime : public MH
+{
+private:
+    TGraph     fGraph;
+    Int_t      fIndex;
+
+    MCamEvent *fEvt; //! the current event
+    MGeomCam  *fCam; //! the camera geometry
+
+    TString fNameEvt;
+
+    Int_t fType;
+    Int_t fTypeErr;
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+public:
+    MHPixVsTime(Int_t idx=0, const char *name=NULL, const char *title=NULL);
+    ~MHPixVsTime();
+
+    void SetNameEvt(const TString name) { fNameEvt = name; }
+    void SetType(Int_t type, Int_t e=-1) { fType = type; fTypeErr=e; }
+
+    TH1 *GetHistByName(const TString name="");
+    TGraph &GetGraph() { return fGraph; }
+
+    void Draw(Option_t *o="");
+
+    ClassDef(MHPixVsTime, 1) // Histogram to sum camera events
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhist/Makefile	(revision 2243)
+++ trunk/MagicSoft/Mars/mhist/Makefile	(revision 2244)
@@ -37,4 +37,5 @@
            MH3.cc \
            MHCamEvent.cc \
+           MHPixVsTime.cc \
            MHMatrix.cc \
            MHFadcPix.cc \
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 2243)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 2244)
@@ -447,8 +447,8 @@
 
         // -1 converts the hardware pixel Id into the software pixel index
-        const Int_t npix = fRunHeader->GetPixAssignment(ipos);
+        const Int_t npix = (Int_t)fRunHeader->GetPixAssignment(ipos)-1;
 
         // Check whether the pixel is connected or not
-        if (npix==0)
+        if (npix<0)
             continue;
 
