]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskQCumulants.cxx
57d9c931ffb669abf09af706bf793892ed38313e
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskQCumulants.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 Q-cumulants      * 
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 "AliAnalysisTaskQCumulants.h"
34 #include "AliFlowAnalysisWithQCumulants.h"
35
36 ClassImp(AliAnalysisTaskQCumulants)
37
38 //================================================================================================================
39
40 AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(const char *name, Bool_t useParticleWeights): 
41  AliAnalysisTaskSE(name), 
42  fEvent(NULL),
43  fQC(NULL), 
44  fListHistos(NULL),
45  fFillMultipleControlHistograms(kFALSE),
46  fHarmonic(2),  
47  fApplyCorrectionForNUA(kFALSE), 
48  fApplyCorrectionForNUAVsM(kFALSE), 
49  fPropagateErrorAlsoFromNIT(kFALSE),
50  fCalculate2DFlow(kFALSE),
51  fStoreDistributions(kFALSE),
52  fCalculateCumulantsVsM(kFALSE), 
53  fMinimumBiasReferenceFlow(kTRUE), 
54  fForgetAboutCovariances(kFALSE),  
55  fStorePhiDistributionForOneEvent(kFALSE),
56  fnBinsMult(10000),
57  fMinMult(0.),  
58  fMaxMult(10000.), 
59  fUseParticleWeights(useParticleWeights),
60  fUsePhiWeights(kFALSE),
61  fUsePtWeights(kFALSE),
62  fUseEtaWeights(kFALSE),
63  fWeightsList(NULL),
64  fMultiplicityWeight(NULL)
65 {
66  // constructor
67  cout<<"AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(const char *name, Bool_t useParticleWeights)"<<endl;
68  
69  // Define input and output slots here
70  // Input slot #0 works with an AliFlowEventSimple
71  DefineInput(0, AliFlowEventSimple::Class());  
72  // Input slot #1 is needed for the weights input file:
73  if(useParticleWeights)
74  {
75   DefineInput(1, TList::Class());   
76  }  
77  // Output slot #0 is reserved              
78  // Output slot #1 writes into a TList container
79  DefineOutput(1, TList::Class());  
80  
81  // Event weights:
82  fMultiplicityWeight = new TString("combinations");
83  
84  // Store phi distribution for one event to illustrate flow:
85  for(Int_t p=0;p<4;p++) // [v_min,v_max,refMult_min,refMult_max]
86  {
87   fPhiDistributionForOneEventSettings[p] = 0.;
88  } 
89   
90 }
91
92 AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(): 
93  AliAnalysisTaskSE(),
94  fEvent(NULL),
95  fQC(NULL),
96  fListHistos(NULL),
97  fFillMultipleControlHistograms(kFALSE),
98  fHarmonic(0),  
99  fApplyCorrectionForNUA(kFALSE), 
100  fApplyCorrectionForNUAVsM(kFALSE), 
101  fPropagateErrorAlsoFromNIT(kFALSE),
102  fCalculate2DFlow(kFALSE),
103  fStoreDistributions(kFALSE),
104  fCalculateCumulantsVsM(kFALSE),  
105  fMinimumBiasReferenceFlow(kFALSE), 
106  fForgetAboutCovariances(kFALSE), 
107  fStorePhiDistributionForOneEvent(kFALSE), 
108  fnBinsMult(0),
109  fMinMult(0.),  
110  fMaxMult(0.), 
111  fUseParticleWeights(kFALSE),
112  fUsePhiWeights(kFALSE),
113  fUsePtWeights(kFALSE),
114  fUseEtaWeights(kFALSE),
115  fWeightsList(NULL),
116  fMultiplicityWeight(NULL)
117 {
118  // Dummy constructor
119  cout<<"AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants()"<<endl;
120  
121  // Store phi distribution for one event to illustrate flow:
122  for(Int_t p=0;p<4;p++) // [v_min,v_max,refMult_min,refMult_max]
123  {
124   fPhiDistributionForOneEventSettings[p] = 0.;
125  } 
126  
127 }
128
129 //================================================================================================================
130
131 void AliAnalysisTaskQCumulants::UserCreateOutputObjects() 
132 {
133  // Called at every worker node to initialize
134  cout<<"AliAnalysisTaskQCumulants::UserCreateOutputObjects()"<<endl;
135
136  // Analyser:
137  fQC = new AliFlowAnalysisWithQCumulants();
138  
139  // Common:
140  fQC->SetFillMultipleControlHistograms(fFillMultipleControlHistograms);
141  fQC->SetHarmonic(fHarmonic);
142  fQC->SetApplyCorrectionForNUA(fApplyCorrectionForNUA);
143  fQC->SetApplyCorrectionForNUAVsM(fApplyCorrectionForNUAVsM);
144  fQC->SetPropagateErrorAlsoFromNIT(fPropagateErrorAlsoFromNIT);
145  fQC->SetCalculate2DFlow(fCalculate2DFlow);
146  fQC->SetStoreDistributions(fStoreDistributions);
147  fQC->SetCalculateCumulantsVsM(fCalculateCumulantsVsM);
148  fQC->SetMinimumBiasReferenceFlow(fMinimumBiasReferenceFlow); 
149  fQC->SetForgetAboutCovariances(fForgetAboutCovariances); 
150  // Multiparticle correlations vs multiplicity:
151  fQC->SetnBinsMult(fnBinsMult);
152  fQC->SetMinMult(fMinMult);
153  fQC->SetMaxMult(fMaxMult);
154  // Particle weights:
155  if(fUseParticleWeights)
156  {
157   // Pass the flags to class:
158   if(fUsePhiWeights) fQC->SetUsePhiWeights(fUsePhiWeights);
159   if(fUsePtWeights) fQC->SetUsePtWeights(fUsePtWeights);
160   if(fUseEtaWeights) fQC->SetUseEtaWeights(fUseEtaWeights);
161   // Get data from input slot #1 which is used for weights:
162   if(GetNinputs()==2) 
163   {                   
164    fWeightsList = (TList*)GetInputData(1); 
165   }
166   // Pass the list with weights to class:
167   if(fWeightsList) fQC->SetWeightsList(fWeightsList);
168  }
169  // Event weights:
170  if(!(strcmp(fMultiplicityWeight->Data(),"combinations")==0)) // default is "combinations"
171  {
172   fQC->SetMultiplicityWeight(fMultiplicityWeight->Data());
173  }
174
175  // Store phi distribution for one event to illustrate flow:
176  fQC->SetStorePhiDistributionForOneEvent(fStorePhiDistributionForOneEvent);
177  for(Int_t i=0;i<4;i++)
178  {
179   fQC->SetPhiDistributionForOneEventSettings(fPhiDistributionForOneEventSettings[i],i);
180  }
181   
182  fQC->Init();
183  
184  if(fQC->GetHistList()) 
185  {
186   fListHistos = fQC->GetHistList();
187   // fListHistos->Print();
188  } else 
189    {
190     Printf("ERROR: Could not retrieve histogram list (QC, Task::UserCreateOutputObjects()) !!!!"); 
191    }
192  
193  PostData(1,fListHistos);
194   
195 } // end of void AliAnalysisTaskQCumulants::UserCreateOutputObjects() 
196
197 //================================================================================================================
198
199 void AliAnalysisTaskQCumulants::UserExec(Option_t *) 
200 {
201  // main loop (called for each event)
202  fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
203
204  // Q-cumulants
205  if(fEvent) 
206  {
207   fQC->Make(fEvent);
208  } else 
209    {
210     cout<<"WARNING: No input data (QC, Task::UserExec()) !!!!"<<endl;
211     cout<<endl;
212    }
213   
214  PostData(1,fListHistos);
215 }
216
217 //================================================================================================================
218
219 void AliAnalysisTaskQCumulants::Terminate(Option_t *) 
220 {
221  //accessing the merged output list: 
222  fListHistos = (TList*)GetOutputData(1);
223  
224  fQC = new AliFlowAnalysisWithQCumulants(); 
225  
226  if(fListHistos) 
227  {
228   fQC->GetOutputHistograms(fListHistos);
229   fQC->Finish();
230   PostData(1,fListHistos);
231  } else
232    {
233     cout<<" WARNING: histogram list pointer is empty (QC, Task::Terminate()) !!!!"<<endl;
234     cout<<endl;
235    }
236     
237 } // end of void AliAnalysisTaskQCumulants::Terminate(Option_t *)
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258