coverity 15108 fixed
[u/mrichter/AliRoot.git] / FMD / flow / AliFMDFlowSplitter.h
CommitLineData
9b98d361 1// -*- mode: C++ -*-
2/* Copyright (C) 2007 Christian Holm Christensen <cholm@nbi.dk>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation; either version 2.1 of
7 * the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 * USA
18 */
19/** @file
20 @brief Declaration of an Axis in a Flow "histogram" */
21#ifndef ALIFMDFLOWSPLITTER_H
22#define ALIFMDFLOWSPLITTER_H
23#include "flow/AliFMDFlowAxis.h"
24#include <TArrayI.h>
25#ifndef ROOT_TObject
26# include <TObject.h>
27#endif
133f1578 28#ifndef ROOT_TRandom
29# include <TRandom.h>
30#endif
9b98d361 31class AliFMDFlowAxis;
32class TProfile;
33//
34// Object used by AliFMDFlowBinned1D to split an event into sub-events.
35// Default is to split randomly.
36// User defined derived classes can do other stuff.
37//
38//______________________________________________________
39/** @class AliFMDFlowSplitter flow/AliFMDFlowSplitter.h <flow/AliFMDFlowSplitter.h>
40
41 @brief Object used by AliFMDFlowBinned1D to split an event into
42 sub-events. Default is to split randomly. User defined derived
43 classes can do other stuff.
44
45 @ingroup c_binned
46*/
47class AliFMDFlowSplitter : public TObject
48{
49public:
50 /** Constructor
51 @param axis Axis object */
133f1578 52 AliFMDFlowSplitter() : fRandom(0) {}
53 /** Constructor
54 @param axis Axis object */
55 AliFMDFlowSplitter(ULong_t seed) : fRandom(seed) {}
9b98d361 56 /** Copy constructor
57 @param o Other splitter to copy from */
133f1578 58 AliFMDFlowSplitter(const AliFMDFlowSplitter& o)
59 : TObject(o), fRandom(o.fRandom)
60 {}
6ce810fc 61
9b98d361 62 /** Destructor */
63 virtual ~AliFMDFlowSplitter() {}
64 /** Assignment operator
65 @param o Other splitter to assign from.
66 @return Reference to this object */
6ce810fc 67 AliFMDFlowSplitter& operator=(const AliFMDFlowSplitter&);
9b98d361 68 /** Called at the beginning of an event */
69 virtual void Begin() {}
70 /** Prepare for an event
71 @param phis List of phis.
72 @param xs List of bin variable
73 @param n Number of entries in @a phis and @a n
74 @return true on success, false otherwise */
6ce810fc 75 virtual void Event(Double_t* phis, Double_t* xs, ULong_t n);
9b98d361 76 /** Decide whether entry should go in A or B sub-event.
77 @param entry The entry number
78 @return true if this should go in sub-event A */
79 virtual Bool_t Select(ULong_t entry) const;
80 /** Called at the end of an event */
81 virtual void End() {}
82protected:
133f1578 83 mutable TRandom fRandom;
9b98d361 84 /** Reference to axis object */
85 ClassDef(AliFMDFlowSplitter,1) // Split events
86};
6ce810fc 87inline AliFMDFlowSplitter&
88AliFMDFlowSplitter::operator=(const AliFMDFlowSplitter& /*o*/)
89{
90 return *this;
91}
92inline void
93AliFMDFlowSplitter::Event(Double_t*, Double_t*,ULong_t)
94{}
9b98d361 95
96//____________________________________________________________________
97class AliFMDFlowShuffle : public AliFMDFlowSplitter
98{
99public:
100 /** Constuctor */
6ce810fc 101 AliFMDFlowShuffle() : fIdx(), fN(0) {}
9b98d361 102 /** Prepare for an event
103 @param phis List of phis.
104 @param xs List of bin variable
105 @param n Number of entries in @a phis and @a n
106 @return true on success, false otherwise */
107 virtual void Event(Double_t* phis, Double_t* xs, ULong_t n);
108 /** Decide whether entry should go in A or B sub-event.
109 @param entry The entry number
110 @return true if this should go in sub-event A */
111 virtual Bool_t Select(ULong_t entry) const;
112protected:
113 /** Function to shuffle */
114 void Shuffle();
115 /** Array of indicies */
116 TArrayI fIdx;
117 /** Curren number of entries */
118 ULong_t fN;
119 ClassDef(AliFMDFlowShuffle,1) // Split events
120};
121
122
123#endif
124//
125// EOF
126//