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 Harmonic class */
20 //____________________________________________________________________
22 // Calculate the nth order harmonic.
23 // Input is the phis of the observations,
24 // and the resolution of the event plane.
25 // The class derives from AliFMDFlowStat to easy calculating the mean
26 // and the square variance of the harmonic.
27 #include "flow/AliFMDFlowHarmonic.h"
28 #include "flow/AliFMDFlowUtil.h"
33 //====================================================================
34 AliFMDFlowHarmonic::AliFMDFlowHarmonic(UShort_t n)
36 fPhi("phi", "#varphi-#Psi", 40, 0, 2*TMath::Pi()),
37 fNPhi("nphi",Form("%d(#varphi-#Psi)",n),40,0,2*TMath::Pi()),
38 fWeight("weight", Form("cos(%d(#varphi-#Psi))", n), 100, -1, 1),
39 fContrib("contrib", Form("(#varphi-#psi) vs cos(%d(#varphi-#Psi))", n),
40 40, 0, 2 * TMath::Pi(), 100, -1, 1)
42 fContrib.SetDirectory(0);
44 fContrib.SetXTitle("#varphi-#Psi");
45 fContrib.SetYTitle(Form("cos(%d(#varphi-#Psi))", n));
48 fPhi.SetXTitle("#varphi-#Psi");
49 fNPhi.SetDirectory(0);
51 fNPhi.SetXTitle(Form("%d(#varphi-#Psi)", n));
52 fWeight.SetDirectory(0);
54 fWeight.SetXTitle(Form("cos(%d(#varphi-#Psi))", n));
55 fWeight.SetYTitle("#sum_iw_i");
58 //____________________________________________________________________
59 AliFMDFlowHarmonic::AliFMDFlowHarmonic(const AliFMDFlowHarmonic& o)
69 // o Object to copy from
70 fContrib.SetDirectory(0);
72 fContrib.SetXTitle(Form("w_{i}cos(%d(#varphi-#Psi))", fOrder));
74 fPhi.SetXTitle("#varphi-#Psi");
76 fNPhi.SetDirectory(0);
77 fNPhi.SetXTitle(Form("%d(#varphi-#Psi)", fOrder));
79 fWeight.SetDirectory(0);
81 fWeight.SetXTitle(Form("cos(%d(#varphi-#Psi))", fOrder));
82 fWeight.SetYTitle("#sum_iw_i");
85 //____________________________________________________________________
87 AliFMDFlowHarmonic::operator=(const AliFMDFlowHarmonic& o)
89 // Assignment operator
91 // o Object to assign from
92 // Return reference to this object.
93 AliFMDFlowStat::operator=(o);
97 fContrib.Add(&o.fContrib);
103 fWeight.Add(&o.fWeight);
107 //____________________________________________________________________
109 AliFMDFlowHarmonic::Browse(TBrowser* b)
111 // Browse this object
122 //____________________________________________________________________
124 AliFMDFlowHarmonic::Add(Double_t phi, Double_t psi, Double_t weight)
128 // phi Angle of this observation.
129 // psi Event plane of this observation
130 // weight The weight of this observation
131 Double_t a = NormalizeAngle(fOrder * (phi - psi));
132 Double_t cosa = TMath::Cos(a);
133 Double_t contrib = cosa; // weight * cosa;
134 AliFMDFlowStat::Add(contrib);
135 fPhi.Fill(NormalizeAngle(phi-psi));
137 fWeight.Fill(cosa, weight);
138 fContrib.Fill(a/*NormalizeAngle(phi-psi)*/,contrib);
140 //____________________________________________________________________
142 AliFMDFlowHarmonic::Value(Double_t r, Double_t er2, Double_t& e2) const
144 // The corrected value is given by
153 // v_n^obs = - \sum_i(cos(n(\phi_i - \Psi)))
156 // and R is the resolution
158 // The error on the corrected value is given by
161 // d^2v_n = (--------)^2 d^2v_n^obs + (----)^2 d^2R
164 // d^2v_n^obs R^2 + d^2R v_n^obs^2
165 // = -------------------------------
168 Double_t a = fAverage;
171 Double_t s = fSqVar / fN;
172 e2 = (s * r * r + er2 * a * a) / pow(r, 4);
177 //____________________________________________________________________
179 AliFMDFlowHarmonic::Print(Option_t* /*option*/) const
181 Double_t e2, er2 = 1, r = 1;
182 Double_t v = Value(r, er2, e2);
183 std::cout << v << " +/- " << e2 << std::endl;
187 //____________________________________________________________________