Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3399)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3400)
@@ -45,4 +45,21 @@
      - changes such, that it doesn't crash if signal has no lo-gain
        (This might still give wrong results!)
+
+   * macros/dohtml.C:
+     - added pixvstime.C
+     - added sectorvstime.C
+
+   * manalysis/MMcCalibrationUpdate.cc:
+     - some changes on file consistency check done by Abelardo,
+       he may comment on it
+
+   * mhist/MHCamera.[h,cc]:
+     - changed to support also dividing the camera in pixels area indices
+
+   * mhist/MHEvent.cc:
+     - minor change
+
+   * mjobs/MJPedestal.cc:
+     - adapted to changes in MHCamera
 
 
Index: /trunk/MagicSoft/Mars/macros/dohtml.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/dohtml.C	(revision 3399)
+++ /trunk/MagicSoft/Mars/macros/dohtml.C	(revision 3400)
@@ -102,3 +102,5 @@
     html.Convert("pedvsevent.C",    "MARS - Example to use MPedCalcPedRun");
     html.Convert("pedphotcalc.C",   "MARS - Example to use MPedPhotCalc");
+    html.Convert("pixvstime.C",     "MARS - Example how to plot a pixel value versus time");
+    html.Convert("sectorvstime.C",  "MARS - Example how to plot mean value of a camera sector versus time");
 }
Index: /trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 3399)
+++ /trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 3400)
@@ -62,4 +62,5 @@
 
 #include "MRawRunHeader.h"
+#include "MMcRunHeader.hxx"
 #include "MMcFadcHeader.hxx"
 
@@ -169,4 +170,6 @@
     }
 
+    MMcRunHeader* mcrunh = (MMcRunHeader*) pList->FindObject("MMcRunHeader");
+
     //
     // Initialize Fadc simulation parameters:
@@ -175,17 +178,36 @@
     {
 	fAmplitude = fHeaderFadc->GetAmplitud();
-	fAmplitudeOuter = fHeaderFadc->GetAmplitudOuter();
-	fConversionHiLo = fHeaderFadc->GetLow2HighGain();
+	if (mcrunh->GetCamVersion() > 60)
+	  {
+	    fAmplitudeOuter = fHeaderFadc->GetAmplitudOuter();
+	    fConversionHiLo = fHeaderFadc->GetLow2HighGain();
+	  }
+	else // old MC files, camera  < v0.7
+	  {
+	    fAmplitudeOuter = fAmplitude;
+	    fConversionHiLo = 1;  // dummy value
+	  }
+
     }
     else   // Check that following files have all the same FADC parameters
     {
-	if ( fabs(fHeaderFadc->GetAmplitud()-fAmplitude)           > 1.e-6  ||
-	     fabs(fHeaderFadc->GetAmplitudOuter()-fAmplitudeOuter) > 1.e-6  ||
-	     fabs(fConversionHiLo-fHeaderFadc->GetLow2HighGain())  > 1.e-6 )
-	  {
-              *fLog << err << "Parameters of MMcFadcHeader are not the same for all files... aborting." << endl;
-            return kFALSE;
-          }
-    }
+      if ( fabs(fHeaderFadc->GetAmplitud()-fAmplitude) > 1.e-6 )
+	{
+	  *fLog << err << "Parameters of MMcFadcHeader are not the same for all files... aborting." << endl;
+	  return kFALSE;
+	}
+
+      if (mcrunh->GetCamVersion() > 60) // old MC files, camera < v0.7
+	{
+	  if( fabs(fHeaderFadc->GetAmplitudOuter()-fAmplitudeOuter) > 1.e-6  ||
+	      fabs(fConversionHiLo-fHeaderFadc->GetLow2HighGain())  > 1.e-6 )
+	    {
+	      *fLog << err << "Parameters of MMcFadcHeader are not the same for all files... aborting." << endl;
+	      return kFALSE;
+	    }
+	}
+    }
+
+
 
     //
Index: /trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3399)
+++ /trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3400)
@@ -164,7 +164,8 @@
 // sector idx matches the sector of the pixel with index idx.
 //
