Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 5428)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 5429)
@@ -26,4 +26,18 @@
      - fixed a bug in the handling of kUsePed which caused the MTaskEnv
        to be set incorrectly
+
+   * mfbase/MFEventSelector2.[h,cc]:
+     - added possibility to set a propability distribution
+
+   * mgeom/MGeomCam.[h,cc]:
+     - enhanced the Print function
+     - fixed the Clone function for the class being MGeomCam
+     - made InitGeometry public to support unsupported geometries
+
+   * mgeom/MGeomPix.h:
+     - added Copy function
+
+   * mhbase/MH3.[h,cc]:
+     - added a constructor taking a TH1 as argument
 
 
Index: /trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc	(revision 5428)
+++ /trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc	(revision 5429)
@@ -150,9 +150,8 @@
 //     variable(s) of interest and the binnings)
 //
-
 MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title)
 : fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL),
   fDataX(hist.GetRule('x')), fDataY(hist.GetRule('y')),
-  fDataZ(hist.GetRule('z')), fNumMax(-1)
+  fDataZ(hist.GetRule('z')), fNumMax(-1), fHistIsProbability(kFALSE)
 {
     fName  = name  ? (TString)name  : gsDefName;
@@ -384,18 +383,15 @@
     }
 
-    MRead *read = (MRead*)tasklist->FindObject("MRead");
-    if (!read)
-    {
-        *fLog << err << "MRead not found... abort." << endl;
-        return kFALSE;
-    }
-
     if (!PreProcessData(parlist))
         return kFALSE;
+
+    fHistNom->SetTitle(fHistIsProbability ? "ProbabilityDistribution" : "Users Nominal Distribution");
+
+    if (fHistIsProbability)
+        return kTRUE;
 
     InitHistogram(fHistOrig);
     InitHistogram(fHistRes);
 
-    fHistNom->SetTitle("Users Nominal Distribution");
     fHistOrig->SetTitle("Primary Distribution");
     fHistRes->SetTitle("Resulting Distribution");
@@ -407,4 +403,11 @@
 
     // Generate primary distribution
+    MRead *read = (MRead*)tasklist->FindObject("MRead");
+    if (!read)
+    {
+        *fLog << err << "MRead not found... abort." << endl;
+        return kFALSE;
+    }
+
     if (!ReadDistribution(*read))
         return kFALSE;
@@ -445,4 +448,12 @@
 
     return rc;
+}
+
+Bool_t MFEventSelector2::SelectProb(Int_t ibin) const
+{
+    //
+    // If value is outside histogram range, accept event
+    //
+    return ibin<0 ? kTRUE : fHistNom->GetHist().GetBinContent(ibin) > gRandom->Uniform();
 }
 
@@ -462,7 +473,9 @@
     const Double_t valz=fDataZ.GetValue();
 
+    const Int_t ibin = fHistNom->FindFixBin(valx, valy, valz)-1;
+
     // Get corresponding bin number and check
     // whether a selection should be made
-    fResult = Select(fHistNom->FindFixBin(valx, valy, valz)-1);
+    fResult = fHistIsProbability ? Select(ibin) : SelectProb(ibin);
 
     fCounter[fResult ? 1 : 0]++;
@@ -481,15 +494,15 @@
     if (GetNumExecutions()>0)
     {
-      *fLog << inf << endl;
-      *fLog << GetDescriptor() << " execution statistics:" << endl;
-      *fLog << dec << setfill(' ');
-      *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3)
-            << (int)(fCounter[0]*100/GetNumExecutions())
-            << "%) Events not selected" << endl;
-
-      *fLog << " " << fCounter[0] << " ("
-            << (int)(fCounter[1]*100/GetNumExecutions())
-            << "%) Events selected" << endl;
-      *fLog << endl;
+        *fLog << inf << endl;
+        *fLog << GetDescriptor() << " execution statistics:" << endl;
+        *fLog << dec << setfill(' ');
+        *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3)
+              << (int)(fCounter[0]*100/GetNumExecutions())
+              << "%) Events not selected" << endl;
+
+        *fLog << " " << fCounter[0] << " ("
+              << (int)(fCounter[1]*100/GetNumExecutions())
+              << "%) Events selected" << endl;
+        *fLog << endl;
     }
 
Index: /trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h
===================================================================
--- /trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h	(revision 5428)
+++ /trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h	(revision 5429)
@@ -42,4 +42,5 @@
 
     Bool_t fResult;
+    Bool_t fHistIsProbability;
     Int_t  fCounter[2];
 
@@ -49,4 +50,5 @@
     Bool_t PreProcessData(MParList *parlist);
     Bool_t Select(Int_t bin);
