Index: trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 9303)
+++ trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 9308)
@@ -159,5 +159,6 @@
     if (!fTitle.Contains(";"))
         fSum->SetYTitle("a.u.");
-    fSum->SetBit(MHCamera::kProfile);
+    if (fUseThreshold!=kCollectMin && fUseThreshold!=kCollectMax)
+        fSum->SetBit(MHCamera::kProfile);
     if (!fErrorSpread)
         fSum->SetBit(MHCamera::kErrorMean);
@@ -178,8 +179,29 @@
         return kERROR;
     }
-    if (fUseThreshold)
+
+    switch (fUseThreshold)
+    {
+    case kNoBound:
+        fSum->AddCamContent(*evt, fType);
+        break;
+
+    case kIsLowerBound:
+    case kIsUpperBound:
         fSum->CntCamContent(*evt, fThreshold, fType, fUseThreshold>0);
-    else
-        fSum->AddCamContent(*evt, fType);
+        break;
+
+    case kCollectMin:
+        fSum->SetMinCamContent(*evt, /*fThreshold,*/ fType);
+        break;
+
+    case kCollectMax:
+        fSum->SetMaxCamContent(*evt, /*fThreshold,*/ fType);
+        break;
+
+    default:
+        *fLog << err << "ERROR - MHCamEvent::Fill: Unknown type." << endl;
+        return kERROR;
+    }
+
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mhist/MHCamEvent.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamEvent.h	(revision 9303)
+++ trunk/MagicSoft/Mars/mhist/MHCamEvent.h	(revision 9308)
@@ -35,5 +35,5 @@
 
 public:
-    enum { kIsLowerBound=1, kIsUpperBound=-1, kNoBound=0 };
+    enum { kIsLowerBound=1, kIsUpperBound=-1, kNoBound=0, kCollectMin=-2, kCollectMax=2 };
 
     MHCamEvent(const char *name=NULL, const char *title=NULL);
@@ -57,4 +57,6 @@
 
     void SetThreshold(Float_t f=0, Char_t direction=kIsLowerBound) { fThreshold = f; fUseThreshold=direction; }
+    void SetCollectMin() { fUseThreshold=kCollectMin; }
+    void SetCollectMax() { fUseThreshold=kCollectMax; }
     void SetErrorSpread(Bool_t b=kTRUE) { fErrorSpread = b; }
     void SetErrorRelative(Bool_t b=kTRUE) { fErrorRelative = b; }
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 9303)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 9308)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.113 2009-02-07 20:47:41 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.114 2009-02-09 11:30:53 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -1591,6 +1591,8 @@
 //
 // Call this function to add a MCamEvent on top of the present contents.
-// 1 is added to each pixel if the contents of MCamEvent>threshold (in case isabove is set to kTRUE == default)
-// 1 is added to each pixel if the contents of MCamEvent<threshold (in case isabove is set to kFALSE)
+// 1 is added to each pixel if the contents of MCamEvent>threshold
+//   (in case isabove is set to kTRUE == default)
+// 1 is added to each pixel if the contents of MCamEvent<threshold
+//   (in case isabove is set to kFALSE)
 //
 // in unused pixel is not counted if it didn't fullfill the condition.
@@ -1658,6 +1660,8 @@
 //
 // Call this function to add a MCamEvent on top of the present contents.
-// 1 is added to each pixel if the contents of MCamEvent>threshold (in case isabove is set to kTRUE == default)
-// 1 is added to each pixel if the contents of MCamEvent<threshold (in case isabove is set to kFALSE)
+// 1 is added to each pixel if the contents of MCamEvent>threshold
+//   (in case isabove is set to kTRUE == default)
+// 1 is added to each pixel if the contents of MCamEvent<threshold
+//   (in case isabove is set to kFALSE)
 //
 // in unused pixel is not counted if it didn't fullfill the condition.
@@ -1702,4 +1706,76 @@
         if (!ispos || fArray[idx+1]>0)
             SetUsed(idx);
+    }
+    fEntries++;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a MCamEvent on top of the present contents.
+// 1 is added to each pixel if the contents of MCamEvent>threshold
+//   (in case isabove is set to kTRUE == default)
+// 1 is added to each pixel if the contents of MCamEvent<threshold
+//   (in case isabove is set to kFALSE)
+//
+// in unused pixel is not counted if it didn't fullfill the condition.
+//
+void MHCamera::SetMaxCamContent(const MCamEvent &event, Int_t type)
+{
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Double_t val=0;
+        const Bool_t rc = event.GetPixelContent(val, idx, *fGeomCam, type);
+        if (!rc)
+            continue;
+
+        if (!IsUsed(idx))
+        {
+            fArray[idx+1] = val;
+            SetUsed(idx);
+            fBinEntries.fArray[idx+1]=1;
+        }
+        else
+            if (val>fArray[idx+1])
+                fArray[idx+1] = val;
+    }
+    fEntries++;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a MCamEvent on top of the present contents.
+// 1 is added to each pixel if the contents of MCamEvent>threshold
+//   (in case isabove is set to kTRUE == default)
+// 1 is added to each pixel if the contents of MCamEvent<threshold
+//   (in case isabove is set to kFALSE)
+//
+// in unused pixel is not counted if it didn't fullfill the condition.
+//
+void MHCamera::SetMinCamContent(const MCamEvent &event, Int_t type)
+{
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Double_t val=0;
+        const Bool_t rc = event.GetPixelContent(val, idx, *fGeomCam, type);
+        if (!rc)
+            continue;
+
+        if (!IsUsed(idx))
+        {
+            fArray[idx+1] = val;
+            SetUsed(idx);
+            fBinEntries.fArray[idx+1]=1;
+        }
+        else
+            if (val<fArray[idx+1])
+                fArray[idx+1] = val;
     }
     fEntries++;
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 9303)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 9308)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-!  $Name: not supported by cvs2svn $:$Id: MHCamera.h,v 1.66 2008-12-02 11:22:19 tbretz Exp $
+!  $Name: not supported by cvs2svn $:$Id: MHCamera.h,v 1.67 2009-02-09 11:30:53 tbretz Exp $
 \* ======================================================================== */
 #ifndef MARS_MHCamera
@@ -180,4 +180,7 @@
     virtual void     CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE);
     virtual void     CntCamContent(const MCamEvent &event, Int_t type1, const MCamEvent &thresevt, Int_t type2, Double_t threshold, Bool_t isabove);
+
+    virtual void     SetMaxCamContent(const MCamEvent &evt, Int_t type=0);
+    virtual void     SetMinCamContent(const MCamEvent &evt, Int_t type=0);
 
     Stat_t   GetBinContent(Int_t bin) const;
