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"
35 //====================================================================
36 AliFMDFlowBin::AliFMDFlowBin(const AliFMDFlowBin& o)
44 fHarmonic(o.fHarmonic)
48 // o Object to copy from
51 //____________________________________________________________________
53 AliFMDFlowBin::operator=(const AliFMDFlowBin& o)
55 // Assignment operator
57 // o Object to assign from
62 fResStar = o.fResStar;
64 fHarmonic = o.fHarmonic;
68 //____________________________________________________________________
70 AliFMDFlowBin::Begin()
72 // Clear event plane calculators
78 //____________________________________________________________________
80 AliFMDFlowBin::AddToEventPlane(Double_t phi, Double_t w, Bool_t a)
82 // Called to add a contribution to the event plane
84 // phi The angle phi in [0,2pi]
86 // a If true, add to sub-event A, otherwise to sub-event B.
88 if (a) fPsiA.Add(phi, w);
89 else fPsiB.Add(phi, w);
92 //____________________________________________________________________
94 AliFMDFlowBin::AddToHarmonic(Double_t phi, Double_t w)
96 // Called to add a contribution to the harmonic.
98 // phi The angle phi in [0,2pi]
99 // w Weight of phi (only used in the calculation of
102 // Disregard the obervation of phi from the event plane angle.
103 Double_t psi = fPsi.Psi(phi, w);
104 fHarmonic.Add(phi, psi);
107 //____________________________________________________________________
111 // Should be called at the end of an event
112 Double_t psiA = fPsiA.Psi();
113 Double_t psiB = fPsiB.Psi();
115 // Update the resolutions
116 fRes.Add(psiA, psiB);
117 fResStar.Add(psiA, psiB);
118 fResTdr.Add(psiA, psiB);
121 //____________________________________________________________________
123 AliFMDFlowBin::Event(Double_t* phis, Double_t* ws, UInt_t n)
127 // phis Array of phi, (phi_1, ..., phi_n)
128 // ws Weights (optional)
129 // n Size of phis and possibly ws
133 UInt_t split = n / 2;
135 for (UInt_t i = 0; i < split; i++)
136 AddToEventPlane(phis[i], (ws ? ws[i] : 1), kTRUE);
138 for (UInt_t i = split; i < n; i++)
139 AddToEventPlane(phis[i], (ws ? ws[i] : 1), kFALSE);
140 // Add contributions to the harmonic.
141 for (UInt_t i = 0; i < n; i++)
142 AddToHarmonic(phis[i], (ws ? ws[i] : 1));
147 //____________________________________________________________________
149 AliFMDFlowBin::Value(CorType t) const
151 // Get the value in this bin
153 // t Which type of correction
155 // return the value of the harmonic
160 //____________________________________________________________________
162 AliFMDFlowBin::EValue(CorType t) const
164 // Get the value in this bin
166 // t Which type of correction
168 // return the error on the value of the harmonic
174 //____________________________________________________________________
176 AliFMDFlowBin::Value(Double_t& e2, CorType t) const
178 // Get the value in this bin
180 // e2 On return, the square error.
181 // t Which type of correction
183 // return the value of the harmonic
185 r = Correction(er2, t);
186 return fHarmonic.Value(r, er2, e2);
189 //____________________________________________________________________
191 AliFMDFlowBin::Correction(Double_t& er2, CorType t) const
193 // Get the value in this bin
195 // e2 On return, the square error.
196 // t Which type of correction
198 // return the value of the Correction
200 UShort_t k = fHarmonic.Order()/fRes.Order();
202 case kNaive: r = fRes.Correction(k, er2); break;
203 case kStar: r = fResStar.Correction(k, er2); break;
204 case kTdr: r = fResTdr.Correction(k, er2); break;
205 default: r = 1; er2 = 0; break;
210 //____________________________________________________________________
212 AliFMDFlowBin::Finish()
214 // Called at the end of the event
217 //____________________________________________________________________
219 AliFMDFlowBin::Browse(TBrowser* b)
222 b->Add(&fPsi, "Full event plane");
223 b->Add(&fPsiA, "Sub-event A event plane");
224 b->Add(&fPsiB, "Sub-event A event plane");
225 b->Add(&fRes, "Naive resolution");
226 b->Add(&fResStar, "STAR resolution");
227 b->Add(&fResTdr, "TDR resolution");
228 b->Add(&fHarmonic, "Harmonic");
231 //____________________________________________________________________
233 AliFMDFlowBin::Print(Option_t*) const
236 Double_t e2v[4], v[4], r[4], e2r[4];
237 const char* names[] = { "Bare", "Naive", "STAR", "TDR" };
238 v[0] = 100 * Value(e2v[0], AliFMDFlowBin::kNone);
239 v[1] = 100 * Value(e2v[1], AliFMDFlowBin::kNaive);
240 v[2] = 100 * Value(e2v[2], AliFMDFlowBin::kStar);
241 v[3] = 100 * Value(e2v[3], AliFMDFlowBin::kTdr);
242 r[0] = 100 * Correction(e2r[0], AliFMDFlowBin::kNone);
243 r[1] = 100 * Correction(e2r[1], AliFMDFlowBin::kNaive);
244 r[2] = 100 * Correction(e2r[2], AliFMDFlowBin::kStar);
245 r[3] = 100 * Correction(e2r[3], AliFMDFlowBin::kTdr);
247 std::streamsize oldP = std::cout.precision(3);
248 std::ios_base::fmtflags oldF = std::cout.setf(std::ios_base::fixed,
249 std::ios_base::floatfield);
250 std::cout << " v" << std::setw(1) << fHarmonic.Order() << ": ";
251 for (UInt_t i = 0; i < 4; i++)
252 std::cout << std::setw(6+(i == 0 ? 0 : 6)) << names[i] << ": "
253 << std::setw(6) << v[i] << " +/- "
254 << std::setw(6) << 100*sqrt(e2v[i]) << " ["
255 << std::setw(7) << r[i] << " +/- "
256 << std::setw(7) << 100*sqrt(e2r[i]) << "]\n";
257 std::cout << std::flush;
258 std::cout.precision(oldP);
259 std::cout.setf(oldF, std::ios_base::floatfield);
263 //____________________________________________________________________