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
19 @brief implementation of a Bin in a Flow histogram */
20 //____________________________________________________________________
22 // This contains an of class AliFMDFlowHarmonic and an object of
23 // class AliFMDFlowEventPlane to calculate v_n and \Psi_k. It contain
24 // two objects of class AliFMDFlowEventPlane to calculate the
25 // sub-event event planes Psi_A, \Psi_B. It also contain 3 objects of
26 // class AliFMDFlowResolution to calculate the event plane angle
29 #include "flow/AliFMDFlowBin.h"
30 #include "flow/AliFMDFlowUtil.h"
36 //====================================================================
37 AliFMDFlowBin::AliFMDFlowBin(UShort_t order, UShort_t k)
45 fSplit("ab_split", "Relative split in A,B sub-event", 2, 0, 2, 100, 0, 1),
46 fPhi("phi", "Distribution of #varphi-#Psi", 40, 0, 2*TMath::Pi()),
50 fAB("psiAB", "Distribution of #Psi_{A} vs. #Psi_{B}",
51 40, 0, 2*TMath::Pi()/fPsiA.Order(), 40, 0, 2*TMath::Pi()/fPsiA.Order())
53 fSplit.SetDirectory(0);
54 fSplit.GetXaxis()->SetBinLabel(1, "A");
55 fSplit.GetXaxis()->SetBinLabel(2, "B");
56 fSplit.SetXTitle("Sub-event");
57 fSplit.SetYTitle("Fraction");
59 fPhi.SetXTitle("#varphi");
61 fAB.SetXTitle("#Psi_{A}");
62 fAB.SetYTitle("#Psi_{B}");
65 //____________________________________________________________________
66 AliFMDFlowBin::AliFMDFlowBin(const AliFMDFlowBin& o)
74 fHarmonic(o.fHarmonic),
84 // o Object to copy from
85 fSplit.SetDirectory(0);
86 fSplit.GetXaxis()->SetBinLabel(1, "A");
87 fSplit.GetXaxis()->SetBinLabel(2, "B");
88 fSplit.SetXTitle("Sub-event");
89 fSplit.SetYTitle("Fraction");
92 fPhi.SetXTitle("#varphi");
95 fAB.SetXTitle("#Psi_{A}");
96 fAB.SetYTitle("#Psi_{B}");
99 //____________________________________________________________________
101 AliFMDFlowBin::operator=(const AliFMDFlowBin& o)
103 // Assignment operator
105 // o Object to assign from
110 fResStar = o.fResStar;
112 fHarmonic = o.fHarmonic;
119 fSplit.Add(&(o.fSplit));
130 //____________________________________________________________________
132 AliFMDFlowBin::Begin()
134 // Clear event plane calculators
141 //____________________________________________________________________
143 AliFMDFlowBin::AddToEventPlane(Double_t phi, Double_t w, Bool_t a)
145 // Called to add a contribution to the event plane
147 // phi The angle phi in [0,2pi]
149 // a If true, add to sub-event A, otherwise to sub-event B.
151 if (a) fPsiA.Add(phi, w);
152 else fPsiB.Add(phi, w);
153 if (a) fNA++; else fNB++;
157 //____________________________________________________________________
159 AliFMDFlowBin::AddToHarmonic(Double_t phi, Double_t wp, Double_t wh)
161 // Called to add a contribution to the harmonic.
163 // phi The angle phi in [0,2pi]
164 // wp Weight of phi (only used in the calculation of
166 // wh Weight of observation.
168 // Disregard the obervation of phi from the event plane angle.
169 Double_t psi = fPsi.Psi(phi, wp);
170 fHarmonic.Add(phi, psi, wh);
171 fPhi.Fill(NormalizeAngle(phi-psi));
174 //____________________________________________________________________
178 // Should be called at the end of an event
182 Double_t psiA = fPsiA.Psi();
183 Double_t psiB = fPsiB.Psi();
185 // Update the resolutions
186 fRes.Add(psiA, psiB);
187 fResStar.Add(psiA, psiB);
188 fResTdr.Add(psiA, psiB);
190 fSplit.Fill(.5, float(fNA)/fN);
191 fSplit.Fill(1.5, float(fNB)/fN);
193 fAB.Fill(psiA, psiB);
196 //____________________________________________________________________
198 AliFMDFlowBin::Event(UInt_t n, Double_t* phis, Double_t* wp, Double_t* wh)
202 // n Size of phis and possibly ws
203 // phis Array of phi, (phi_1, ..., phi_n)
204 // wp Weights of event plane (optional)
205 // wh Weights of harmonic (optional)
209 UInt_t split = n / 2;
211 for (UInt_t i = 0; i < split; i++)
212 AddToEventPlane(phis[i], (wp ? wp[i] : 1), kTRUE);
214 for (UInt_t i = split; i < n; i++)
215 AddToEventPlane(phis[i], (wp ? wp[i] : 1), kFALSE);
216 // Add contributions to the harmonic.
217 for (UInt_t i = 0; i < n; i++)
218 AddToHarmonic(phis[i], (wp ? wp[i] : 1), (wh ? wh[i] : 1));
223 //____________________________________________________________________
225 AliFMDFlowBin::Value(CorType t) const
227 // Get the value in this bin
229 // t Which type of correction
231 // return the value of the harmonic
236 //____________________________________________________________________
238 AliFMDFlowBin::EValue(CorType t) const
240 // Get the value in this bin
242 // t Which type of correction
244 // return the error on the value of the harmonic
250 //____________________________________________________________________
252 AliFMDFlowBin::Value(Double_t& e2, CorType t) const
254 // Get the value in this bin
256 // e2 On return, the square error.
257 // t Which type of correction
259 // return the value of the harmonic
261 r = Correction(er2, t);
262 return fHarmonic.Value(r, er2, e2);
265 //____________________________________________________________________
267 AliFMDFlowBin::Correction(Double_t& er2, CorType t) const
269 // Get the value in this bin
271 // e2 On return, the square error.
272 // t Which type of correction
274 // return the value of the Correction
276 UShort_t k = fHarmonic.Order()/fRes.Order();
278 case kNaive: r = fRes.Correction(k, er2); break;
279 case kStar: r = fResStar.Correction(k, er2); break;
280 case kTdr: r = fResTdr.Correction(k, er2); break;
281 default: r = 1; er2 = 0; break;
286 //____________________________________________________________________
288 AliFMDFlowBin::Counts() const
290 // Return the number of counts used in this bin.
292 // Number of counts that is used in this bin.
293 return fHarmonic.N();
296 //____________________________________________________________________
298 AliFMDFlowBin::Finish()
300 // Called at the end of the event
303 //____________________________________________________________________
305 AliFMDFlowBin::Browse(TBrowser* b)
308 b->Add(&fPsi, "Full event plane");
309 b->Add(&fPsiA, "Sub-event A event plane");
310 b->Add(&fPsiB, "Sub-event B event plane");
311 b->Add(&fRes, "Naive resolution");
312 b->Add(&fResStar, "STAR resolution");
313 b->Add(&fResTdr, "TDR resolution");
314 b->Add(&fHarmonic, "Harmonic");
315 b->Add(&fSplit, "Split");
316 b->Add(&fPhi, "Phi");
320 //____________________________________________________________________
322 AliFMDFlowBin::Print(Option_t*) const
325 Double_t e2v[4], v[4], r[4], e2r[4];
326 const char* names[] = { "Bare", "Naive", "STAR", "TDR" };
327 v[0] = 100 * Value(e2v[0], AliFMDFlowBin::kNone);
328 v[1] = 100 * Value(e2v[1], AliFMDFlowBin::kNaive);
329 v[2] = 100 * Value(e2v[2], AliFMDFlowBin::kStar);
330 v[3] = 100 * Value(e2v[3], AliFMDFlowBin::kTdr);
331 r[0] = 100 * Correction(e2r[0], AliFMDFlowBin::kNone);
332 r[1] = 100 * Correction(e2r[1], AliFMDFlowBin::kNaive);
333 r[2] = 100 * Correction(e2r[2], AliFMDFlowBin::kStar);
334 r[3] = 100 * Correction(e2r[3], AliFMDFlowBin::kTdr);
336 std::streamsize oldP = std::cout.precision(3);
337 std::ios_base::fmtflags oldF = std::cout.setf(std::ios_base::fixed,
338 std::ios_base::floatfield);
339 std::cout << " v" << std::setw(1) << fHarmonic.Order() << ": ";
340 for (UInt_t i = 0; i < 4; i++)
341 std::cout << std::setw(6+(i == 0 ? 0 : 6)) << names[i] << ": "
342 << std::setw(6) << v[i] << " +/- "
343 << std::setw(6) << 100*sqrt(e2v[i]) << " ["
344 << std::setw(7) << r[i] << " +/- "
345 << std::setw(7) << 100*sqrt(e2r[i]) << "]\n";
346 std::cout << std::flush;
347 std::cout.precision(oldP);
348 std::cout.setf(oldF, std::ios_base::floatfield);
352 //____________________________________________________________________