]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/flow/AliFMDFlowSplitter.cxx
Compilation warnings
[u/mrichter/AliRoot.git] / FMD / flow / AliFMDFlowSplitter.cxx
CommitLineData
9b98d361 1/* Copyright (C) 2007 Christian Holm Christensen <cholm@nbi.dk>
2 *
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.
7 *
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.
12 *
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
16 * USA
17 */
18//____________________________________________________________________
19//
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.
23//
24#include "flow/AliFMDFlowSplitter.h"
25#include "flow/AliFMDFlowAxis.h"
26#include <TRandom.h>
27#include <cmath>
b09247a2 28#include <cstdlib>
9b98d361 29#include <iostream>
30
31//____________________________________________________________________
32Bool_t
33AliFMDFlowSplitter::Select(ULong_t) const
34{
35 // Decide whether entry should go in A or B sub-event.
36 // Parameters:
37 // entry The entry number
38 // Return
39 // true if this should go in sub-event A
40 return (Float_t(rand()) / RAND_MAX > 0.5);
41}
42
43
44//____________________________________________________________________
45void
46AliFMDFlowShuffle::Event(Double_t*, Double_t*, ULong_t n)
47{
48 // Prepare for an event
49 // Parameters
50 // phis List of phis.
51 // xs List of bin variable
52 // n Number of entries in @a phis and @a n
53 // Return
54 fN = n;
55 Shuffle();
56}
57
58//____________________________________________________________________
59Bool_t
60AliFMDFlowShuffle::Select(ULong_t entry) const
61{
62 // Decide whether entry should go in A or B sub-event.
63 // Parameters:
64 // entry The entry number
65 // Return
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];
69 return (n < fN/2);
70}
71
72//____________________________________________________________________
73void
74AliFMDFlowShuffle::Shuffle()
75{
76 // Suffle index
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));
82 ULong_t k = fIdx[j];
83 fIdx[j] = fIdx[i];
84 fIdx[i] = k;
85 }
86}
87
88//____________________________________________________________________
89//
90// EOF
91//