]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/flow/AliFMDFlowHarmonic.cxx
Updated Detector Algorithm base class to write the conditions data to file. The class...
[u/mrichter/AliRoot.git] / FMD / flow / AliFMDFlowHarmonic.cxx
1 /* Copyright (C) 2007 Christian Holm Christensen <cholm@nbi.dk>
2  *
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.
7  *
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.
12  *
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
16  * USA
17  */
18 /** @file 
19     @brief Implementation of a Harmonic class */
20 //____________________________________________________________________
21 //
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"
29 #include <TBrowser.h>
30 #include <iostream>
31 // #include <cmath>
32
33 //====================================================================
34 AliFMDFlowHarmonic::AliFMDFlowHarmonic(UShort_t n) 
35   : fOrder(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)
41 {
42   fContrib.SetDirectory(0);
43   fContrib.Sumw2();
44   fContrib.SetXTitle("#varphi-#Psi");
45   fContrib.SetYTitle(Form("cos(%d(#varphi-#Psi))", n));
46   fPhi.SetDirectory(0);
47   fPhi.Sumw2();
48   fPhi.SetXTitle("#varphi-#Psi");
49   fNPhi.SetDirectory(0);
50   fNPhi.Sumw2();
51   fNPhi.SetXTitle(Form("%d(#varphi-#Psi)", n));
52   fWeight.SetDirectory(0);
53   fWeight.Sumw2();
54   fWeight.SetXTitle(Form("cos(%d(#varphi-#Psi))", n));
55   fWeight.SetYTitle("#sum_iw_i");
56
57
58 //____________________________________________________________________
59 AliFMDFlowHarmonic::AliFMDFlowHarmonic(const AliFMDFlowHarmonic& o)
60   : AliFMDFlowStat(o), 
61     fOrder(o.fOrder), 
62     fPhi(o.fPhi),
63     fNPhi(o.fNPhi),
64     fWeight(o.fWeight),
65     fContrib(o.fContrib)
66 {
67   // Copy constructor 
68   // Parameters: 
69   //   o   Object to copy from 
70   fContrib.SetDirectory(0);
71   fContrib.Sumw2();
72   fContrib.SetXTitle(Form("w_{i}cos(%d(#varphi-#Psi))", fOrder));
73   fPhi.SetDirectory(0);
74   fPhi.SetXTitle("#varphi-#Psi");
75   fPhi.Sumw2();
76   fNPhi.SetDirectory(0);
77   fNPhi.SetXTitle(Form("%d(#varphi-#Psi)", fOrder));
78   fNPhi.Sumw2();
79   fWeight.SetDirectory(0);
80   fWeight.Sumw2();
81   fWeight.SetXTitle(Form("cos(%d(#varphi-#Psi))", fOrder));
82   fWeight.SetYTitle("#sum_iw_i");
83 }
84
85 //____________________________________________________________________
86 AliFMDFlowHarmonic&
87 AliFMDFlowHarmonic::operator=(const AliFMDFlowHarmonic& o)
88 {
89   // Assignment operator 
90   // Parameters: 
91   //   o   Object to assign from 
92   // Return reference to this object. 
93   AliFMDFlowStat::operator=(o);
94   fOrder = o.fOrder;
95
96   fContrib.Reset();
97   fContrib.Add(&o.fContrib);
98   fPhi.Reset();
99   fPhi.Add(&o.fPhi);
100   fNPhi.Reset();
101   fNPhi.Add(&o.fNPhi);
102   fWeight.Reset();
103   fWeight.Add(&o.fWeight);
104   return *this;
105 }
106
107 //____________________________________________________________________
108 void 
109 AliFMDFlowHarmonic::Browse(TBrowser* b)
110 {
111   // Browse this object 
112   // Parameters 
113   //   b        Browser to use 
114   // Return 
115   //   nothing
116   b->Add(&fContrib);
117   b->Add(&fPhi);
118   b->Add(&fNPhi);
119   b->Add(&fWeight);
120 }
121
122 //____________________________________________________________________
123 void 
124 AliFMDFlowHarmonic::Add(Double_t phi, Double_t psi, Double_t weight) 
125
126   // Add a data point. 
127   // Parameters: 
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));
136   fNPhi.Fill(a); 
137   fWeight.Fill(cosa, weight);
138   fContrib.Fill(a/*NormalizeAngle(phi-psi)*/,contrib);
139 }
140 //____________________________________________________________________
141 Double_t 
142 AliFMDFlowHarmonic::Value(Double_t r, Double_t er2, Double_t& e2) const 
143 {
144   // The corrected value is given by 
145   //
146   //          v_n^obs
147   //    v_n = -------
148   //             R
149   // 
150   // where 
151   // 
152   //              1
153   //    v_n^obs = - \sum_i(cos(n(\phi_i - \Psi)))
154   //              N 
155   // 
156   // and R is the resolution 
157   // 
158   // The error on the corrected value is given by 
159   //
160   //                dv_n                    dv_n
161   //    d^2v_n = (--------)^2 d^2v_n^obs + (----)^2 d^2R
162   //              dv_n^obs                   dR
163   //
164   //             d^2v_n^obs R^2 + d^2R v_n^obs^2
165   //           = -------------------------------
166   //                         R^4 
167   // 
168   Double_t a = fAverage;
169   Double_t v = a / r;
170   if (fN != 0) { 
171     Double_t s = fSqVar / fN;
172     e2         = (s * r * r + er2 * a * a) / pow(r, 4);
173   }
174   else e2      = 0;
175   return v;
176 }
177 //____________________________________________________________________
178 void
179 AliFMDFlowHarmonic::Print(Option_t* /*option*/) const 
180 {
181   Double_t e2, er2 = 1, r = 1;
182   Double_t v = Value(r, er2, e2);
183   std::cout << v << " +/- " << e2 << std::endl;
184   
185
186
187 //____________________________________________________________________
188 //
189 // EOF
190 //