Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2132)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2133)
@@ -1,5 +1,14 @@
                                                  -*-*- END OF LINE -*-*-
 
-
+ 2003/05/22: Abelardo Moralejo
+
+   * mhist/MHMatrix.[h,cc]
+     - add member function ShuffleRows() to randomize the order of the
+       matrix rows. This is useful for instance for the random forest, 
+       (See RanForest.C) when we feed a hadron training sample with 
+       both protons and helium nuclei: if they are ordered (first all
+       events of one type, then those of the other) the method does not
+       seem to work well. Any other kind of ordering might be harmful 
+       as well (in theta, phi or whatever).
 
  2003/05/22: Wolfgang Wittek
Index: trunk/MagicSoft/Mars/mhist/MHMatrix.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 2132)
+++ 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 2132)
+++ 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
 };
