]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskCumulants.cxx
Reverting the wrong commit of AliAnalysisTaskFlowEvent
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskCumulants.cxx
1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  * 
14 **************************************************************************/
15
16 /**************************************
17  * analysis task for cumulant method  * 
18  *                                    * 
19  * authors: Naomi van der Kolk        *
20  *           (kolk@nikhef.nl)         *  
21  *          Raimond Snellings         *
22  *           (snelling@nikhef.nl)     * 
23  *          Ante Bilandzic            *
24  *           (anteb@nikhef.nl)        * 
25  * ***********************************/
26  
27 class TFile;
28 class TList;
29 class AliAnalysisTaskSE; 
30  
31 #include "Riostream.h"
32 #include "AliFlowEventSimple.h"
33 #include "AliAnalysisTaskCumulants.h"
34 #include "AliFlowAnalysisWithCumulants.h"
35
36 ClassImp(AliAnalysisTaskCumulants)
37
38 //================================================================================================================
39
40 AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name, Bool_t useWeights): 
41 AliAnalysisTaskSE(name), 
42 fEvent(NULL),
43 fGFC(NULL),
44 fListHistos(NULL),
45 fHarmonic(2),  
46 fMultiple(1),
47 fCalculateVsMultiplicity(kFALSE),
48 fnBinsMult(10000),  
49 fMinMult(0.),   
50 fMaxMult(10000.),
51 fUseWeights(useWeights),
52 fUsePhiWeights(kFALSE),
53 fUsePtWeights(kFALSE),
54 fUseEtaWeights(kFALSE),
55 fWeightsList(NULL),
56 fTuneParameters(kFALSE)
57 {
58  // Constructor
59  cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name, Bool_t useWeights)"<<endl;
60  
61  // Define input and output slots here
62  // Input slot #0 works with an AliFlowEventSimple
63  DefineInput(0, AliFlowEventSimple::Class());
64  
65  // Input slot #1 is needed for the weights input files 
66  if(useWeights) 
67  {
68   DefineInput(1, TList::Class());   
69  }
70  // Output slot #0 is reserved
71  // Output slot #1 writes into a TList container
72  DefineOutput(1, TList::Class());   
73  
74  // Initilize arrays:
75  for(Int_t r=0;r<10;r++)
76  {
77   fTuningR0[r] = 0.;
78  }
79 } // end of constructor
80
81 AliAnalysisTaskCumulants::AliAnalysisTaskCumulants():
82 AliAnalysisTaskSE(),
83 fEvent(NULL),
84 fGFC(NULL),
85 fListHistos(NULL),
86 fHarmonic(0),  
87 fMultiple(0),
88 fCalculateVsMultiplicity(kFALSE),
89 fnBinsMult(0),  
90 fMinMult(0.),   
91 fMaxMult(0.),
92 fUseWeights(kFALSE),
93 fUsePhiWeights(kFALSE),
94 fUsePtWeights(kFALSE),
95 fUseEtaWeights(kFALSE),
96 fWeightsList(NULL),
97 fTuneParameters(kFALSE)
98 {
99  // Dummy constructor
100  cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants()"<<endl;
101
102  // Initilize arrays:
103  for(Int_t r=0;r<10;r++)
104  {
105   fTuningR0[r] = 0.;
106  }
107 }
108
109 //================================================================================================================
110
111 void AliAnalysisTaskCumulants::UserCreateOutputObjects() 
112 {
113  // Called at every worker node to initialize
114  cout<<"AliAnalysisTaskCumulants::UserCreateOutputObjects()"<<endl;
115
116  // Analyser:
117  fGFC = new AliFlowAnalysisWithCumulants(); 
118  fGFC->SetHarmonic(fHarmonic);
119  
120  // Calculation vs multiplicity:
121  if(fCalculateVsMultiplicity)
122  {
123   fGFC->SetCalculateVsMultiplicity(fCalculateVsMultiplicity);
124   fGFC->SetnBinsMult(fnBinsMult);
125   fGFC->SetMinMult(fMinMult);
126   fGFC->SetMaxMult(fMaxMult);
127  }
128  
129  // Weights:
130  if(fUseWeights)
131  {
132   // Pass the flags to class:
133   if(fUsePhiWeights) fGFC->SetUsePhiWeights(fUsePhiWeights);
134   if(fUsePtWeights) fGFC->SetUsePtWeights(fUsePtWeights);
135   if(fUseEtaWeights) fGFC->SetUseEtaWeights(fUseEtaWeights);
136   // Get data from input slot #1 which is used for weights:
137   if(GetNinputs()==2) 
138   {                   
139    fWeightsList = (TList*)GetInputData(1); 
140   }
141   // Pass the list with weights to class:
142   if(fWeightsList) fGFC->SetWeightsList(fWeightsList);
143  }
144
145  // Tuning:
146  if(fTuneParameters)
147  {
148   fGFC->SetTuneParameters(fTuneParameters); 
149   for(Int_t r=0;r<10;r++) {fGFC->SetTuningR0(fTuningR0[r],r);}
150  }
151  
152  fGFC->Init();
153
154  if(fGFC->GetHistList()) 
155  {
156   fListHistos = fGFC->GetHistList();
157   //fListHistos->Print();
158  } else
159    {
160     Printf("ERROR: Could not retrieve histogram list (GFC, Task::UserCreateOutputObjects()) !!!!"); 
161    }
162
163  PostData(1,fListHistos);
164    
165 } // end of void AliAnalysisTaskCumulants::UserCreateOutputObjects() 
166
167 //================================================================================================================
168
169 void AliAnalysisTaskCumulants::UserExec(Option_t *) 
170 {
171  // Main loop (called for each event)
172  fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
173
174  // Generating function cumulants (GFC):
175  if(fEvent) 
176  {
177   fGFC->Make(fEvent);
178  } else 
179    {
180     cout<<"WARNING: No input data (GFC, Task::UserExec()) !!!!"<<endl;
181    }
182   
183  PostData(1,fListHistos);
184  
185 } // end of void AliAnalysisTaskCumulants::UserExec(Option_t *)
186
187 //================================================================================================================
188
189 void AliAnalysisTaskCumulants::Terminate(Option_t *) 
190 {  
191  // Accessing the output list which contains the merged 2D and 3D profiles from all worker nodes
192  fListHistos = (TList*)GetOutputData(1);
193  //fListHistos->Print();
194  
195  fGFC = new AliFlowAnalysisWithCumulants();  
196  
197  if(fListHistos)
198  {
199   fGFC->GetOutputHistograms(fListHistos);
200   fGFC->Finish();
201   PostData(1,fListHistos);
202  } else
203    {
204     cout<<"WARNING: histogram list pointer is empty (GFC, Task::Terminate()) !!!!"<<endl;
205     cout<<endl;
206    }
207    
208 } // end of void AliAnalysisTaskCumulants::Terminate(Option_t *) 
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229