Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3394)
+++ 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 3394)
+++ 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 3394)
+++ trunk/MagicSoft/Mars/mhist/MHEvent.cc	(revision 3400)
@@ -238,4 +238,5 @@
 
         txt += fMcEvt->GetParticleName();
+        txt += " ";
 
         s.Insert(0, txt);
