2 @brief Implementation of a 2-dimensional Flow "histogram" */
3 #include "flow/AliFMDFlowBinned2D.h"
4 #include "flow/AliFMDFlowBin.h"
10 //====================================================================
11 AliFMDFlowBinned2D::AliFMDFlowBinned2D(UShort_t order,
12 UShort_t nxbins, Double_t* xbins,
13 UShort_t nybins, Double_t* ybins)
14 : fXAxis(nxbins, xbins),
15 fYAxis(nybins, ybins),
18 UInt_t n = fXAxis.N() * fYAxis.N();
19 fBins = new AliFMDFlowBin*[n];
20 for (UInt_t i = 0; i < n; i++) fBins[i]= new AliFMDFlowBin(order);
22 //____________________________________________________________________
23 AliFMDFlowBinned2D::AliFMDFlowBinned2D(UShort_t order,
24 const AliFMDFlowAxis& xaxis,
25 const AliFMDFlowAxis& yaxis)
29 UShort_t n = fXAxis.N() * fYAxis.N();
30 fBins = new AliFMDFlowBin*[n];
31 for (UInt_t i = 0; i < n; i++) fBins[i]= new AliFMDFlowBin(order);
33 //____________________________________________________________________
34 AliFMDFlowBinned2D::AliFMDFlowBinned2D(const AliFMDFlowBinned2D& o)
39 UShort_t n = fXAxis.N() * fYAxis.N();
40 fBins = new AliFMDFlowBin*[n];
41 for (UInt_t i = 0; i < n; i++) fBins[i]= new AliFMDFlowBin(*(o.fBins[i]));
43 //____________________________________________________________________
45 AliFMDFlowBinned2D::operator=(const AliFMDFlowBinned2D& o)
48 UInt_t n = fXAxis.N() * fYAxis.N();
49 for (UInt_t i = 0; i < n; i++) delete fBins[i];
53 UShort_t n = fXAxis.N() * fYAxis.N();
54 fBins = new AliFMDFlowBin*[n];
55 for (UInt_t i = 0; i < n; i++) fBins[i]= new AliFMDFlowBin(*(o.fBins[i]));
59 //____________________________________________________________________
60 AliFMDFlowBinned2D::~AliFMDFlowBinned2D()
63 UInt_t n = fXAxis.N() * fYAxis.N();
64 for (UInt_t i = 0; i < n; i++) delete fBins[i];
68 //____________________________________________________________________
70 AliFMDFlowBinned2D::GetBin(UShort_t i, UShort_t j) const
72 if (i >= fXAxis.N() || j >= fYAxis.N()) return 0;
73 return fBins[i * fYAxis.N() + j];
75 //____________________________________________________________________
77 AliFMDFlowBinned2D::GetBin(Double_t x, Double_t y) const
79 Int_t i = fXAxis.FindBin(x);
81 Int_t j = fYAxis.FindBin(y);
87 //____________________________________________________________________
89 AliFMDFlowBinned2D::Begin()
91 UInt_t n = fXAxis.N() * fYAxis.N();
92 for (UInt_t i = 0; i < n; i++) fBins[i]->Begin();
94 //____________________________________________________________________
96 AliFMDFlowBinned2D::End()
98 UInt_t n = fXAxis.N() * fYAxis.N();
99 for (UInt_t i = 0; i < n; i++) fBins[i]->End();
101 //____________________________________________________________________
103 AliFMDFlowBinned2D::Finish()
105 UInt_t n = fXAxis.N() * fYAxis.N();
106 for (UInt_t i = 0; i < n; i++) fBins[i]->Finish();
108 //____________________________________________________________________
110 AliFMDFlowBinned2D::AddToEventPlane(Double_t x, Double_t y, Double_t phi,
111 Double_t w, Bool_t a)
113 AliFMDFlowBin* bin = GetBin(x, y);
114 if (!bin) return kFALSE;
115 bin->AddToEventPlane(phi, w, a);
119 //____________________________________________________________________
121 AliFMDFlowBinned2D::AddToHarmonic(Double_t x, Double_t y, Double_t phi)
123 AliFMDFlowBin* bin = GetBin(x, y);
124 if (!bin) return kFALSE;
125 bin->AddToHarmonic(phi);
129 //____________________________________________________________________
131 AliFMDFlowBinned2D::Event(Double_t* phis, Double_t* xs, Double_t* ys,
132 Double_t* ws, ULong_t n)
135 for (UInt_t i = 0; i < n; i++)
136 AddToEventPlane(xs[i], ys[i], phis[i], (ws ? ws[i] : 1),
137 Float_t(rand()) / RAND_MAX > 0.5);
138 for (UInt_t i = 0; i < n; i++)
139 AddToHarmonic(xs[i], ys[i], phis[i]);
143 //____________________________________________________________________
145 AliFMDFlowBinned2D::Browse(TBrowser* b)
147 b->Add(&fXAxis, "xaxis");
148 b->Add(&fYAxis, "yaxis");
149 for (UInt_t i = 0; i < fXAxis.N(); i++) {
150 for (UInt_t j = 0; i < fYAxis.N(); j++) {
151 b->Add(fBins[i*fXAxis.N()+j], Form("bin_%03d_%03d", i, j));
156 //____________________________________________________________________