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 an EventPlane class */
20 //____________________________________________________________________
22 // Class to determine the event plane
24 // The event plane is calculated as
26 // Psi_n = 1/n * atan((sum_i(w_i sin(n phi_i)))
27 // sum_i(w_i cos(n phi_i))))
29 // where i runs over all observations of phi in an event, and
30 // w_i is the weight of the ith observation of phi
31 #include "flow/AliFMDFlowEventPlane.h"
32 #include "flow/AliFMDFlowUtil.h"
38 /** Function to caculate @f$ \sin(a), \cos(a)@f$ in one go. Note,
39 that with GCC, this is a built-in, and we only have this to
40 serve as a replacement function
42 inline void sincos(Double_t a, Double_t* sina, Double_t* cosa) {
49 //====================================================================
50 AliFMDFlowEventPlane::AliFMDFlowEventPlane(const AliFMDFlowEventPlane& o)
52 fSumSinMPhi(o.fSumSinMPhi),
53 fSumCosMPhi(o.fSumCosMPhi),
59 // o Object to copy from.
61 //____________________________________________________________________
63 AliFMDFlowEventPlane::operator=(const AliFMDFlowEventPlane& o)
65 // Assignment operator.
67 // o Object to assign from
68 fSumSinMPhi = o.fSumSinMPhi;
69 fSumCosMPhi = o.fSumCosMPhi;
75 //____________________________________________________________________
77 AliFMDFlowEventPlane::Clear(Option_t*)
79 // clear internal variables.
84 //____________________________________________________________________
86 AliFMDFlowEventPlane::Add(Double_t phi, Double_t weight)
90 // phi The angle phi in[0,2pi]
92 Double_t a = NormalizeAngle(fOrder * phi);
95 if (TMath::IsNaN(s) || !TMath::Finite(s) ||
96 TMath::IsNaN(c) || !TMath::Finite(s)) return;
97 fSumSinMPhi += weight * s;
98 fSumCosMPhi += weight * c;
100 //____________________________________________________________________
102 AliFMDFlowEventPlane::Psi() const
104 // Get the event plane
107 if (fCache < 0) fCache = DoPsi(fSumSinMPhi, fSumCosMPhi);
110 //____________________________________________________________________
112 AliFMDFlowEventPlane::Psi(Double_t phi, Double_t w) const
114 // Get the event plane angle Psi_k disregarding the contribution
115 // from the observation phi with weight w. This is to avoid
119 // phi The observation phi
120 // w The weight w of the obervation.
122 // Returns The event plane angle Psi with out the contribution from
124 Double_t a = NormalizeAngle(fOrder * phi);
127 if (TMath::IsNaN(s) || !TMath::Finite(s) ||
128 TMath::IsNaN(c) || !TMath::Finite(s)) return Psi();
129 Double_t psi = DoPsi(fSumSinMPhi - w * s, fSumCosMPhi - w * c);
133 //____________________________________________________________________
135 AliFMDFlowEventPlane::DoPsi(Double_t sumsin, Double_t sumcos) const
137 // Calculate the event plane
139 // sumsin Sum of sines
140 // sumcos Sum of cosines
142 // Make sure we get an angle everywhere
143 if (sumcos != 0) psi = atan2(sumsin, sumcos);
144 else if (sumsin == 0) psi = 0;
145 else if (sumsin > 0) psi = M_PI / 2;
146 else psi = -M_PI / 2;
147 psi = NormalizeAngle(psi);
152 //____________________________________________________________________