Index: trunk/MagicSoft/Mars/mhist/MHMatrix.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 2128)
+++ trunk/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 2133)
@@ -1083,2 +1083,27 @@
     return i!=0;
 }
+
+// --------------------------------------------------------------------------
+//
+// ShuffleEvents. Shuffles the order of the matrix rows.
+// 
+//
+void MHMatrix::ShuffleRows(UInt_t seed)
+{
+  TRandom rnd(seed);
+
+  for (Int_t irow = 0; irow < fNumRow; irow++)
+    {
+      Int_t jrow = rnd.Integer(fNumRow);
+
+      for (Int_t icol = 0; icol < fM.GetNcols(); icol++)
+	{
+	  Real_t tmp = fM(irow,icol);
+	  fM(irow,icol) = fM(jrow,icol);
+	  fM(jrow,icol) = tmp;
+	}
+    }
+
+  *fLog << warn << this->GetName() << " : Attention! Matrix rows have been shuffled." << endl;
+
+}
Index: trunk/MagicSoft/Mars/mhist/MHMatrix.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMatrix.h	(revision 2128)
+++ trunk/MagicSoft/Mars/mhist/MHMatrix.h	(revision 2133)
@@ -112,4 +112,6 @@
     Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
 
+    void ShuffleRows(UInt_t seed);
+
     ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
 };
