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"
31 //____________________________________________________________________
33 AliFMDFlowSplitter::Select(ULong_t) const
35 // Decide whether entry should go in A or B sub-event.
37 // entry The entry number
39 // true if this should go in sub-event A
40 return (Float_t(rand()) / RAND_MAX > 0.5);
44 //____________________________________________________________________
46 AliFMDFlowShuffle::Event(Double_t*, Double_t*, ULong_t n)
48 // Prepare for an event
51 // xs List of bin variable
52 // n Number of entries in @a phis and @a n
58 //____________________________________________________________________
60 AliFMDFlowShuffle::Select(ULong_t entry) const
62 // Decide whether entry should go in A or B sub-event.
64 // entry The entry number
66 // true if this should go in sub-event A
67 if (entry >= fN || Int_t(entry) >= fIdx.fN) return false;
68 ULong_t n = fIdx[entry];
72 //____________________________________________________________________
74 AliFMDFlowShuffle::Shuffle()
77 if (fIdx.fN < Int_t(fN)) fIdx.Set(fN);
78 for (ULong_t i = 0; i < fN; i++) fIdx[i] = i;
79 for (ULong_t i = 0; i < fN; i++) {
80 // Swap 2 random locations
81 ULong_t j = ULong_t(gRandom->Rndm()*(fN-1));
88 //____________________________________________________________________