1 /* Copyright (C) 2007 Christian Holm Christensen <cholm@nbi.dk>
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 2.1 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 //____________________________________________________________________
20 // Object used by AliFMDFlowBinned1D to split an event into sub-events.
21 // Default is to split randomly.
22 // User defined derived classes can do other stuff.
24 #include "flow/AliFMDFlowSplitter.h"
25 #include "flow/AliFMDFlowAxis.h"
30 //____________________________________________________________________
32 AliFMDFlowSplitter::Select(ULong_t) const
34 // Decide whether entry should go in A or B sub-event.
36 // entry The entry number
38 // true if this should go in sub-event A
39 return (Float_t(rand()) / RAND_MAX > 0.5);
43 //____________________________________________________________________
45 AliFMDFlowShuffle::Event(Double_t*, Double_t*, ULong_t n)
47 // Prepare for an event
50 // xs List of bin variable
51 // n Number of entries in @a phis and @a n
57 //____________________________________________________________________
59 AliFMDFlowShuffle::Select(ULong_t entry) const
61 // Decide whether entry should go in A or B sub-event.
63 // entry The entry number
65 // true if this should go in sub-event A
66 if (entry >= fN || Int_t(entry) >= fIdx.fN) return false;
67 ULong_t n = fIdx[entry];
71 //____________________________________________________________________
73 AliFMDFlowShuffle::Shuffle()
76 if (fIdx.fN < Int_t(fN)) fIdx.Set(fN);
77 for (ULong_t i = 0; i < fN; i++) fIdx[i] = i;
78 for (ULong_t i = 0; i < fN; i++) {
79 // Swap 2 random locations
80 ULong_t j = ULong_t(gRandom->Rndm()*(fN-1));
87 //____________________________________________________________________