-Bool_t MHCamera::MatchSector(Int_t idx, Int_t sector) const
-{
-    return sector<0 ? kTRUE : (*fGeomCam)[idx].GetSector()==(UInt_t)sector;
+Bool_t MHCamera::MatchSector(Int_t idx, const TArrayI &sector, const TArrayI &aidx) const
+{
+    const MGeomPix &pix = (*fGeomCam)[idx];
+    return FindVal(sector, pix.GetSector()) && FindVal(aidx, pix.GetAidx());
 }
 
@@ -270,5 +271,5 @@
 // entries with match the given sector are taken into account.
 //
-Stat_t MHCamera::GetMeanSector(Int_t sector, Bool_t all) const
+Stat_t MHCamera::GetMeanSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all) const
 {
     if (fNcells<=1)
@@ -280,5 +281,5 @@
     for (int i=0; i<fNcells-2; i++)
     {
-        if ((all || IsUsed(i)) && MatchSector(i, sector))
+        if ((all || IsUsed(i)) && MatchSector(i, sector, aidx))
         {
             mean += fArray[i+1];
@@ -296,5 +297,5 @@
 // entries with match the given sector are taken into account.
 //
-Stat_t MHCamera::GetRmsSector(Int_t sector, Bool_t all) const
+Stat_t MHCamera::GetRmsSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all) const
 {
     if (fNcells<=1)
@@ -307,5 +308,5 @@
     for (int i=0; i<fNcells-2; i++)
     {
-        if ((all || IsUsed(i)) && MatchSector(i, sector))
+        if ((all || IsUsed(i)) && MatchSector(i, sector, aidx))
         {
             sum += fArray[i+1];
@@ -327,5 +328,5 @@
 // only pixels with matching sector number are taken into account.
 //
-Double_t MHCamera::GetMinimumSector(Int_t sector, Bool_t all) const
+Double_t MHCamera::GetMinimumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all) const
 {
     if (fMinimum != -1111)
@@ -338,5 +339,5 @@
 
     for (Int_t idx=0; idx<fNcells-2; idx++)
-        if (MatchSector(idx, sector) && (all || IsUsed(idx)) && fArray[idx+1]<minimum)
+        if (MatchSector(idx, sector, aidx) && (all || IsUsed(idx)) && fArray[idx+1]<minimum)
             minimum = fArray[idx+1];
 
@@ -350,5 +351,5 @@
 // only pixels with matching sector number are taken into account.
 //
-Double_t MHCamera::GetMaximumSector(Int_t sector, Bool_t all) const
+Double_t MHCamera::GetMaximumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all) const
 {
     if (fMaximum!=-1111)
@@ -360,5 +361,5 @@
     Double_t maximum=-FLT_MAX;
     for (Int_t idx=0; idx<fNcells-2; idx++)
-        if (MatchSector(idx, sector) && (all || IsUsed(idx)) && fArray[idx+1]>maximum)
+        if (MatchSector(idx, sector, aidx) && (all || IsUsed(idx)) && fArray[idx+1]>maximum)
             maximum = fArray[idx+1];
 
@@ -496,5 +497,5 @@
 // into account.
 //
-TH1D *MHCamera::ProjectionS(Int_t sector, const char *name) const
+TH1D *MHCamera::ProjectionS(const TArrayI &sector, const TArrayI &aidx, const char *name) const
 {
     Int_t nbins = 50;
@@ -505,6 +506,16 @@
     {
         pname.Prepend(GetName());
-        if (sector>=0)
-            pname += sector;
+        if (sector.GetSize()>0)
+        {
+            pname += ";";
+            for (int i=0; i<sector.GetSize(); i++)
+                pname += sector[i];
+        }
+        if (aidx.GetSize()>0)
+        {
+            pname += ";";
+            for (int i=0; i<aidx.GetSize(); i++)
+                pname += aidx[i];
+        }
     }
 
@@ -520,6 +531,6 @@
     if (!h1)
     {
-        Double_t min = GetMinimumSector(sector);
-        Double_t max = GetMaximumSector(sector);
+        Double_t min = GetMinimumSectors(sector, aidx);
+        Double_t max = GetMaximumSectors(sector, aidx);
 
         Int_t newbins=0;
@@ -536,5 +547,5 @@
     // Fill the projected histogram
     for (Int_t idx=0; idx<fNcells-2; idx++)
-        if (IsUsed(idx) && MatchSector(idx, sector))
+        if (IsUsed(idx) && MatchSector(idx, sector, aidx))
             h1->Fill(GetBinContent(idx+1));
 
Index: /trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3399)
+++ /trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3400)
@@ -78,5 +78,19 @@
     void   ResetUsed(Int_t idx)    { CLRBIT(fUsed[idx], kIsUsed); }
 
-    Bool_t MatchSector(Int_t idx, Int_t sector) const;
+    Bool_t FindVal(const TArrayI &arr, Int_t val) const
+    {
+        const Int_t n = arr.GetSize();
+        if (n==0)
+            return kTRUE;
+
+        const Int_t *p = arr.GetArray();
+        const Int_t *end = p+n;
+        while (p<end)
+            if (val==*p++)
+                return kTRUE;
+
+        return kFALSE;
+    }
+    Bool_t MatchSector(Int_t idx, const TArrayI &sector, const TArrayI &aidx) const;
 
     // This is a trick to remove TH1 entries from the context menu
@@ -140,12 +154,20 @@
     Stat_t   GetBinError(Int_t binx, Int_t biny, Int_t binz) const { return GetBinError(binx); }
 
-    Double_t GetMinimum(Bool_t all) const { return GetMinimumSector(-1, all); }
-    Double_t GetMaximum(Bool_t all) const { return GetMaximumSector(-1, all); }
-
-    Double_t GetMinimum() const { return GetMinimumSector(-1, kFALSE); }
-    Double_t GetMaximum() const { return GetMaximumSector(-1, kFALSE); }
-
-    Double_t GetMinimumSector(Int_t sector, Bool_t all=kFALSE) const;
-    Double_t GetMaximumSector(Int_t sector, Bool_t all=kFALSE) const;
+    Double_t GetMinimum(Bool_t all) const { return GetMinimumSectors(TArrayI(), TArrayI(), all); }
+    Double_t GetMaximum(Bool_t all) const { return GetMaximumSectors(TArrayI(), TArrayI(), all); }
+
+    Double_t GetMinimum() const { return GetMinimumSectors(TArrayI(), TArrayI(), kFALSE); }
+    Double_t GetMaximum() const { return GetMaximumSectors(TArrayI(), TArrayI(), kFALSE); }
+
+    Double_t GetMinimumSector(Int_t sector, Int_t aidx, Bool_t all=kFALSE) const
+    {
+        return GetMinimumSectors(TArrayI(1, &sector), TArrayI(1, &aidx), all);
+    }
+    Double_t GetMaximumSector(Int_t sector, Int_t aidx, Bool_t all=kFALSE) const
+    {
+        return GetMaximumSectors(TArrayI(1, &sector), TArrayI(1, &aidx), all);
+    }
+    Double_t GetMinimumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all=kFALSE) const;
+    Double_t GetMaximumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all=kFALSE) const;
 
     void     SetLevels(const TArrayF &arr);
@@ -186,17 +208,30 @@
     void     AddNotify(TObject *event);
 
-    Stat_t   GetMean(Bool_t all) const { return GetMeanSector(-1, all); }
-    Stat_t   GetRMS(Bool_t all)  const { return GetRmsSector(-1, all); }
-
-    Stat_t   GetMean(Int_t sector=-1) const { return GetMeanSector(-1, kFALSE); }
-    Stat_t   GetRMS(Int_t sector=-1)  const { return GetRmsSector(-1, kFALSE); }
-
-    Stat_t   GetMeanSector(Int_t sector, Bool_t all=kFALSE) const;
-    Stat_t   GetRmsSector(Int_t sector, Bool_t all=kFALSE) const;
+    Stat_t   GetMean(Bool_t all) const { return GetMeanSectors(TArrayI(), TArrayI(), all); }
+    Stat_t   GetRMS(Bool_t all)  const { return GetRmsSectors(TArrayI(), TArrayI(), all); }
+
+    Stat_t   GetMean(Int_t=0) const { return GetMeanSectors(TArrayI(), TArrayI(), kFALSE); }
+    Stat_t   GetRMS(Int_t=0)  const { return GetRmsSectors(TArrayI(), TArrayI(), kFALSE); }
+
+    Stat_t   GetMeanSector(Int_t sector, Int_t aidx, Bool_t all=kFALSE) const
+    {
+        return GetMeanSectors(TArrayI(1, &sector), TArrayI(1, &aidx), all);
+    }
+    Stat_t   GetRmsSector(Int_t sector, Int_t aidx, Bool_t all=kFALSE) const
+    {
+        return GetRmsSectors(TArrayI(1, &sector), TArrayI(1, &aidx), all);
+    }
+
+    Stat_t   GetMeanSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all=kFALSE) const;
+    Stat_t   GetRmsSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all=kFALSE) const;
 
     UInt_t   GetNumPixels() const;
 
-    TH1D    *Projection(const char *name="_py") const { return ProjectionS(-1, name); }
-    TH1D    *ProjectionS(Int_t sector, const char *name="_py") const;
+    TH1D    *Projection(const char *name="_py") const { return ProjectionS(TArrayI(), TArrayI(), name); }
+    TH1D    *ProjectionS(Int_t sector, Int_t aidx, const char *name="_py") const
+    {
+        return ProjectionS(TArrayI(1, &sector), TArrayI(1, &aidx), name);
+    }
+    TH1D    *ProjectionS(const TArrayI &sector, const TArrayI &aidx, const char *name="_py") const;
 
     const MGeomCam &GetGeomCam() const { return *fGeomCam; }
Index: /trunk/MagicSoft/Mars/mhist/MHEvent.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHEvent.cc	(revision 3399)
+++ /trunk/MagicSoft/Mars/mhist/MHEvent.cc	(revision 3400)
@@ -238,4 +238,5 @@
 
         txt += fMcEvt->GetParticleName();
+        txt += " ";
 
         s.Insert(0, txt);
Index: /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 3399)
+++ /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 3400)
@@ -119,17 +119,30 @@
     if (obj1->GetGeomCam().InheritsFrom("MGeomCamMagic"))
     {
+        TArrayI s0(3);
+        s0[0] = 6;
+        s0[1] = 1;
+        s0[2] = 2;
+
+        TArrayI s1(3);
+        s1[0] = 3;
+        s1[1] = 4;
+        s1[2] = 5;
+
+        TArrayI inner(1);
+        inner[0] = 0;
+
         // Just to get the right (maximum) binning
         TH1D *half[2];
-        half[0] = obj1->Projection("Sector 6-1-2");
-        half[1] = obj1->Projection("Sector 3-4-5");
-
-        half[0]->Reset();
-        half[1]->Reset();
-
-        TH1D *dummy = obj1->Projection("Dummy");
-
-        for (int i=1; i<7/*obj1->GetGeomCam().GetNumSectors()*/; i++)
-            half[(i/3)%2]->Add(obj1->ProjectionS(i, "Dummy"));
-
+        half[0] = obj1->ProjectionS(s0, inner, "Sector 6-1-2");
+        half[1] = obj1->ProjectionS(s0, inner, "Sector 3-4-5");
+        /*
+         half[0]->Reset();
+         half[1]->Reset();
+
+         TH1D *dummy = obj1->Projection("Dummy");
+
+         for (int i=1; i<7; i++)
+         half[(i/3)%2]->Add(obj1->ProjectionS(i, "Dummy"));
+         */
         for (int i=0; i<2; i++)
         {
@@ -140,5 +153,5 @@
         }
 
-        delete dummy;
+        //delete dummy;
     }
 