+    Bool_t SelectProb(Int_t bin) const;
 
     Int_t PreProcess(MParList *parlist);
@@ -61,4 +63,5 @@
 
     void SetNumMax(Long_t max=-1) { fNumMax = max; }
+    void SetHistIsProbability(Bool_t b=kTRUE) { fHistIsProbability=b; }
     Bool_t IsExpressionTrue() const { return fResult; }
 
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 5428)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 5429)
@@ -285,4 +285,6 @@
     //
     *fLog << all << " Number of Pixels (" << GetTitle() << "): " << fNumPixels << endl;
+    *fLog << " Number of Sectors: " << GetNumSectors() << "  Area-Indices: " << GetNumAreas() << endl;
+    *fLog << " Min.Radius: " << GetMinRadius() << "  Max.Radius: " << GetMaxRadius() << endl;
 
     fPixels.Print();
@@ -296,4 +298,13 @@
 TObject *MGeomCam::Clone(const char *newname) const
 {
+    if (IsA()==MGeomCam::Class())
+    {
+        MGeomCam *cam = new MGeomCam(fNumPixels, fCamDist);
+        for (UInt_t i=0; i<fNumPixels; i++)
+            (*this)[i].Copy((*cam)[i]);
+        cam->InitGeometry();
+        return cam;
+    }
+
     return (TObject*)IsA()->New();
 }
Index: /trunk/MagicSoft/Mars/mgeom/MGeomCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 5428)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 5429)
@@ -39,12 +39,4 @@
     void CalcNumAreas();
     void InitOuterRing();
-    void InitGeometry()
-    {
-        CalcNumSectors();
-        CalcNumAreas();
-        CalcMaxRadius();
-        CalcPixRatio();
-        InitOuterRing();
-    }
 
 
@@ -59,4 +51,12 @@
     // the use of some camera files from the 0.7 beta version in which the 
     // array containing pixel ratios is not initialized.
+    void InitGeometry()
+    {
+        CalcNumSectors();
+        CalcNumAreas();
+        CalcMaxRadius();
+        CalcPixRatio();
+        InitOuterRing();
+    }
 
     Float_t GetCameraDist() const { return fCamDist; }
Index: /trunk/MagicSoft/Mars/mgeom/MGeomPix.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 5428)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 5429)
@@ -33,4 +33,18 @@
 public:
     MGeomPix(Float_t x=0, Float_t y=0, Float_t d=0, UInt_t s=0, UInt_t aidx=0);
+
+    void Copy(TObject &obj) const
+    {
+        MGeomPix &pix = (MGeomPix&)obj;
+        pix.fX = fX;
+        pix.fY = fY;
+        pix.fD = fD;
+        pix.fA = fA;
+        pix.fNumNeighbors = fNumNeighbors;
+        pix.fSector = fSector;
+        pix.fAidx = fAidx;
+        for (int i=0; i<6; i++)
+            pix.fNeighbors[i] = fNeighbors[i];
+    }
 
     void Print(Option_t *opt=NULL) const;
Index: /trunk/MagicSoft/Mars/mhbase/MH3.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 5428)
+++ /trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 5429)
@@ -166,4 +166,36 @@
 }
 
+MH3::MH3(const TH1 &h1) : fDimension(1)
+{
+    if (h1.InheritsFrom(TH3::Class()))
+        fDimension = 3;
+    if (h1.InheritsFrom(TH2::Class()))
+        fDimension = 2;
+
+    fData[0] = NULL;
+    fData[1] = NULL;
+    fData[2] = NULL;
+
+    switch (fDimension)
+    {
+    case 3:
+        fData[2] = new MDataChain(h1.GetZaxis()->GetTitle());
+    case 2:
+        fData[1] = new MDataChain(h1.GetYaxis()->GetTitle());
+    case 1:
+        fData[0] = new MDataChain(h1.GetXaxis()->GetTitle());
+    }
+
+    fName  = gsDefName;
+    fTitle = gsDefTitle;
+
+    fHist = (TH1*)h1.Clone();
+    fHist->SetDirectory(NULL);
+
+    fScale[0] = 1;
+    fScale[1] = 1;
+    fScale[2] = 1;
+}
+
 // --------------------------------------------------------------------------
 //
Index: /trunk/MagicSoft/Mars/mhbase/MH3.h
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH3.h	(revision 5428)
+++ /trunk/MagicSoft/Mars/mhbase/MH3.h	(revision 5429)
@@ -39,4 +39,5 @@
 public:
     MH3(const unsigned int dim=0);
+    MH3(const TH1 &h1);
     MH3(const char *memberx);
     MH3(const char *memberx, const char *membery);
